]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add VG_(atoll).
authorNicholas Nethercote <njn@valgrind.org>
Sat, 22 Sep 2007 06:23:07 +0000 (06:23 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sat, 22 Sep 2007 06:23:07 +0000 (06:23 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6899

coregrind/m_libcbase.c
include/pub_tool_libcbase.h

index 8628feb9752e2771ddf74696f518e90f99ec2b73..a1f073cb3923bde1bfa39f1c36adab45f7cd7b9f 100644 (file)
@@ -63,6 +63,33 @@ Long VG_(atoll) ( Char* str )
    return n;
 }
 
+Long VG_(atoll16) ( Char* str )
+{
+   Bool neg = False;
+   Long n = 0;
+   if (*str == '-') { str++; neg = True; };
+   while (True) {
+      Char c = *str;
+      if (c >= '0' && c <= (Char)'9') {
+         n = 16*n + (Long)(c - '0');
+      }
+      else 
+      if (c >= 'A' && c <= (Char)'F') {
+         n = 16*n + (Long)((c - 'A') + 10);
+      }
+      else 
+      if (c >= 'a' && c <= (Char)'f') {
+         n = 16*n + (Long)((c - 'a') + 10);
+      }
+      else {
+       break;
+      }
+      str++;
+   }
+   if (neg) n = -n;
+   return n;
+}
+
 Long VG_(atoll36) ( Char* str )
 {
    Bool neg = False;
index d9765fa976e2d6331771375c73fbf58339e0f298..658aedb4f343b2946a89fd42448a31e40e742fc0 100644 (file)
@@ -42,7 +42,9 @@ extern Bool VG_(isdigit) ( Char c );
    Converting strings to numbers
    ------------------------------------------------------------------ */
 
+   // Nb: atoll16 doesn't handle a "0x" prefix.
 extern Long  VG_(atoll)   ( Char* str );     // base 10
+extern Long  VG_(atoll16) ( Char* str );     // base 16
 extern Long  VG_(atoll36) ( Char* str );     // base 36
 
 /* ---------------------------------------------------------------------