| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
* tests/012/seq.tl: New tests.
|
|
|
|
|
|
| |
* eval.c (map_common): use the all_zero_init macro, defined
differently for C and C++ for initializing a struct to all
zero.
|
|
|
|
| |
* stdlib/quips.tl (%quips%): New one.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The profile and history files should have used hyphens
from the beginning. Let's switch to that but continue
to work with the old files if present, as an obsolescent
feature.
* parser.c (open_txr_file): Treat files with .txr-profile
suffix as Lisp.
(load_rcfile): Arguments rearranged. This function now needs
the home directory and the existence test function, but
does not need the profile file name. It tries .txr-profile
first, then .txr-profile.
(repl): Call load_rcfile in the new way. Try two history
files: first .txr-history and then .txr_history. Remember
which one was used so the same one is saved. If neither file
existed at startup, then save new history into .txr-history.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (make_ffi_type_struct): We must calculate the size
of a flexible structure the way GCC does it. We cannot simply
truncate it at the offset of the member. Rather, the size
is calculated in the usual way. The alignment of the array is
taken into account for the purpose of determining what is the
most aligned member of the structure, and then padding is
added, if required. Thus, the size may exceed the offset of
that member.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
* lib.c (refset, replace): Word the bad object diagnostic in
terms of it not being a modifiable sequence. This covers
cases when the object is something abstractly iterable, like
a range. We don't want to say that it's not a sequence.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* regex.c (nfa_closure, nfa_move_closure): Do not add epsilon
states to the output array. We only need to add them to the
stack for the spanning traversal. Epsilon states are not real
states; they are just a representation of the concept of
transitioning to multiple states at the same time.
When we add them to the output, they just end up being ignored
when nfa_move_closure is called again on that set, since it
only cares about states that have real transitions for a
character.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* regex.c (nfa_has_transitions): The logical disjunction here
is wrong. We would like to test whether a state has
transitions if it is not an epsilon state. The code which uses
this macro doesn't care about epsilon states, even though they
have transitions; those are squeezed out by transitively
closure. The wrong condition here makes the code think that
a NFA set has transitions when it does not, preventing the
result code REGM_MATCH_DONE to be produced which can spare
a character from being consumed from a stream.
|
|
|
|
|
|
| |
* regex.c (mfa_move_closure): Fix misleading wording in
comment. The state which matches the character (has a
transition for it) is not the one added to the move set.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 9aa751c8a4f845ef2d2bba091c81ffeded941afd
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.
|
|
|
|
| |
* stdlib/quips.tl (%quips%): New entry.
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Bind new map symbol to the same function
as mapcar.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
This issue was spotted by Alpine Linux people; I'm
upstreaming their patch (originally authored by
a user named huajingyun01).
* jmp.S (jmp_save, jmp_restore): Use recommended
register names on loongarch64: a0 and a1 rather
than v0 and v1.
|
|
|
|
| |
* genman.txr: PayPay form replaced.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
* txr.1: patterns are also nontrivial if they contain
quasiquotes that contain nontrivial patterns, and
quasiliterals that contain operators. Also, we
italicize the term trivial pattern as well as nontrivial.
|
|
|
|
| |
* txr.1: Fix sentence which needs a subject, "the operator".
|
|
|
|
|
|
|
| |
* txr.1: Fix a number of places that use quasiliteral in
reference to a structural quasiquote. In the TXR manual,
quasiliteral syntax is the `...` that produces strings,
short for quasistring literal. ^(...) is a quasiquote.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Iterator rewinding is only used by the three functions isec,
isecp and diff, which can easily just re-initialize the
iterator.
* lib.c (seq_iter_rewind): Static function removed.
(seq_iter_init_with_info): Remove support_rewind argument, and
adjust all code referencing it on the assumption that it's zero.
(seq_iter_init_with_rewind): Static function removed.
(seq_iter_init, iter_begin, iter_reset, nullify, find, rfind):
Drop last argument from seq_iter_init_with_info.
(diff, isec, iescp): Use seq_iter_init rather than
seq_iter_init_with_rewind. Instead of seq_iter_rewind, just
reinitialize the iterator.
* lib.h (seq_iter_init_with_info): Declaration updated.
* eval.c (tprint): Drop last argument from seq_iter_init_with_info.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
| |
* txr.1: The *print-json-format*, *read-bad-json*
and *read-json-int* variables are special (i.e.
dynamically scoped) variables, and so reaquire the
Special Variable heading, not Variable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (int_str_wc): New function, made out of int_str.
This can be used by the parser to work with a wchar_t *
string without having to create a string object.
(int_str): Implemented in terms of int_str_wc.
* parser.l (grammar): Remove string_own calls from numerous
rule bodies that use int_str to return a number.
These rules now capture the wchar_t string, pass it to
int_str_wc and then immediately free it. Whereas string_own
allocates an extra object and leaves it to the garbage
collector.
* lex.yy.c.shipped: Regenerated.
|
|
|
|
|
|
|
|
|
| |
* genvim.txr (tl_ident): Move the pattern which matches the #
and #: symbols above the more general one. Because, remember,
because Vim's syntax match definitions work such that the last
definition which matches wins, even if it's not the longest
match. Not regenerating the txr.vim and tl.vim files; that
will be done at release time.
|
|
|
|
|
|
| |
* txr.1: In examples for append, whereq and tuples*,
fix backslashes not encoded as the \e sequence,
causing improper rendering.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
| |
* stdlib/struct.tl (sys:check-slot): Don't issue the
diagnostic "<obj> isn't the name of a struct slot"
for slots that are not bindable symbols like obj."abc".
|
|
|
|
|
|
| |
* txr.1: We cannot say that (. pattern) is not a
list pattern, since it is indistinguishable from
pattern, which could itself be a list pattern.
|
|
|
|
|
|
|
|
|
| |
* txr.1: In the "Comparison to Macro Parameter Lists" section,
which compares structural pattern matching to macro parameter
lists, we remove the outdated claim that all positions in
a macro parameter pattern must bind a variable. This has not
been true since t has been supported as a way to support
binding variables.
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This variable controls whether we emit the "__type" key
for structures.
* lib.c (out_json_rec): React to the new variable, via
the flag in the json_opts structure: include the "__type" key
only if it is requested.
(out_json, put_json): Initialize the type flag in the josn_opts
according to the *print-json-type* dynamic variable.
* stream.c (print_json_type_s): New symbol variable.
(stream_init): print_json_type_s initialized, and
corresponding special variable registered, with intial value t.
* stream.h (struct json_opts): New bitfield member, type.
(print_json_type_s): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
| |
* txr.1: Clarify what repeated values mean in partition,
since they are allowed. For split/split*, clarify that indice
have to be strictly increasing after negative indicates
are displaced by the sequence length, and that the behavior
is unspecified otherwise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
| |
* tests/012/seq.tl: New tests.
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
| |
* tests/012/seq.tl: Add tests for split* that were lost
in some editing. Corresponding tests exist for split
already and for partition.
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a bug introduced in 9cfa3435 on 2024-02-24.
The underlying cause is lack of test coverage for
these functions.
* lib.c (partition_func, split_func, split_star_func): The
original code iterated through the indies using the pop macro,
thus extracting the next index and stepping in one step.
The iter_begin rewrite wrongly moved the iter_step into one
of the cases. The index iteration must be stepped in the case
where the loop is continued vi continue, otherwise an infinite
loop results.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Having the sub function yield an iterator in some cases
is a defective requirement, causing problems like this:
1> (partition 1..10 '(2 3))
((1 2) (3) #<seq-iter: a24c380>)
With fix:
1> (partition 1..10 '(2 3))
((1 2) (3) (4 5 6 7 8 9))
* lib.c (sub_iter): When the interval is open and we are
operating on a sequence via iter-begin, do not return an
iterator. Convert it to a lazy list. Not subjecting this to -C
compat flag; I can't imagine anyone writing code to depend on
this, rather than stepping around it as a bugx.
* txr.1: Documentation updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The flat-p flag is not being passed through ther recursion.
Some of the formatting code emits newlines unconditionally.
Instead of passing down the enum json_fmt, we pass down a new
structure which carries the flat-p flag also.
* stream.h (struct json_opts): New struct.
* lib.c (out_json_rec): Take a struct json_opts argument
instead of enum json_fmt. Handle the flat flag to avoid
generating line breaks.
(out_json, put_json): Prepare json_opt structure and pass to
out_json_rec.
|
|
|
|
|
|
|
| |
* lib.c (out_json_sym): New static function.
(out_json_rec): Handle structp.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
Almost exactly 6 years ago, commit 612f4f57e made hashes
use the full width of the ucnum type. However, several
reductions of the form hash &= NUM_MAX were forgotten.
* hash.c (hash_hash_op): Eliminate reductions modulo NUM_MAX.
* struct.c (struct_inst_hash): Likewise.
|
|
|
|
|
|
|
|
| |
* regex.c (scan_until_common): in the REGM_MATCH case, there
is no need to push the current character into the unget stack.
That character is not supposed to be pushed back, and it won't
be because it's below the match point; the stack node just
ends up recycled at the end of the function.
|