summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* New macro: letrec.Kaz Kylheku2025-03-211-0/+21
| | | | | | | | | * eval.c (me_letrec): New function. (eval_init): Register letrec intrinsic macro. * tests/012/let.tl: New file. * txr.1: Documented, and also referenced from mlet.
* Expose brace expansion bexp function.Kaz Kylheku2025-03-091-37/+37
| | | | | | | | | | | | | | | | | * autoload.c (glob_set_entries): Remove autoload on sys:brace-expand. Add usr:exp. * stdlib/glob.tl (brace-expand): Renamed to usr:bexp. (glob*): Call bexp rather than brace-expand. * tests/018/glob.tl: Rename references to sys:brace expand to bexp. * txr.1: Add section describing the bexp function. Move brace expansion documentation from glob* to this new section, adjusting the wording a little bit, mainly to avoid referring to "patterns". Point glob* documentation to bexp, which also in turn references glob*.
* glob*: add string and integer ranges to brace expansion.Kaz Kylheku2025-03-081-1/+76
| | | | | | | | | | | | | | | | * stdlb/glob.tl (bexp-parse): Recognize .. as a token. (bexp-parse-brace): If a brace expansion doesn't contain commas, then check whether it contains .. and that its elements are all strings. In that case it is a possible range expansion and we thus transform it to a (- ...) node, subject to more validation in bexp-expand. (bexp-expand): Add casees to handle range expansion, taking care that invalid forms translate to verbatim syntax. * tests/018/glob.tl: New tests. * txr.1: Documented.
* New feature: range iteration with skip.Kaz Kylheku2025-03-071-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | The notation X..Y..Z now denotes an iterable range, if X..Y is a valid iterable range on its own, and Z is a positive integer. Z gives a step size: 1 takes every element, 2 every other and so on. * lib.c (seq_iter_get_skip, set_iter_peek_skip): New static functions. (si_skip_ops): New static structure. (iter_dynamic): Function relocated earlier in file to avoid forward declaration. (seq_iter_init_with_info): When the iterated object is a range, check for the to element itself being a range. If so, it is potentially a skip iteration. Validate it and implement via a skip iterator referencing a dynamic range iterator. * lib.h (struct seq_iter): New sub-union member, ul.skip. We could use an existing member of type cnum; this is for naming clarity. * tests/012/iter.tl: New tests. * txr.1: Documented.
* New function: iterp.Kaz Kylheku2025-03-071-0/+20
| | | | | | | | | | | | | | | | | * eval.c (eval_init): Register iterp intrinsic. * lib.[ch] (iterp): New function. * tests/012/iter.tl: New tests. * txr.1: Document iterp. Update documentation for iter-more, iter-item and iter-step to more precisely identify which objects are valid arguments in terms of iterp and additional conditions, and that other objects throw a type-error exception. Fix wrong references to iter-more under documentation for iter-item. Removed obsolete text specifying that iter-step uses car on list-like sequences, a dubious behavior removed in the previous commit.
* iterator API: reject objects that don't make sense.Kaz Kylheku2025-03-061-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (iter_more): Do not return t for unrecognized objects, but thrown an exception. Do return t for conses, which is necessary since they are iterators for lists. Also, as a special case, we return t for struct objects that don't have an iter-more method. This is needed for the documented fast protocol. Iterator objects implementing the fast protocol still get iter-more invoked on them. The client usually doesn't know that the iterator implements the fast protocol, and so calls iter-more, which unconditionally has to returns true. (iter_item): Do not fall back on car(iter) for all unhandled objects. Only conses are handled via car. All unrecognized objects trigger an exception. (iter_step): Do not try to handle list-like objects via cdr, only lists. Improve the diagnostic for hitting the end of an improper list: diagnostic shows the cons cell rather than just the terminating atom. * tests/012/iter.tl: Some test cases validating that the functions error out for strings and vectors. Much more coverage is possible here but doesn't seem worth it; e.g. that the functions reject a buffer, regex, function, ...
* awk: add CSV support.Kaz Kylheku2025-01-301-0/+18
| | | | | | | | | | | * stdlib/awk (awk-state upd-rec-to-f): Handle a new case of fs being the keyword symbol :csv, producing a field-splitting lambda that calls get-csv. * tests/015/awk-basic.tl: Several new test cases for this CSV feature. * txr.1: Documented.
* awk: use prepared lambdas for field separation.Kaz Kylheku2025-01-282-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Handle field separations with lambdas, similarly to record separation. The idea is that we replace the rec-to-f method, which contains a cond statement checking the variables for which field separation discipline applies, with a lambda which is updated whenever any of those ariables change. * awk.tl (awk-state): New instance slot, rec-to-f. (awk-state :postinit): Call new upd-rec-to-f method so that rec-to-f is populated with the default field separating lambda. (awk-state rec-to-f): Method removed. (awk-state upd-rec-to-f): New method, based on rec-to-f. This doesn't perform the field separation, but returns a lambda which will perform it. (awk-state loop): We must call upd-rec-to-f whenever we change par-mode, because it influences field separation. (awk-mac-let): Replace the symbol macros fs, ft, fw and kfs with new implementations that use the reactive slot mechanism provided by rslot. Whenever the awk macro assigns any of these, the upd-rec-to-f method will be called. * tests/015/awk-basic.tl: New file. These basic tests of field separation pass before and after this change. * tests/common.tl (otest, motest): New macros.
* get-csv: bugfix: return nil on EOF.Kaz Kylheku2025-01-241-1/+23
| | | | | | | | | | | | | | | | | * stream.c (get_csv): Let's add a new state init. If get_char returns nil and we are in the init state, let's bail to a nil return. While we are at it, let's not allocate the record or string until we read at least one character. If we read a character in the init state, let's allocate those two objects, and then change to the rfield state and fall through to it to handle the character. * tests/010/csv.tl: Fix one incorrect test: (tocsv "") now returns nil, as it should. Add tests for multiple record extraction, also covering missing line termination on the last record as well as CR-LF termination. * txr.1: Documented nil return conditions.
* New functions for producing CSV.Kaz Kylheku2025-01-241-0/+19
| | | | | | | | | | | | * stream.c (put_csv, tocsv): New functions. (stream_init): put-csv and tocsv intrinsics registered. * stream.h (put_csv, tocsv): Declared. * tests/010/csv.tl (mtest-pcsv): New macro. New test cases. * txr.1: Documented.
* New function: get-csv.Kaz Kylheku2025-01-211-0/+166
| | | | | | | | | | | | | * autloload.c (csv_set_entries, csv_instantiate): New static funtions. (autoload_init): Register autoload of stdlib/csv module via new functions. * stdlib/csv.tl: New file. * tests/010/csv.tl: Likewise. * txr.1: Documented.
* New macros for enumerated constants.Kaz Kylheku2025-01-201-0/+23
| | | | | | | | | | | | | * autoload.c (enum_set_entries, enum_instantiate): New static functions. (autoload_init): Register autoload of stdlib/enum module via new functions. * stdlib/enum.tl: New file. * tests/016/enum.tl: Likewise. * txr.1: Documented.
* New macro: lop1.Kaz Kylheku2025-01-171-0/+13
| | | | | | | | | | | | | * autoload.c (op_set_entries): Autoload on lop1 symbol. * stldlib/op.tl (sys:op-expand): Add lop1 case. (sys:opip-expand): Add lop1 to the list of operators that are recgonized and specially treated. (lop1): New macro. * tests/012/op.tl: New tests. * txr.1: Documented.
* json: flat must override all effects of :standardKaz Kylheku2025-01-161-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | * stream.h (struct json_opts): Member flat removed. I noticed that !jo.flat was always being tested together with jo.fmt == json_fmt_standard. Except for a few places where the code only tested for json_fmt_standard, resulting in flat output, but some extra spaces. What distiguishes flat mode now is simply that we disable stream indentation. * lib.c (out_json_rec): Remove tests for !jo.flat. (out_json): Remove initialization of jo.flat member. In this function we set up indentation on the stream resulting in multi-line mode (existing behavior). (put_json): Remove initialization of jo.flat member. If flat mode is requested, then it overrides the format to json_fmt_default. I.e. json_fmt_standard coresponding to :standard is only in effect if flat is not requested. In this function we set up indentation on the stream if flat mode isn't requested, otherwise we disable indentation (existing behavior, enough to make flat work). * tests/010/json.tl: Tests for flat mode, :standard formatting, and combinaton of both.
* lop: don't insert args when metas present.Kaz Kylheku2025-01-081-0/+44
| | | | | | | | | | | | | | | | | | | | | The lop macro is inconsistent from op in that it inserts the trailing function arguments on the left even if arguments are explicitly given in the form via @1, @2, ... or @rest. This change makes lop is equivalent to op in all situations when these metas are given. * stdlib/op.tl (compat-225, compat-298): New top-level variables. (op-expand): local variable compat replaced by references to compat-225. If compat-298 is *not* in effect, then metas are checked for first in the cond, preventing the lop transformation from taking place. * tests/012/op.tl: Test cases for lop, combinations of do with lop and a few for op also. * txr.1: Redocumented, added compat notes.
* match-case: bugfix in conversion to casequal.Kaz Kylheku2024-12-201-0/+3
| | | | | | | | | | | | | * stdlib/match.tl (match-case-to-casequal): the (do inc dfl-cnt) action has a problem: it inserts an implicit extra parameter to the invocation of inc, which crashes the + addition due to that parameter being the matching @nil object. We don't need this entire case because it handles @nil, which also matches the following case for (sys:var ...), since @nil is (sys:var nil). That case ahs the same action of incrementing dfl-cnt. * tests/011/patmatch.tl: Test case added.
* string ranges: bug: ranges of length 1.Kaz Kylheku2024-12-152-1/+13
| | | | | | | | | * lib.c (seq_iter_init_with_info): String ranges are inclusive. We must not assume at a range whose endpoints are the same is empty; we must check that case for the endpoints being strings. * tests/012/seq.tl: New tests.
* tests for string range length.Kaz Kylheku2024-12-151-0/+12
| | | | * tests/012/seq.tl: New tests.
* copy: now handles range objects.Kaz Kylheku2024-10-012-0/+6
| | | | | | | | | | | | | | | | Ranges are iterable, denoting abstract sequences. The copy function now copies a range by constructing the array. This is useful when copy is used for the purpose of obtaining a mutable copy. For example, (shuffle 0..100) will now work, returning a shuffled vector of the integers from 0 to 99. * lib.c (copy): Handle RNG case via vec_seq. * tests/012/seq.tl, * tests/012/sort.tl: New test cases. * txr.1: Documented. Documentation for the copy function improved.
* read-until-match: fix regression.Kaz Kylheku2024-09-141-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | Commit e7ce1b7d7da3fdebee6d5ba67f359bc6e3bb9e52 broke things. This fix affects the function read-until-match, scan-until-match and count-until-match which share implementation. * regex.c (scan_until_common): In the REGM_MATCH_DONE and REGM_MATCH cases, we must push the character onto the local stack, before doing the match = stack assignment. Otherwise, it's possible that the stack is empty and so no match is recorded. The REGM_FAIL case will then behave as if no match was found, consuming a character and continuing. * txr.1: Codify an existing behavior: only non-empty matches for the regex are considered by read-until-match. * tests/015/regex.tl: New file. I am amazed to discover that we don't seem to have a test suite for regexes at all. Putting the tests here which confirm this fix and provide coverage for some edge cases in read-until-match.
* keep-if, remove-if, keep-keys-if: mapfun argument.Kaz Kylheku2024-07-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We introduce a mapfun argument to these functions so that they can additionally transform the accumulated values. The keep-keys-if function is now implemented through the same helper function as keep-if but with the mapfun argument defaulting to a copy of the keyfun argument. * eval.c (eval_init): Update registrations of remove-if, keep-if and keep-keys-if to new arities of C functions. * lib.c (rem_if_impl): Implement new optional mapfun parameter. (remove_if, keep_if): Add mapfun parameter. (keep_keys_if): Implement via rem_if_impl, and add mapfun argument. We do the defaulting of keyfun here, so that we can then use that argument's value to default mapfun. * lib.h (remove_if, keep_if, keep_keys_if): Declarations updated. * tests/012/seq.tl: Couple of test cases exercising mapfun argument of keep-if and remove-if. * txr.1: Documented.
* zip: more permissive implementation.Kaz Kylheku2024-07-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | zip and transpose should allow non-character data when the leftmost column is a string, falling back on making lists, like seq_build. We can't use seq_build as-is because of the special semantics of transpose/zip with regard to strings. We introduce a "strcat" variant of seq_build for this purpose. * lib.c (seq_build_strcat_add): New static function. (sb_strcat_ops): New static structure like sb_str_ops, but with seq_build_strcat_add as the add operation, which allows string arguments to be appended to the string rather than switching to a list. (seq_build_strcat_init): New function. * lib.h (seq_build_strcat_init): Declared. * eval.c (zip_strcat): New static function; uses seq_build_strcat_init. (zipv): Only recognize strings specially; all else goes through the existing default case. Strings use zip_strcat. * tests/012/seq.tl: New test case. * txr.1: Describe special semantics of zip/tranpose; previously only documented in one example. Clarify that the rows are only sequences of the same kind as the leftmost column if possible, otherwise lists. Remove text which says that it's an error for the other columns to contain non-string, non-character objects if the leftmost column is a string.
* make-like: use seq_build.Kaz Kylheku2024-07-231-3/+5
| | | | | | | | | | | * lib.c (make_like): Simplify implementation using seq_build, which also lets it handle more cases. * tests/012/seq.tl: New tests. Some existing test fixed, including one for tuples*. * txr.1: Documentation updated: mainly that make-like doesn't strictly require a list argument.
* New function: seq-like.Kaz Kylheku2024-07-231-0/+14
| | | | | | | | | | | | * eval.c (zip_fun): Renamed to seq_like. (zipv): Follow rename of zip_fun. (eval_init): Register seq-like intrinsic. * tests/seq.tl: Some tests for make-like and seq-like, revealing a difference: make-like needs to be rewritten to use seq_build. * txr.1: Documented.
* json: new *read-json-int* variable.Kaz Kylheku2024-07-221-0/+15
| | | | | | | | | | | | | | | | | | | | | * parser.h (struct parser): New member, read_json_int. * parser.c (read_json_int_s): New symbol variable for *read-json-int* symbol. (parser_common_init): Look up value of *read-json-int* and store in read_json_int struct member. (parse_init): Initialize read_json_int_s with interned symbol and also register the dynamic variable. * parser.l (grammar): Extend the {JNUM} rule to check the read_json_int flag and produce an integer value if the lexeme does not contain a decimal point, e or E. * tests/010/json.tl: New tests. * txr.1: Documented. * lex.yy.c.shipped: Regenerated.
* oop: special methods to handle missing slots.Kaz Kylheku2024-07-191-0/+36
| | | | | | | | | | | | | | | | | | | | | * struct.h (slotset_s, static_slot_s, static_slot_set_s): New symbol variables declared. (enum special_slot): New enum symbols: slot_m, slotset_m, static_slot_m, static_slot_set_m. * struct.c (slotset_s, static_slot_s, static_slot_set_s): New symbol variables. (special_sym): Associate new symbols with new enums. (struct_init): Intern slotset, static-slot and static-slot-set symbols, initializing the variables. Change the registrations of the same-named functions to use the variables. (slot, maybe_slot, slotset, static_slot, static_slot_set): In the no-such-slot case, check for the special method and call it. * tests/012/oop.tl: New tests. * txr.1: Documented.
* New functions: find-maxes and find-mins.Kaz Kylheku2024-07-161-0/+22
| | | | | | | | | | | * eval.c (eval_init): New intrinsic functions find-maxes and find-mins. * lib.[ch] (find_maxes, find_mins): New function. * tests/012/seq.tl: New tests. * txr.1: Documented.
* New funtion related to where function.Kaz Kylheku2024-07-111-0/+39
| | | | | | | | | | | | | | * eval.c (eval_init): register intrinsics wheref, whereq, whereql and wherequal. * lib.c (wheref_fun): New static function. (wheref, whereq, whereql, wherequal): New functions. * lib.h (wheref, whereq, whereql, wherequal): Declared. * tests/012/seq.tl: New tests. * txr.1: Documented.
* partition, split, split*: bug handling negative indices.Kaz Kylheku2024-07-101-19/+31
| | | | | | | | | | | | | | | | * lib.c (partition_func, split_func, split_star_func): When negative indices occur after the sequence has already been shortened, the conversion to positivce must take into account the base. This must be added so that the positive index produced is relative to the original length of the input sequence. When index_rebased is calculated, the base is subtracted out again. If we based the positive index off the shortened length, it's as if we are subtracting base twice. * tests/012/seq.tl: Dubious test cases for split* are replaced with the new results that make sense. Additional test cases are added which cover this issue, for not only split* but split and partition.
* split, split*: fix poor behavior for beyond-length indices.Kaz Kylheku2024-07-101-24/+24
| | | | | | | | | | * lib.c (split_func, split_Star_func): Ignore indices greater than the length of the sequence, the same as negative indices are ignored which don't become nonnegative after adding the length. * tests/012/seq.tl: Fix questionable test cases, which now confirm the right behavior.
* partition: add negative index tests.Kaz Kylheku2024-07-101-0/+36
| | | | * tests/012/seq.tl: New tests.
* split**: split for far negative indices.Kaz Kylheku2024-07-101-0/+32
| | | | | | | | | * lib.c (split_star_func): In empty index case, convert sequence via sub(seq, zero, t), so that ranges are properly expanded. This was done in split_func and partition_func in recent commits. * tests/012/seq.tl: Test cases added.
* split*: add missing tests.Kaz Kylheku2024-07-101-0/+125
| | | | | | * tests/012/seq.tl: Add tests for split* that were lost in some editing. Corresponding tests exist for split already and for partition.
* split: fix for far negative indices.Kaz Kylheku2024-07-101-0/+28
| | | | | | | | | * lib.c (split_func): In empty index case, convert sequence via sub(seq, zero, t), so that ranges are properly expanded. This was done in partition_func in the previous commit. * tests/012/seq.tl: Test cases added.
* split, split*, partition: tests, fixes.Kaz Kylheku2024-07-101-0/+410
| | | | | | | | | | | | | | * lib.c (partition_func): In empty index list case, run the sequence through sub(seq, zero, t) so that ranges are expanded: e.g. 1..3 becomes (1 2). The corresponding code in split_func and split_star_func also needs this fix, but the current test cases don't reproduce a problem. (partition_split_common): Likewise here. * tests/012/seq.tl: Tests for split, split* and partition. Some tests have questionable results. We accept these as they are for now; will address these.
* match: new @(scan-all) operator.Kaz Kylheku2024-06-281-0/+8
| | | | | | | | | | | | | | | | This is like @(scan) but collects all matches over the suffixes of the list. * autoload.c (match_set_entries): Intern scan-all symbol. * stdlib/match.tl (compile-scan-all-match): New function. (compile-match): Dispatch compile-scan-all-match on scan-all symbol. * tests/011/patmatch.tl: Tests for scanall and also missing tests for scan. * txr.1: Documented.
* iter-begin: handle FLNUM.Kaz Kylheku2024-06-261-0/+13
| | | | | | | | | | * lib.c (iter_begin, iter_more, iter_item, iter_step, iter_reset, copy_iter): Handle FLNUM like NUM, so that we don't wastefully return a dynamic iterator object. * tests/012/iter.tl: Test cases for numeric and character iteration. Test cases for iter-begin on some basic types. copy-iter test for floats.
* copy-iter: test for common types.Kaz Kylheku2024-06-261-0/+18
| | | | | * tests/012/iter.tl: Test copy-iter for lists, vectors, integers, characters, strings, string ranges, numeric ranges.
* copy-iter: test that the combi iterators copy.Kaz Kylheku2024-06-261-0/+12
| | | | * tests/015/comb.tl: New tests.
* copy-iter: some tests.Kaz Kylheku2024-06-261-2/+15
| | | | | | | * test/012/oop-seq.tl: Add tests that verify that an OOP iter without a copy method cannot be copied with copy-iter, and that one which has the method can be copied, in accordance with the requirements.
* combi: fix permi and rpermi; impl combi, rcombi; test.Kaz Kylheku2024-06-241-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | * combi.c (permi_get, permi_peek): Fix algorithm. (permi_mark): New static function. (permi_ops): Reference permi_mark for mark operation. (permi): Initialize it->ul.next to nao as required by new get/peek algorithm. (rpermi_get, rpermi_peek): Fix algorithm. (rpermi_mark): New static function. (rpermi_ops): Reference permi_mark for mark operation. (rpermi): Initialize it->ul.next to nao as required by new get/peek algorithm. (combi_get, combi_peek, combi_mark, combi_clone): New static functions. (combi_ops): New static structure. (combi): New function. (rcombi_get, rcombi_peek, rcombi_mark, rcombi_clone): New static functions. (rcombi_ops): New static structure. (rcombi): New function. * combi.h (combi, rcombi): Declared. * tests/015/comb.tl: New tests.
* string ranges: individual positions are ascending/descending.Kaz Kylheku2024-06-201-0/+4
| | | | | | | | | | | | | | | | | | | | In this patch we get rid of the wrongheaded notion that a string range, as such, is ascending or descending. In fact, the corresponding character positions are individually ascending or descending. * lib.c (seq_iter_get_range_str): Either increment or decrement the character in the step string depending on whether that position is in order or reversed. (seq_iter_get_rev_range_str): Static function removed. (si_rev_range_str_ops): Static structure removed. (seq_iter_init_with_info): For string ranges, use si_range_str_ops regardless of the strings being lexicographically reversed. * test/012/iter.tl: New test case. * txr.1: Redocumented string ranges.
* combi: fix broken k 0 edge cases for sequences.Kaz Kylheku2024-06-201-0/+10
| | | | | | | | | * combi.c (rperm, comb, rcomb): In the default case for generic sequences, check k, like in the other cases and return the special case result. * tests/015/comb.tl: New tests.
* New function: copy-hash-iter.Kaz Kylheku2024-06-181-0/+11
| | | | | | | | | | | | * hash.c (hash_iter_ops): Use copy_hash_iter as the clone operation. (copy_hash_iter): New function. * hash.h (copy_hash_iter): Declared. * tests/010/hash.tl: New tests. * txr.1: Documented.
* cobj: clone method streamlines copy; structs get copy method.Kaz Kylheku2024-06-171-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* quasiliterals: buffers in hex, separation for strings and buffers.Kaz Kylheku2024-05-271-2/+17
| | | | | | 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
* interpose: use seq_iter and seq_build.Kaz Kylheku2024-05-261-0/+11
| | | | | | | * lib.c (interpose): non-list cases consolidated into one, which uses generic iteration and building. * tests/012/seq.tl: New tests
* buf: pprint produces hex, not raw bytes.Kaz Kylheku2024-05-031-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The pprint semantics of buffers is that the raw bytes are dumped into the stream. This is poor. It was hastily designed based on analogy with strings, which pprint by just sending their contents to the stream; but for strings this is justified because they represent text. We also fix the semantics of buffer values being rendered by quasiliteral notation. Currently, the are treated as sequences, and so they explode into individual decimal integers. * buf.c (buf_pprint): Print the bytes as pairs of lower-case hex digits, with no line breaks. In 294 compatibility or lower, put out bytes as before. * eval.c (fmt_cat): When not in 294 compatibility mode, treat a buffer object via tostringp, which will render it to hexadecimal via buf_pprintf. In compatibility mode, treat it as before, which is as a sequence: the individual values of the buffer are converted to text, thus decimal values in the range 0 to 255, catenated using the given separator. * tests/012/readprint.tl: New tests. * txr.1: Documented. Also expanding on what pretty printing means in TXR.
* New function: iter-cat.Kaz Kylheku2024-04-161-0/+5
| | | | | | | | | | | | | | | | * 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 functions for filtering through external processes.Kaz Kylheku2024-04-041-0/+8
| | | | | | | | | | | | | | * stdlib/getput.tl (sys:maproc-common): new function. (map-command-lines, map-command-str, map-command-buf, map-process-lines, map-process-str, map-process-buf): New functions. * autoload.c (getput_set_entries): Trigger autoload of getput module on new function symbols. * tests/018/getput.tl: New tests. * txr.1: Documented.