Browse Source

ignore all preceding space chars (close #477)

Nicolas Cannasse 3 years ago
parent
commit
da5ba07af7
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/std/ucs2.c

+ 6 - 2
src/std/ucs2.c

@@ -67,12 +67,16 @@ uchar *ustrdup( const uchar *str ) {
 	return d;
 	return d;
 }
 }
 
 
+static bool is_space_char( uchar c ) {
+	return c == ' ' || c == '\r' || c == '\n' || c == '\t';
+}
+
 double utod( const uchar *str, uchar **end ) {
 double utod( const uchar *str, uchar **end ) {
 	char buf[31];
 	char buf[31];
 	char *bend;
 	char *bend;
 	int i = 0;
 	int i = 0;
 	double v;
 	double v;
-	while( *str == ' ' ) str++;
+	while( is_space_char(*str) ) str++;
 	while( i < 30 ) {
 	while( i < 30 ) {
 		int c = *str++;
 		int c = *str++;
 		if( (c < '0' || c > '9') && c != '.' && c != 'e' && c != 'E' && c != '-' && c != '+' )
 		if( (c < '0' || c > '9') && c != '.' && c != 'e' && c != 'E' && c != '-' && c != '+' )
@@ -90,7 +94,7 @@ int utoi( const uchar *str, uchar **end ) {
 	char *bend;
 	char *bend;
 	int i = 0;
 	int i = 0;
 	int v;
 	int v;
-	while( *str == ' ' ) str++;
+	while( is_space_char(*str) ) str++;
 	while( i < 16 ) {
 	while( i < 16 ) {
 		int c = *str++;
 		int c = *str++;
 		if( (c < '0' || c > '9') && c != '-' )
 		if( (c < '0' || c > '9') && c != '-' )