aboutsummaryrefslogtreecommitdiff
path: root/src/list.c
AgeCommit message (Collapse)AuthorFiles
2022-01-12Update copyright yearsSergey Poznyakoff1
2021-01-06Update copyright yearsSergey Poznyakoff1
2016-08-25symtabs: allow to modify the list during iteration over it.Sergey Poznyakoff1
* include/grecs/list.h (grecs_list_remove): New proto. * include/grecs/symtab.h (grecs_symtab_count_entries): Rename to grecs_symtab_count. * src/list.c (grecs_list_remove): New function. (grecs_list_remove_tail, grecs_list_clear) (grecs_list_locate,grecs_list_index): Treat NULL list as empty list. * src/symtab.c: Defer table modifications during iteration (symtab_defer_type): New enum. (grecs_symtab)<elcount,itr_level,defer_list>: New members. (symtab_defer_op): New static function. (grecs_symtab_remove): When called during iteration, add the entry to the defer_del deferment list, unless it is already in defer_add, in which case remove it from there. Update elcount. (grecs_symtab_lookup_or_install): Defer addition when iterating. Update elcount. (grecs_symtab_clear): Reset elcount to 0. (grecs_symtab_create): Initialize elcount. (grecs_symtab_foreach): Process deferred modifications.
2016-07-04Update copyright yearsSergey Poznyakoff1
2016-01-21Implement grecs_list_compare; other minor fixes.Sergey Poznyakoff1
* src/grecs.hin (grecs_list_compare) (grecs_node_unlink): New protos. * src/list.c (grecs_list_compare): New function. * src/wordsplit.c (wordsplit_getwords): Word count is size_t * src/wordsplit.h (wordsplit_getwords): Fix proto.
2016-01-09Fix memory leakSergey Poznyakoff1
* src/list.c (grecs_list_remove_entry): Free the entry, but not its data. All callers updated. * src/txtacc.c (grecs_txtacc_free_string): Free the txtacc entry after removal.
2015-12-17Update copyright yearsSergey Poznyakoff1
2015-12-16Shut useless compiler warningsSergey Poznyakoff1
2012-01-03Happy GNU YearSergey Poznyakoff1
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-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-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.

Return to:

Send suggestions and report system problems to the System administrator.