Update of /cvsroot/plib/plib/src/pui
In directory usw-pr-cvs1:/tmp/cvs-serv30655
Modified Files:
puValue.cxx
Log Message:
Changed strtoint () to handle plus signs and whitespace between sign and number
Index: puValue.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/pui/puValue.cxx,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- puValue.cxx 11 Jun 2002 18:58:15 -0000 1.18
+++ puValue.cxx 11 Jun 2002 19:35:12 -0000 1.19
@@ -24,10 +24,15 @@
#include "puLocal.h"
+inline void skip_whitespace ( const char **str )
+{
+ while ( isspace ( **str ) != 0 )
+ (*str)++ ;
+}
+
static int strtoint ( const char *str )
{
- while ( isspace ( *str ) != 0 )
- str++ ;
+ skip_whitespace ( &str ) ;
if ( *str == '\0')
return 0 ;
@@ -37,10 +42,15 @@
if ( *str == '-' )
{
result = -1 ;
- str++ ;
+ skip_whitespace ( &(++str) ) ;
}
else
+ {
result = 1 ;
+
+ if ( *str == '+' )
+ skip_whitespace ( &(++str) ) ;
+ }
if ( ulStrNEqual ( str, "0x", 2 ) == TRUE )
result *= (int) strtol ( str + 2, NULL, 16 ) ; /* try hexadecimal */
|