aboutsummaryrefslogtreecommitdiff
path: root/src/format.c
AgeCommit message (Collapse)AuthorFiles
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
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.
2015-01-15Bugfix in node formatting codeSergey Poznyakoff1
* src/format.c (grecs_format_node_path) (grecs_format_node_path): don't coredump on NULL values.
2014-09-25Add support for IPv6, multiple addresses and CIDRs.Sergey Poznyakoff1
* am/grecs.m4 (GRECS_SETUP): New option sockaddr-list. Build grecs.h at configure stage. * src/Make.am (GRECS_SRC): Add cidr.c and ipstr.c [GRECS_COND_SOCKADDR_LIST] (GRECS_SRC): Add sockaddr.c Remove rule for building grecs.h (see above). * src/cidr.c: New file. * src/ipstr.c: New file. * src/sockaddr.c: New file. * src/format.c (grecs_data_type_string): Change spelling of sockaddr. * src/grecs-lex.l: Treat square brackets as part of word. * src/grecs.hin (GRECS_SOCKADDR_LIST): New define. [GRECS_SOCKADDR_LIST] (grecs_sockaddr): New member: next. (grecs_str_is_ipv4,grecs_str_is_ipv6) (grecs_str_is_ipaddr,grecs_str_is_num): New functions. [GRECS_SOCKADDR_LIST] (grecs_sockaddr_hints): New struct. [GRECS_SOCKADDR_LIST] (grecs_sockaddr_new,grecs_sockaddr_free) (grecs_str_to_sockaddr): New protos. (grecs_cidr): New struct. (grecs_str_to_cidr,grecs_sockaddr_to_cidr) (grecs_sockadd_cidr_match): New protos. * src/tree.c [GRECS_SOCKADDR_LIST] (grecs_sockaddr_hints): New global. [!GRECS_SOCKADDR_LIST] (string_to_sockaddr): Retain for backward compatibility. [GRECS_SOCKADDR_LIST] (grecs_string_convert): Use grecs_str_to_sockaddr. (grecs_prop_tab): Add entry for grecs_type_cidr
2013-03-12Complement bef65e80 for block statements.Sergey Poznyakoff1
* src/format.c (grecs_print_block_statement): If argument name begins with \', omit the surrounding angle brackets and \' itself.
2012-10-11Minor fixes.Sergey Poznyakoff1
* src/format.c (grecs_data_type_string): Handle grecs_type_null * src/grecsopt.h: Add missing prototypes. * src/lookup.c: Remove unused variables. * src/opthelp.c: Likewise.
2012-10-08Minor improvement.Sergey Poznyakoff1
* src/format.c (grecs_print_simple_statement): If the type docstring begins with a \', print it as is, without the leading \' and data type specification. This is useful for fixed data types. * src/grecs.h (grecs_type_null): New keyword type. * src/tree.c: Silently ignore grecs_type_null.
2012-01-04Separate statement type and flags.Sergey Poznyakoff1
This change is incompatible with prior versions. Grecs users will have to add a new field to their keyword definitions. See tests/gcfset.c for an example. * src/grecs.h (GRECS_DFLT): New flag. (grecs_keyword) <flags>: New member. * src/format.c: Use flags where appropriate. * src/tree.c: Likewise. * tests/gcfset.c: Likewise.
2012-01-03Implement "inactive" statements.Sergey Poznyakoff1
* README.submodule: Minor change. * src/format.c (grecs_print_simple_statement): Mark inactive statements as such. (grecs_print_statement_array): Fix type comparison. Return immediately if given a NULL argument. * src/grecs.h (GRECS_INAC): New flag. * src/tree.c (find_keyword): Avoid coredump if cursect->kwd is NULL. (reduceproc): Skip inactive statements.
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-06-23Minor fixes.Sergey Poznyakoff1
2011-05-26Fix output formatting.Sergey Poznyakoff1
* Makefile.am (EXTRA_DIST): Add @GRECS_DISTDOC@. * am/grecs.m4 (GRECS_SETUP): New flag syntax-doc sets GRECS_DISTDOC. * doc/GRECS_SETUP.3: Update. * src/format.c (grecs_format_node): Print value if GRECS_NODE_FLAG_VALUE is set. * tests/glob01.at: Update.
2011-05-25Change GRECS_NODE_.* flag handling.Sergey Poznyakoff1
* src/grecs.h: Rearange GRECS_NODE_FLAG_* constants. Remove GRECS_NODE_FLAG_NODESCEND, introduce GRECS_NODE_FLAG_DESCEND instead. (_GRECS_NODE_MASK_DELIM,_GRECS_NODE_MASK_OUTPUT): New macros. (grecs_format_node): Returns int. (grecs_print_node): Likewise.
2011-05-19Implement "path-style" (Xres-style) config parser.Sergey Poznyakoff1
* src/path-parser.c: New file. * src/format.c (grecs_format_node): Attempt to print value only if the node is grecs_node_stmt. * src/grecs.h (grecs_path_parser): New proto. (grecs_node_from_path_locus): New proto. * src/lookup.c (grecs_node_from_path_locus): New function. * src/Make.am (GRECS_SRC): Add path-parser.c. * build-aux/getopt.m4: Implement print_help_hook.
2011-05-19Reimplement grecs_format_ familiy as output-independent functions.Sergey Poznyakoff1
* src/format.c (grecs_format_docstring): Rename to grecs_print_docstring. (grecs_format_simple_statement): Rename to grecs_print_simple_statement. (grecs_format_block_statement): Rename to grecs_print_block_statement. (grecs_format_statement_array): Rename to grecs_print_statement_array. (grecs_format_locus): Rename to grecs_print_locus. (grecs_format_node_path): Rename to grecs_print_node_path. (grecs_format_value): Rename to grecs_print_value. (grecs_format_node): Rename to grecs_print_node. (grecs_format_locus,grecs_format_node_path) (grecs_format_value,grecs_format_node): Reimplement as output-independent functions. All uses changed. * src/grecs.h: Update prototypes. * doc/grecs_format_locus.3: Update. * doc/grecs_format_node.3: Update. * doc/grecs_format_node_path.3: Update. * doc/grecs_format_value.3: Update.
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-14Wildcard look-ups (initial implementation).Sergey Poznyakoff1
* src/grecs-gram.y (union)<ident>: New field. (IDENT): Change type to <ident>. All uses changed. * src/grecs-lex.l (ident): Initialize ident.locus. * src/grecs.h (GRECS_NODE_FLAG_NODESCEND): New flag. (grecs_match_buf_t): New data type. (grecs_match_first,grecs_match_next) (grecs_match_buf_free): New protos. (grecs_tree_first_node,grecs_next_node): New protos. * src/format.c (grecs_format_node): Handle GRECS_NODE_FLAG_NODESCEND flag. * src/lookup.c (grecs_match_buf): New struct. (grecs_match_first,grecs_match_next) (grecs_match_buf_free): New functions. (split_cfg_path): Fill in array of values, if given. (parse_tag): Remove. All uses updated. (node_finder): Use grecs_match_buf. * src/tree.c (grecs_tree_reduce): Fill config_keywords with 0s. (grecs_tree_first_node, grecs_next_node): New functions. * tests/.gitignore: Add gcfenum * tests/enum.at: New file. * tests/glob00.at: New file. * tests/glob01.at: New file. * tests/glob02.at: New file. * tests/gcfenum.c: New file. * tests/Makefile.am: Build gcfenum. Add enum.at test. * tests/testsuite.at: Include enum.at. * tests/gcfpeek.c: Implement -match option.
2011-05-09Allow for statements without values, for compatibility with bind.Sergey Poznyakoff1
* src/format.c (grecs_format_value): Return immediately if val is NULL. * src/grecs-gram.y: Accept statements without values and arrays as block tags. * src/tree.c (grecs_process_ident): Bail out if a value is required, but not given.
2011-05-07Implement table-driven statement aggregation.Sergey Poznyakoff1
* src/grecs.h (grecs_tree_reduce): Change signature. (nodeproc_closure)<flags>: New member. (value_to_list): Bugfixes. (value_to_array,array_add): New functions. (node_aggregate_stmt): Rewrite. (node_merge_stmt): Take additional argument. (grecs_tree_reduce): Take additional argument. All uses changed. * src/tree.c (grecs_tree_free): Don't coredump on NULL arg. * src/format.c (grecs_format_simple_statement): Bugfix. * tests/reduce03.at: New testcase. * tests/Makefile.am: Add reduce03.at * tests/testsuite.at: Add reduce03.at * tests/gcffmt.c: Single grecs_format_node call is enough to print the entire tree. * tests/gcfset.c (logging_kwtab): Mark "facility" as GRECS_AGGR to disable aggregation. (usage): Update. (main): New options: -print, -locus, -sort, -noset. Pass GRECS_AGGR to grecs_tree_reduce.
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-06Redo memory management (1).Sergey Poznyakoff1
* src/grecs-lex.l (grecs_lex_end): Free both lists. Additional argument specifies if string data should be freed as well (on error). (grecs_value_dup): Don't append to string_list. * src/grecs.h (grecs_value) <v.string>: Remove const qualifier. <v.arg.v>: Array of struct grecs_value pointers. (grecs_node)<value>: Move to the union v. <v.texttab>: Text storage table (for grecs_node_root). (grecs_lex_end): Fix prototype. (grecs_value_list_create): New prototype. (grecs_value_free: New prototype. (grecs_value_dup): Rename to grecs_value_ptr_from_static. * src/text.c (grecs_text_table): New function. * src/tree.c (grecs_value_free): New function. (grecs_node_free): Reimplement. (grecs_tree_free): Rewrite using grecs_tree_recurse. (grecs_string_convert): strdup string values. (grecs_value_list_create): New function. * tests/gcffmt.c: Call grecs_tree_free. * tests/gcfpeek.c: Likewise. * tests/gcfset.c: Likewise.
2011-05-06Rewrite list support to keep doubly-linked lists. Implement tree reduction.Sergey Poznyakoff1
* src/format.c (grecs_format_node) (grecs_format_node_path): Handle grecs_node_root. * src/grecs-gram.y (input production): Create root node. * src/grecs.h (grecs_list_entry)<prev>: New member. (grecs_node_root): New node type. (grecs_node_eq): New proto. (grecs_list_add,grecs_tree_reduce): New protos. * src/list.c: Rewrite as a doubly-linked list. * src/tree.c (grecs_node_bind): Bugfix. (grecs_node_unlink): New function. (_tree_recurse): Allow for removal of the current node. (grecs_node_eq): New function. (grecs_tree_reduce): New function. (grecs_tree_process): Descend into the first subnode at once. * src/lookup.c (node_finder): Handle grecs_node_root. * tests/reduce00.at: New testcase. * tests/reduce01.at: New testcase. * tests/reduce02.at: New testcase. * tests/testsuite.at (GRECS_TEST): New macro. Include reduce0[0-2].at. * tests/gcffmt.c: New option -reduce. * tests/gcfpeek.c: Likewise. * tests/gcfset.c: Likewise.
2011-05-05Improve node formatting. Add version comparasion functions.Sergey Poznyakoff1
* am/grecs.m4 (GRECS_SETUP): New option: shared. * doc/GRECS_SETUP.3: Document new options. * doc/grecs_format_locus.3: Update. * doc/grecs_format_node.3: Document new flags. * src/.gitignore: Update. * src/version.c: New file. * src/Make.am (GRECS_SRC): Add version.c (EXTRA_DIST): Update. * src/diag.c (default_print_diag): Flush stdout as per the docs. * src/format.c (grecs_format_locus): Don't print trailing semicolon. (grecs_format_value): Handle GRECS_NODE_FLAG_NOQUOTE flag. (grecs_format_node): Print delimiters when needed. * src/grecs.h (grecs_version_info): New struct. (grecs_version, grecs_version_cmp): New protos. (GRECS_NODE_FLAG_NOQUOTE): New flag. * tests/gcfver.c: New file. * tests/vercmp.at: New file. * tests/.gitignore: Update. * tests/Makefile.am: Define GRECS_VERCMP_AT in package.m4 (TESTSUITE_AT): Add vercmp.at (conditionally). (noinst_PROGRAMS): Add gcfver. * tests/testsuite.at: Conditionally include vercmp.at.
2011-05-03Minor fix.Sergey Poznyakoff1
* src/format.c (grecs_format_value): Fix quoting (missed trailing 0).
2011-05-03Various impovements.Sergey Poznyakoff1
* am/grecs.m4 (GRECS_SETUP): New flags: getopt and git2chg. * src/format.c (grecs_format_locus): Ignore NULL loci. (grecs_format_node_ident): Rename to grecs_format_node_path. Change semantics of the second argument. (grecs_format_value): Change signature (take flags). Correctly quote string values. * src/grecs.h: Protect the contents with #ifndef _GRECS_H. (GRECS_AGGR): New flag (for future use). (grecs_node) <prev>: New member. (grecs_format_value): Change signature. (grecs_format_node_ident): Rename to grecs_format_node_path. (GRECS_NODE_FLAG_PATH,GRECS_NODE_FLAG_VALUE) (GRECS_NODE_FLAG_QUOTE,GRECS_NODE_FLAG_QUOTE_HEX) (GRECS_NODE_FLAG_DEFAULT): New flags. (grecs_node_from_path): New proto. * src/lookup.c (grecs_node_from_path): New function. * src/tree.c (grecs_node_bind): Keep track of node->prev.
2011-05-03Switch to the two-layer model. Add testsuite.Sergey Poznyakoff1
The configuration file parser creates a syntax tree. This step does not require any knowledge about which keywords are allowed. The user can then either use that tree directly, or post-process it using parser tables. The latter approach is equivalent to previous versions of grecs.
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.
2010-01-02Update copyright years.Sergey Poznyakoff1
Happy GNU Year!
2009-10-12Namespace cleanup. Add grecs_process_ident function.Sergey Poznyakoff1
* src/grecs.h (GCONF_): Change prefix to GRECS_. All usages updated. (grecs_string_convert): Change prototype. (grecs_process_ident): New prototype. * src/grecs-gram.y (CURRENT_BASE): New define. (target_ptr): Take base as 2nd parameter. All callers updated. (string_to_signed, string_to_unsigned) (string_to_bool, string_to_host) (string_to_sockaddr, grecs_string_convert): Take additional argument: source location. (grecs_process_ident): New function. (process_ident): Rewrite as a wrapper over grecs_process_ident. * src/wordsplit.c (wordsplit_init): Fix handling of WRDSF_DOOFFS.
2009-04-20Diverge from Wydawca gconf/ subdirectory into a separate projectSergey Poznyakoff1

Return to:

Send suggestions and report system problems to the System administrator.