From 0caf96cfe7783c6d0dc30c74e7bed7dd315cc30a Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 15 Dec 2024 16:53:07 -0500 Subject: Parse negative integers --- stdlib/patterns.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'stdlib/patterns.c') diff --git a/stdlib/patterns.c b/stdlib/patterns.c index f6a7aa85..66855d2d 100644 --- a/stdlib/patterns.c +++ b/stdlib/patterns.c @@ -380,8 +380,9 @@ static int64_t match_id(TextIter_t *state, int64_t index) static int64_t match_int(TextIter_t *state, int64_t index) { + int64_t negative = EAT1(state, index, grapheme == '-') ? 1 : 0; int64_t len = EAT_MANY(state, index, uc_is_property((ucs4_t)grapheme, UC_PROPERTY_DECIMAL_DIGIT)); - return len > 0 ? len : -1; + return len > 0 ? negative + len : -1; } static int64_t match_alphanumeric(TextIter_t *state, int64_t index) -- cgit v1.2.3