Author: njn
Date: 2007-09-22 07:23:07 +0100 (Sat, 22 Sep 2007)
New Revision: 6899

Log:
Add VG_(atoll).

Modified:
   trunk/coregrind/m_libcbase.c
   trunk/include/pub_tool_libcbase.h


Modified: trunk/coregrind/m_libcbase.c
===================================================================
--- trunk/coregrind/m_libcbase.c        2007-09-22 00:07:09 UTC (rev 6898)
+++ trunk/coregrind/m_libcbase.c        2007-09-22 06:23:07 UTC (rev 6899)
@@ -63,6 +63,33 @@
    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;

Modified: trunk/include/pub_tool_libcbase.h
===================================================================
--- trunk/include/pub_tool_libcbase.h   2007-09-22 00:07:09 UTC (rev 6898)
+++ trunk/include/pub_tool_libcbase.h   2007-09-22 06:23:07 UTC (rev 6899)
@@ -42,7 +42,9 @@
    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
 
 /* ---------------------------------------------------------------------


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to