summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Version 220.txr-220Kaz Kylheku2019-07-086-987/+1023
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* crc32: comment header formatting problem.Kaz Kylheku2019-07-082-2/+6
| | | | * crc32.c, crc32.h: Repair accidentally joined lines.
* compile-file: elide top-level atoms.Kaz Kylheku2019-07-071-1/+1
| | | | | | | * share/txr/stdlib/compiler.tl (usr:compile-file): If a top-level form is compiled that is an atom, don't emit the translation, since it has no effect (beyond interning the symbol).
* compile-file: don't ignore atomic forms.Kaz Kylheku2019-07-071-22/+22
| | | | | | | | | * share/txr/stdlib/compiler.tl (usr:compile-file): do not silently ignore forms that (after macroexpansion) are atoms; treat them like any other forms. This is mostly useless, but if unbound variables are used as top-level forms, it is diagnosed, and keeps the file compilation behavior closer to interpreted semantics.
* doc: op: incorrect example.Kaz Kylheku2019-07-061-5/+14
| | | | | | * txr.1: Switch op example to ap and move under description of ap, which needs an example anyway. Add new examples for op. Reported by user vapnik spaknik.
* replace: deal with overlapping.Kaz Kylheku2019-07-053-4/+16
| | | | | | | | | | | | | * buf.c (replace_buf): In the same-type case, use memmove rather than memcpy in case the objects overlap, so we don't invoke C undefined behavior. * lib.c (replace_str, replace_vec): Likewise. * txr.1: Specify that if the replacement sequence overlaps with the target range of the destination sequence, or with any portion that has to be relocated if range changes size, then the behavior is unspecified.
* replace: third argument is a sequence.Kaz Kylheku2019-07-051-1/+1
| | | | | * txr.1: The index-list argument of replace can be a sequence of any kind, not just a list or vector.
* bugfix: broken carray-replace.Kaz Kylheku2019-07-051-1/+1
| | | | | | | | * ffi.c (carray_replace): Use original fn < vn loop guard, like in the original code that was replaced by the generic sequence iteration loop. For instance, when we replace a range like 1..1, fn == tn, and so the loop doesn't copy anything.
* buffers: remove unused buf_fill function.Kaz Kylheku2019-07-052-7/+0
| | | | * buf.c, buf.h (buf_fill): Removed.
* New function: buf-put-buf.Kaz Kylheku2019-07-053-0/+49
| | | | | | | | | | * buf.c (buf_move_bytes): New static function. (buf_put_buf): New function. (buf_init): Register buf-put-buf intrinsic. * buf.h (buf_put_buf): Declared. * txr.1: Documented.
* crc32-stream: recycle I/O buffer.Kaz Kylheku2019-07-041-2/+3
| | | | | * chksum.c (crc32_stream): use iobuf_get to obtain the I/O buffer, and iobuf_put to recycle it.
* sha256: allow application to specify digest buffer.Kaz Kylheku2019-07-043-19/+56
| | | | | | | | | | | | | | | | | | | | | * chksum.c (sha256_stream_impl): New static function, formed out of bulk of sha256_stream. Takes a pointer to a buffer where the digest is stored. (sha256_ensure_buf): New static function. (sha256_stream): Take buf argument; use sha256_ensure_buf to allocate a buffer if necessary, and to obtain the low-level buffer pointer. Implementation moved into sha256_stream_impl. (sha256_buf, sha256_str): Take pointer to digest buffer; don't allocate a buf object, don't return anything. (sha256): Take buf argument; use sha256_ensure_buf to allocate a buffer if necessary, and to obtain the low-level buffer pointer, which is passed to sha256_buf and sha256_str. (chksum_init): Update registrations of intrinsics with new optional parameters. * chksum.h (sha256_stream, sha256): Declarations updated. * txr.1: Updated.
* sha256: recycle I/O buffer used in stream hash.Kaz Kylheku2019-07-044-3/+34
| | | | | | | | | | | | | * chksum.c (sha256_stream): Use iobuf_get and iobuf_put. * gc.c (gc): Do not mark the list of recycled buffers; just consider them to be garbage and clear the list, like we do with recycled conses via rcyc_empty. * stream.c (iobuf_free_list): New static variable. (iobuf_get, iobuf_put, iobuf_list_empty): New functions. * stream.h (iobuf_get, iobuf_put, iobuf_list_empty): Declared.
* Expose make-byte-input-stream.Kaz Kylheku2019-07-042-0/+32
| | | | | | | * stream.c (stream_init): Register make-byte-input-stream intrinsic. * txr.1: Documented.
* tests: add @{var1 var2} match test.Kaz Kylheku2019-07-035-4/+16
| | | | | | | | | | | | | | * tests/001/query-5.txr: New file. * tests/001/query-5.expected: New file. * Makefile (tst/tests/001/query-5.ok): Pass -B to txr for this new test. * tests/017/glob-carray.expected: Updated, because the glob test globs over the contents of tests/001 directory. * tests/017/glob-zarray.expected: Likewise.
* doc: mistakes in dot position funcalls examples.Kaz Kylheku2019-07-031-2/+2
| | | | | * txr.1: Two examples have a comment claiming an incorrect return value. Reported by user vapnik spaknik.
* @{var1 var2}: bugfix: broken when var2 is regex.Kaz Kylheku2019-07-021-1/+1
| | | | | | | | | | * match.c (h_var): When processing variable bound over a regex or text match, if that datum came from a modifier which was a variable, we must process the substituted modifier, not the original variable symbol. This is a regression that was introduced on November 16, 2011, in commit b86a599bbfcd591f64f31ddfc9ab1a659d39a7c0: "Variable matches can span over function calls.". Reported by user vapnik spaknik.
* @(define): bugfix: incorrect parameter list walk.Kaz Kylheku2019-07-021-2/+2
| | | | | | | | | * parser.y (elem, define_clause): The match_reg_params function is supposed to walk the pattern function parameters, not the argument of the define directive (of which the second one is those arguments). This bug causes spurious unbound variable warnings when function bodies refer to their second or subsequent arguments. Issue reported by user vapnik spaknik.
* Version 219.txr-219Kaz Kylheku2019-07-016-889/+922
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* empty: handle buffers.Kaz Kylheku2019-06-301-0/+2
| | | | * lib.c (empty): Handle BUF in switch.
* sha256: C++ fix: void *conversion.Kaz Kylheku2019-06-302-3/+2
| | | | | | | | * chksums/sha256.c (SHA256_update): Change in parameter to const unsigned char *, avoiding the need for a local variable in that type. * chksums/sha256.h (SHA256_update): Declaration updated.
* stdlib: pass env to constantpKaz Kylheku2019-06-292-8/+8
| | | | | | | * share/txr/stdlib/except.tl (catch**): Obtain macro environment and pass to constantp. * share/txr/stdlib/place.tl (last, butlast): Likewise.
* keyparams: bugfix: key list order scrambled.Kaz Kylheku2019-06-291-17/+11
| | | | | | | | | | | | When the keyword parameter list contains a mixture of constant and non-constant default value expressions, the order of the extracted keys is scrambled, so values go to the wrong variables. * share/txr/stdlib/keyparams.tl (sys:build-key-list): Renamed to build-key-list-expr and rewritten to preserve the key order. (:key): Follow rename of build-key-list.
* keyparams: use environment for constantp.Kaz Kylheku2019-06-291-3/+3
| | | | | | * share/txr/stdlib/keyparams.tl (sys:build-key-list): Take macro environment parameter, and pass to constantp. (:key): Pass macro environment to sys:build-key-list.
* defset: small code improvement.Kaz Kylheku2019-06-291-15/+14
| | | | | | * share/txr/stdlib/defset.tl (defset-expander): Move with-gensyms to outermost scope so we can include nvsym in it, avoiding the explicit (nvnsm (gensym)) binding.
* defset: bind new-val-sym to temporary variable.Kaz Kylheku2019-06-283-23/+23
| | | | | | | | | | | | | | | | | | | | | | Users of defset no longer have to ensure that in the store form, the symbol which gives the new value to be stored is inserted only once. * share/txr/stdlib/defset.tl (defset-expander): Transform the store form by inserting a temporary variable using alet. (sub-list, sub-vec, sub-str): These place forms no longer require a local gensym. * txr.1: Updated doc. * tests/012/defset.tl: The expected output for the inc case now incorporates a gensym that comes from the compiled defset macro. Since we can't control that by means of the gensym counter, we resort to extracting it from the expansion itself, then check the test case against a template which incorporates that gensym. We check that the extracted item really is a gensym: it's a symbol with no home package whose name starts with "g".
* seq_info: nullify bugfix.Kaz Kylheku2019-06-281-13/+19
| | | | | | | | | | | | | | | | | | | | | A change in the nullify function to support hash tables has broken various functions which classify an object using seq_info, obtainig a SEQ_HASHLIKE kind, and then work with si.obj using hash functions. But si.obj has been nullified. An example of a broken function is find-max. Basically, this can be attributed to a careless use of nullify in seq_info. The purpose of nullify is to support code which treats any sequence as if it were a list. But seq_info doesn't do that; it classifies sequences and treats them according to their kind. Under seq_info, the only non-list objects that get treated as lists are list-like structures. For these it makes sense to call nullify, in case they have a nullify method. * lib.c (seq_info): Don't unconditionally call nullify on all COBJ objects. Only call nullify on struct objects. If that returns nil, then treat the object as SEQ_NIL; and if it returns an object different from the original, then recurse.
* seq-begin: bugfix: non-lists don't work.Kaz Kylheku2019-06-282-1/+8
| | | | | | | | | | | | | * lib.c (seq_begin): Do not null out si->inf.obj; it's needed for accessing hashes and vector-like objects. This bug means that seq-begin iteration has only worked correctly for lists. The original motivation was not to have spurious retention of the head of a lazy list, which is hereby reintroduced. But iterators can be rewound. Let's just document this away and leave it as a to-do item. * txr.1: Document the limitation of seq-begin w.r.t. lazy lists.
* doc: put-buf/fill-buf clarification of pos.Kaz Kylheku2019-06-271-0/+2
| | | | | * txr.1: The pos argument of put-buff and fill-buf is a position within the buffer (not the stream).
* doc: update syntactic places.Kaz Kylheku2019-06-271-3/+10
| | | | | * txr.1: Update the list of syntactic places to list all the new places that have been added, plus a few additional edits.
* in: allow hash with keyfun and testfun.Kaz Kylheku2019-06-252-4/+31
| | | | | | | * lib.c (in): A simple check and fallthrough lets this function process hash tables more generally in this function. * txr.1: Documented.
* in: use seq_infoKaz Kylheku2019-06-251-26/+28
| | | | | * lib.c (in): Keep the existing specialized cases, but use seq_info in the fallback.
* Factor function name into self variable.Kaz Kylheku2019-06-251-10/+15
| | | | | * lib.c (take, take_while, take_until, drop_while, drop_until): Move repeated function name into self variable.
* drop-{while,until}: convert to seq_info.Kaz Kylheku2019-06-251-16/+16
| | | | | | * lib.c (drop_while, drop_until): Use seq_info, so these functions work with all sequences. Thus now for instance [drop-while zerop #b'0000f00d'] yields #b'f00d'.
* empty: handle carray.Kaz Kylheku2019-06-251-0/+2
| | | | * lib.c (empty): Add carray sub case to COBJ case.
* nullify: handle carray and hashes.Kaz Kylheku2019-06-251-0/+4
| | | | | * lib.c (nullify): Add carray and hash subcases into the COBJ case.
* doc: clarify nullify.Kaz Kylheku2019-06-251-5/+26
| | | | | | * txr.1: Clarify that nullify also just returns its argument if it is not a sequence at all. Clarify that nullify works on objects via the nullify method only.
* Handle buffers in list collector functions.Kaz Kylheku2019-06-251-0/+19
| | | | | | * lib.c (nullify, list_collect, list_collect_nconc, list_collect_append, list_collect_nreconc, list_collect_revappend): Handle buffer type.
* list_collect: handle objects.Kaz Kylheku2019-06-252-1/+11
| | | | | | | | | * lib.c (list_collect): Handle sequence-like COBJ objects. We can add an item to using their respective replace functions. (replace_obj): Change to external linkage. * lib.h (replace_obj): Declared.
* Code clean-up in list collector functions.Kaz Kylheku2019-06-251-19/+23
| | | | | | | * lib.c (list_collect, list_collect_append, list_collect_revappend): Use local variables to avoid repeated expressions. (list_collect_nconc): Only call nullify in necessary cases.
* seqp: expand definition of sequences.Kaz Kylheku2019-06-252-13/+18
| | | | | | | * lib.c (seqp): Use seq_info to classify the object as a sequence. * txr.1: Update description of seqp.
* replace: fix strange diagnostic from bad fallthrough.Kaz Kylheku2019-06-241-2/+2
| | | | | | | | | * lib.c (replace): If a COBJ is passed to replace which doesn't support the operation, we wrongly pass it to replace_buf because the BUF case was added into the fallthrough pass. The end result is that length_buf blows up on the object, resulting in a strange diagnostic. The BUF case must be moved above COBJ.
* New: CRC-32 functions.Kaz Kylheku2019-06-245-1/+243
| | | | | | | | | | | | * Makefile (OBJS): Add chksums/crc32.o. * chksum.c (crc32_stream, crc32): New functions. (chksum_init): Register crc32-stream and crc32 intrinsic functions. * chksums/crc32.c, chksums/crc32.h: New files. * txr.1: Documented.
* lnew: two regressions fixed.Kaz Kylheku2019-06-241-2/+2
| | | | | | | | | * share/txr/stdlib/struct.tl (sys:new-expander): The syntax (lnew (type boa args ...)) is not being handled at all due a typo in the case. Moreover, the syntax (lnew type slot0 val0 slot1 val1 ...) is broken due to a missing unquote on the type gensym in the output template.
* * Makefile (OBJS): New objects chksum.o and chksums/sha256.o.Kaz Kylheku2019-06-238-1/+585
| | | | | | | | | | * chksum.c, chksum.h, chksums/sha256.c, chksums/sha256.h: New files. * lib.c (init): Call chksum_init. * txr.1: Documented. * LICENSE: Add SHA-256 copyright notice.
* doc: move buffers out of dynamic lib section.Kaz Kylheku2019-06-231-1341/+1343
| | | | | | | | * txr.1: Buffers are now documented after strings and vectors. Buffer streams are in the I/O section. Note: the diff between this and the previous commit needs to be generated with git diff --minimal. Otherwise it looks like over 30,000 lines of changes.
* base64: integrate with buffers.Kaz Kylheku2019-06-215-8/+54
| | | | | | | | | | | | | | | * filter.c (base64_encode): Handle an object of either string or buffer type by using make_byte_input_stream. (base64_decode_buf): New function. (filter_init): Register base64-decode-buf intrinsic. * filter.h (base64_decode_buf): Declared. * stream.c (make_byte_input_stream): New function. * stream.h (make_byte_input_stream): Declared. * txr.1: Updated.
* streams: use ~s and ~a properly in errors.Kaz Kylheku2019-06-211-27/+27
| | | | | | | | | | | | | Objects should almost always be printed as ~s. If a bad object is printed as ~a, junk could result on the terminal if it's a buffer, for instance. * stream.c (stdio_maybe_read_error, stdio_maybe_error, stdio_close, pipe_close, parse_mode, normalize_mode, normalize_mode_no_bin, cat_unget_byte, cat_unget_char, unget_byte, open_directory, open_file, open_tail, open_command, open_process, run, remove_path, rename_path): Revise conversion specifiers in error message formatting.
* doc: minor grammar problems in Lisp CompilationKaz Kylheku2019-06-211-2/+2
| | | | | * txr.1: Two issues fixed while proof-reading: missing "a" article and a missing plural.
* doc: cure that-is-itis.Kaz Kylheku2019-06-211-3/+3
| | | | | * txr.1: In two places, fix an awkward "; that is, has ..." and "; that is, is ..." grammatical curiosity.