X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=gmqcc.h;h=593ab811c6bf23104404a19ecf2707322f370a52;hp=d6055dbeedf2d27ac8e8a9061744302027fcb515;hb=684112474b4ff1eee2dde4aa3f84c8b6c52c612f;hpb=0eab97283f30db40344105a699440d7b5fbd2f96 diff --git a/gmqcc.h b/gmqcc.h index d6055db..593ab81 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -305,6 +305,28 @@ void *stat_mem_allocate (size_t, size_t, const char *); /*===================================================================*/ /*=========================== util.c ================================*/ /*===================================================================*/ + +/* + * Microsoft implements against the spec versions of ctype.h. Which + * means what ever the current set locale is will render the actual + * results of say isalpha('A') wrong for what ever retarded locale + * is used. Simalerly these are also implemented inefficently on + * some toolchains and end up becoming actual library calls. Perhaps + * this is why tools like yacc provide their own? Regardless implementing + * these as functions is equally as silly, the call overhead is not + * justified when this could happen on every character from an input + * stream. We provide our own as macros for absolute inlinability. + */ +#define util_isupper(C) ((C) >= 'A' && (C) <= 'Z') +#define util_islower(C) ((C) >= 'a' && (C) <= 'z') +#define util_isdigit(C) ((C) >= '0' && (C) <= '9') +#define util_isprint(C) ((C) >= 32 && (C) <= 126) +#define util_isspace(C) ((C) == ' ' || (C) == '\f' || \ + (C) == '\n'|| (C) == '\r' || \ + (C) == '\t'|| (C) == '\v') + +#define util_isalpha(C) (util_islower(C) || util_isupper(C)) + bool util_filexists (const char *); bool util_strupper (const char *); bool util_strdigit (const char *); @@ -721,7 +743,7 @@ typedef struct { * code_genstrin -- generates string for code * code_alloc_field -- allocated a field * code_push_statement -- keeps statements and linenumbers together - * code_pop_statement -- keeps statements and linenumbers together + * code_pop_statement -- keeps statements and linenumbers together */ bool code_write (code_t *, const char *filename, const char *lno); GMQCC_WARN