libft
Loading...
Searching...
No Matches
Files | Functions
Character and String Classification

Custom functions to classify characters or validate string content. More...

Files

file  ft_check.h
 Classification and validation functions for characters and strings.
 
file  ft_is_valid_integer.c
 Validates whether a string represents a valid long long integer.
 

Functions

bool ft_is_valid_integer (const char *str)
 Validates C-style signed integer string format.
 
int ft_isalnum (int c)
 Alphanumeric character.
 
int ft_isalpha (int c)
 Alphabetic character.
 
int ft_isascii (int c)
 ASCII character (0–127)
 
int ft_isdigit (int c)
 Decimal digit (0–9)
 
int ft_islower (int c)
 Lowercase letter.
 
int ft_isprint (int c)
 Printable character (including space)
 
int ft_ispunct (int c)
 Printable non-alphanumeric (e.g., punctuation)
 
int ft_issign (int c)
 '+' or '-'
 
int ft_isspace (int c)
 Whitespace (space, tab, newline, etc.)
 
bool ft_isstrpositive (const char *str)
 Checks if string contains only digits and is > 0.
 
int ft_isupper (int c)
 Uppercase letter.
 
static bool is_in_longlong_range (const char *str, bool negative)
 Checks if a numeric string fits within the long long range.
 

Detailed Description

Custom functions to classify characters or validate string content.

This group includes replacements and enhancements for standard <ctype.h> checks as well as boolean helpers to test string-wide properties (e.g., numeric strings, positivity).

This group includes:

Function Documentation

◆ ft_is_valid_integer()

bool ft_is_valid_integer ( const char *  str)

#include <include/ft_check.h>

Validates C-style signed integer string format.

Validates if a string represents a valid long long integer.

The string may start with a '+' or '-' sign, followed by decimal digits. The function rejects empty strings, non-digit characters, and any numeric values that would overflow a long long.

Parameters
strNull-terminated string to validate.
Returns
true if valid, false otherwise.
See also
is_in_longlong_range

◆ ft_isalnum()

int ft_isalnum ( int  c)

#include <include/ft_check.h>

Alphanumeric character.

Checks if a character is alphanumeric.

Parameters
cCharacter to check.
Returns
1 if alphabetic or digit, otherwise 0.

◆ ft_isalpha()

int ft_isalpha ( int  c)

#include <include/ft_check.h>

Alphabetic character.

Checks if a character is an alphabetic letter.

Parameters
cCharacter to check.
Returns
1 if 'A'–'Z' or 'a'–'z', otherwise 0.

◆ ft_isascii()

int ft_isascii ( int  c)

#include <include/ft_check.h>

ASCII character (0–127)

Checks if a character is an ASCII character.

Parameters
cCharacter to check.
Returns
1 if ASCII (0–127), otherwise 0.

◆ ft_isdigit()

int ft_isdigit ( int  c)

#include <include/ft_check.h>

Decimal digit (0–9)

Checks if a character is a decimal digit.

Parameters
cCharacter to check.
Returns
1 if '0'–'9', otherwise 0.

◆ ft_islower()

int ft_islower ( int  c)

#include <include/ft_check.h>

Lowercase letter.

Checks if a character is lowercase.

Parameters
cCharacter to check.
Returns
1 if 'a'–'z', otherwise 0.

◆ ft_isprint()

int ft_isprint ( int  c)

#include <include/ft_check.h>

Printable character (including space)

Checks if a character is printable.

Parameters
cCharacter to check.
Returns
1 if printable (32–126), otherwise 0.

◆ ft_ispunct()

int ft_ispunct ( int  c)

#include <include/ft_check.h>

Printable non-alphanumeric (e.g., punctuation)

Checks if a character is a punctuation mark.

Parameters
cCharacter to check.
Returns
1 if punctuation, otherwise 0.

◆ ft_issign()

int ft_issign ( int  c)

#include <include/ft_check.h>

'+' or '-'

Checks if a character is a sign symbol.

Parameters
cCharacter to check.
Returns
1 if '+' or '-', otherwise 0.

◆ ft_isspace()

int ft_isspace ( int  c)

#include <include/ft_check.h>

Whitespace (space, tab, newline, etc.)

Checks if a character is a whitespace character.

Recognized: space, tab, newline, vertical tab, form feed, carriage return.

Parameters
cCharacter to check.
Returns
1 if whitespace, otherwise 0.

◆ ft_isstrpositive()

bool ft_isstrpositive ( const char *  str)

#include <include/ft_check.h>

Checks if string contains only digits and is > 0.

Checks if a string represents a positive number.

Returns 1 if the string exists, is non-empty, and does not start with '-'.

Parameters
strNull-terminated string to check.
Returns
1 if positive, otherwise 0.

◆ ft_isupper()

int ft_isupper ( int  c)

#include <include/ft_check.h>

Uppercase letter.

Checks if a character is uppercase.

Parameters
cCharacter to check.
Returns
1 if 'A'–'Z', otherwise 0.

◆ is_in_longlong_range()

static bool is_in_longlong_range ( const char *  str,
bool  negative 
)
static

#include <srcs/check/ft_is_valid_integer.c>

Checks if a numeric string fits within the long long range.

This helper function verifies whether the numeric value represented by the string (without sign prefix) is within the bounds of a signed long long, depending on whether it's negative.

Uses manual overflow detection logic to avoid undefined behavior.

Parameters
strThe numeric string to check (must not include the sign).
negativeIndicates if the original number was negative.
Returns
true if the value fits in long long, false otherwise.
See also
ft_isdigit