removed ultrabreak gotos

Wed, 15 Apr 2015 08:57:46 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 15 Apr 2015 08:57:46 +0200
changeset 94
8822f7c08843
parent 93
2176ffbf1346
child 95
8ed7d8df6427

removed ultrabreak gotos

libidav/davqlparser.c file | annotate | diff | comparison | revisions
--- a/libidav/davqlparser.c	Mon Apr 13 20:06:04 2015 +0200
+++ b/libidav/davqlparser.c	Wed Apr 15 08:57:46 2015 +0200
@@ -505,17 +505,13 @@
     
     // Process tokens
     UCX_FOREACH(token, tokens) {
-        if (stmt->errorcode) {
-            ultrabreak: break;
-        }
-        
         sstr_t tokendata = *token_sstr(token);
         
         switch (step) {
         // too much input data
         case _step_end_:
             dav_parse_unexpected_token(stmt, token);
-            goto ultrabreak;
+            break;
         // optional clauses
         case _step_expect_WWO_:
             if (!sstrcasecmp(tokendata, S("with"))) {
@@ -535,7 +531,6 @@
                 continue;
             } else { // last possible clause checked and not present
                 dav_parse_unexpected_token(stmt, token);
-                goto ultrabreak;
             }
             break;
         case _step_expect_BY:
@@ -545,7 +540,6 @@
                 stmt->errorcode = DAVQL_ERROR_UNEXPECTED_TOKEN;
                 stmt->errormessage = ucx_sprintf(_expected_by,
                     sfmtarg(tokendata)).ptr;
-                goto ultrabreak;
             }
             break;
         case _step_comma_WITH_:
@@ -559,7 +553,6 @@
                 step = _step_expect_BY;
             } else {
                 dav_parse_unexpected_token(stmt, token);
-                goto ultrabreak;
             }
             break;
         // field list
@@ -571,13 +564,12 @@
                         dav_parse_expression(stmt, exprstart, exprlen));
                     exprstart = NULL;
                     exprlen = 0;
+                    
+                    if (fromkeyword) {
+                        step = _step_FROM_;
+                    }
                 } else {
                     dav_parse_unexpected_token(stmt, token);
-                    goto ultrabreak;
-                }
-                
-                if (fromkeyword) {
-                    step = _step_FROM_;
                 }
             } else {
                 // collect tokens for field expression
@@ -629,6 +621,11 @@
             stmt->errorcode = DAVQL_ERROR_INVALID;
             stmt->errormessage = strdup(_parser_state);
         }
+        
+        // cancel processing, when an error has been detected
+        if (stmt->errorcode) {
+            break;
+        }
     }
     
     if (!stmt->errorcode && step < _step_end_) {

mercurial