summaryrefslogtreecommitdiffstats
path: root/lib.c
Commit message (Collapse)AuthorAgeFilesLines
* bugfix: several seq_iter kinds need clone operation.Kaz Kylheku2024-06-181-8/+18
| | | | | | | | | | | | | | Several seq_iter_t kinds of objects cannot be correctly bitwise copied, because they point to an iterator object that cannot be shared. * lib.c (seq_iter_clone_op): New static function. (si_hash_ops, si_tree_ops, si_oop_ops, si_fast_oop_ops): Use seq_iter_clone_op, which uses the copy function to duplicate it->ui.iter after doing a bitwise copy of the structure. * lib.h (seq_iter_ops_init_full): New macro.
* iter_reset: call seq_info only when needed.Kaz Kylheku2024-06-171-7/+11
| | | | | | * lib.c (iter_reset): Propagate sinf variable and seq_info call which initializes it into the scopes where it is used.
* More work on copy-iter.Kaz Kylheku2024-06-171-10/+35
| | | | | | | | | | * lib.c (copy_iter): Use the copy method for arguments which are structures, or else return just the objects if they implement list-like sequences. Error out otherwise. For an argument that is not an iterators or structure, error out if it is not a number, nil, or a list-like sequence. * txr.1: Documented.
* cobj: clone method streamlines copy; structs get copy method.Kaz Kylheku2024-06-171-14/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.h (struct cobj_ops): New function pointer, clone. (cobj_ops_init, cobj_ops_init_ex): Add clone argument to macros. * lib.c (seq_iter_cobj_ops): Use copy_iter as the clone operation. (cptr_ops): Use copy_cptr as clone operation. (copy): Replace if statements by check whether COBJ has a clone operation. If so, we use it to copy the object. * struct.h (enum special_slot): New member, copy_m. * struct.c (copy_s): New symbol variable. (special_sym): Associate copy_m enum value with copy symbol. (struct_init): Initialize copy_s with interned symbol. (struct_inst_clone): New static function. (struct_type_ops): Specify no clone operation via null pointer. (struct_inst_ops): Specify struct_inst_clone as clone operation. * arith.c (psq_ops): Indicate no clone operation via null pointer. * buf.c (buf_strm_ops): Likewise. * chksum.c (sha1_ops, sha256_ops, md5_ops): Likewise. * ffi.c (ffi_type_builtin_ops, ffi_type_struct_ops, ffi_type_ptr_ops, ffi_type_enum_ops, ffi_closure_ops, union_ops): Likewise. (carray_borrowed_ops, carry_owned_ops, carray_mmap_ops): Specify copy_carray as clone operation. * gc.c (prot_array_ops): Indicate no clone operation via null pointer. * gzip.c (gzio_ops_rd, gzip_ops_wr): Likewise. * hash.c (hash_iter_ops): Likewise. (hash_ops): Specify copy_hash as clone operation. * parser.c (parser_ops): Indicate no clone operation via null pointer. * rand.c (random_state_clone): New static function. (random_state_ops): Use random_state_clone as clone function. * regex.c (char_set_obj_ops, regex_obj_ops): Indicate no clone operation via null pointer. * socket.c (dgram_strm_ops): Likewise. * stream.c (null-ops, stdio_ops, tail_ops, pipe_ops, dir_ops, string_in_ops, byte_in_ops, strlist_in_ops, string_out_ops, strlist_out_ops, cat_stream_ops, record_adapter_ops): Likewise. * strudel.c (strudel_ops): Likewise. * sysif.c (cptr_dl_ops, opendir_ops): Likewise. * syslog.c (syslog_strm_ops): Likewise. * unwind.c (cont_ops): Likewise. * vm.c (vm_desc_ops, vm_closure_ops): Likewise. * tree.c (tree_ops): Use copy_search_tree for clone operation. (tree_iter_ops): Use copy_tree_iter for clone operation. * genchksum.txr: Changes in chksum.c specified in one place here. * tests/012/oop.tl: Couple of new tests. * txr.1: Documented.
* New function: copy-iter.Kaz Kylheku2024-06-151-0/+16
| | | | | | * eval.c (eval_init): Register copy-iter intrinsic. * lib.[ch] (copy_iter): New function.
* seq_iter: fix inadequate gc marking for some types.Kaz Kylheku2024-06-151-6/+21
| | | | | | | | | | | | * lib.c (seq_iter_mark_oop, seq_iter_mark_cat): New static functions. (si_oop_ops, si_fast_oop_ops): Use seq_iter_mark_oop instead of the generic one, because we need to mark the next field, not only the iter. (si_cat_ops): Use seq_iter_mark_cat, since we need to mark only the second field, dargs. * lib.h (seq_iter_ops_init_mark): New macro.
* New permi: iterator version of perm.Kaz Kylheku2024-06-151-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register permi intrinsic. * combi.c (permi_get, permi_peek, permi_clone): New static functions. (permi_ops): New static structure. (permi_iter): New static function. (permi): New function. * combi.h (permi): Declared. * lib.h (struct seq_iter_ops): New function pointer, clone. (seq_iter_ops_init, seq_iter_ops_init_nomark): Initialize new member. (seq_iter_ops_init_clone): New macro. (seq_iter_cls): Existing external name declared. (seq_iter_cobj_ops, seq_iter_mark_op): Previously internal names declared external. * lib.c (seq_iter_mark_op, seq_iter_cobj_ops): Static variables become extern. (seq_iter_clone): New static function. (seq_iter_init_with_info): Use seq_iter_clone instead of assuming we can trivially clone an iterator state bitwise.
* lib: rename seq_iter_ops static object.Kaz Kylheku2024-06-141-9/+10
| | | | | | | | | | The seq_iter_ops static structure is an instance of cobj_ops. Its name is the same identifier as that of struct seq_iter_ops, which is not related. This is confusing. * lib.c (seq_iter_ops): Structure renamed to seq_iter_obj_ops. (seq_begin, iter_begin, iter_dynamic, iter_catv): References to object updated to new name.
* quasiliterals: buffers in hex, separation for strings and buffers.Kaz Kylheku2024-05-271-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this commit, output variables in the TXR Pattern language and in TXR Lisp quasiliterals now support separator strings for values that are strings and buffers. Values which are buffers appear differently: they are rendered as a sequence of lower case hex digit pairs. When a string-valued variable specifies a separator, the separator appears between characters of the string value. Previously, the separator was ignored. When a buffer-valued variable specifies a separator. the separator appears between pairs of digits, not between digits. For instance if ethaddr is a variable holding #b'08:00:27:79:c7:f5', then the quasiliteral `@ethaddr` produces "08002779c7f" whereas `@{ethaddr ":"}` produces "08:00:27:79:c7:f5". * buf.[ch] (buf_str_sep): New function. * lib.[ch] (fmt_str_sep): New function. * eval.c (fmt_cat): If the argument is a string, and a separator is present, replace the value with the result of calling fmt_str_sep. If the argument is a buffer, and a separator is present, use buf_str_sep to convert to a string, otherwise use tostringp. * txr.1: Section on Output Variables updated. * tests/012/readprint.tl: New tests.
* interpose: use seq_iter and seq_build.Kaz Kylheku2024-05-261-7/+21
| | | | | | | * lib.c (interpose): non-list cases consolidated into one, which uses generic iteration and building. * tests/012/seq.tl: New tests
* cat-str: grammar in diagnostic.Kaz Kylheku2024-05-031-1/+1
| | | | | * lib.c (cat_str_measure): add missing word "is" in type error message.
* New function: iter-cat.Kaz Kylheku2024-04-161-0/+64
| | | | | | | | | | | | | | | | * eval.c (eval_init): Register iter-cat intrinsic. * lib.h (struct seq_iter): New union member dargs. (iter_catv): Declared. * lib.c (seq_iter_get_cat, seq_iter_peek_cat): New static functions. (si_cat_ops): New static structure. (iter_catv): New function. * tests/012/iter.tl: New tests. * txr.1: Documented.
* New function: lcons-force.Kaz Kylheku2024-04-041-0/+12
| | | | | | | | * lib.[ch] (lcons_force): New function. * eval.c (eval_init): Register lcons-force intrinsic. * txr.1: Documented.
* append, nconc; replace implementation with seq_build.Kaz Kylheku2024-03-101-28/+78
| | | | | | | | | | * lib.c (seq_append2, seq_appendv, seq_nconc2, seq_nconcv): New functions. (append2, appendv, nappend2, nconcv): Now implemented using new functions. * lib.h (seq_append2, seq_appendv, seq_nconc2, seq_nconcv): Declared.
* window-map: condense with seq_iter and seq_build.Kaz Kylheku2024-03-091-73/+45
| | | | | | | | | | | * lib.c (window_map_common): New static function formed from window_map_list. (window_map_list, window_map_vec): Function removed. (window_map, window_mappend, window_mapdo): Simplify to wrappers around window_map_common. * txr.1: Some wording improved in the window-map documentation.
* rfind: use seq_iter.Kaz Kylheku2024-03-071-7/+8
| | | | | | * lib.c (rfind): We combine the default case with SEQ_LISTLIKE and use the seq_iter abstraction rather than car/cdr.
* find: use seq_iter.Kaz Kylheku2024-03-071-41/+21
| | | | | | | * lib.c (find): We retain the optimization for strings when the comparison is regular equality (eq, eql, equal). The other cases are handled by seq_iter rather than separate list-like and vector-like cases.
* New function: rangeref.Kaz Kylheku2024-03-071-1/+34
| | | | | | | | | | | | | | | | | | | | | Because ranges can be iterated like sequences, and are identified as vector-like, they have to support indexing. However, ranges already have semantics as a function: with a sequence argument, they slice it. Let's put the semantics into a function called rangeref, so it can be coherently documented. * eval.c (eval_init): Register rangeref intrinsic. * lib.c (generic_funcall): Range as a function works in terms of rangeref. (ref): Handle RNG case via rangeref. (rangeref): New function. * lib.h (rangeref): Declared. * tests/012/seq.tl: New tests.
* list-vec: replace int type.Kaz Kylheku2024-03-021-2/+2
| | | | | * lib.c (list_vec): use ucnum rather than int for the index and length variables.
* unique: covert to seq_build.Kaz Kylheku2024-03-021-3/+4
| | | | | | * lib.c (unique): Build output using seq_build_t, rather than consing up a list which is then converted to the desired sequence type.
* zip: make more generic.Kaz Kylheku2024-03-011-39/+0
| | | | | | | | | | | | | | | | * lib.c (do_pa_12_1_v, pa_12_1_v): Static functions removed. (transposev, transpose): Functions removed. * lib.c (transposev, transpose): Declarations removed. * eval.c (join_f): New global variable. (zip_fun, zipv, transpose): New static functions. (eval_init): gc-protect join_f, and initialize it. Registration of zip intrinsic goes to zipv rather than transposev. sys:fmt-join and join registered with help of global join_f rather than local. * tests/012/seq.tl: New zip test cases.
* partition, split, split*: iter used for indicesKaz Kylheku2024-02-291-10/+14
| | | | | | | | | | | | | | | | | | * lib.c (partition_func, split_func, split_star_func): Indices passed through lazy cons are now iterator, rather than a sequence accessed via car and cdr, which is inefficient for nonlists. (partition-split-common): Use iter-begin to convert indices to iterator, which becomes the cdr field of the lazy cons. * txr.1: Update documentation for these functions to clarify that the second argument is a sequence. The inaccurate text claiming that "if the second argument is an atom other than a function" is rewritten. This doesn't describe the behavior that is implemented, where the test applied is seqp, not atom. The indices can be a vector of integers, which is an atom.
* partition-if: use seq_build for accumulating partitions.Kaz Kylheku2024-02-281-4/+6
| | | | | * lib.c (partition_if_func): Instead of list_collect_decl and make_like, use seq_build.
* partition-by: replace sequence traversal with iter.Kaz Kylheku2024-02-281-10/+13
| | | | | | | | * lib.c (partition_by_func): The seq object is now an iter object: use iter_more, iter_item and iter_step rather than non-null test, car and cdr. (partition_by): Obtain iterator for sequence using iter_begin, and use that in its place.
* partition-by: replace tuple accumulation with seq_build.Kaz Kylheku2024-02-281-6/+7
| | | | | * lib.c (partition_by_func): Use seq_build instead of list_collect_decl and make_like.
* seq_build: seq_pend must be nondestructive for lists.Kaz Kylheku2024-02-281-1/+17
| | | | | | | | | | | | | | | | | | | | Let's have both a seq_pend and seq_nconc, where seq_nconc can reuse the pieces of list passed to it. * lib.h (struct seq_build_ops): New member, nconc. (seq_build_ops_init): Add nconc parameter and initializer. (seq_nconc): Function declared. * lib.c (seq_build_list_pend): Switch to list_collect_append, otherwise mappend behaves destructively. (seq_build_list_nconc): New function. (sb_vec_ops, sb_str_ops, sb_buf_ops, sb_struct_ops, sb_carray_ops): Use seq_build_generic_pend for nconc operation. (sb_list_ops): Use new seq_build_list_nconc for nconc operation. (sb_finished_ops): Use null pointer for nconc operation. (seq_nconc): New function.
* seq_build: convert list buiding to list_collect.Kaz Kylheku2024-02-281-68/+9
| | | | | | | | | | | | | | | | | | | | | | | | | We want to use the list_collect functions for consistency. For instance, these functions allow an atom to be added to an improper list if the terminating atom is a sequence. (append '(1 . "abc") "d") yields (1 . "abcd"). * lib.h (struct seq_build): New member, tail. * lib.c (seq_build_list_add): Use list_collect. (seq_build_list_pend): Use list_collect_nconc. (seq_build_list_finish): Nothing to do here, except call seq_build_convert_to_finished since bu->obj is the head of the list at all times now. (seq_build_improper_add, seq_build_improper_pend): Functions removed. (sb_improper_ops): Structure removed. (seq_build_convert_to_improper): Function removed. (seq_build_convert_to_list): Different strategy needed here now. The list just goes into bu->obj, and we have to set up the tail to either point to the last cons cell's cdr, or else to bu->obj if the list is empty. (seq_build_init): Initialize bu->tail in the three cases that set up list collection.
* seq_build: whitespace.Kaz Kylheku2024-02-281-1/+1
| | | | * lib.c (sb_vec_ops): fix indentation.
* seq_build: remove unnecessary convert calls.Kaz Kylheku2024-02-281-2/+0
| | | | | | * lib.c (seq_build_struct_finish, seq_build_carray_finish): Do not call seq_build_convert_to_finished, since seq_build_list_finish has already done that.
* seq_build: remove one finish function.Kaz Kylheku2024-02-281-6/+1
| | | | | | | | * lib.c (seq_build_improper_finish): Function removed. (sb_improper_ops): Replace seq_build_improper_finish with null pointer. The seq_finish function checks for null and avoids calling, so we don't need the noop implementation.
* seq_build: safeguard against adding to finished object.Kaz Kylheku2024-02-281-0/+14
| | | | | | | | * lib.c (seq_build_convert_to_finished): New function. (seq_build_list_finish): call seq_build_convert_to_finished. (sb_finished_ops): New static struct. All operations except mark are null pointers so this will crash if used.
* mapcar, mappend: switch to seq_build.Kaz Kylheku2024-02-271-4/+16
| | | | | | | | | | | | | | * lib.c (mapcar): Implement with seq_iter and seq_build, rather than relying on mapcar_listout and make_like. (mappend): Replace list_collect_decl and make_like with seq_build. * eval.c (map_common): Replace list_collect_decl and make_like with seq_build. The collect_fn is now a pointer to either seq_add or seq_pend rather than list_collect or list_collect_append. (mapcarv, mappendv): Pass seq_add and seq_pend to map_common, rather than list_collect and list_collect_append.
* seq_build: support improper lists.Kaz Kylheku2024-02-271-1/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To be useful for some operations, the seq_build framework must handle the pend operation on lists specially. The appended piece must only be treated as a sequence if it is a cons. Moreover, if it is an atom, or of it is an improper list, then the list terminates. Subsequent add and pend operations must fail. The atom must appear as the terminator. We meet these objectives by switching the object's operations, sb_list_ops, to a new set of operations, sb_improper_ops. * lib.c (seq_build_list_pend): New static function. This individually adds all items from the input list, until it hits a terminating atom. If the atom isn't nil, it converts the seq_build_t object to improper operations. (seq_build_improper_add, seq_build_improper_pend): New static functions. These throw an error: adding anything to an improper list is impossible. (seq_build_improper_finish): New function, which does nothing: the improper list is finished already. (sb_list_ops): Use the seq_build_list_pend operation rather than the generic one. (sb_improper_ops): New static structure. (seq_build_convert_to_improper): New static function. Finishes the list, giving it the specified terminating atom, and then switches to sb_improper_ops so that adding is no longer possible.
* tuples: convert tuple generation to seq_build.Kaz Kylheku2024-02-271-4/+7
| | | | | | | | | | * lib.c (tuples_func): Replace list accumulation with make_like with seq_build. * tests/012/seq.tl: Fix one test case here which no longer errors out. It produces a tuple which is not a string, due to the inclusion of a non-character object.
* seq_build: fix: incompatible items must create list.Kaz Kylheku2024-02-271-12/+30
| | | | | | | | | | | | | | | | | | | | | In the make_like function, the list is converted to string or buffer if the first element of the list is a character, or integer. We need similar logic in seq_build. We can make it better. When any item is added which is incompatible, we can convert what we have so far to a list, change the seq_build type to list, and keep going. * lib.c (seq_build_convert_to_list): New static function. (seq_build_str_add, seq_build_buf_add): If the item is incompatible, convert the string or buffer to a list and pass to seq_build_convert_to_list. Then call bu->ops->add to add the item, now as a list. (seq_build_buf_pend): Function removed. (sb_buf_ops): Use the seq_build_generic_pend function for the pend operation. This is because we have to check each item one by one; we cannot use replace_buf.
* seq_build: struct/carray bugfix.Kaz Kylheku2024-02-271-3/+4
| | | | | | | * lib.c (seq_build_struct_finish, seq_build_carray_finish): These functions are still wrongly assuming that the list is finished by nreverse. We intead call seq_build_list_finish for that, which puts the list back into bu->obj.
* seq_build: put self name into structure.Kaz Kylheku2024-02-271-15/+16
| | | | | | | | | | | | | | | * lib.h (struct seq_build): New member, self. (struct seq_build_ops): Remove self parameter from pend function. (seq_build_init, seq_pend): Declarations updated. * lib.c (seq_build_generic_pend): Drop self parameter, take the value from structure. (seq_build_buf_pend): Drop self parameter. (seq_build_init): New self parameter. Pass recursively. (seq_pend): Self parameter dropped. (rem_impl, rem_if_impl, keep_keys_if, separate, separate_keys): Pass self to seq_build_init.
* seq_build: build lists in order using tail pointer.Kaz Kylheku2024-02-271-2/+19
| | | | | | | | | | * lib.c (seq_build_list_add, seq_build_list_finish): We use the trick that bu->obj (if not nil) points to the tail cons cell of the list being built, and the cdr of that tail always points back to the head. To finish the list, all we do is nil out that head pointer, so the list is properly terminated, and then plan the head as bu->obj.
* separate-keys: rework using seq_buildKaz Kylheku2024-02-271-62/+13
| | | | * lib.c (separate_keys): Rewrite using seq_info and seq_build.
* separate: rework using seq_build.Kaz Kylheku2024-02-271-75/+13
| | | | | * lib.c (separate): switch statement with type-specific coding replaced with generic sequence iteration and building.
* seq_build: allow initialization from iterator.Kaz Kylheku2024-02-271-0/+6
| | | | | | * lib.c (seq_build_init): Replicate a feature of make_like: if the reference object is an iterator, then we recurse: we initialize according to the object it is iterating.
* keep-keys-if: rework with generic sequence processing.Kaz Kylheku2024-02-261-56/+12
| | | | | * lib.c (keep_keys_if): Replace with generic sequence iteration and building.
* New sequence building framework.Kaz Kylheku2024-02-261-123/+207
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Just as the "seq_iter" iterators help to condense the code for iterating any kind of sequence, "seq_builder" objects solve the problem of producing a sequence of the same kind as an input sequence. Until now, two approaches have been taken for this. One was to have separately coded cases: code iterating over a string building up a string, and so on. The other has been to produce a list, which is then coerced to the right sequence type using make_like. The approach introduced here is similar to using make_like, but without wastefully consing up a temporary list. The remove-if, remqual, remql, remq and keep-if functions are retargetted to this new abstraction. * lib.h (struct seq_build, seq_build_t): New struct type. (struct seq_build_ops): New struct type. (seq_build_ops_init): New macro. (seq_build_init, seq_add, seq_pend, seq_finish): Functions declared. * lib.c (seq_build_generic_pend, seq_build_obj_mark, seq_build_struct_mark, seq_build_carray_mark, seq_build_vec_add, seq_build_str_add, seq_build_buf_add, seq_build_buf_pend, seq_build_buf_finish, seq_build_list_add, seq_build_list_finish, seq_build_struct_finish, seq_build_carray_finish): New static functions. (sb_vec_ops, sb_str_ops, sb_buf_ops, sb_struct_ops, sb_carray_ops, sb_list_ops): New static structs. (seq_build_init, seq_add, seq_pend, seq_finish): New functions. (rem_impl, rem_if_impl): Reworked in terms of seq_iter and seq_build, becoming much shorter, and handling all iterable objects.
* keep-if: don't report as remove-if in errors.Kaz Kylheku2024-02-261-3/+7
| | | | | | | * lib.c (rem_if_impl): New static function, based on renaming remove_if, and adding a self parameter. (remove_if): Now wrapper around rem_if_impl. (keep_if): Retarget to rem_if_impl, passing "keep-if" name.
* New function: cons-count.Kaz Kylheku2024-02-091-0/+19
| | | | | | | | | | | | | * eval.c (eval_init): Register cons-count intrinsic. * lib.c (cons_count_rec): New static function. (cons_count): New function. * lib.h (cons_count): Declared. * tests/012/cons.tl: New tests. * txr.1: Documented.
* New function: cons-find.Kaz Kylheku2024-02-091-0/+17
| | | | | | | | | | | | | | | | | * eval.c (cons_find): Static function removed; a new one is implemented in lib.c. (eval_init): Register cons-find intrinsic. * lib.c (cons_find_rec): New static function. (cons_find): New function. * lib.h (cons_find): Declared. * tests/012/cons.tl: New file. * txr.1: Documented cons-find together with tree-find. Document that tree-find's test-fun argument is optional, defaulting to equal.
* New function: hist-sort-by.Kaz Kylheku2024-02-021-2/+7
| | | | | | | | | | | | | * eval.c (eval_init): Register hist-sort-by intrinsic. * lib.c (hist_sort_by): New function. (hist_sort): Wrapper for hist_sort_by now. * lib.h (hist_sort_by): Declared. * tests/012/sort.tl: Tests. * txr.1: Documented.
* We need a length-< special method.Kaz Kylheku2024-01-191-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Structure objects can be used to implement lazy structures such as sequences. It is undesirable to take the length of a lazy sequence because it forces all of its elements to exist. Moreover, if the sequence is infinite, it is impossible. There are situations in which it is only necessary to know whether the length is less than a certain bound, and for that we have the length-< function. That works on infinite sequence such as lazy lists, requiring them to be forced only so far as to determine the truth value of the test. We need objects that implement lazy sequences to work with this function. * struct.h (enum special_slot): New member length_lt_m. * lib.h (length_lt_s): Symbol variable declared. * struct.c (special_sym): New entry in this table, associating the length_lt_m enum with the length_lt_s symbol variable. * lib.c (length_lt_s): Symbol variable defined. (length_lt): Handle COBJ objects that are structures. we test whether they have a length-< method, or else length method. If they don't have either, we throw. We don't fall back on the default case for objects that don't have a length-< method, because the diagnostic won't be good if they don't have a length method either; the programmer will be informed that the length function couldn't find a length method, without mentioning that it was actually length-< that is being used. * eval.c (eval_init): Register length-< using the length_lt_s symbol variable rather than using intern. * txr.1: Documented. * tests/012/oop-seq.tl: New tests.
* Copyright year bump 2024.Kaz Kylheku2024-01-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, alloca.h, args.c, args.h, arith.c, arith.h, autoload.c, autoload.h, buf.c, buf.h, cadr.c, cadr.h, chksum.c, chksum.h, chksums/crc32.c, chksums/crc32.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, gzio.c, gzio.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lib.c, lib.h, linenoise/linenoise.c, linenoise/linenoise.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, psquare.h, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, socket.c, socket.h, stdlib/arith-each.tl, stdlib/asm.tl, stdlib/awk.tl, stdlib/build.tl, stdlib/cadr.tl, stdlib/compiler.tl, stdlib/constfun.tl, stdlib/conv.tl, stdlib/copy-file.tl, stdlib/csort.tl, stdlib/debugger.tl, stdlib/defset.tl, stdlib/doloop.tl, stdlib/each-prod.tl, stdlib/error.tl, stdlib/except.tl, stdlib/expander-let.tl, stdlib/ffi.tl, stdlib/getopts.tl, stdlib/getput.tl, stdlib/glob.tl, stdlib/hash.tl, stdlib/ifa.tl, stdlib/keyparams.tl, stdlib/load-args.tl, stdlib/match.tl, stdlib/op.tl, stdlib/optimize.tl, stdlib/package.tl, stdlib/param.tl, stdlib/path-test.tl, stdlib/pic.tl, stdlib/place.tl, stdlib/pmac.tl, stdlib/quips.tl, stdlib/save-exe.tl, stdlib/socket.tl, stdlib/stream-wrap.tl, stdlib/struct.tl, stdlib/tagbody.tl, stdlib/termios.tl, stdlib/trace.tl, stdlib/txr-case.tl, stdlib/type.tl, stdlib/vm-param.tl, stdlib/with-resources.tl, stdlib/with-stream.tl, stdlib/yield.tl, stream.c, stream.h, struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, time.c, time.h, tree.c, tree.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, vm.c, vm.h, vmop.h, win/cleansvg.txr, y.tab.c.shipped: Copyright year bumped to 2024.
* lib: avoid realloc with zero size.Kaz Kylheku2024-01-161-3/+13
| | | | | | | | | | | | | I spotted in the N3096 draft of ISO C (April 2023) that a zero size in realloc is no longer defined behavior, like it used to be. I don't know exactly when it changed; in C99 it is not mentioned. We call realloc only in one place, so we can defend agains this. * lib.c (chk_realloc): If the new size is zero, we implement the C99 and older semantics: deallocate the object, and then behave like malloc(0). In other cases, we use realloc.