Code

Include config.h in source files.
[sysdb.git] / src / frontend / scanner.l
index cd7ea8513109fd266437b10dfaf5a2428b55aec3..6c2bfa148fd802ff4365187015d7636895af86bf 100644 (file)
 
 %{
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "frontend/connection.h"
 #include "frontend/parser.h"
 #include "frontend/grammar.h"
 #include "utils/error.h"
@@ -35,6 +40,8 @@
 
 #include <string.h>
 
+#define YY_EXTRA_TYPE sdb_fe_yyextra_t *
+
 void
 sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg);
 
@@ -77,7 +84,7 @@ identifier    ([A-Za-z_][A-Za-z_0-9$]*)
 <CSC>{csc_inside}      { /* ignore */ }
 <CSC>{csc_end}         { BEGIN(INITIAL); }
 <CSC><<EOF>> {
-               sdb_fe_yyerror(yylval, yyscanner, "unterminated C-style comment");
+               sdb_fe_yyerror(yylloc, yyscanner, "unterminated C-style comment");
                return SCANNER_ERROR;
        }
 
@@ -94,10 +101,13 @@ identifier ([A-Za-z_][A-Za-z_0-9$]*)
 %%
 
 sdb_fe_yyscan_t
-sdb_fe_scanner_init(const char *str)
+sdb_fe_scanner_init(const char *str, int len, sdb_fe_yyextra_t *yyext)
 {
        yyscan_t scanner;
 
+       if (! str)
+               return NULL;
+
        if (sdb_fe_yylex_init(&scanner)) {
                char errbuf[1024];
                sdb_log(SDB_LOG_ERR, "frontend: yylex_init failed: %s",
@@ -105,9 +115,14 @@ sdb_fe_scanner_init(const char *str)
                return NULL;
        }
 
+       sdb_fe_yyset_extra(yyext, scanner);
+
+       if (len < 0)
+               len = strlen(str);
+
        /* the newly allocated buffer state (YY_BUFFER_STATE) is stored inside the
         * scanner and, thus, will be freed by yylex_destroy */
-       yy_scan_string(str, scanner);
+       sdb_fe_yy_scan_bytes(str, len, scanner);
        return scanner;
 } /* sdb_fe_scanner_init */