Ruby  3.4.0dev (2024-11-05 revision e440268d51fe02b303e3817a7a733a0dac1c5091)
Functions
pm_char.h File Reference

(e440268d51fe02b303e3817a7a733a0dac1c5091)

Functions for working with characters and strings. More...

#include "prism/defines.h"
#include "prism/util/pm_newline_list.h"
#include <stdbool.h>
#include <stddef.h>
Include dependency graph for pm_char.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

size_t pm_strspn_whitespace (const uint8_t *string, ptrdiff_t length)
 Returns the number of characters at the start of the string that are whitespace. More...
 
size_t pm_strspn_whitespace_newlines (const uint8_t *string, ptrdiff_t length, pm_newline_list_t *newline_list)
 Returns the number of characters at the start of the string that are whitespace while also tracking the location of each newline. More...
 
size_t pm_strspn_inline_whitespace (const uint8_t *string, ptrdiff_t length)
 Returns the number of characters at the start of the string that are inline whitespace. More...
 
size_t pm_strspn_decimal_digit (const uint8_t *string, ptrdiff_t length)
 Returns the number of characters at the start of the string that are decimal digits. More...
 
size_t pm_strspn_hexadecimal_digit (const uint8_t *string, ptrdiff_t length)
 Returns the number of characters at the start of the string that are hexadecimal digits. More...
 
size_t pm_strspn_octal_number (const uint8_t *string, ptrdiff_t length, const uint8_t **invalid)
 Returns the number of characters at the start of the string that are octal digits or underscores. More...
 
size_t pm_strspn_decimal_number (const uint8_t *string, ptrdiff_t length, const uint8_t **invalid)
 Returns the number of characters at the start of the string that are decimal digits or underscores. More...
 
size_t pm_strspn_hexadecimal_number (const uint8_t *string, ptrdiff_t length, const uint8_t **invalid)
 Returns the number of characters at the start of the string that are hexadecimal digits or underscores. More...
 
size_t pm_strspn_regexp_option (const uint8_t *string, ptrdiff_t length)
 Returns the number of characters at the start of the string that are regexp options. More...
 
size_t pm_strspn_binary_number (const uint8_t *string, ptrdiff_t length, const uint8_t **invalid)
 Returns the number of characters at the start of the string that are binary digits or underscores. More...
 
bool pm_char_is_whitespace (const uint8_t b)
 Returns true if the given character is a whitespace character. More...
 
bool pm_char_is_inline_whitespace (const uint8_t b)
 Returns true if the given character is an inline whitespace character. More...
 
bool pm_char_is_binary_digit (const uint8_t b)
 Returns true if the given character is a binary digit. More...
 
bool pm_char_is_octal_digit (const uint8_t b)
 Returns true if the given character is an octal digit. More...
 
bool pm_char_is_decimal_digit (const uint8_t b)
 Returns true if the given character is a decimal digit. More...
 
bool pm_char_is_hexadecimal_digit (const uint8_t b)
 Returns true if the given character is a hexadecimal digit. More...
 

Detailed Description

Functions for working with characters and strings.

Definition in file pm_char.h.

Function Documentation

◆ pm_char_is_binary_digit()

bool pm_char_is_binary_digit ( const uint8_t  b)

Returns true if the given character is a binary digit.

Parameters
bThe character to check.
Returns
True if the given character is a binary digit.

Definition at line 279 of file pm_char.c.

◆ pm_char_is_decimal_digit()

bool pm_char_is_decimal_digit ( const uint8_t  b)

Returns true if the given character is a decimal digit.

Parameters
bThe character to check.
Returns
True if the given character is a decimal digit.

Definition at line 295 of file pm_char.c.

Referenced by pm_string_query_method_name().

◆ pm_char_is_hexadecimal_digit()

bool pm_char_is_hexadecimal_digit ( const uint8_t  b)

Returns true if the given character is a hexadecimal digit.

Parameters
bThe character to check.
Returns
True if the given character is a hexadecimal digit.

Definition at line 303 of file pm_char.c.

◆ pm_char_is_inline_whitespace()

bool pm_char_is_inline_whitespace ( const uint8_t  b)

Returns true if the given character is an inline whitespace character.

Parameters
bThe character to check.
Returns
True if the given character is an inline whitespace character.

Definition at line 141 of file pm_char.c.

◆ pm_char_is_octal_digit()

bool pm_char_is_octal_digit ( const uint8_t  b)

Returns true if the given character is an octal digit.

Parameters
bThe character to check.
Returns
True if the given character is an octal digit.

Definition at line 287 of file pm_char.c.

◆ pm_char_is_whitespace()

bool pm_char_is_whitespace ( const uint8_t  b)

Returns true if the given character is a whitespace character.

Parameters
bThe character to check.
Returns
True if the given character is a whitespace character.

Definition at line 133 of file pm_char.c.

Referenced by pm_buffer_rstrip().

◆ pm_strspn_binary_number()

size_t pm_strspn_binary_number ( const uint8_t *  string,
ptrdiff_t  length,
const uint8_t **  invalid 
)

Returns the number of characters at the start of the string that are binary digits or underscores.

Disallows searching past the given maximum number of characters.

If multiple underscores are found in a row or if an underscore is found at the end of the number, then the invalid pointer is set to the index of the first invalid underscore.

Parameters
stringThe string to search.
lengthThe maximum number of characters to search.
invalidThe pointer to set to the index of the first invalid underscore.
Returns
The number of characters at the start of the string that are binary digits or underscores.

Disallows searching past the given maximum number of characters.

If multiple underscores are found in a row or if an underscore is found at the end of the number, then the invalid pointer is set to the index of the first invalid underscore.

Definition at line 202 of file pm_char.c.

◆ pm_strspn_decimal_digit()

size_t pm_strspn_decimal_digit ( const uint8_t *  string,
ptrdiff_t  length 
)

Returns the number of characters at the start of the string that are decimal digits.

Disallows searching past the given maximum number of characters.

Parameters
stringThe string to search.
lengthThe maximum number of characters to search.
Returns
The number of characters at the start of the string that are decimal digits.

Disallows searching past the given maximum number of characters.

Definition at line 225 of file pm_char.c.

◆ pm_strspn_decimal_number()

size_t pm_strspn_decimal_number ( const uint8_t *  string,
ptrdiff_t  length,
const uint8_t **  invalid 
)

Returns the number of characters at the start of the string that are decimal digits or underscores.

Disallows searching past the given maximum number of characters.

If multiple underscores are found in a row or if an underscore is found at the end of the number, then the invalid pointer is set to the index of the first invalid underscore.

Parameters
stringThe string to search.
lengthThe maximum number of characters to search.
invalidThe pointer to set to the index of the first invalid underscore.
Returns
The number of characters at the start of the string that are decimal digits or underscores.

Disallows searching past the given maximum number of characters.

If multiple underscores are found in a row or if an underscore is found at the end of the number, then the invalid pointer is set to the index of the first invalid underscore

Definition at line 239 of file pm_char.c.

◆ pm_strspn_hexadecimal_digit()

size_t pm_strspn_hexadecimal_digit ( const uint8_t *  string,
ptrdiff_t  length 
)

Returns the number of characters at the start of the string that are hexadecimal digits.

Disallows searching past the given maximum number of characters.

Parameters
stringThe string to search.
lengthThe maximum number of characters to search.
Returns
The number of characters at the start of the string that are hexadecimal digits.

Disallows searching past the given maximum number of characters.

Definition at line 249 of file pm_char.c.

◆ pm_strspn_hexadecimal_number()

size_t pm_strspn_hexadecimal_number ( const uint8_t *  string,
ptrdiff_t  length,
const uint8_t **  invalid 
)

Returns the number of characters at the start of the string that are hexadecimal digits or underscores.

Disallows searching past the given maximum number of characters.

If multiple underscores are found in a row or if an underscore is found at the end of the number, then the invalid pointer is set to the index of the first invalid underscore.

Parameters
stringThe string to search.
lengthThe maximum number of characters to search.
invalidThe pointer to set to the index of the first invalid underscore.
Returns
The number of characters at the start of the string that are hexadecimal digits or underscores.

Disallows searching past the given maximum number of characters.

If multiple underscores are found in a row or if an underscore is found at the end of the number, then the invalid pointer is set to the index of the first invalid underscore.

Definition at line 263 of file pm_char.c.

◆ pm_strspn_inline_whitespace()

size_t pm_strspn_inline_whitespace ( const uint8_t *  string,
ptrdiff_t  length 
)

Returns the number of characters at the start of the string that are inline whitespace.

Disallows searching past the given maximum number of characters.

Parameters
stringThe string to search.
lengthThe maximum number of characters to search.
Returns
The number of characters at the start of the string that are inline whitespace.

Disallows searching past the given maximum number of characters.

Definition at line 108 of file pm_char.c.

◆ pm_strspn_octal_number()

size_t pm_strspn_octal_number ( const uint8_t *  string,
ptrdiff_t  length,
const uint8_t **  invalid 
)

Returns the number of characters at the start of the string that are octal digits or underscores.

Disallows searching past the given maximum number of characters.

If multiple underscores are found in a row or if an underscore is found at the end of the number, then the invalid pointer is set to the index of the first invalid underscore.

Parameters
stringThe string to search.
lengthThe maximum number of characters to search.
invalidThe pointer to set to the index of the first invalid underscore.
Returns
The number of characters at the start of the string that are octal digits or underscores.

Disallows searching past the given maximum number of characters.

If multiple underscores are found in a row or if an underscore is found at the end of the number, then the invalid pointer is set to the index of the first invalid underscore.

Definition at line 216 of file pm_char.c.

◆ pm_strspn_regexp_option()

size_t pm_strspn_regexp_option ( const uint8_t *  string,
ptrdiff_t  length 
)

Returns the number of characters at the start of the string that are regexp options.

Disallows searching past the given maximum number of characters.

Parameters
stringThe string to search.
lengthThe maximum number of characters to search.
Returns
The number of characters at the start of the string that are regexp options.

Disallows searching past the given maximum number of characters.

Definition at line 117 of file pm_char.c.

◆ pm_strspn_whitespace()

size_t pm_strspn_whitespace ( const uint8_t *  string,
ptrdiff_t  length 
)

Returns the number of characters at the start of the string that are whitespace.

Disallows searching past the given maximum number of characters.

Parameters
stringThe string to search.
lengthThe maximum number of characters to search.
Returns
The number of characters at the start of the string that are whitespace.

Disallows searching past the given maximum number of characters.

Definition at line 76 of file pm_char.c.

◆ pm_strspn_whitespace_newlines()

size_t pm_strspn_whitespace_newlines ( const uint8_t *  string,
ptrdiff_t  length,
pm_newline_list_t newline_list 
)

Returns the number of characters at the start of the string that are whitespace while also tracking the location of each newline.

Disallows searching past the given maximum number of characters.

Parameters
stringThe string to search.
lengthThe maximum number of characters to search.
newline_listThe list of newlines to populate.
Returns
The number of characters at the start of the string that are whitespace.

Disallows searching past the given maximum number of characters.

Definition at line 86 of file pm_char.c.