diff --git a/code/entry_windows.c b/code/entry_windows.c index 257bda4..3ceac60 100644 --- a/code/entry_windows.c +++ b/code/entry_windows.c @@ -1,9 +1,11 @@ #include<_platform.h> +#include extern int main(); int mainCRTStartup() { + setlocale(LC_ALL, "C"); return main(); } diff --git a/code/locale.c b/code/locale.c new file mode 100644 index 0000000..3094585 --- /dev/null +++ b/code/locale.c @@ -0,0 +1,59 @@ + +// TODO: X-macros +// TODO: data race possible (see 7.11.1.1 p. 5) +// TODO: something about restoring locales (see 7.11.1.1 p. 8) + +#include + +#define _LC_FIRST 0 +#define _LC_LAST 5 + +static struct lconv _locale; +static char *_locale_str; + +char *setlocale(int category, const char *locale) +{ + assert(_LC_FIRST <= category && category <= _LC_LAST); + + if(locale == NULL) { + return _locale_str; + } + if(strcmp(locale, "C") == 0) { + if(category == LC_ALL) { + _locale.decimal_point = "."; + _locale.thousands_sep = ""; + _locale.grouping = ""; + _locale.mon_decimal_point = ""; + _locale.mon_thousands_sep = ""; + _locale.mon_grouping = ""; + _locale.positive_sign = ""; + _locale.negative_sign = ""; + _locale.currency_symbol = ""; + _locale.frac_digits = CHAR_MAX; + _locale.p_cs_precedes = CHAR_MAX; + _locale.n_cs_precedes = CHAR_MAX; + _locale.p_sep_by_space = CHAR_MAX; + _locale.n_sep_by_space = CHAR_MAX; + _locale.p_sign_posn = CHAR_MAX; + _locale.n_sign_posn = CHAR_MAX; + _locale.int_curr_symbol = ""; + _locale.int_frac_digits = CHAR_MAX; + _locale.int_p_cs_precedes = CHAR_MAX; + _locale.int_n_cs_precedes = CHAR_MAX; + _locale.int_p_sep_by_space = CHAR_MAX; + _locale.int_n_sep_by_space = CHAR_MAX; + _locale.int_p_sign_posn = CHAR_MAX; + _locale.int_n_sign_posn = CHAR_MAX; + } + } + else { + return NULL; + } + _locale_str = locale; + return locale; +} + +struct lconv *localeconv(void) +{ + +} diff --git a/code/string.c b/code/string.c new file mode 100644 index 0000000..349467b --- /dev/null +++ b/code/string.c @@ -0,0 +1,10 @@ + +int strcmp(const char *s1, const char *s2) +{ + while(*s1 != 0 && *s2 != 0) { + if(*s1 != *s2) break; + } + if(*s1 > *s2) return 1; + if(*s1 < *s2) return -1; + return 0; +} diff --git a/test/bake.bat b/test/bake.bat index dd919ca..eedb7f7 100644 --- a/test/bake.bat +++ b/test/bake.bat @@ -1,6 +1,15 @@ @echo off -cl /c /I ..\inc /nologo /Gm- /GR- /EHa- /Oi /W4 /Z7 test.c -clang -c -Wall test.c -otest1.obj +pushd %~dp0 + +cl /nologo inctoarg.c +inctoarg > temp +set /P includes= +#include + +int main() +{ + char *include = getenv("INCLUDE"); + printf(" "); + while(*include != 0) { + printf("-I \""); + while(*include != ';' && *include != 0) { + printf("%c", *include); + *include ++; + } + if(*include == ';') { + ++include; + } + printf("\" "); + } +} diff --git a/test/test.c b/test/test.c index 1cd2011..b41e98f 100644 --- a/test/test.c +++ b/test/test.c @@ -1,8 +1,10 @@ -// MSVC won't use my unless i provide path explicitly -// idk -#include"..\inc\assert.h" + +#include +#include int main() { - assert(0); + for(char c = 'a'; c != 'z'; ++c) { + assert(isupper(toupper(c))); + } return 0; } \ No newline at end of file