Browse Source

cmLex.c: Fixed bug where a '-' with no following digits was interpretted as a integer.

master
kevin 11 years ago
parent
commit
18fc1b0a12
1 changed files with 5 additions and 1 deletions
  1. 5
    1
      cmLex.c

+ 5
- 1
cmLex.c View File

200
 unsigned _cmLexIntMatcher(   cmLex* p, const cmChar_t* cp, unsigned cn, const cmChar_t* keyStr )
200
 unsigned _cmLexIntMatcher(   cmLex* p, const cmChar_t* cp, unsigned cn, const cmChar_t* keyStr )
201
 {
201
 {
202
   unsigned i = 0;
202
   unsigned i = 0;
203
+  bool signFl = false;
203
   for(; i<cn; ++i)
204
   for(; i<cn; ++i)
204
   {
205
   {
205
     if( i==0 && cp[i]=='-' )
206
     if( i==0 && cp[i]=='-' )
207
+    {
208
+      signFl = true;
206
       continue;
209
       continue;
210
+    }
207
 
211
 
208
     if( !isdigit(cp[i]) )
212
     if( !isdigit(cp[i]) )
209
       break;
213
       break;
220
   // containing a decimal point as reals. 
224
   // containing a decimal point as reals. 
221
  
225
  
222
 
226
 
223
-  return i;
227
+  return signFl && i==1 ? 0 : i;
224
 }
228
 }
225
 
229
 
226
 unsigned _cmLexHexMatcher(   cmLex* p, const cmChar_t* cp, unsigned cn, const cmChar_t* keyStr )
230
 unsigned _cmLexHexMatcher(   cmLex* p, const cmChar_t* cp, unsigned cn, const cmChar_t* keyStr )

Loading…
Cancel
Save