token parser checks if token of class DAVQL_TOKEN_NUMBER consists of digits only

Sun, 02 Jul 2017 21:35:01 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 02 Jul 2017 21:35:01 +0200
changeset 263
f24b730cb75e
parent 262
e2579b63595a
child 264
94c0a938b66c

token parser checks if token of class DAVQL_TOKEN_NUMBER consists of digits only

libidav/davqlparser.c file | annotate | diff | comparison | revisions
mingw.mk file | annotate | diff | comparison | revisions
--- a/libidav/davqlparser.c	Tue Feb 07 18:36:28 2017 +0100
+++ b/libidav/davqlparser.c	Sun Jul 02 21:35:01 2017 +0200
@@ -475,6 +475,13 @@
 
     if (isdigit(firstchar)) {
         token->tokenclass = DAVQL_TOKEN_NUMBER;
+        // check, if all characters are digits
+        for (size_t i = 1 ; i < token->value.length ; i++) {
+            if (!isdigit(token->value.ptr[i])) {
+                token->tokenclass = DAVQL_TOKEN_INVALID;
+                break;
+            }
+        }
     } else if (firstchar == '%') {
         token->tokenclass = DAVQL_TOKEN_FMTSPEC;
     } else if (token->value.length == 1) {
@@ -496,6 +503,7 @@
         token->tokenclass = DAVQL_TOKEN_KEYWORD;
     } else {
         token->tokenclass = DAVQL_TOKEN_IDENTIFIER;
+        // TODO: check for illegal characters
     }
     
     // remove quotes (extreme cool feature)
--- a/mingw.mk	Tue Feb 07 18:36:28 2017 +0100
+++ b/mingw.mk	Sun Jul 02 21:35:01 2017 +0200
@@ -42,6 +42,6 @@
 LIB_EXT = .a
 APP_EXT = .exe
 
-DAV_CFLAGS = -I /mingw/include/libxml2
+DAV_CFLAGS = -I/usr/include/libxml2
 DAV_LDFLAGS = -lcurl  -lxml2 -lssl -lcrypto -lws2_32 -lgdi32 -lregex
 

mercurial