aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/diag.c2
-rw-r--r--src/json-gram.y1
-rw-r--r--src/json-lex.l35
3 files changed, 25 insertions, 13 deletions
diff --git a/src/diag.c b/src/diag.c
index bdbb407..db96e75 100644
--- a/src/diag.c
+++ b/src/diag.c
@@ -39,3 +39,3 @@ default_print_diag(grecs_locus_t const *locus, int err, int errcode,
if (errcode)
- fprintf(stderr, ": %s", strerror(errno));
+ fprintf(stderr, ": %s", strerror(errcode));
fputc('\n', stderr);
diff --git a/src/json-gram.y b/src/json-gram.y
index fe8996b..d5b0248 100644
--- a/src/json-gram.y
+++ b/src/json-gram.y
@@ -282,2 +282,3 @@ json_parse_string(char const *input, size_t len)
}
+ jsonlex_cleanup();
return json_return_obj;
diff --git a/src/json-lex.l b/src/json-lex.l
index 169cf32..4bbdedf 100644
--- a/src/json-lex.l
+++ b/src/json-lex.l
@@ -57,14 +57,2 @@ struct grecs_locus json_err_locus;
void
-jsonlex_setup(char const *s, size_t l)
-{
- input_ptr = s;
- input_size = l;
- json_current_locus_point.file = NULL;
- json_current_locus_point.line = 1;
- json_current_locus_point.col = 0;
- json_err_diag = NULL;
- yy_flex_debug = 0;
-}
-
-void
jsonlex_diag(const char *s)
@@ -229 +217,24 @@ false { yylval.b = 0; return T_BOOL; }
return T_ERR; }
+%%
+void
+jsonlex_setup(char const *s, size_t l)
+{
+ input_ptr = s;
+ input_size = l;
+ json_current_locus_point.file = "input";
+ json_current_locus_point.line = 1;
+ json_current_locus_point.col = 0;
+ json_err_diag = NULL;
+ yy_flex_debug = 0;
+ BEGIN(INITIAL);
+ yyrestart(NULL);
+}
+
+void
+jsonlex_cleanup(void)
+{
+ if (json_line_acc) {
+ grecs_txtacc_free(json_line_acc);
+ json_line_acc = NULL;
+ }
+}

Return to:

Send suggestions and report system problems to the System administrator.