aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-24 17:36:37 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-24 17:36:37 -0400
commit73659ac01be2d2d0acb3da2afe6ada597205f57a (patch)
tree2138ddff16c44abbbcee99522b8f3b71834d5004 /src
parente3a79d45f641a7cd866cb53e766b8606a72b2ba1 (diff)
Command line arg parsing fix for negative integers: `tomo foo.tm -- -123`
Diffstat (limited to 'src')
-rw-r--r--src/stdlib/stdlib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/stdlib/stdlib.c b/src/stdlib/stdlib.c
index a7eeb745..cc0ea114 100644
--- a/src/stdlib/stdlib.c
+++ b/src/stdlib/stdlib.c
@@ -313,7 +313,7 @@ public void _tomo_parse_args(int argc, char *argv[], Text_t usage, Text_t help,
exit(0);
}
print_err("Unrecognized argument: ", argv[i], "\n", usage);
- } else if (argv[i][0] == '-' && argv[i][1] && argv[i][1] != '-') { // Single flag args
+ } else if (argv[i][0] == '-' && argv[i][1] && argv[i][1] != '-' && !isdigit(argv[i][1])) { // Single flag args
used_args[i] = true;
for (char *f = argv[i] + 1; *f; f++) {
char flag[] = {'-', *f, 0};
@@ -404,7 +404,7 @@ public void _tomo_parse_args(int argc, char *argv[], Text_t usage, Text_t help,
if (non_opt_type->tag == ListInfo) {
int num_args = 0;
while (i + num_args < argc) {
- if (!ignore_dashes && argv[i+num_args][0] == '-')
+ if (!ignore_dashes && (argv[i+num_args][0] == '-' && !isdigit(argv[i+num_args][1])))
break;
used_args[i+num_args] = true;
num_args += 1;
@@ -414,7 +414,7 @@ public void _tomo_parse_args(int argc, char *argv[], Text_t usage, Text_t help,
} else if (non_opt_type->tag == TableInfo) {
int num_args = 0;
while (i + num_args < argc) {
- if (argv[i+num_args][0] == '-' || !strchr(argv[i+num_args], '='))
+ if ((argv[i+num_args][0] == '-' && !isdigit(argv[i+num_args][1])) || !strchr(argv[i+num_args], '='))
break;
used_args[i+num_args] = true;
num_args += 1;