aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-12-15 16:53:07 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-12-15 16:53:07 -0500
commit0caf96cfe7783c6d0dc30c74e7bed7dd315cc30a (patch)
tree23dccb7ae50272003202f5f3220b73a87ceee290
parent5c15238e2f6891340b7bc655e25c4b5e56192784 (diff)
Parse negative integers
-rw-r--r--stdlib/patterns.c3
1 files changed, 2 insertions, 1 deletions
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)