|
From: Nicholas N. <nj...@cs...> - 2005-06-02 03:48:59
|
SVN commit 421064 by nethercote:
Made VG_(atoll36) less flexible -- it now only does base-36 numbers
instead of any base in the range 2..36, since base-36 is the only one we
need. As part of that, I fixed a horrible bug in it which caused it to
return incorrect answers for any base-36 number containing the digits=20
'A'..'I'! (Eg. for "A" it would return 17 instead of 10!)
MERGED FROM 3.0 REPOSITORY
M +1 -1 coregrind/demangle/cp-demangle.c =20
M +9 -11 coregrind/vg_mylibc.c =20
M +2 -2 include/tool.h.base =20
--- trunk/valgrind/coregrind/demangle/cp-demangle.c #421063:421064
@@ -1408,7 +1408,7 @@
}
=20
if (base =3D=3D 36) {
- *value =3D VG_(atoll36) (36, dyn_string_buf (number));
+ *value =3D VG_(atoll36) (dyn_string_buf (number));
} else {
*value =3D VG_(atoll) (dyn_string_buf (number));
}
--- trunk/valgrind/coregrind/vg_mylibc.c #421063:421064
@@ -760,26 +760,23 @@
return n;
}
=20
-Long VG_(atoll36) ( UInt base, Char* str )
+Long VG_(atoll36) ( Char* str )
{
Bool neg =3D False;
Long n =3D 0;
- vg_assert(base >=3D 2 && base <=3D 36);
if (*str =3D=3D '-') { str++; neg =3D True; };
while (True) {
- if (*str >=3D '0'=20
- && *str <=3D (Char)('9' - (10 - base))) {
- n =3D base*n + (Long)(*str - '0');
+ Char c =3D *str;
+ if (c >=3D '0' && c <=3D (Char)'9') {
+ n =3D 36*n + (Long)(c - '0');
}
else=20
- if (base > 10 && *str >=3D 'A'=20
- && *str <=3D (Char)('Z' - (36 - base))) {
- n =3D base*n + (Long)((*str - 'A') + 10);
+ if (c >=3D 'A' && c <=3D (Char)'Z') {
+ n =3D 36*n + (Long)((c - 'A') + 10);
}
else=20
- if (base > 10 && *str >=3D 'a'=20
- && *str <=3D (Char)('z' - (36 - base))) {
- n =3D base*n + (Long)((*str - 'a') + 10);
+ if (c >=3D 'a' && c <=3D (Char)'z') {
+ n =3D 36*n + (Long)((c - 'a') + 10);
}
else {
break;
@@ -791,6 +788,7 @@
}
=20
=20
+
Char* VG_(strcat) ( Char* dest, const Char* src )
{
Char* dest_orig =3D dest;
--- trunk/valgrind/include/tool.h.base #421063:421064
@@ -382,8 +382,8 @@
/* Like atoll(), but converts a number of base 16 */
extern Long VG_(atoll16) ( Char* str );
=20
-/* Like atoll(), but converts a number of base 2..36 */
-extern Long VG_(atoll36) ( UInt base, Char* str );
+/* Like atoll(), but converts a number of base 36 */
+extern Long VG_(atoll36) ( Char* str );
=20
/* Like qsort(), but does shell-sort. The size=3D=3D1/2/4 cases are spe=
cialised. */
extern void VG_(ssort)( void* base, SizeT nmemb, SizeT size,
|