]> git.mxchange.org Git - simgear.git/blobdiff - simgear/nasal/lex.c
Alas. Fix #pragma magic for GCC <= 4.5.
[simgear.git] / simgear / nasal / lex.c
index 685393ad24447b0159f5306e61789e9b4f736104..89c3c407b28c578181f07c4e460c684ea8fe591d 100644 (file)
@@ -257,15 +257,16 @@ static int lexHexLiteral(struct Parser* p, int index)
 }
 
 #define ISNUM(c) ((c) >= '0' && (c) <= '9')
-#define NUMSTART(c) (ISNUM(c) || (c)=='+' || (c) == '-')
+#define ISHEX(c) (ISNUM(c) || ((c)>='a' && (c)<='f') || ((c)>='A' && (c)<='F'))
+#define NUMSTART(c) (ISNUM(c) || (c) == '+' || (c) == '-')
 static int lexNumLiteral(struct Parser* p, int index)
 {
     int len = p->len, i = index;
     unsigned char* buf = (unsigned char*)p->buf;
     double d;
 
-    if(buf[0] == '0' && i+1<len && buf[i+1] == 'x')
-        return lexHexLiteral(p, index+2);
+    if(buf[i] == '0' && i+2<len && buf[i+1] == 'x' && ISHEX(buf[i+2]))
+       return lexHexLiteral(p, index+2);
 
     while(i<len && ISNUM(buf[i])) i++;
     if(i<len && buf[i] == '.') {