mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-06 15:48:47 +00:00
Radix for MD_I64FromString.
This commit is contained in:
@@ -18,6 +18,7 @@ echo ~~~ Build All Tests ~~~
|
|||||||
clang %compile_flags% ..\tests\sanity_tests.c -o sanity_tests.exe
|
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\unicode_test.c -o unicode_test.exe
|
||||||
clang++ %compile_flags% ..\tests\cpp_build_test.cpp -o cpp_build_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
|
popd
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ MakeDateString(MD_Node *date)
|
|||||||
"January", "February", "March", "April", "May", "June", "July", "August",
|
"January", "February", "March", "April", "May", "June", "July", "August",
|
||||||
"September", "October", "November", "December",
|
"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]))
|
if(month_idx >= 0 && month_idx < sizeof(month_names)/sizeof(month_names[0]))
|
||||||
{
|
{
|
||||||
result = MD_PushStringF("%.*s %s %.*s",
|
result = MD_PushStringF("%.*s %s %.*s",
|
||||||
|
|||||||
+1
-2
@@ -5,7 +5,6 @@
|
|||||||
//
|
//
|
||||||
// - Expression/Type helper
|
// - Expression/Type helper
|
||||||
// - Parsing things as a type, getting basic type info
|
// - Parsing things as a type, getting basic type info
|
||||||
// - Radix for MD_I64FromString
|
|
||||||
// - Freeing calls, allow hooking the allocator with an arena or
|
// - Freeing calls, allow hooking the allocator with an arena or
|
||||||
// something so that someone can use this for work at an application/game's
|
// something so that someone can use this for work at an application/game's
|
||||||
// runtime
|
// 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_JoinStringList(MD_String8List list);
|
||||||
MD_FUNCTION MD_String8 MD_JoinStringListWithSeparator(MD_String8List list, MD_String8 separator);
|
MD_FUNCTION MD_String8 MD_JoinStringListWithSeparator(MD_String8List list, MD_String8 separator);
|
||||||
// TODO(rjf): Radix
|
// 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_f64 MD_F64FromString(MD_String8 string);
|
||||||
MD_FUNCTION MD_u64 MD_HashString(MD_String8 string);
|
MD_FUNCTION MD_u64 MD_HashString(MD_String8 string);
|
||||||
MD_FUNCTION MD_u64 MD_CalculateCStringLength(char *cstr);
|
MD_FUNCTION MD_u64 MD_CalculateCStringLength(char *cstr);
|
||||||
|
|||||||
+4
-4
@@ -474,11 +474,11 @@ MD_JoinStringListWithSeparator(MD_String8List list, MD_String8 separator)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MD_FUNCTION_IMPL MD_i64
|
MD_FUNCTION_IMPL MD_i64
|
||||||
MD_I64FromString(MD_String8 string)
|
MD_I64FromString(MD_String8 string, MD_u32 radix)
|
||||||
{
|
{
|
||||||
char str[64];
|
char str[64];
|
||||||
_MD_WriteStringToBuffer(string, sizeof(str), str);
|
_MD_WriteStringToBuffer(string, sizeof(str), str);
|
||||||
return strtoll(str, 0, 0);
|
return strtoll(str, 0, radix);
|
||||||
}
|
}
|
||||||
|
|
||||||
MD_FUNCTION_IMPL MD_f64
|
MD_FUNCTION_IMPL MD_f64
|
||||||
@@ -2601,7 +2601,7 @@ MD_EvaluateExpr_I64(MD_Expr *expr)
|
|||||||
_MD_BinaryOp(Multiply, *);
|
_MD_BinaryOp(Multiply, *);
|
||||||
_MD_BinaryOp(Divide, /);
|
_MD_BinaryOp(Divide, /);
|
||||||
#undef _MD_BinaryOp
|
#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;
|
default: break;
|
||||||
}
|
}
|
||||||
return result;
|
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)
|
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].str = 0;
|
||||||
cmdln->arguments[i+out_idx+1].size = 0;
|
cmdln->arguments[i+out_idx+1].size = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user