gmio_core/internal: rename gmio_clocale_xxx() -> gmio_ascii_xxx()
This commit is contained in:
parent
e4b7753fea
commit
2f282d6c29
@ -61,7 +61,7 @@ GMIO_INLINE uint32_t strtoul10(const char* in, const char** out)
|
||||
gmio_bool_t overflow=GMIO_FALSE;
|
||||
uint32_t unsignedValue = 0;
|
||||
|
||||
while ( gmio_clocale_isdigit(*in) )
|
||||
while ( gmio_ascii_isdigit(*in) )
|
||||
{
|
||||
const uint32_t tmp = ( unsignedValue * 10 ) + ( *in - '0' );
|
||||
if (tmp<unsignedValue)
|
||||
@ -150,7 +150,7 @@ GMIO_INLINE uint32_t strtoul16(const char* in, const char** out)
|
||||
for (;;)
|
||||
{
|
||||
uint32_t tmp = 0;
|
||||
if (gmio_clocale_isdigit(*in))
|
||||
if (gmio_ascii_isdigit(*in))
|
||||
tmp = (unsignedValue << 4u) + (*in - '0');
|
||||
else if ((*in >= 'A') && (*in <= 'F'))
|
||||
tmp = (unsignedValue << 4u) + (*in - 'A') + 10;
|
||||
@ -242,7 +242,7 @@ GMIO_INLINE gmio_float32_t strtof10(const char* in, const char** out)
|
||||
|
||||
/* Use integer arithmetic for as long as possible, for speed
|
||||
* and precision. */
|
||||
while ( gmio_clocale_isdigit(*in) )
|
||||
while ( gmio_ascii_isdigit(*in) )
|
||||
{
|
||||
/* If it looks like we're going to overflow, bail out
|
||||
now and start using floating point. */
|
||||
@ -254,7 +254,7 @@ GMIO_INLINE gmio_float32_t strtof10(const char* in, const char** out)
|
||||
floatValue = (gmio_float32_t)intValue;
|
||||
/* If there are any digits left to parse, then we need to use
|
||||
* floating point arithmetic from here. */
|
||||
while ( gmio_clocale_isdigit(*in) )
|
||||
while ( gmio_ascii_isdigit(*in) )
|
||||
{
|
||||
floatValue = (floatValue * 10.f) + (gmio_float32_t)(*in - '0');
|
||||
++in;
|
||||
|
@ -49,7 +49,7 @@ gmio_eat_word_error_t gmio_eat_word(
|
||||
++i;
|
||||
} while(i < str_capacity
|
||||
&& stream_curr_char != NULL
|
||||
&& !gmio_clocale_isspace(*stream_curr_char));
|
||||
&& !gmio_ascii_isspace(*stream_curr_char));
|
||||
|
||||
if (i < str_capacity) {
|
||||
str_ptr[i] = 0; /* End string with terminating null byte */
|
||||
|
@ -138,7 +138,7 @@ const char* gmio_skip_spaces(
|
||||
gmio_string_stream_fwd_iterator_t* it)
|
||||
{
|
||||
const char* curr_char = gmio_current_char(it);
|
||||
while (curr_char != NULL && gmio_clocale_isspace(*curr_char))
|
||||
while (curr_char != NULL && gmio_ascii_isspace(*curr_char))
|
||||
curr_char = gmio_next_char(it);
|
||||
return curr_char;
|
||||
}
|
||||
@ -148,7 +148,7 @@ void gmio_copy_spaces(
|
||||
{
|
||||
const char* curr_char = gmio_current_char(it);
|
||||
while (curr_char != NULL
|
||||
&& gmio_clocale_isspace(*curr_char)
|
||||
&& gmio_ascii_isspace(*curr_char)
|
||||
&& str->len < str->max_len)
|
||||
{
|
||||
str->ptr[str->len] = *curr_char;
|
||||
|
@ -18,43 +18,42 @@
|
||||
|
||||
#include "../global.h"
|
||||
|
||||
/*! Returns non-zero if \p c is a space (for C-locale), zero otherwise */
|
||||
GMIO_INLINE int gmio_clocale_isspace(char c);
|
||||
/*! Returns non-zero if \p c is a space, zero otherwise */
|
||||
GMIO_INLINE int gmio_ascii_isspace(char c);
|
||||
|
||||
/*! Returns non-zero if \p c is a digit (for C-locale), zero otherwise */
|
||||
GMIO_INLINE int gmio_clocale_isdigit(char c);
|
||||
/*! Returns non-zero if \p c is a digit, zero otherwise */
|
||||
GMIO_INLINE int gmio_ascii_isdigit(char c);
|
||||
|
||||
/*! Returns non-zero if \p c is an uppercase letter (for C-locale), zero
|
||||
* otherwise */
|
||||
GMIO_INLINE int gmio_clocale_isupper(char c);
|
||||
/*! Returns non-zero if \p c is an uppercase letter, zero otherwise */
|
||||
GMIO_INLINE int gmio_ascii_isupper(char c);
|
||||
|
||||
/*! Returns non-zero if \p c is a lowercase letter (for C-locale), zero
|
||||
* otherwise */
|
||||
GMIO_INLINE int gmio_clocale_islower(char c);
|
||||
/*! Returns non-zero if \p c is a lowercase letter, zero otherwise */
|
||||
GMIO_INLINE int gmio_ascii_islower(char c);
|
||||
|
||||
/*! Returns the lowercase letter converted to uppercase */
|
||||
GMIO_INLINE char gmio_clocale_toupper(char c);
|
||||
GMIO_INLINE char gmio_ascii_toupper(char c);
|
||||
|
||||
/*! Returns the uppercase letter converted to lowercase */
|
||||
GMIO_INLINE char gmio_clocale_tolower(char c);
|
||||
GMIO_INLINE char gmio_ascii_tolower(char c);
|
||||
|
||||
/*! Returns true if \p c1 compare equals to \p c2
|
||||
/*! Returns 0 if \p c1 compare equals to \p c2, non-zero otherwise
|
||||
*
|
||||
* Comparison is case-insensitive
|
||||
*/
|
||||
GMIO_INLINE gmio_bool_t gmio_clocale_char_iequals(char c1, char c2);
|
||||
GMIO_INLINE gmio_bool_t gmio_ascii_char_iequals(char c1, char c2);
|
||||
|
||||
/*! Returns 0 if \p str1 and \p str2 compare equal, non-zero otherwise
|
||||
*
|
||||
* Comparison is case-insensitive
|
||||
*/
|
||||
GMIO_INLINE int gmio_stricmp(const char* str1, const char* str2);
|
||||
GMIO_INLINE int gmio_ascii_stricmp(const char* str1, const char* str2);
|
||||
|
||||
/*! Returns true if \p str starts with string \p begin
|
||||
*
|
||||
* Comparison is case-insensitive
|
||||
*/
|
||||
GMIO_INLINE gmio_bool_t gmio_istarts_with(const char* str, const char* begin);
|
||||
GMIO_INLINE gmio_bool_t gmio_ascii_istarts_with(
|
||||
const char* str, const char* begin);
|
||||
|
||||
|
||||
|
||||
@ -68,7 +67,7 @@ GMIO_INLINE gmio_bool_t gmio_istarts_with(const char* str, const char* begin);
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
|
||||
int gmio_clocale_isspace(char c)
|
||||
int gmio_ascii_isspace(char c)
|
||||
{
|
||||
/* 0x20 : space (SPC)
|
||||
* 0x09 : horizontal tab (TAB)
|
||||
@ -79,115 +78,42 @@ int gmio_clocale_isspace(char c)
|
||||
#if defined(GMIO_STRINGUTILS_DIRECT_TESTS)
|
||||
/* TODO: eliminate branch */
|
||||
return c == 0x20 || ((uint8_t)(c - 0x09) < 5);
|
||||
#elif defined(GMIO_STRINGUTILS_C_ARRAYS)
|
||||
static const unsigned char space_chars[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
return space_chars[c];
|
||||
#elif defined(GMIO_STRINGUTILS_CTYPE_H)
|
||||
return isspace(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
int gmio_clocale_isdigit(char c)
|
||||
int gmio_ascii_isdigit(char c)
|
||||
{
|
||||
static const unsigned char digit_chars[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
return digit_chars[(unsigned char)c];
|
||||
/* 48 <= c <= 57 */
|
||||
#if defined(GMIO_STRINGUTILS_DIRECT_TESTS)
|
||||
return (uint8_t) (c - 48) < 10;
|
||||
#elif defined(GMIO_STRINGUTILS_CTYPE_H)
|
||||
return isdigit(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
int gmio_clocale_isupper(char c)
|
||||
int gmio_ascii_isupper(char c)
|
||||
{
|
||||
/* 65 <= c <= 90; */
|
||||
#if defined(GMIO_STRINGUTILS_DIRECT_TESTS)
|
||||
/* TODO: eliminate branch */
|
||||
return 65 <= c && c <= 90;
|
||||
#elif defined(GMIO_STRINGUTILS_C_ARRAYS)
|
||||
static const unsigned char upper_chars[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
return upper_chars[c];
|
||||
return (uint8_t) (c - 65) < 26;
|
||||
#elif defined(GMIO_STRINGUTILS_CTYPE_H)
|
||||
return isupper(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
int gmio_clocale_islower(char c)
|
||||
int gmio_ascii_islower(char c)
|
||||
{
|
||||
/* 97 <= c <= 122; */
|
||||
#if defined(GMIO_STRINGUTILS_DIRECT_TESTS)
|
||||
/* TODO: eliminate branch */
|
||||
return 97 <= c && c <= 122;
|
||||
#elif defined(GMIO_STRINGUTILS_C_ARRAYS)
|
||||
static const unsigned char lower_chars[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
return lower_chars[c];
|
||||
return (unsigned) (c - 97) < 26;
|
||||
#elif defined(GMIO_STRINGUTILS_CTYPE_H)
|
||||
return islower(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
char gmio_clocale_toupper(char c)
|
||||
char gmio_ascii_toupper(char c)
|
||||
{
|
||||
static const char table_toupper[128] = {
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,0x09,0x0A, 0 , 0 ,0x0D, 0 , 0 ,
|
||||
@ -202,7 +128,7 @@ char gmio_clocale_toupper(char c)
|
||||
return table_toupper[(unsigned char)c];
|
||||
}
|
||||
|
||||
char gmio_clocale_tolower(char c)
|
||||
char gmio_ascii_tolower(char c)
|
||||
{
|
||||
static const char table_tolower[128] = {
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,0x09,0x0A, 0 , 0 ,0x0D, 0 , 0 ,
|
||||
@ -217,16 +143,16 @@ char gmio_clocale_tolower(char c)
|
||||
return table_tolower[(unsigned char)c];
|
||||
}
|
||||
|
||||
gmio_bool_t gmio_clocale_char_iequals(char c1, char c2)
|
||||
gmio_bool_t gmio_ascii_char_iequals(char c1, char c2)
|
||||
{
|
||||
/* TODO: eliminate branch */
|
||||
return c1 == c2 || (gmio_clocale_toupper(c1) == gmio_clocale_toupper(c2));
|
||||
return c1 == c2 || (gmio_ascii_toupper(c1) == gmio_ascii_toupper(c2));
|
||||
}
|
||||
|
||||
int gmio_stricmp(const char* str1, const char* str2)
|
||||
int gmio_ascii_stricmp(const char* str1, const char* str2)
|
||||
{
|
||||
while (*str1 != 0 && *str2 != 0) {
|
||||
if (!gmio_clocale_char_iequals(*str1, *str2))
|
||||
if (!gmio_ascii_char_iequals(*str1, *str2))
|
||||
return 1;
|
||||
++str1;
|
||||
++str2;
|
||||
@ -234,10 +160,10 @@ int gmio_stricmp(const char* str1, const char* str2)
|
||||
return *str1 == 0 && *str2 == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
gmio_bool_t gmio_istarts_with(const char* str, const char* begin)
|
||||
gmio_bool_t gmio_ascii_istarts_with(const char* str, const char* begin)
|
||||
{
|
||||
while (*begin != 0) {
|
||||
if (*str == 0 || !gmio_clocale_char_iequals(*str, *begin))
|
||||
if (*str == 0 || !gmio_ascii_char_iequals(*str, *begin))
|
||||
return GMIO_FALSE;
|
||||
++str;
|
||||
++begin;
|
||||
|
@ -74,13 +74,13 @@ gmio_stl_format_t gmio_stl_get_format(gmio_stream_t *stream)
|
||||
{
|
||||
/* Skip spaces at beginning */
|
||||
size_t pos = 0;
|
||||
while (pos < read_size && gmio_clocale_isspace(fixed_buffer[pos]))
|
||||
while (pos < read_size && gmio_ascii_isspace(fixed_buffer[pos]))
|
||||
++pos;
|
||||
|
||||
/* Next token (if exists) must match "solid\s" */
|
||||
if ((pos + 6) < read_size
|
||||
&& gmio_istarts_with(fixed_buffer + pos, "solid")
|
||||
&& gmio_clocale_isspace(fixed_buffer[pos + 5]))
|
||||
&& gmio_ascii_istarts_with(fixed_buffer + pos, "solid")
|
||||
&& gmio_ascii_isspace(fixed_buffer[pos + 5]))
|
||||
{
|
||||
return GMIO_STL_FORMAT_ASCII;
|
||||
}
|
||||
|
@ -82,21 +82,8 @@
|
||||
/* Fixed maximum length of any string user in this source file */
|
||||
enum { GMIO_STLA_READ_STRING_MAX_LEN = 1024 };
|
||||
|
||||
/* gmio_stream_fwd_iterator_stla_cookie */
|
||||
typedef struct
|
||||
{
|
||||
/* Copy of gmio_stla_read() corresponding argument */
|
||||
gmio_transfer_t* transfer;
|
||||
/* Cache for gmio_stream_size(&transfer->stream) */
|
||||
size_t stream_size;
|
||||
/* Offset (in bytes) from beginning of stream : current position */
|
||||
size_t stream_offset;
|
||||
/* Cache for gmio_transfer::func_is_stop_requested() */
|
||||
gmio_bool_t is_stop_requested;
|
||||
} gmio_string_stream_fwd_iterator_cookie_t;
|
||||
|
||||
/* gmio_stla_token */
|
||||
typedef enum
|
||||
enum gmio_stla_token
|
||||
{
|
||||
null_token = 0,
|
||||
ENDFACET_token,
|
||||
@ -112,7 +99,8 @@ typedef enum
|
||||
FLOAT_token = ID_token,
|
||||
empty_token,
|
||||
unknown_token
|
||||
} gmio_stla_token_t;
|
||||
};
|
||||
typedef enum gmio_stla_token gmio_stla_token_t;
|
||||
|
||||
static const char gmio_stla_tokstr_ENDFACET[] = "endfacet";
|
||||
static const char gmio_stla_tokstr_ENDLOOP[] = "endloop";
|
||||
@ -124,10 +112,10 @@ static const char gmio_stla_tokstr_OUTER[] = "outer";
|
||||
static const char gmio_stla_tokstr_SOLID[] = "solid";
|
||||
static const char gmio_stla_tokstr_VERTEX[] = "vertex";
|
||||
|
||||
static const gmio_const_string_t gmio_stla_tokstr[] = {
|
||||
static const gmio_const_string_t gmio_stla_tokcstr[] = {
|
||||
{0},
|
||||
GMIO_CONST_STRING_FROM_ARRAY(gmio_stla_tokstr_ENDFACET),
|
||||
GMIO_CONST_STRING_FROM_ARRAY(gmio_stla_tokstr_ENDLOOP) ,
|
||||
GMIO_CONST_STRING_FROM_ARRAY(gmio_stla_tokstr_ENDLOOP),
|
||||
GMIO_CONST_STRING_FROM_ARRAY(gmio_stla_tokstr_ENDSOLID),
|
||||
GMIO_CONST_STRING_FROM_ARRAY(gmio_stla_tokstr_FACET),
|
||||
GMIO_CONST_STRING_FROM_ARRAY(gmio_stla_tokstr_LOOP),
|
||||
@ -135,11 +123,24 @@ static const gmio_const_string_t gmio_stla_tokstr[] = {
|
||||
GMIO_CONST_STRING_FROM_ARRAY(gmio_stla_tokstr_OUTER),
|
||||
GMIO_CONST_STRING_FROM_ARRAY(gmio_stla_tokstr_SOLID),
|
||||
GMIO_CONST_STRING_FROM_ARRAY(gmio_stla_tokstr_VERTEX),
|
||||
{ "ID", 2 },
|
||||
{ "ID", 2 }, /* ID_token */
|
||||
{ "", 0 }, /* empty_token */
|
||||
{ "?", 1 } /* unknown_token */
|
||||
};
|
||||
|
||||
/* gmio_stream_fwd_iterator_stla_cookie */
|
||||
typedef struct
|
||||
{
|
||||
/* Copy of gmio_stla_read() corresponding argument */
|
||||
gmio_transfer_t* transfer;
|
||||
/* Cache for gmio_stream_size(&transfer->stream) */
|
||||
size_t stream_size;
|
||||
/* Offset (in bytes) from beginning of stream : current position */
|
||||
size_t stream_offset;
|
||||
/* Cache for gmio_transfer::func_is_stop_requested() */
|
||||
gmio_bool_t is_stop_requested;
|
||||
} gmio_string_stream_fwd_iterator_cookie_t;
|
||||
|
||||
/* gmio_stla_parse_data */
|
||||
typedef struct
|
||||
{
|
||||
@ -173,7 +174,7 @@ GMIO_INLINE gmio_bool_t parsing_can_continue(
|
||||
|
||||
GMIO_INLINE const char* token_to_string(gmio_stla_token_t token)
|
||||
{
|
||||
return gmio_stla_tokstr[token].ptr;
|
||||
return gmio_stla_tokcstr[token].ptr;
|
||||
}
|
||||
|
||||
GMIO_INLINE void parsing_error_msg(
|
||||
@ -218,32 +219,32 @@ static gmio_stla_token_t parsing_find_token(const char* word, size_t word_len)
|
||||
switch (word[0]) {
|
||||
case 'f':
|
||||
case 'F':
|
||||
if (gmio_stricmp(word + 1, "acet") == 0)
|
||||
if (gmio_ascii_stricmp(word + 1, "acet") == 0)
|
||||
return FACET_token;
|
||||
break;
|
||||
case 'l':
|
||||
case 'L':
|
||||
if (gmio_stricmp(word + 1, "oop") == 0)
|
||||
if (gmio_ascii_stricmp(word + 1, "oop") == 0)
|
||||
return LOOP_token;
|
||||
break;
|
||||
case 'n':
|
||||
case 'N':
|
||||
if (gmio_stricmp(word + 1, "ormal") == 0)
|
||||
if (gmio_ascii_stricmp(word + 1, "ormal") == 0)
|
||||
return NORMAL_token;
|
||||
break;
|
||||
case 'o':
|
||||
case 'O':
|
||||
if (gmio_stricmp(word + 1, "uter") == 0)
|
||||
if (gmio_ascii_stricmp(word + 1, "uter") == 0)
|
||||
return OUTER_token;
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
if (gmio_stricmp(word + 1, "olid") == 0)
|
||||
if (gmio_ascii_stricmp(word + 1, "olid") == 0)
|
||||
return SOLID_token;
|
||||
break;
|
||||
case 'v':
|
||||
case 'V':
|
||||
if (gmio_stricmp(word + 1, "ertex") == 0)
|
||||
if (gmio_ascii_stricmp(word + 1, "ertex") == 0)
|
||||
return VERTEX_token;
|
||||
break;
|
||||
default:
|
||||
@ -252,21 +253,21 @@ static gmio_stla_token_t parsing_find_token(const char* word, size_t word_len)
|
||||
}
|
||||
|
||||
/* Might be "end..." token */
|
||||
if (word_len >= 7 && gmio_istarts_with(word, "end") == GMIO_TRUE) {
|
||||
if (word_len >= 7 && gmio_ascii_istarts_with(word, "end")) {
|
||||
switch (word[3]) {
|
||||
case 'f':
|
||||
case 'F':
|
||||
if (gmio_stricmp(word + 4, "acet") == 0)
|
||||
if (gmio_ascii_stricmp(word + 4, "acet") == 0)
|
||||
return ENDFACET_token;
|
||||
break;
|
||||
case 'l':
|
||||
case 'L':
|
||||
if (gmio_stricmp(word + 4, "oop") == 0)
|
||||
if (gmio_ascii_stricmp(word + 4, "oop") == 0)
|
||||
return ENDLOOP_token;
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
if (gmio_stricmp(word + 4, "olid") == 0)
|
||||
if (gmio_ascii_stricmp(word + 4, "olid") == 0)
|
||||
return ENDSOLID_token;
|
||||
break;
|
||||
default:
|
||||
@ -286,14 +287,14 @@ GMIO_INLINE gmio_stla_token_t parsing_find_token_from_buff(
|
||||
static gmio_bool_t parsing_eat_next_token(
|
||||
gmio_stla_token_t next_token, gmio_stla_parse_data_t* data)
|
||||
{
|
||||
const char* next_token_str = token_to_string(next_token);
|
||||
gmio_string_t* data_strbuff = &data->string_buffer;
|
||||
gmio_eat_word_error_t eat_error;
|
||||
|
||||
data_strbuff->len = 0;
|
||||
eat_error = gmio_eat_word(&data->stream_iterator, data_strbuff);
|
||||
if (eat_error == GMIO_EAT_WORD_ERROR_OK) {
|
||||
if (gmio_stricmp(data_strbuff->ptr, next_token_str) == 0) {
|
||||
const char* next_token_str = token_to_string(next_token);
|
||||
if (gmio_ascii_stricmp(data_strbuff->ptr, next_token_str) == 0) {
|
||||
data->token = next_token;
|
||||
return GMIO_TRUE;
|
||||
}
|
||||
@ -385,6 +386,7 @@ static gmio_bool_t parse_solidname_beg(gmio_stla_parse_data_t* data)
|
||||
|
||||
static gmio_bool_t parse_solidname_end(gmio_stla_parse_data_t* data)
|
||||
{
|
||||
GMIO_UNUSED(data);
|
||||
/* TODO: parse according to retrieved solid name */
|
||||
return GMIO_TRUE;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ void gmio_string_trim_from_end(char *str, size_t len)
|
||||
if (len > 0) {
|
||||
do {
|
||||
--len;
|
||||
if (str[len] == 0 || gmio_clocale_isspace(str[len]))
|
||||
if (str[len] == 0 || gmio_ascii_isspace(str[len]))
|
||||
str[len] = 0;
|
||||
else
|
||||
break;
|
||||
|
@ -244,59 +244,63 @@ const char* test_internal__string_utils()
|
||||
{
|
||||
char c; /* for loop counter */
|
||||
|
||||
UTEST_ASSERT(gmio_clocale_isspace(' '));
|
||||
UTEST_ASSERT(gmio_clocale_isspace('\t'));
|
||||
UTEST_ASSERT(gmio_clocale_isspace('\n'));
|
||||
UTEST_ASSERT(gmio_clocale_isspace('\r'));
|
||||
UTEST_ASSERT(gmio_ascii_isspace(' '));
|
||||
UTEST_ASSERT(gmio_ascii_isspace('\t'));
|
||||
UTEST_ASSERT(gmio_ascii_isspace('\n'));
|
||||
UTEST_ASSERT(gmio_ascii_isspace('\r'));
|
||||
|
||||
for (c = 0; c >= 0 && c <= 127; ++c) {
|
||||
if (65 <= c && c <= 90) {
|
||||
UTEST_ASSERT(gmio_clocale_isupper(c));
|
||||
UTEST_ASSERT(gmio_ascii_isupper(c));
|
||||
}
|
||||
else if (97 <= c && c <= 122) {
|
||||
UTEST_ASSERT(gmio_clocale_islower(c));
|
||||
UTEST_ASSERT(gmio_ascii_islower(c));
|
||||
}
|
||||
else if (c == 0x20 || (0x09 <= c && c <= 0x0d)) {
|
||||
UTEST_ASSERT(gmio_clocale_isspace(c));
|
||||
UTEST_ASSERT(gmio_ascii_isspace(c));
|
||||
}
|
||||
else if (48 <= c && c <= 57) {
|
||||
UTEST_ASSERT(gmio_ascii_isdigit(c));
|
||||
}
|
||||
else {
|
||||
UTEST_ASSERT(!gmio_clocale_isupper(c));
|
||||
UTEST_ASSERT(!gmio_clocale_islower(c));
|
||||
UTEST_ASSERT(!gmio_clocale_isspace(c));
|
||||
UTEST_ASSERT(!gmio_ascii_isupper(c));
|
||||
UTEST_ASSERT(!gmio_ascii_islower(c));
|
||||
UTEST_ASSERT(!gmio_ascii_isspace(c));
|
||||
UTEST_ASSERT(!gmio_ascii_isdigit(c));
|
||||
}
|
||||
}
|
||||
|
||||
UTEST_ASSERT(gmio_clocale_tolower('A') == 'a');
|
||||
UTEST_ASSERT(gmio_clocale_tolower('Z') == 'z');
|
||||
UTEST_ASSERT(gmio_clocale_tolower('(') == '(');
|
||||
UTEST_ASSERT(gmio_clocale_toupper('a') == 'A');
|
||||
UTEST_ASSERT(gmio_clocale_toupper('z') == 'Z');
|
||||
UTEST_ASSERT(gmio_clocale_toupper('(') == '(');
|
||||
UTEST_ASSERT(gmio_ascii_tolower('A') == 'a');
|
||||
UTEST_ASSERT(gmio_ascii_tolower('Z') == 'z');
|
||||
UTEST_ASSERT(gmio_ascii_tolower('(') == '(');
|
||||
UTEST_ASSERT(gmio_ascii_toupper('a') == 'A');
|
||||
UTEST_ASSERT(gmio_ascii_toupper('z') == 'Z');
|
||||
UTEST_ASSERT(gmio_ascii_toupper('(') == '(');
|
||||
|
||||
UTEST_ASSERT(gmio_clocale_char_iequals('a', 'a'));
|
||||
UTEST_ASSERT(gmio_clocale_char_iequals('a', 'A'));
|
||||
UTEST_ASSERT(gmio_clocale_char_iequals('A', 'a'));
|
||||
UTEST_ASSERT(gmio_clocale_char_iequals('{', '{'));
|
||||
UTEST_ASSERT(!gmio_clocale_char_iequals('{', '['));
|
||||
UTEST_ASSERT(gmio_ascii_char_iequals('a', 'a'));
|
||||
UTEST_ASSERT(gmio_ascii_char_iequals('a', 'A'));
|
||||
UTEST_ASSERT(gmio_ascii_char_iequals('A', 'a'));
|
||||
UTEST_ASSERT(gmio_ascii_char_iequals('{', '{'));
|
||||
UTEST_ASSERT(!gmio_ascii_char_iequals('{', '['));
|
||||
|
||||
UTEST_ASSERT(gmio_stricmp("FACET", "facet") == 0);
|
||||
UTEST_ASSERT(gmio_stricmp("facet", "FACET") == 0);
|
||||
UTEST_ASSERT(gmio_stricmp("facet", "facet") == 0);
|
||||
UTEST_ASSERT(gmio_stricmp("FACET", "FACET") == 0);
|
||||
UTEST_ASSERT(gmio_stricmp("", "") == 0);
|
||||
UTEST_ASSERT(gmio_stricmp("", "facet") != 0);
|
||||
UTEST_ASSERT(gmio_stricmp("facet", "facet_") != 0);
|
||||
UTEST_ASSERT(gmio_stricmp("facet_", "facet") != 0);
|
||||
UTEST_ASSERT(gmio_ascii_stricmp("FACET", "facet") == 0);
|
||||
UTEST_ASSERT(gmio_ascii_stricmp("facet", "FACET") == 0);
|
||||
UTEST_ASSERT(gmio_ascii_stricmp("facet", "facet") == 0);
|
||||
UTEST_ASSERT(gmio_ascii_stricmp("FACET", "FACET") == 0);
|
||||
UTEST_ASSERT(gmio_ascii_stricmp("", "") == 0);
|
||||
UTEST_ASSERT(gmio_ascii_stricmp("", "facet") != 0);
|
||||
UTEST_ASSERT(gmio_ascii_stricmp("facet", "facet_") != 0);
|
||||
UTEST_ASSERT(gmio_ascii_stricmp("facet_", "facet") != 0);
|
||||
|
||||
UTEST_ASSERT(gmio_istarts_with("facet", ""));
|
||||
UTEST_ASSERT(gmio_istarts_with("facet", "f"));
|
||||
UTEST_ASSERT(gmio_istarts_with("facet", "fa"));
|
||||
UTEST_ASSERT(gmio_istarts_with("facet", "facet"));
|
||||
UTEST_ASSERT(!gmio_istarts_with("facet", "a"));
|
||||
UTEST_ASSERT(!gmio_istarts_with("facet", " facet"));
|
||||
UTEST_ASSERT(gmio_istarts_with("facet", "F"));
|
||||
UTEST_ASSERT(gmio_istarts_with("FACET", "f"));
|
||||
UTEST_ASSERT(gmio_istarts_with("FACET", "fa"));
|
||||
UTEST_ASSERT(gmio_ascii_istarts_with("facet", ""));
|
||||
UTEST_ASSERT(gmio_ascii_istarts_with("facet", "f"));
|
||||
UTEST_ASSERT(gmio_ascii_istarts_with("facet", "fa"));
|
||||
UTEST_ASSERT(gmio_ascii_istarts_with("facet", "facet"));
|
||||
UTEST_ASSERT(!gmio_ascii_istarts_with("facet", "a"));
|
||||
UTEST_ASSERT(!gmio_ascii_istarts_with("facet", " facet"));
|
||||
UTEST_ASSERT(gmio_ascii_istarts_with("facet", "F"));
|
||||
UTEST_ASSERT(gmio_ascii_istarts_with("FACET", "f"));
|
||||
UTEST_ASSERT(gmio_ascii_istarts_with("FACET", "fa"));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user