aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-12-18 11:26:43 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-12-18 11:26:43 -0200
commit0c9080c7a9c2e0f9ee39a887bbde5385160b9747 (patch)
tree228c4571278479593d0b34f01495504feb395a0c
parentb8fcb7b151a2eba126e042634d23834f4653f208 (diff)
downloadlua-0c9080c7a9c2e0f9ee39a887bbde5385160b9747.tar.gz
lua-0c9080c7a9c2e0f9ee39a887bbde5385160b9747.tar.bz2
lua-0c9080c7a9c2e0f9ee39a887bbde5385160b9747.zip
"tonumber" goes crazy with negative numbers in other bases (not 10),
because "strtol" returns long, not unsigned long.
-rw-r--r--bugs6
-rw-r--r--lbuiltin.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/bugs b/bugs
index bd5806e5..c07d8a66 100644
--- a/bugs
+++ b/bugs
@@ -52,3 +52,9 @@ of view) when functions have upvalues.
52** lstrlib.c 52** lstrlib.c
53Tue Nov 10 17:29:36 EDT 1998 53Tue Nov 10 17:29:36 EDT 1998
54>> gsub/strfind do not check whether captures are properly finished. 54>> gsub/strfind do not check whether captures are properly finished.
55
56** lbuiltin.c
57Fri Dec 18 11:22:55 EDT 1998
58>> "tonumber" goes crazy with negative numbers in other bases (not 10),
59because "strtol" returns long, not unsigned long.
60
diff --git a/lbuiltin.c b/lbuiltin.c
index 0398c7ac..d72a320d 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.37 1998/12/15 14:59:59 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.38 1998/12/15 15:21:09 roberto Exp $
3** Built-in functions 3** Built-in functions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -268,7 +268,7 @@ static void luaB_tonumber (void) {
268 } 268 }
269 else { 269 else {
270 char *s = luaL_check_string(1); 270 char *s = luaL_check_string(1);
271 unsigned long n; 271 long n;
272 luaL_arg_check(0 <= base && base <= 36, 2, "base out of range"); 272 luaL_arg_check(0 <= base && base <= 36, 2, "base out of range");
273 n = strtol(s, &s, base); 273 n = strtol(s, &s, base);
274 while (isspace(*s)) s++; /* skip trailing spaces */ 274 while (isspace(*s)) s++; /* skip trailing spaces */