summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* mpi: bug converting most negative 64 bit value.Kaz Kylheku2021-05-211-2/+3
| | | | | | | | | * mpi/mpi.c (s_mp_in_big_range): If the value is negative, extend the range. This is exactly the same fix as what was applied to mp_in_range in 2019 in commit 11b5c567124a61d8e8249a0fbcce47f2688573c6. This function should have been fixed at the same time. The corresponding test cases now pass.
* match: binary-integer conv tests for #x-8000...Kaz Kylheku2021-05-211-0/+21
| | | | | | * tests/016/arith.tl: Test providing coverage for the most negative two's complement integer, #x-800...00 in various sizes. The 64 bit cases are failing.
* mpi: incorrect unsigned integer extraction.Kaz Kylheku2021-05-211-4/+6
| | | | | | | | | | * mpi/mpi.c (mp_get_uintptr, mp_get_double_uintptr): Fix loops which shift and mask the bignum digits together in the wrong way. The post-iteration shift is also wrong. We are fine in mp_get_uintptr because the affected code is in an #if that doesn't actually occur: bignum digits are pointer-sized. mp_get_double_uintptr affects the conversion of bignums to 64 bits on 32 bit platforms.
* mpi: bug in range test predictes.Kaz Kylheku2021-05-211-3/+3
| | | | | | | | | | | * mpi/mpi.c (mp_in_range, s_mp_in_big_range): The ptrnd calculation here is wrong; it adds together dissimilar units: bits and bytes. In the case of mp_in_range, we are okay by fluke, because the calculation works out to 1 anyway. We would not be okay of a mp_digit was half the size of a pointer. In s_mp_in_big_range we have a problem. On 32 bit platforms, ptrnd is wrongly calculated as 1 rather than 2, and so values perfectly in range are rejected.
* math: add some tests related to integer conversion.Kaz Kylheku2021-05-211-0/+50
| | | | | | * tests/016/arith.tl: Add tests covering the fixnum/bignum knee, and ffi operations of various sizes that provide coverage of various conversion routines.
* listener: don't complete on unbound symbolsKaz Kylheku2021-05-181-4/+3
| | | | | | | | | | | | | | | | | | | | | This patch prevents Tab-completing on interned symbols that have no binding. The current behavior is, for instance: 1> 'hamsandwich hamsandwich 2> 'ham[Tab] 2> 'hamsandwich ;; completes The new behavior will not complete hamsandwich, because it has no binding as a function or variable. * parser.c (find_matching_syms): Treat the default case the same as after '[': a function or variable binding is required, or the symbol is not listed. Use fboundp instead of lookup_fun. They are the same, except in TXR 127 compat mode, which includes macros under fboundp.
* doc: macrolet doesn't contain top-level forms.Kaz Kylheku2021-05-171-0/+28
| | | | | | * txr.1: For eval and for compilation, document that symacrolet and macrolet do not enclose multiple top-level forms.
* doc: deindent top-level form rules.Kaz Kylheku2021-05-171-1/+0
| | | | | * txr.1: Because we are not in indented paragraphs, we don't need the opening .RS.
* doc: a round of documentation fixes.Paul A. Patience2021-05-171-98/+190
| | | | | * txr.1: Hyphenation, punctuation, spelling and formatting throughout document.
* doc: incorrect precedence of repeat special clauses.Kaz Kylheku2021-05-171-16/+28
| | | | | | | | | * txr.1: The precedence among the repeat clauses is documented incorrectly: the @(mod) clause has a lower precedence than modlast and last. Redocumenting this area for better clarity, and mentioning why @(empty) isn't in the precedence list. This issue was reported by Paul A. Patience with a patch, which I reworked.
* doc: deffi, defplace: syntax heading.Paul A. Patience2021-05-171-4/+4
| | | | | | * txr.1: Use let-like small indentation for the clauses of defplace. Formatting adjusted slightly by K. K. Remove spurious defmacro element in deffi syntax.
* doc: rewrite flawed doc for sme operator.Kaz Kylheku2021-05-161-15/+42
| | | | | | | * txr.1: The documentation of the semantics of sme contradicts itself by neglecting to specify that the middle part of the input is searched for match for the middle pattern mpat. Let's fix this by giving detailed semantics in bulleted form.
* lib: sys_rplacd misnamed parameter.Kaz Kylheku2021-05-141-3/+3
| | | | | * lib.c (sys_rplacd): Change parameter name from new_car to new_cdr, for obvious reasons.
* compiler: better code for global var definitions.Kaz Kylheku2021-05-144-10/+33
| | | | | | | | | | | | | | | | | | | | | | | | * eval.c (rt_defvarl): More accurate self string. (rt_defv): New static function: like rt_defvarl but ensures that the new variable has a binding cell, and returns that cell instead of the hash cell. (op_defvarl): Take advantage of rt_defv to not have to cons up the binding cell. (eval_init): Register sys:rt-defv intrinsic. * parser.c (read_file_common): Compiled files are now version 7, so we must recognize them. We still load version 6 files because rt:defvarl still exists for them. * share/txr/stdlib/compiler.tl (expand-defvarl): Improve the generated code in two ways. Firstly, use the new sys:rt-defv, which returns the binding cell, so that the value can be stored into it with rplacd without having to cons up anything. Secondly, if there is no value expression, don't emit the code to do the assignment. (%tlo-ver%): Bump compiled file version to (7 0). * txr.1: Add note about TXR 260 loading version 7 and 6.
* doc: sort doc-syms, and html-decode.Kaz Kylheku2021-05-132-2049/+2063
| | | | | | | | | | | * genman.txr: generate doc-syms as a sorted list fed to hash-from-pairs. Now the symbols won't jump around so much whenever we update it. Also, the names must be HTML-decoded. For instance "str<" was being stored as "str&lt;" causing (doc 'str<) to fail. We use TXR @(output) to adjust the formatting as if it were maintained by hand. * share/txr/stdlib/doc-syms.tl: Regenerated.
* Version 259txr-259Kaz Kylheku2021-05-136-865/+920
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Bumped. * txr.vim, tl.vim: Regenerated.
* cygwin: fix broken string catenation.Kaz Kylheku2021-05-121-4/+4
| | | | | | * lib.c (cat_str, vscat, scat3, join_with): Pass onech rather than wref(onech) to cat_str_init. Reason being, cat_str_init calls wref(onech).
* parser: bug: handing of lex state in pushback tokens.Kaz Kylheku2021-05-125-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is fairly obscure. A repro test case is a file which contains: 3"foo" When the 3 is parsed, the " is also scanned as a lookahead token, and when that happens, the lexer shifts into the STRLIT state. At that point the parse job finishes for that top-level form. The next time the parser is called, it will prime the token stream by pushing the " token into it. But, the lex state is not put into the STRLIT. State. The result is that the parser obtains the " token, and then foo is lexically analyzed in the wrong state as a symbol. A syntax error occurs: symbol token in the middle of a string literal, instead of just a sequence of LITCHAR tokens, as expected. What we can do is associate a lex state with pushback tokens. If a pushback token has a nonzero lex state which is different from the current YYSTATE, then when that pushback token is consumed, we push that state also. * parser.h (struct yy_token): New member, yy_lex_state. * parser.c (parser_common_init): Initialize the new yy_lex_state member of every token member of the parser structure. * parser.l (yylex): When feeding a pushed token to the parser, if that token has a nonzero state, and the state is different from YYSTATE, we push that state. So for instance a pushed back " token will carry the STRLIT state, which is different from the NESTED state that will be in effect at the start of the parse job, and so it will be pushed, as if the " character had been scanned. Also, when we call the real yylex_impl, when we are storing the recenty seen token in recent_tok, we also store the current YYSTATE along with it. That's how tokens get associated with a state. The artificial tokens that are used for priming parsing like SECRET_ESCAPE_E are never associated with a nonzero state. * tests/012/syntax.tl: Some test cases that didn't pass before this. * lex.yy.c.shipped: Regenerated.
* vim: attempt at #; syntax.Kaz Kylheku2021-05-121-4/+7
| | | | | | | | | | Problem is, there is no way to assert that txr_ign_tok should be colored as a comment, overriding the non-transparent item that it contains. * genvim.txr (txr_list, txr_bracket, txr_mlist): Add new contained item, txr_ign_tok. (txr_ign_tok): New region.
* doc: show .tlo files in deployment example.Kaz Kylheku2021-05-121-0/+2
| | | | | * txr.1: The example deployment structure shows only .tl files. Add a .tlo in there.
* tree: let tree-iter be iterable via generic iteration.Kaz Kylheku2021-05-123-0/+36
| | | | | | | | | | * lib.c (seq_iter_init_with_info): Recognize tree_iter object, and treat using tree iterator function. * tests/010/tree.tl: test case for tree subrange iteration with collect-each. * txr.1: Updated.
* doc: nonexistent tree-value-atKaz Kylheku2021-05-112-3/+3
| | | | * txr.1: Fix typos: tree-value-at should be trie-value-at.
* tree: streamline iteration; provide high limit.Kaz Kylheku2021-05-117-1704/+1692
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Getting rid of tree-begin-at and tree-reset-at. Now tree-begin takes two optional parameters, for specifying high and low range. * tree.c (struct tree_diter): New members, tree and highkey. We need tree due to requiring access to the less function. If the iterator has no highkey, the iterator itself is stored in that member to indicate this. (tree_iter_mark): Mark the tree and highkey. (tree_begin): Take optional lowkey and highkey arguments, initializing iterator acordingly. (tree_begin_at): Function removed. (copy_tree_iter, replace_tree_iter): Copy tree and highkey members. The latter require special handling due to the funny convention for indicating highkey absence. (tree_reset): Take optional lowkey and highkey arguments, configuring these in the iterator being reset. (tree_reset_at): Function removed. (tree_next, tree_peek): Implement highkey semantics. (sub_tree): Simplified: from and to arguments are just passed through to tree_begin, and there is no need for a separate loop which enforces the upper limit, that now being handled by the iterator itself. (tree_begin): Update registrations of tree-begin and tree-reset; remove tree-begin-at and tree-reset-at intrinsics. * tree.h (tree_begin_at, tree_reset_at): Declarations removed. (tree_begin, tree_reset): Declarations updated. * lib.c (seq_iter_rewind, seq_iter_init_with_info, where, populate_obj_hash): Default new optional arguments in tree_begin and tree_reset calls. * parser.c (circ_backpatch): Likewise. * tests/010/tree.tl: Affected cases updated. * txr.1: Documentation updated. * share/txr/stdlib/doc-syms.tl: Regenerated.
* tree: support indexing and range extraction.Kaz Kylheku2021-05-116-1564/+1702
| | | | | | | | | | | | | | | | | | | * lib.c (do_generic_funcall): Support tree object invocation with one or two arguments via sub and ref. (sub): Implement for trees via sub_tree. (ref): Implement for trees via tree_lookup. * tree.c (sub_tree): New function. (tree_init): Register sub-tree intrinsic. * tree.h (sub_tree): Declared. * tests/010/tree.tl: New tests. * txr.1: Documented: DWIM bracket syntax on trees, sub and ref support for trees, sub-tree function, * share/txr/stdlib/doc-syms.tl: Regenerated.
* tree: replace-tree-iter function.Kaz Kylheku2021-05-115-1/+66
| | | | | | | | | | | | | * tree.c (replace_tree_iter): New function. (tree_init): Register replace-tree-iter intrinsic. * tree.h (tree_init): Declared. * share/txr/stdlib/doc-syms.tl: Updated. * txr.1: Documented. * tests/010/tree.tl: New test case.
* tree: copy-tree-iter function.Kaz Kylheku2021-05-106-2/+62
| | | | | | | | | | | | | | | * lib.c (copy): Handle tree_iter_s via copy_tree_iter. * tree.c (copy_tree_iter): New function. (tree_init): copy-tree-iter intrinsic registered. * tree.h (copy_tree_iter): Declared. * tests/010/tree.tl: New test case. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* diff/isec: reset hash/tree iter instead making new.Kaz Kylheku2021-05-103-2/+13
| | | | | | | | | | | * lib.c (seq_iter_rewind): Use hash_reset and tree_reset to rewind the existing iterator rather than allocating a new one. * tests/010/hash.tl: New file, covering uni, diff and isec for hash tables. * tests/010/tree.tl: New tests.
* doc: fix out of order compat notes.Kaz Kylheku2021-05-101-23/+23
| | | | | * txr.1: Move compatibility notes 258, 257 and 231 to the correct position, so the numbers are descending.
* lib: remove spurious null statement.Kaz Kylheku2021-05-101-1/+1
| | | | | * lib.c (seq_getpos): Remove spurious semicolon which adds an unreachable null statement.
* math: poly/rpoly diagnostic mixup.Kaz Kylheku2021-05-101-2/+2
| | | | | * arith.c (poly, rpoly): fix: the poly function wrongly refers to itself as rpoly and vice versa in diagnostics.
* lib: basic support for trees as sequences.Kaz Kylheku2021-05-094-38/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As of this commit, binary search trees can be iterated: mapped over with mapcar and such. * arith.c (poly, rpoly): rpoly won't work with trees. They work just with vectors and lists so let's make the error message more accurate. I noticed the self names of these two are swapped; will fix in another commit. * eval.c (tprint): Refactor to use iterator framework for objects other than lists. The tree case falls into this, so trees are supported. * lib.h (enum seq_kind): New enum constant SEQ_TREELIKE. (seq_iter_init_with_info): Declared. * lib.c (seq_info): Map tree object to SEQ_TREELIKE type. (seq_iter_get_tree, seq_iter_peek_tree): New static functions. (seq_iter_rewind): Support rewinding tree iteration. I think we could reuse the existing iterator here, and in the hash case as well. I made a note to look into this. (seq_iter_init_with_info): Internal linkage changed to external, because tprint in eval.c uses this. Handle SEQ_TREELIKE case here, by setting up iterator with the two new static functions. (seq_iter_mark): Handle SEQ_TREELIKE_CASE. Change switch statement to exhaustively list cases. (ldiff): Add SEQ_TREELIKE to various cases. Idea is that we handle it like SEQ_HASH. (nsort, sort, nshuffle, take, take_while, take_until, drop_while, drop_until, update): Add case for SEQ_TREELIKE, routing to error message. (lazy_where_tree_func): New static function. (where, sel, reject): Support trees.
* tree: expose insert, lookup and delete functions.Kaz Kylheku2021-05-092-5/+10
| | | | | | | | | | * tree.c (tree_insert, tree_lookup_node, tree_delete_node, tree_delete): Switch internal linkage to external linkage. * tree.h (tree_insert, tree_lookup_node, tree_delete_node, tree_delete): Declared.
* tree: new tree-peek function.Kaz Kylheku2021-05-095-13/+95
| | | | | | | | | | | | | | * tree.c (tn_peek_next): New static function. (tree_peek): New function. (tree_init): Register tree-peek intrinsic. * tree.h (tree_peek): Declared. * txr.1: Documented. * tests/010/tree.c: Work tree-peek into existing test case. * share/txr/stdlib/doc-syms.tl: Updated.
* tree: new make_similar_tree unction.Kaz Kylheku2021-05-094-0/+39
| | | | | | | | | | | * tree.c (make_similar_tree): New function. (tree_init): Register make-similar-tree intrinsic * tree.h (make_similar_tree): Declared. * tests/010/tree.tl: New tests. * txr.1: Documented.
* parser: #; tests and bugfixes.Kaz Kylheku2021-05-063-1638/+1706
| | | | | | | | | | | | | | | | This is motivated by the recent crash regression in the #; comment out mechanism. The parser doesn't have adequate coverage in the test suite. * tests/012/syntax.tl: New file, for testing syntax. A problem was found #;.expr did not work inside a list, only at top level. It required a space before the dot. * parser.y (listacc): A couple of productions to handle hash-semicolon immediately followed by a dot without any whitespace, and then by an expression. * y.tab.c.shipped: Regenerated.
* configure: reconfigure: add "$@" to configure line.Kaz Kylheku2021-05-051-2/+2
| | | | | | * configure: Allow the conveninence of additional parameters to be passed through reconfigure, to tweak the previous configuration.
* configure: bug: in-place reconfigure clobber.Kaz Kylheku2021-05-051-0/+1
| | | | | | * configure: before generating reconfigure, remove it. Otherwise, if are executing the reconfigure script, errors can appear in it if its length is extended.
* matcher: new "each-match family" of macros.Kaz Kylheku2021-05-045-6/+331
| | | | | | | | | | | | | | | | | | * lisplib.c (match_set_entries): New autoload symbols: each-match, append-matches, keep-matches, each-match-product, append-match-products, keep-match-products. * share/txr/stdlib/doc-syms.tl: Updated. * share/txr/stdlib/match.tl (each-match-expander): New function. (each-match, append-matches, keep-matches, each-match-product, append-match-products, keep-match-products): New macros. * tests/011/patmatch.tl: New tests covering each macro, far from exhaustively. * txr.1: Documented.
* parser: fix regression in #; syntax.Kaz Kylheku2021-05-043-3/+9
| | | | | | | | | | | | A crash has showed up when processing commented-out objects. This is due to the most recent gc fix to the parser. * parser.y (set_syntax_tree): Avoid the set macro when tree has the special value nao (not an object). * y.tab.c.shipped: Regenerated. * y.tab.h.shipped: Likewise.
* format: use self variable in error messages.Kaz Kylheku2021-05-041-6/+6
| | | | | * stream.c (formatv): Replace hard-coded "format:" with ~a and self argument. Several error messages are revised.
* format: ~x/~X specifiers support buffers.Kaz Kylheku2021-05-045-18/+84
| | | | | | | | | | | | | * buf.c (buf_hex): New function. * buf.h (buf_hex): Declared. * stream.c (formatv): Support printing of buffers in hex via temporary buffer containing hex characters, similarly to how bignums are handled. * tests/018/format.tl: New file, providing some coverage over new and affected code.
* sha256/md5: leak: don't use borrowed buffer for hash.Kaz Kylheku2021-05-043-2/+3
| | | | | | | | | | | | | | | It's incorrect to use a borrowed buf, because a borrowed buf assumes that the memory isn't dynamically allocated, and will not free it when it is finalized by the garbage collector. The buffer which holds the hash returned by sha256 and md5 does in fact own the memory. * buf.c (make_owned_buf): Static function becomes external. * buf.h (make_owned_buf): Declared. * chksum.c (chksum_ensure_buf): Use make_owned_buf rather than make_borrowed_buf.
* buf: bugfix: int-buf, uint-buf refer to alloc size.Kaz Kylheku2021-05-042-2/+6
| | | | | | | | | | * buf.c (int_buf, uint_buf): Refer to the buffer length b->len rather than the underlying allocation size b->size. Referring to b->size will not only produce the wrong value when it is larger than len, but b->size can be null for a borrowed buffer, producing a crash. * tests/012/buf.tl: Tests.
* compiler: bug: not warning bad uses of some local funs.Kaz Kylheku2021-05-031-2/+3
| | | | | | | | | | | | | | | | | | When a lexical function defined with flet or labels is called with the wrong arguments, this is not being diagnosed if that function is being lifted to load-time. This is because the sys:load-time-lit that the lambda is wrapped with is not propagating the pars attribute of the frag structure from the lambda to its own returned frag. * share/txr/stdlib/compiler.tl (compiler comp-load-time-lit): After compiling the expression to obtain the exp frag, stuff exp.pars to both the lt-frag that is generated, as well as to the returned dummy frag carrying the dreg access that retrieves the function. It's important for this returned frag to carry the info, because from there it is propagated to the function binding by comp-fbind by the (set bind.pars frag.pars) expression.
* rel-path: bugfixes.Kaz Kylheku2021-05-033-21/+136
| | | | | | | | | | | | | | | * share/txr/stdlib/copy-file.tl: When removing .. components, a dotdot must only cancel preceding non-dotdot. We must check not only that the out stack is not empty but that the top element isn't dotdot. Also, eliminate empty components, like the documentation says. Lastly, we must check for the impossible cases, when the from path uses .. components that are impossible to navigate backwards to form a relative path. * tests/018/rel-path.tl: Test cases added. * txr.1: Updated with additional descriptions, fixes and examples.
* New function: rel-path.Kaz Kylheku2021-05-035-1/+150
| | | | | | | | | | | | | * lisplib.c (copy_file_set_entries): Add rel-path as autoload trigger for copy-file module. * share/txr/stdlib/copy-file.tl (rel-path): New function. * tests/018/rel-path.tl: New file. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* New function: portable-abs-path-p.Kaz Kylheku2021-05-024-8/+61
| | | | | | | | | | | | | | | * share/txr/stdlib/doc-syms.tl: Updated. * stream.c (portable_abs_path_p): New function, exact copy of old abs_path_p. (abs_path_p): Rewritten to be specific to host platform. No Windows-drive-like prefixes are checked on POSIX. (stream_init): Register new function. Register abs-path-p conditionally based on 258 compatibility. * stream.h (portable_abs_path_p): Declared. * txr.1: Documented, with compat notes.
* bug: join-with segfault on character separators.Kaz Kylheku2021-05-022-1/+25
| | | | | | | * lib.c (join_with): Pass the correct onech array down to cat_str_init, rather than a null pointer. * tests/015/split.tl: New tests covering join and join-with.
* doc: "suficient" typo in new paragraph.Kaz Kylheku2021-05-021-1/+1
| | | | | * txr.1: Fix typo in recently introduced paragraph about file compiler's treatment of symbols.
* Version 258txr-258Kaz Kylheku2021-05-016-146/+176
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Bumped. * txr.vim, tl.vim: Regenerated.