diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib.c | 5 |
2 files changed, 9 insertions, 1 deletions
@@ -1,5 +1,10 @@ 2011-12-01 Kaz Kylheku <kaz@kylheku.com> + * lib.c (int_str): Return nil rather than 0 if no digits are extracted + at all. + +2011-12-01 Kaz Kylheku <kaz@kylheku.com> + * match.c (h_skip, h_coll, v_skip, v_collect): Evaluate the arguments. (do_txeval): Optimization: short-circuit out if the expression is nil, without establishing the exception handler. @@ -1393,9 +1393,12 @@ val string_lt(val astr, val bstr) val int_str(val str, val base) { const wchar_t *wcs = c_str(str); + wchar_t *ptr; cnum b = c_num(base); /* TODO: detect if we have wcstoll */ - long val = wcstol(wcs, 0, b); + long val = wcstol(wcs, &ptr, b); + if (val == 0 && ptr == wcs) + return nil; numeric_assert (val >= NUM_MIN && val <= NUM_MAX); return num(val); } |