From 135a6da54cd6920da09eb70b28151b33be7fb9ae Mon Sep 17 00:00:00 2001 From: Abdelrahman Said Date: Sat, 1 Jul 2023 15:12:21 +0100 Subject: [PATCH] Ensure negative numbers are handled properly --- compile_commands.json | 20 ++++++++++---------- src/lexer/lexer.c | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/compile_commands.json b/compile_commands.json index 858ba5e..9228369 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -170,12 +170,12 @@ "-x", "c", "-o", - "/tmp/main-6b800d.o", + "/tmp/main-5fdd54.o", "src/main.c" ], "directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json", "file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/main.c", - "output": "/tmp/main-6b800d.o" + "output": "/tmp/main-5fdd54.o" }, { "arguments": [ @@ -243,12 +243,12 @@ "-x", "c", "-o", - "/tmp/dstring-08596e.o", + "/tmp/dstring-157144.o", "src/dstring/dstring.c" ], "directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json", "file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/dstring/dstring.c", - "output": "/tmp/dstring-08596e.o" + "output": "/tmp/dstring-157144.o" }, { "arguments": [ @@ -316,12 +316,12 @@ "-x", "c", "-o", - "/tmp/json_entities-a48410.o", + "/tmp/json_entities-f20100.o", "src/json_entities/json_entities.c" ], "directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json", "file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/json_entities/json_entities.c", - "output": "/tmp/json_entities-a48410.o" + "output": "/tmp/json_entities-f20100.o" }, { "arguments": [ @@ -389,12 +389,12 @@ "-x", "c", "-o", - "/tmp/lexer-174a98.o", + "/tmp/lexer-eb6c2d.o", "src/lexer/lexer.c" ], "directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json", "file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/lexer/lexer.c", - "output": "/tmp/lexer-174a98.o" + "output": "/tmp/lexer-eb6c2d.o" }, { "arguments": [ @@ -462,11 +462,11 @@ "-x", "c", "-o", - "/tmp/parser-baae30.o", + "/tmp/parser-73724a.o", "src/parser/parser.c" ], "directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json", "file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/parser/parser.c", - "output": "/tmp/parser-baae30.o" + "output": "/tmp/parser-73724a.o" } ] diff --git a/src/lexer/lexer.c b/src/lexer/lexer.c index 6161248..7dd85f8 100644 --- a/src/lexer/lexer.c +++ b/src/lexer/lexer.c @@ -639,7 +639,7 @@ lexer_state_t handle_key(lexer_t *lexer, char input) { lexer_state_t handle_value(lexer_t *lexer, char input) { if (isspace(input)) { return LEXER_STATE_VALUE; - } else if (isdigit(input) && input != '0') { + } else if ((isdigit(input) && input != '0') || input == '-') { dstr_append(&(lexer->current_string), input); return LEXER_STATE_NUMBER;