Code

Enable flex verbose output only in verbose build mode.
[sysdb.git] / src / tools / sysdb / scanner.l
index 1404690a1256354f078ab87f863e516d57ff270e..fb7b9d5fe92c3e7e9895a048b6ae2b229150faad 100644 (file)
@@ -38,6 +38,7 @@
 
 #include "tools/sysdb/input.h"
 
+#include <ctype.h>
 #include <string.h>
 
 #ifdef YY_INPUT
@@ -48,6 +49,8 @@
 
 #define APPEND() \
        do { \
+               if (! isspace((int)yytext[0])) \
+                       sysdb_input->have_input = 1; \
                sysdb_input->query_len += strlen(yytext); \
        } while (0)
 
 %option yylineno
 %option nodefault
 %option noyywrap
-%option verbose
 %option warn
 
 %x CSC
 
-newline                        ([\n\r]+)
+newline                        (\n|\r\n)
 simple_comment ("--"[^\n\r]*)
 
 /*
@@ -99,10 +101,17 @@ string             ('([^']|'')*')
         * The following rules are specific to the command line tool.
         */
 
+";\n"          { APPEND(); sdb_input_exec_query(); }
 ";"                    { APPEND(); sdb_input_exec_query(); }
 
+{newline}      {
+                               APPEND();
+                               if (! sysdb_input->have_input)
+                                       /* give the input module a chance to do stuff on empty lines */
+                                       sdb_input_exec_query();
+                       }
+
 .                      { APPEND(); }
-{newline}      { APPEND(); }
 
 %%