Re-insert errno=0 before calling strtoXX() (thanks go to Manuele)
authorMario de Sousa <msousa@fe.up.pt>
Sat, 09 Jun 2012 08:35:46 +0100
changeset 571 97b85630e496
parent 570 cb704eca7e37
child 572 c353bc67bf91
Re-insert errno=0 before calling strtoXX() (thanks go to Manuele)
absyntax_utils/absyntax_utils.cc
--- a/absyntax_utils/absyntax_utils.cc	Fri Jun 08 19:47:45 2012 +0100
+++ b/absyntax_utils/absyntax_utils.cc	Sat Jun 09 08:35:46 2012 +0100
@@ -129,6 +129,7 @@
   for(unsigned int i = 3; i < strlen(hex_integer->value); i++)
     if (hex_integer->value[i] != '_') str += hex_integer->value[i];
     
+  errno = 0; // since strtoXX() may legally return 0, we must set errno to 0 to detect errors correctly!
   ret = strtoull(str.c_str(), &endptr, 16);
   if (errno != 0) ERROR;
 
@@ -148,6 +149,7 @@
   for(unsigned int i = 3; i < strlen(real_sym->value); i++)
     if (real_sym->value[i] != '_') str += real_sym->value[i];
     
+  errno = 0; // since strtoXX() may legally return 0, we must set errno to 0 to detect errors correctly!
   #if    (real64_t  == float)
     ret = strtof(str.c_str(), NULL);
   #elif  (real64_t  == double)