From ee6fdfbc480f4bafdcaac954b76b82fe00776097 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sun, 31 May 2026 17:30:53 +0100 Subject: [PATCH] bshell.runtime: add a compiler option for disabling floating-point usage --- bshell.runtime/CMakeLists.txt | 1 + bshell.runtime/parse/lex/lex.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/bshell.runtime/CMakeLists.txt b/bshell.runtime/CMakeLists.txt index 970007d..eeb035f 100644 --- a/bshell.runtime/CMakeLists.txt +++ b/bshell.runtime/CMakeLists.txt @@ -24,5 +24,6 @@ endif () target_include_directories(bshell.runtime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) target_compile_definitions(bshell.runtime PUBLIC BSHELL_VERSION="${bshell_version}" + BSHELL_ENABLE_FLOATING_POINT=${bshell_enable_floating_point} BSHELL_INTERACTIVE=${bshell_interactive} BSHELL_VERBOSE=${bshell_verbose}) diff --git a/bshell.runtime/parse/lex/lex.c b/bshell.runtime/parse/lex/lex.c index 09036f4..819c226 100644 --- a/bshell.runtime/parse/lex/lex.c +++ b/bshell.runtime/parse/lex/lex.c @@ -653,6 +653,7 @@ bool string_is_valid_number( } char *ep = NULL; +#if BSHELL_ENABLE_FLOATING_POINT == 1 double dvalue = strtod(s, &ep); if (string_could_be_double(s) && *ep == '\0') { if (out) { @@ -665,6 +666,7 @@ bool string_is_valid_number( return true; } +#endif int base = get_int_base_by_prefix(&s);