Update of /cvsroot/jython/jython/org/python/core
In directory usw-pr-cvs1:/tmp/cvs-serv15096
Modified Files:
PyString.java
Log Message:
fixed some int(), long() minor bugs.
Index: PyString.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/core/PyString.java,v
retrieving revision 2.43
retrieving revision 2.44
diff -C2 -r2.43 -r2.44
*** PyString.java 2001/03/04 18:58:40 2.43
--- PyString.java 2001/05/31 18:16:55 2.44
***************
*** 1250,1267 ****
if (sign == '-' || sign == '+') {
b++;
! while (b < e && Character.isWhitespace(string.charAt(b)))
! b++;
}
- }
! if (base == 0 || base == 16) {
! if (string.charAt(b) == '0') {
! if (b < e-1 && string.charAt(b+1) == 'x') {
! if (base == 0)
base = 16;
! b += 2;
! } else {
! if (base == 0)
! base = 8;
}
}
--- 1250,1265 ----
if (sign == '-' || sign == '+') {
b++;
! while (b < e && Character.isWhitespace(string.charAt(b))) b++;
}
! if (base == 0 || base == 16) {
! if (string.charAt(b) == '0') {
! if (b < e-1 && (string.charAt(b+1) == 'x' || string.charAt(b+1) == 'X')) {
base = 16;
! b += 2;
! } else {
! if (base == 0)
! base = 8;
! }
}
}
***************
*** 1313,1330 ****
if (sign == '-' || sign == '+') {
b++;
! while (b < e && Character.isWhitespace(str.charAt(b)))
! b++;
}
! }
! if (base == 0) {
! if (str.charAt(b) != '0')
! base = 10;
! else if (str.charAt(b+1) == 'x' || str.charAt(b+1) == 'X') {
! base = 16;
! b += 2;
! } else
! base = 8;
}
if (base < 2 || base > 36)
throw Py.ValueError("invalid base for long literal:" + base);
--- 1311,1333 ----
if (sign == '-' || sign == '+') {
b++;
! while (b < e && Character.isWhitespace(str.charAt(b))) b++;
}
!
! if (base == 0 || base == 16) {
! if (string.charAt(b) == '0') {
! if (b < e-1 && (string.charAt(b+1) == 'x' || string.charAt(b+1) == 'X')) {
! base = 16;
! b += 2;
! } else {
! if (base == 0)
! base = 8;
! }
! }
! }
}
+ if (base == 0)
+ base = 10;
+
if (base < 2 || base > 36)
throw Py.ValueError("invalid base for long literal:" + base);
***************
*** 1341,1347 ****
return new PyLong(bi);
} catch (NumberFormatException exc) {
! throw Py.ValueError("invalid literal for __int__: "+str);
} catch (StringIndexOutOfBoundsException exc) {
! throw Py.ValueError("invalid literal for __int__: "+str);
}
}
--- 1344,1350 ----
return new PyLong(bi);
} catch (NumberFormatException exc) {
! throw Py.ValueError("invalid literal for __long__: "+str);
} catch (StringIndexOutOfBoundsException exc) {
! throw Py.ValueError("invalid literal for __long__: "+str);
}
}
|