| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure (txr_ver): Bumped version.
* stdlib/ver.tl (lib-version): Bumped.
* txr.1: Bumped version and date.
* txr.vim, tl.vim: Regenerated.
* protsym.c: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
* stdlib/match.tl (compile-scan-match): Fix wrong indentation
of let* body.
|
|
|
|
|
|
|
|
| |
* genprotsym.txr: Do not glob .c files; use "git ls-files" to
only pick up tracked files. Skip the protsym.c file itself.
Parenthesize any if guards that have || operators in them.
Rearrange the output so that @{gpp "&&"} expressions actually
operate on lists and not strings.
|
|
|
|
|
|
|
| |
* lib.c (make_sym, make_package, use_sym_as, find_symbol,
find_symbol_fb, intern_intrinsic, intern_fallback_intrinsic):
replace stringp test with dummy calls to c_str, for the
side effect of the type check.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If, for instance ?2 is specified in the mode string argument
of open-process and related functions, this means that the
file descriptor 2 of the process will be used as the data
source (or sink) for the stream that is returned by the
function. With this feature we can easily read the standard
error of a process while leaving its standard output
unredirected.
* stream.c (do_parse_mode): Parse the ? mode option.
(open_subprocess): Check for the presence of the alternative
file descriptor in the stdio_mode structure, and and use it
isntead of STDIN_FILENO or STDOUT_FILENO.
* stream.h (struct stdio_mode): New member, streamfd.
(stdio_mode_init_blank, stdio_mode_init_r,
stdio_mode_init_rpb, stdio_mode_init_blank, stdio_mode_init_r,
stdio_mode_init_rpb): Update initializer macros to cover the
new member, setting it to the default value -1 (not
specified).
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
| |
* tests/012/iter.tl: Test copy-iter for lists, vectors,
integers, characters, strings, string ranges, numeric ranges.
|
|
|
|
| |
* tests/015/comb.tl: New tests.
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When we open a data source using @(next), or use one
implicitly at the top level of the script, we would like
the top level scanning construct as @(collect) or @(repeat)
which does not backtrack not to consume memmory when moving
through a large file.
I experimented with ways to fix this in the past that
were ineffective, but I think I hit upon a working approach.
* match.c (match_files_ctx): Make the data field (pointer to
lazy list data source) volatile.
(match_files_byref): New function, based on converting
match_files to take a context by pointer rather than by value.
(match_files): By-value wrapper for match_files_byref that
most constructs use.
(v_next_impl): When opening a stream source, use
match_files_byref to avoid possible duplication of the
structure. Without the volatile in match_files_ctx, this
doesn't squelch all spurious retention.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
| |
* txr.1: document new iterator-based combinatoric
functions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (unsup_obj, iter_step, last, nthcdr, list_collect,
list_collect_nconc, list_collect_append, list_collect_nreconc,
list_collect_revappend, nreverse, reverse, replace_list,
lazy_appendv, tuples, tuples_star, chk_grow_vec,
chk_manage_vec, chk_wrealloc, chk_substrdup,
chk_substrdup_utf8, chk_strdup_8bit, chk_xalloc, endp,
mkstring, mkustring, string_extend, replace_str, replace_str,
cat_str_measure, fmt_str_sep, split_str_keep, spln, tok_str,
tokn, cmp_str, int_str, chr_str, chr_str_set, chr_str_set,
symbol_package, make_package, use_sym_as, find_symbol,
find_symbol_fb, intern_intrinsic, intern_fallback_intrinsic,
get_current_package, func_interp, func_get_form, callerror,
vec_set_length, vecref, vecref_l, replace_vec, replace_obj,
fill_vec, cat_vec, int_cptr, calc_win_size, mismatch,
rmismatch, refset, dwim_set, dwim_del, rangeref):
Replace error in exceptions with more specific error
like type_error, range_error, numeric_error or alloc_error.
|
|
|
|
|
|
|
| |
* combi.c (rperm, comb_init): Replace zerop(k)
tests with k == zero which is more specific and
faster, testing only for the integer zero that
we care about.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.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.
|
|
|
|
|
|
|
|
| |
For calculating the length of a range, we can't just do
numeric subtractions because it fails for string ranges.
* lib.c (length_str_range, length_rng): New static functions.
(length): Use length_rng for ranges.
|
|
|
|
|
|
| |
* txr.1: Revise text which claims that when iter-begin
is invoked on an existing iterator, the returned iterator
may share state it. We recently fixed that with the cloning.
|
|
|
|
|
| |
* combi.c (permi_ops, rpermi_ops): Change external linkage to
internal.
|
|
|
|
|
|
|
|
|
|
|
| |
* combi.c (rpermi_get, rpermi_peek, rpermi_clone): New static
functions.
(rpermi_ops): New static structure.
(rpermi): New function.
* combi.h (rpermi): Declared.
* eval.c (eval_init): Register rpermi intrinsic.
|
|
|
|
|
| |
* combi.c (permi_iter): Don't need gc_hint(obj) since we are
returning that value.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The quant_fun blindly trusts that the state object has
the correct type. But the function environment is mutable.
To fix this, we end up switching the state from cptr_typed
to cobj because cptr_typed has a weak form of safety based
on symbols that is better suited for FFI stuff. For anything
built into the language, we want it to be bulletproof.
* arith.c (quant_state_s): New symbol variable.
(quant_cls): New static variable.
(psq_ops): Rename to quant_ops.
(quant_fun): Parameter renamed to state. We use
cobj_handle to get the pointer to the context structure,
using the quant_cls class.
(quantile): Use cobj to create the context object, rather
than cptr_typed.
(arith_init): Initialized quant_state_s and quant_cls.
|
|
|
|
|
|
|
|
|
| |
* gc.c (gc_prot_array_s): New symbol variable.
(gc_late_init): Initialize gc_prot_array_s. Use it when
registering prot_array_cls. The _s variables are gc-protected
by registrations in the protsym.c module which gets regularly
updated, at least before every software release.
The cobj class array is not traversed by gc.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
| |
* lib.c (iter_reset): Propagate sinf variable and
seq_info call which initializes it into the scopes
where it is used.
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
| |
* eval.c (eval_init): Register copy-iter intrinsic.
* lib.[ch] (copy_iter): New function.
|
|
|
|
|
| |
* stdlib/quips.tl (%quips%): Remove quip about lecithin;
it does not wear well.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
* combi.c (perm_str): We don't have to convert the string
to a list and then vector, since we have vec_seq.
|
|
|
|
|
|
| |
* combi.c (check_k): New static function.
(perm, rperm, comb, rcomb): Replace copy pasted code
with call to check_k.
|
|
|
|
|
|
|
|
|
|
| |
In a recent commit, the defaulting of the separator in quasiliteral
variable formatting was moved down into the fmt_cat routine.
One stray case remains in subst_vars.
* eval.c (subst_vars): A call to fmt_cat is specifying a separator
value consisting of a single space. This is wrong, preventing
fmt_cat from defaulting it in different ways according to type.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
* lib.c (interpose): non-list cases consolidated into
one, which uses generic iteration and building.
* tests/012/seq.tl: New tests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The motivation here is an upcoming change in which
we will support the separator modifier for buffers
and strings. Currently, it does nothing. If we write
`@{a ":"}`, and a is a buffer or string, the separator
is ignored. We don't fix that in this commit, but
we fix the problem that some higher level formatting
functions are defaulting the separator to " " (single
space) and passing it down. We want to control the
defaulting based on the type of the object in one place.
* eval.c (fmt_cat): Do not assume here that sep has been
defaulted; do the defaulting to space here.
(format_field, fmt_flex): Initialize the separator to nil,
not space. If no separator occurs among the modifiers,
it gets passed down as nil through to fmt_cat.
(fmt_simple): Don't default the sep argument to space;
pass it through to do_format_field which will pass it down
to fmt_cat.
|
|
|
|
|
| |
* lib.c (cat_str_measure): add missing word "is" in
type error message.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
| |
* txr.1: Fix "stream is recorded in a hidden." and revise
some neighboring text for clarity.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stdlib/constfun.tl (%const-foldable-funs%): Numerous
functions added, mostly new ones.
(%effect-free-funs%): Indentation fixed. Some functions
added, but also removed. We don't want anything in here that
could take a functional argument. The optimizer will blindly
a call to an effect-free function, if its result is not
used, regardless of what the arguments are. It won't take into
consideration that there is a functional argument, which could
be a function that has a side effect, and that is called
by the supposedly effect-free function. So for instance, sort
is out; the comparison or key functions could have side effects.
We could put these functions into a special category.
|
|
|
|
|
| |
* txr.1: Fix bad formatting in syntax synopsis of
command-get-buf.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
| |
* lib.[ch] (lcons_force): New function.
* eval.c (eval_init): Register lcons-force intrinsic.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure (txr_ver): Bumped version.
* stdlib/ver.tl (lib-version): Bumped.
* txr.1: Bumped version and date.
* txr.vim, tl.vim: Regenerated.
* protsym.c: Regenerated.
|
|
|
|
|
|
|
|
| |
* test/012/fini.tl: Pass t to sys:gc to request full
garbage collection. Otherwise the output may be reordered,
due to some of the objects made earlier in the test case
being promoted to the mature generation and thus not
finalized by the (sys:gc) call.
|