aboutsummaryrefslogtreecommitdiff
path: root/src/preproc.c
AgeCommit message (Collapse)AuthorFiles
2021-07-14Rewrite preprocessing of native grecs configuration files.Sergey Poznyakoff1
When external preprocessing is required, each source file is preprocessed separately. This means that if you use #include or #include_once statements, a separate copy of external preprocessor will be started for each included file. In other words, when both internal and external preprocessing is used, the order is: external first, internal next. Previous versions of grecs implemented opposite order, when one external preprocessor was started, which obtained input from the internal preprocessor. One concequence of this is that any macros defined in a configuration file are no longer visible for files included from it. * include/grecs/lex.h (grecs_parse_line_directive) (grecs_parse_line_directive_cpp): Change signature. * include/grecs/preproc.h (grecs_preproc_init) (grecs_preproc_done) (grecs_preproc_run): Remove. (grecs_preprocess): New proto. * src/grecs-lex.l: Rewrite. * src/Make.am: Remove preproc.c * src/preproc.c: Remove. * src/bind-lex.l: Update calls to grecs_parse_line_directive* functions. * src/dhcpd-lex.l: Likewise. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Inlcude new tests. * tests/epp.at: New file. * tests/ipp.at: New file. * tests/fpp.c: Rename to tests/failpp.c * tests/gcfpp.c: New file. * tests/incl01.at: Change expected strings. * tests/ppexit.at: Change expected strings.
2021-07-13Correctly report preprocessor error status. Avoid cascading errors.Sergey Poznyakoff1
* src/grecs-gram.y (yyerror): Suppress error diagnostics if grecs_yyerror_suppress is set. * src/grecs-lex.l (yywrap): Suppress error diagnostics on external preprocessor failure and on #abend. * src/preproc.c (grecs_preproc_run): Return exit status of the preprocessor or -1 on errors. (grecs_preproc_extrn_start): Likewise. * tests/fpp.c: New file. * tests/gcffmt.c: New option: -preproc * tests/abend.at: Test error suppression after #abend. * tests/ppexit.at: New file. * tests/.gitignore: Add fpp. * tests/Makefile.am: Add new files. * tests/testsuite.at: Include ppexit.at
2021-07-12BugfixesSergey Poznyakoff1
* src/grecs-lex.l (yywrap): Fix return value. * src/preproc.c (grecs_preproc_extrn_start): Don't emit extra newlines while reporting errors. (grecs_preproc_extrn_shutdown): Fix conditional.
2021-07-10New preprocessor statements: #warning, #error, #abend.Sergey Poznyakoff1
* doc/grecs-syntax.texi: Document new preprocessor statements. * include/grecs/preproc.h (grecs_preproc_extrn_shutdown): Return int. * src/grecs-lex.l: Handle new preprocessor statements. * src/preproc.c (grecs_preproc_extrn_shutdown): Return error code. Bail out unless the preprocessor command terminates with code 0. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Include new tests. * tests/abend.at: New test. * tests/error.at: Likewise. * tests/warning.at: Likewise.
2021-06-09Don't look into cwd when searching for the pp-setup file.Sergey Poznyakoff1
* src/preproc.c (grecs_preproc_run): Change arguments in a call to grecs_find_include_file
2021-01-06Update copyright yearsSergey Poznyakoff1
2016-07-04Split declarations between several header files.Sergey Poznyakoff1
* Makefile.am (SUBDIRS): Add include * am/grecs.m4 (GRECS_INCLUDES): Update (GRECS_COND_BUILD_INSTALL) (GRECS_COND_BUILD_SHARED) (GRECS_COND_BUILD_STATIC): New conditions. Build include/Makefile and include/grecs/Makefile. * configure.ac: Use src/grecs-gram.y as a source validity marker * include/Makefile.a: New file. * src/grecs.hin: Remove. Split into include/*. See below. * include/grecs.h: New file. * include/grecs/.gitignore: New file. * include/grecs/Makefile.am: New file. * include/grecs/doc.h: New file. * include/grecs/error.h: New file. * include/grecs/format.h: New file. * include/grecs/lex.h: New file. * include/grecs/list.h: New file. * include/grecs/mem.h: New file. * include/grecs/node.h: New file. * include/grecs/parser.h: New file. * include/grecs/preproc.h: New file. * include/grecs/sockaddr.h: New file. * include/grecs/symtab.h: New file. * include/grecs/table.h: New file. * include/grecs/tree.h: New file. * include/grecs/txtacc.h: New file. * include/grecs/types.h.in: New file. * include/grecs/util.h: New file. * include/grecs/value.h: New file. * include/grecs/version.h: New file. * src/grecs-locus.h: Move to ... * include/grecs/locus.h: ... here * src/grecsopt.h: Move to ... * include/grecs/opt.h: ... here * src/json.h: Move to ... * include/grecs/json.h: ... here * src/wordsplit.h: Move to ... * include/wordsplit.h: ... here * src/Make-inst.am (include_HEADERS): Remove. * src/Make-shared.am (grecsinclude_HEADERS) (noinst_HEADERS): Remove. * src/Make-static.am (noinst_HEADERS): Remove. * src/Make.am: Remove header-related stuff * src/bind-gram.y: Fix includes. * src/bind-lex.l: Likewise. * src/cidr.c: Likewise. * src/dhcpd-gram.y: Likewise. * src/dhcpd-lex.l: Likewise. * src/diag.c: Likewise. * src/format.c: Likewise. * src/grecs-gram.y: Likewise. * src/grecs-lex.l: Likewise. * src/json-gram.y: Likewise. * src/json-lex.l: Likewise. * src/jsonfmt.c: Likewise. * src/lookup.c: Likewise. * src/meta1-gram.y: Likewise. * src/meta1-lex.l: Likewise. * src/opthelp.c: Likewise. * src/preproc.c: Likewise. * src/sockaddr.c: Likewise. * src/txtacc.c: Likewise. * src/version.c: Likewise. * tests/gcfenum.c: Likewise. * tests/gcffmt.c: Likewise. * tests/gcfpeek.c: Likewise. * tests/gcfset.c: Likewise. * tests/gcfver.c: Likewise. * tests/json.c: Likewise.
2016-07-04Update copyright yearsSergey Poznyakoff1
2016-06-20Ensure grecs_preproc reentrancy after grecs_preproc_doneSergey Poznyakoff1
* src/preproc.c (grecs_preproc_done): Reset static variables after free.
2016-06-20Fix grecs_foreach_include_dirSergey Poznyakoff1
2016-06-20Fix grecs_include_path_countSergey Poznyakoff1
* src/preproc.c (grecs_include_path_count): Return count.
2015-12-17Update copyright yearsSergey Poznyakoff1
2015-12-16Add option to hide configuration statements from help outputSergey Poznyakoff1
* src/format.c (grecs_print_statement_array): Skip elements marked with GRECS_HIDDEN flag. * src/grecs.hin (GRECS_HIDDEN): New flag.
2014-12-26Add globbing pattern support to #include and #include_onceSergey Poznyakoff1
* doc/grecs-syntax.texi: Document changes to the #include statement. * doc/grecs_config.5: Likewise. * src/preproc.c (include_glob, include_pos) (include_once): New statics. (pp_list_find): Return 0 if list is NULL. (incl_copy): New statics. (source_lookup): Use incl_copy as the copy function. (pop_source): If more glob expansions are available, push next one onto input stack. (isglob): New static. (parse_include): Support globbing patterns. * tests/Makefile.am: Add new testes. * tests/testsuite.at: Likewise. * tests/incl00.at: New test case. * tests/incl01.at: New test case. * tests/incl02.at: New test case. * tests/incl03.at: New test case.
2012-12-30Check returns from pipe and dup2.Sergey Poznyakoff1
2012-01-09Add functions for iterating over include directories.Sergey Poznyakoff1
* src/grecs.h (GRECS_STD_INCLUDE,GRECS_USR_INCLUDE): New defines. (grecs_include_path_count) (grecs_foreach_include_dir): New protos. * src/preproc.c (grecs_include_path_count) (grecs_foreach_include_dir): New functions.
2012-01-03Happy GNU YearSergey Poznyakoff1
2011-06-26Keep track of columns in the node and value locations. Improve error ↵Sergey Poznyakoff1
diagnostics. * src/grecs.h (grecs_locus_point): New struct. (grecs_locus_point_advance_line): New macro. (grecs_locus_t): Redesign. (grecs_value) <locus>: New member. (grecs_node) <idloc>: New member. (grecs_print_diag_fun): Change signature. (grecs_warning,grecs_error): Change signature. (grecs_parse_line_directive) (grecs_parse_line_directive_cpp) (grecs_string_convert): Change signature. (grecs_current_locus): Remove. (grecs_current_locus_point): New extern. * src/grecs-locus.h: New file. * src/Make.am (noinst_HEADERS): Add grecs-locus.h. * src/join.c (reset_locus): Rewrite. * src/lookup.c: Initialize new members of grecs_value and grecs_node. (split_cfg_path): Return wrdse error code. (grecs_node_from_path_locus): Take two grecs_locus_t arguments. Make sure all created nodes have their locus members properly initialized. * src/parser.c (grecs_parse): Initialize grecs_current_locus_point. * src/tree.c (grecs_node_create_points): New function. (string_to_bool,string_to_host,string_to_sockaddr) (grecs_string_convert): Change signatures. Be more precise in what locus to report. * src/diag.c (default_print_diag): Use YY_LOCATION_PRINT to output locus. (grecs_print_diag_fun): Change signature. (grecs_warning,grecs_error): Change signature. * src/format.c (grecs_format_locus): Rewrite. (grecs_format_node): Be more precise in what locus is being output. * src/bind-gram.y: Keep track of locations. Turn on error-verbose mode. * src/grecs-gram.y: Likewise. * src/meta1-gram.y: Likewise. * src/bind-lex.l: Keep track of locations. * src/git-parser.c: Likewise. * src/grecs-lex.l: Likewise. * src/meta1-lex.l: Likewise. * src/path-parser.c: Likewise. * src/preproc.c: Likewise. * tests/gcf1.conf: Untabify. * tests/format01.at: Reflect changes in the output. * tests/join.at: Likewise. * tests/set.at: Likewise. * tests/locus-bind.at: New testcase. * tests/locus-git.at: New testcase. * tests/locus-meta1.at: New testcase. * tests/locus00.at: New testcase. * tests/locus01.at: New testcase. * tests/locus02.at: New testcase. * tests/path-locus.at: New testcase.
2011-05-18Minor change.Sergey Poznyakoff1
* src/grecs.h (grecs_include_path_clear): New proto. * src/preproc.c (grecs_include_path_clear): New function.
2011-05-16Add bind testsuite.Sergey Poznyakoff1
* README.submodule: Update URL. * src/bind-lex.l (grecs_bind_new_source): Scan include path. * src/grecs.h (grecs_find_include_file): new proto. * src/preproc.c (try_file): Rename to grecs_find_include_file. Change signature and return type. All uses updated. * tests/Makefile.am (EXTRA_DIST): Add new configs. (TESTSUITE_AT): Add parser-bind.at. * tests/gcffmt.c: Add -I (-include) option. * tests/testsuite.at: Include parser-bind.at. * tests/bind.conf: New file. * tests/bind.dlz: New file. * tests/bind.ext.conf: New file. * tests/bind.int.conf: New file. * tests/bind.keys: New file. * tests/parser-bind.at: New file.
2011-05-16Implement BIND config parser.Sergey Poznyakoff1
* am/grecs.m4: New option: parser-bind. * src/.gitignore: Update. * src/Make.am [GRECS_COND_BIND_PARSER]: Set GRECS_PARSER_BIND and GRECS_EXTRA_BIND. (GRECS_SRC): Include GRECS_PARSER_BIND. (EXTRA_DIST): Include GRECS_EXTRA_BIND. * src/bind-gram.y: New file. * src/bind-lex.l: New file. * src/format.c (grecs_txtacc_format_value): New function. * src/grecs.h (grecs_bind_parser): New proto. * src/parser.c: Set grecs_current_locus. * src/tree.c (grecs_node_bind): Return immediately if node==NULL. * src/yytrans: Update.
2011-05-13Fix memory leaks.Sergey Poznyakoff1
* src/grecs-gram.y (slist production): Free ep->data after appending. * src/grecs-lex.l (string_list): Remove. All uses updated. * src/tree.c (grecs_node_free): Free ident. (grecs_tree_process): Fill config_keywords with zeros. * src/grecs.h (grecs_getline): New proto. * src/preproc.c (pp_getline): Rename to grecs_getline, drop static qualifier. Improve initial allocation.
2011-05-12Bugfixes.Sergey Poznyakoff1
2011-05-07Support standalone compilation.Sergey Poznyakoff1
* AUTHORS, COPYING, NEWS, README: New files. * .gitignore: Update. * am/.gitignore: New file. * build-aux/.gitignore: New file. * build-aux/ylwrap: Remove. * Makefile.am: Define ACLOCAL_AMFLAGS [GRECS_CHANGELOG]: Build ChangeLog. * am/grecs.m4: Define GRECS_CHANGELOG and GRECS_SRCDIR. Fixup first argument, if it is [.]. * configure.ac: New file. * src/Make-inst.am (include_HEADERS): Add wordsplit.h. Install libgrecs.m4. * Make-shared.am (noinst_HEADERS): Add wordsplit.h. * src/Make-static.am: Likewise. * src/Make.am (GRECS_SRC): Remove wordsplit.h (noinst_HEADERS): Add yygrecs.h (YLWRAP): Remove. * src/libgrecs.m4: New file. * src/yygrecs.h: New file. * src/grecs-gram.y: Include yygrecs.h. * src/grecs-lex.l: Likewise. * src/preproc.c (yy_grecs_flex_debug): Rename to grecs_yy_flex_debug.
2011-05-07Redo memory management (2).Sergey Poznyakoff1
* src/grecs.h (grecs_free_fun): New extern. (grecs_free): New proto. * src/format.c: Use grecs_free where appropriate. * src/grecs-lex.l: Likewise. * src/preproc.c: Likewise. * src/tree.c: Likewise. * src/lookup.c (parse_label): Use grecs_value_list_create. * src/mem.c: Initialize hooks with the default values. (grecs_free_fun): New hook. (grecs_free): New function. * doc/grecs_malloc.3: Document grecs_free. * doc/grecs_parse.3: Document the recent changes. * doc/grecs_strdup.3: Update.
2011-05-03Reindent all, except wordsplit, which is shared with MU.Sergey Poznyakoff1
2011-05-01Update copyright years. Add docs.Sergey Poznyakoff1
2011-04-30Drop all dependencies from gnulib.Sergey Poznyakoff1
* gnulib.modules: Remove. * src/mem.c: New file. * src/symtab.c: New file. * src/Makefile.am (libgrecs_a_SOURCES): Add mem.c and symtab.c. (INCLUDES): Remove -Ignu * src/grecs-gram.y (grecs_vasprintf, grecs_asprintf): New functions. (grecs_warning, grecs_error): Use grecs_vasprintf. (string_to_signed, string_to_unsigned): Remove. (STRTONUM,STRxTONUM,GETUNUM,GETSNUM): New macros (from Mailutils). (grecs_string_convert): Use macros for numeric conversions. (grecs_prop_tab): Remove entries for uintmax_t and intmax_t. * src/grecs-lex.l: Drop dependency on obstack. (line_acc, string_list): New statics. (line_acc_free_entry,line_acc_add_string): new function (line_acc_add_char,list_acc_unescape_char): new function (line_add_unescape_last): new function (grecs_lex_begin,grecs_line_add, multiline_begin) (grecs_line_finish): Rewrite. * src/grecs.h (grecs_type_uintmax,grecs_type_intmax): Remove. (grecs_malloc_fun,grecs_realloc_fun,grecs_alloc_die_fun): New externs. (grecs_malloc,grecs_realloc,grecs_alloc_die,grecs_strdup) (grecs_list_clear,grecs_list_free) (grecs_vasprintf,grecs_asprintf): New protos. (grecs_symtab,grecs_syment): New structs. (grecs_symtab_enumerator_t): New type. (grecs_symtab_strerror,grecs_symtab_lookup_or_install) (grecs_symtab_clear,grecs_symtab_create) (grecs_symtab_create_default) (grecs_symtab_free,grecs_symtab_remove,grecs_symtab_replace) (grecs_symtab_enumerate,grecs_symtab_count_entries): New protos. * src/list.c (grecs_list_clear): New function. (grecs_list_free): Use grecs_list_clear. * src/preproc.c (linebufbase,linebufsize): New variables. (pp_getline): New function. (pp_line_stmt_size): Remove. (pp_line_stmt): Use grecs_asprintf to format data. (next_line,grecs_preproc_extrn_start): Use pp_getline. (source_lookup): Use grecs_symtab instead of hash. * src/text.c: Rewrite using grecs_symtab.
2011-04-30Remove dependency on xlists.Sergey Poznyakoff1
* gnulib.modules (linked-list, xlist): Remove. * src/list.c: New file. * src/Makefile.am (libgrecs_a_SOURCES): Add list.c * src/grecs-gram.y: Use grecs_list functions. * src/preproc.c: Likewise. * src/grecs.h (grecs_list_entry, grecs_list): New structs. (grecs_value): use struct grecs_list* for the v.list member. (grecs_log_to_stderr): Change type to int. (grecs_list_create, grecs_list_size, grecs_list_push) (grecs_list_pop, grecs_list_locate, grecs_list_index) (grecs_list_remove_tail): New protos.
2011-04-18Remove superfluous gnulib modules. Improve wordsplit.Sergey Poznyakoff1
* gnulib.modules: Remove c-type, error, regex and stdbool. * src/grecs-gram.y: Use 0/1 instead of false/true. * src/preproc.c: Likewise. * src/grecs.h: Don't include stdbool.h * src/wordsplit.c: Apply fixes from Mailutils. * src/wordsplit.h: Likewise.
2010-01-02Update copyright years.Sergey Poznyakoff1
Happy GNU Year!
2009-10-16Minor fixes.Sergey Poznyakoff1
* gnulib.modules: Add error. * src/grecs-gram.y: Include string.h. * src/preproc.c: Include signal.h. (incl_hasher): Fix signature. * src/text.c (text_hasher): Fix signature.
2009-10-16Bugfixes.Sergey Poznyakoff1
* src/grecs-lex.l (unquote_char): Handle \" and \v. * src/preproc.c: Use normal C comments.
2009-04-21Change yyggrecs_ prefix to yy_grecs_Sergey Poznyakoff1
2009-04-20Diverge from Wydawca gconf/ subdirectory into a separate projectSergey Poznyakoff1

Return to:

Send suggestions and report system problems to the System administrator.