diff --git a/build_with_clang.bat b/build_with_clang.bat index ada1080..003a780 100644 --- a/build_with_clang.bat +++ b/build_with_clang.bat @@ -18,6 +18,7 @@ echo ~~~ Build All Tests ~~~ clang %compile_flags% ..\tests\sanity_tests.c -o sanity_tests.exe clang %compile_flags% ..\tests\unicode_test.c -o unicode_test.exe clang++ %compile_flags% ..\tests\cpp_build_test.cpp -o cpp_build_test.exe +clang %compile_flags% ..\tests\grammar.c -o grammar.exe popd echo. diff --git a/samples/static_site_generator/static_site_generator.c b/samples/static_site_generator/static_site_generator.c index e07a162..25c80b9 100644 --- a/samples/static_site_generator/static_site_generator.c +++ b/samples/static_site_generator/static_site_generator.c @@ -357,7 +357,7 @@ MakeDateString(MD_Node *date) "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", }; - int month_idx = MD_I64FromString(month->string)-1; + int month_idx = MD_I64FromString(month->string, 10)-1; if(month_idx >= 0 && month_idx < sizeof(month_names)/sizeof(month_names[0])) { result = MD_PushStringF("%.*s %s %.*s", diff --git a/source/md.h b/source/md.h index 2a5bc3a..d62e2ee 100644 --- a/source/md.h +++ b/source/md.h @@ -5,7 +5,6 @@ // // - Expression/Type helper // - Parsing things as a type, getting basic type info -// - Radix for MD_I64FromString // - Freeing calls, allow hooking the allocator with an arena or // something so that someone can use this for work at an application/game's // runtime @@ -669,7 +668,7 @@ MD_FUNCTION MD_String8List MD_SplitStringByCharacter(MD_String8 string, MD_u8 ch MD_FUNCTION MD_String8 MD_JoinStringList(MD_String8List list); MD_FUNCTION MD_String8 MD_JoinStringListWithSeparator(MD_String8List list, MD_String8 separator); // TODO(rjf): Radix -MD_FUNCTION MD_i64 MD_I64FromString(MD_String8 string); +MD_FUNCTION MD_i64 MD_I64FromString(MD_String8 string, MD_u32 radix); MD_FUNCTION MD_f64 MD_F64FromString(MD_String8 string); MD_FUNCTION MD_u64 MD_HashString(MD_String8 string); MD_FUNCTION MD_u64 MD_CalculateCStringLength(char *cstr); diff --git a/source/md_impl.c b/source/md_impl.c index d290c41..c353cdd 100644 --- a/source/md_impl.c +++ b/source/md_impl.c @@ -474,11 +474,11 @@ MD_JoinStringListWithSeparator(MD_String8List list, MD_String8 separator) } MD_FUNCTION_IMPL MD_i64 -MD_I64FromString(MD_String8 string) +MD_I64FromString(MD_String8 string, MD_u32 radix) { char str[64]; _MD_WriteStringToBuffer(string, sizeof(str), str); - return strtoll(str, 0, 0); + return strtoll(str, 0, radix); } MD_FUNCTION_IMPL MD_f64 @@ -2601,7 +2601,7 @@ MD_EvaluateExpr_I64(MD_Expr *expr) _MD_BinaryOp(Multiply, *); _MD_BinaryOp(Divide, /); #undef _MD_BinaryOp - case MD_ExprKind_Atom: { result = MD_I64FromString(expr->node->string); }break; + case MD_ExprKind_Atom: { result = MD_I64FromString(expr->node->string, 10); }break; default: break; } return result; @@ -2960,7 +2960,7 @@ MD_CommandLine_FlagIntegers(MD_CommandLine *cmdln, MD_String8 string, int out_co { for(int out_idx = 0; out_idx < out_count; out_idx += 1) { - out[out_idx] = MD_I64FromString(cmdln->arguments[i+out_idx+1]); + out[out_idx] = MD_I64FromString(cmdln->arguments[i+out_idx+1], 10); cmdln->arguments[i+out_idx+1].str = 0; cmdln->arguments[i+out_idx+1].size = 0; }