summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib.c5
2 files changed, 9 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index e4478bde..d23bf83d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/lib.c b/lib.c
index 1989e437..da774db6 100644
--- a/lib.c
+++ b/lib.c
@@ -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);
}