From c3850a4d3f94436aab6b23020242bc99c71506ee Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Mon, 4 Jun 2018 11:11:20 +0300 Subject: json: improve parser reentrability * include/grecs/json.h (jsonlex_cleanup): New proto. * src/json-lex.l (jsonlex_setup): Initialize parser state. Initialize json_current_locus_point.file to a non-NULL value. (jsonlex_cleanup): New function. * src/json-gram.y (json_parse_string): Call jsonlex_cleanup before returning. * src/diag.c (default_print_diag): Print the passed errcode argument, instead of errno. --- include/grecs/json.h | 1 + include/wordsplit.h | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/grecs/json.h b/include/grecs/json.h index f8402e7..49a6b87 100644 --- a/include/grecs/json.h +++ b/include/grecs/json.h @@ -54,6 +54,7 @@ extern struct grecs_locus json_err_locus; extern struct json_value *json_return_obj; void jsonlex_setup(char const *s, size_t l); +void jsonlex_cleanup(void); void jsonlex_diag(const char *s); int json_unescape(char c, char *o); diff --git a/include/wordsplit.h b/include/wordsplit.h index d13ec3c..7229df3 100644 --- a/include/wordsplit.h +++ b/include/wordsplit.h @@ -26,9 +26,11 @@ typedef struct wordsplit wordsplit_t; provide return values when the function returns. If neither mark is used, the member is internal and must not be used by the caller. - In the comments below, the - identifiers in parentheses indicate bits that must be set (or unset, if - starting with !) in the ws_flags to initialize or use the given member. + In the comments below, the identifiers in parentheses indicate bits that + must be set (or unset, if starting with !) in ws_flags (if starting with + WRDSF_) or ws_options (if starting with WRDSO_) to initialize or use the + given member. + If not redefined explicitly, most of them are set to some reasonable default value upon entry to wordsplit(). */ struct wordsplit -- cgit v1.2.1