removed DavQLExpression type for path (since it always is an identifier)

Sat, 04 Apr 2015 19:45:58 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 04 Apr 2015 19:45:58 +0200
changeset 87
ed21d95984bb
parent 86
ecba8bdf9741
child 88
4d6b03bd7034

removed DavQLExpression type for path (since it always is an identifier)

libidav/davqlparser.c file | annotate | diff | comparison | revisions
libidav/davqlparser.h file | annotate | diff | comparison | revisions
--- a/libidav/davqlparser.c	Sat Apr 04 19:05:09 2015 +0200
+++ b/libidav/davqlparser.c	Sat Apr 04 19:45:58 2015 +0200
@@ -87,8 +87,6 @@
 }
 
 static void dav_debug_ql_stmt_print(DavQLStatement *stmt) {
-    sstr_t empty = ST("(empty)");
-    
     // Basic information
     size_t fieldcount = ucx_list_size(stmt->fields);
     int specialfield = 0;
@@ -111,7 +109,7 @@
         _map_querytype(stmt->type),
         fieldcount,
         _map_specialfield(specialfield),
-        sfmtarg(stmt->path ? stmt->path->srctext : empty),
+        sfmtarg(stmt->path),
         stmt->where ? "yes" : "no");
     if (stmt->type == DAVQL_SET) {
         printf("Value list size matches: %s",
@@ -173,8 +171,6 @@
         return DQLD_CMD_PS;
     } else if (!strcmp(buffer, "pe\n")) {
         return DQLD_CMD_PE;
-    } else if (!strcmp(buffer, "p\n")) {
-        return DQLD_CMD_P;
     } else if (!strcmp(buffer, "l\n")) {
         return DQLD_CMD_L;
     } else if (!strcmp(buffer, "r\n")) {
@@ -207,10 +203,6 @@
         case DQLD_CMD_Q: return;
         case DQLD_CMD_PS: dav_debug_ql_stmt_print(stmt); break;
         case DQLD_CMD_PE: dav_debug_ql_expr_print(examineexpr); break;
-        case DQLD_CMD_P:
-            examineexpr = stmt->path;
-            dav_debug_ql_expr_print(examineexpr);
-            break;
         case DQLD_CMD_L:
             if (dav_debug_ql_expr_selected(examineexpr)) {
                 if (examineexpr->left) {
@@ -234,7 +226,6 @@
         case DQLD_CMD_H:
             printf(
                 "\nCommands:\n"
-                "p:   examine path\n"
                 "ps:  print statement information\n"
                 "q:   quit\n\n"
                 "\nExpression examination:\n"
@@ -355,6 +346,16 @@
     return expr;
 }
 
+static void dav_free_expression(DavQLExpression *expr) {
+    if (expr->left) {
+        dav_free_expression(expr->left);
+    }
+    if (expr->right) {
+        dav_free_expression(expr->right);
+    }
+    free(expr);
+}
+
 static void dav_parse_unexpected_token(DavQLStatement *stmt, UcxList *token) {
     sstr_t emptystring = ST("");
     stmt->errorcode = DAVQL_ERROR_UNEXPECTED_TOKEN;
@@ -432,10 +433,13 @@
             break;
         }
         // from clause
-        case 20:
-            stmt->path = dav_parse_expression(token, 1);
+        case 20: {
+            DavQLExpression *expr = dav_parse_expression(token, 1);
+            stmt->path = expr->srctext;
+            dav_free_expression(expr);
             step = 520;
             break;
+        }
         // where clause
         case 30:
             step = 530;
@@ -505,16 +509,6 @@
     return stmt;
 }
 
-static void dav_free_expression(DavQLExpression *expr) {
-    if (expr->left) {
-        dav_free_expression(expr->left);
-    }
-    if (expr->right) {
-        dav_free_expression(expr->right);
-    }
-    free(expr);
-}
-
 void dav_free_statement(DavQLStatement *stmt) {
     UCX_FOREACH(expr, stmt->fields) {
         dav_free_expression(expr->data);
@@ -525,9 +519,6 @@
     }
     ucx_list_free(stmt->setvalues);
     
-    if (stmt->path) {
-        dav_free_expression(stmt->path);
-    }
     if (stmt->where) {
         dav_free_expression(stmt->where);
     }
--- a/libidav/davqlparser.h	Sat Apr 04 19:05:09 2015 +0200
+++ b/libidav/davqlparser.h	Sat Apr 04 19:45:58 2015 +0200
@@ -189,9 +189,9 @@
      */
     UcxList* setvalues;
     /**
-     * A DavQLExpression that denotes the queried path.
+     * A string that denotes the queried path.
      */
-    DavQLExpression* path;
+    sstr_t path;
     /**
      * Logical expression for selection.
      * <code>NULL</code>, if there is no where clause.

mercurial