aboutsummaryrefslogtreecommitdiff
path: root/src/lookup.c
AgeCommit message (Collapse)AuthorFiles
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-22Optionally use preprocessor for bind configs.Sergey Poznyakoff1
* src/bind-lex.l: Parse #line directives. (_pop_context): Use fclose or pclose, depending on how the stream was opened. (grecs_bind_new_source): Use preprocessor if grecs_preprocessor was set. * src/grecs-lex.l (parse_line): Rename to grecs_parse_line_directive. (parse_line_cpp): Rename to grecs_parse_line_directive_cpp. * src/grecs.h (grecs_parse_line_directive) (grecs_parse_line_directive_cpp): New protos. * src/lookup.c (grecs_match_first): Bugfix.
2011-05-20Fix bind parser.Sergey Poznyakoff1
* src/bind-gram.y: Special handling for the controls block. * src/bind-lex.l: Handle "controls" separately. * src/lookup.c (grecs_find_node): Handle single dot path (root node). (grecs_match_first): Likewise. (grecs_match_next): Return NULL if buf is NULL. * tests/parser-bind.at: Update.
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-19Bugfixes.Sergey Poznyakoff1
* Makefile.am: Fix format to git log. * src/bind-lex.l (grecs_bind_close_sources): Reset input_stack to 0. * src/lookup.c (split_cfg_path): Allow only one of "./:;,^~" at the beginning of a path.
2011-05-15Improve wildcard matching.Sergey Poznyakoff1
* src/lookup.c (grecs_value_match): New function. (grecs_match_buf_free): Ignore NULL argument. (grecs_match): Implement single-occurrence wildcard (%). Match values using fnmatch globbing patterns. (grecs_match_first): Compress multiple contiguous *
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-09Bugfix.Sergey Poznyakoff1
* src/lookup.c (grecs_value_eq): Allow for NULL values.
2011-05-07Bugfixes.Sergey Poznyakoff1
* src/grecs.h (GRECS_MULT): New flag. * src/lookup.c (parse_label): Allocate array elements. * src/tree.c (grecs_process_ident): Store string duplicates in lists. (reduceproc): Ignore keywords marked with GRECS_MULT.
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-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.

Return to:

Send suggestions and report system problems to the System administrator.