Преглед на файлове

"tonumber" goes crazy with negative numbers in other bases (not 10),
because "strtol" returns long, not unsigned long.

Roberto Ierusalimschy преди 27 години
родител
ревизия
0c9080c7a9
променени са 2 файла, в които са добавени 8 реда и са изтрити 2 реда
  1. 6 0
      bugs
  2. 2 2
      lbuiltin.c

+ 6 - 0
bugs

@@ -52,3 +52,9 @@ of view) when functions have upvalues.
 ** lstrlib.c
 ** lstrlib.c
 Tue Nov 10 17:29:36 EDT 1998
 Tue Nov 10 17:29:36 EDT 1998
 >> gsub/strfind do not check whether captures are properly finished.
 >> gsub/strfind do not check whether captures are properly finished.
+
+** lbuiltin.c
+Fri Dec 18 11:22:55 EDT 1998
+>> "tonumber" goes crazy with negative numbers in other bases (not 10),
+because "strtol" returns long, not unsigned long.
+

+ 2 - 2
lbuiltin.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lbuiltin.c,v 1.37 1998/12/15 14:59:59 roberto Exp roberto $
+** $Id: lbuiltin.c,v 1.38 1998/12/15 15:21:09 roberto Exp $
 ** Built-in functions
 ** Built-in functions
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -268,7 +268,7 @@ static void luaB_tonumber (void) {
   }
   }
   else {
   else {
     char *s = luaL_check_string(1);
     char *s = luaL_check_string(1);
-    unsigned long n;
+    long n;
     luaL_arg_check(0 <= base && base <= 36, 2, "base out of range");
     luaL_arg_check(0 <= base && base <= 36, 2, "base out of range");
     n = strtol(s, &s, base);
     n = strtol(s, &s, base);
     while (isspace(*s)) s++;  /* skip trailing spaces */
     while (isspace(*s)) s++;  /* skip trailing spaces */