summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* doc: fix wrong typesetting of nil and t.Kaz Kylheku2023-11-151-13/+13
| | | | | | | | * txr.1: Fix numerous occurrences of nil and t being typeset using "meta" rather than "code". That makes them slanted in the HTML and PDF, and appear in angle brackets as <nil> and <t> in text-based man output. We want a non-slanted type, and no angle brackets for these.
* oop: allow del on struct sequences.Kaz Kylheku2023-11-153-4/+63
| | | | | | | | | | * lib.c (dwim_del): Remove check against structures from OBJ case; we just let this pass through to the logic that invokes replace. * tests/012/aseq.tl: New test cases. * txr.1: Document how del works on a [obj index] place.
* oop: segfault in special methods cache.Kaz Kylheku2023-11-152-11/+34
| | | | | | | | | | | | | * struct.c (invalidate_special_slots): New static function. (invalidate_special_slot_nonexistence): Move static function up in file, to be next to invalidate_special_slots. (make_struct_type, static_slot_ens_rec): Call the new invalidate_special_slots function in addition to calling static_slot_home_fixup whenever the stslots array is resized. The spslot array contains pointers to the elements of stslots, which become invalid when that is resized. * tests/012/oop-seq.tl: Repro test case added.
* dwim: correction to error diagnostic.Kaz Kylheku2023-11-151-1/+1
| | | | | | | * lib.c (dwim_set): The "not a place" diagnostic applies not only in situations when the object is a list; the diagnostic should not imply that the argument is a list when it isn't.
* New accessor: mref.Kaz Kylheku2023-11-156-0/+308
| | | | | | | | | | | | | | * eval.c (eval_init): Register mref intrinsic. * lib.[ch] (mref): New function. * stdlib/place.tl (sys:mref1): New place. (mref): New place macro, defined in terms of sys:merf1, ref place and mref function. * tests/012/seq.tl: New tests. * txr.1: Documented.
* place: bad indentation.Kaz Kylheku2023-11-131-9/+9
| | | | * stdlib/place.tl (dwim): Fix incorrect indentation.
* ref: bugfix in deletion of ref place.Kaz Kylheku2023-11-113-85/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ref function is not defined in the documentation as an accessor, but there is a ref place. Unfortunately, deletion is broken: (del (ref x y)) does not store the new sequence back into place x, and so it does not work correctly for lists; if x is a list, it doesn't change. Various accessors are defined in terms of ref, as place macros, such as the first, second, third, ... accessors. This fixes the bug for them also; (del (second list)) must update list. * stdlib/place.tl (ref): Fix the delete-expander to fetch the clobber expander of the sequence place, and use the simple setter to put the edited sequence into that place. * tests/012/seq.tl: Test case, which breaks without this fix. Test the (second ...) place also, which is defined in terms of ref. * txr.1: Split documentation for ref and refset, mainly because one is an Accessor and one is a Function. Removing some discussions about the equivalences between DWIM brackets and ref; there are subtleties there not worth going into. Description of refset is simplified. We mention the possibility of del over a ref place; only in that case is the sequence itself required to be a place.
* New macro: tap.Kaz Kylheku2023-11-084-1/+82
| | | | | | | | | | | * autoload.c (op_set_entries): Add tap symbol as autoload trigger for op module. * stdlib/op.tl (tap): New macro. * tests/012/op.tl: New test. * txr.1: Documented.
* quips: philosphy-related joke.Kaz Kylheku2023-11-051-0/+1
| | | | * stdlib/quips.tl (%quips%): New one.
* match: translate some match-case forms into casequal.Kaz Kylheku2023-10-222-32/+102
| | | | | | | | | | | | | | | | | | | The motivation here is that casequal brings in some optimizations not done by match-case, like hashed lookup and jump tables. * stdlib/match.tl (non-triv-pat-t): Move temporary definition higher in file since it is needed earlier in the bootsrapping. (match-case-to-casequal): New function. (match-case): Try converting clauses to casequal with new function. If that returns something, use that as the expansion, otherwise perform the normal expansion. * txr.1: Documentation revised. Existing text is wrong which says that the clauses of a caseq, caseql or casequal are always evaluated sequentially. Furthermore, now that match-case and match-ecase can be transformed to casequal, they also don't necessarily evaluate sequentially. We spell out the conditions under which they may translate.
* build: revise build instructions in configure scriptKaz Kylheku2023-10-151-3/+4
| | | | | * configure: make it clear that the user must run "make" or "make all" before "make tests" and "make install".
* match: bug: missing autloads.Kaz Kylheku2023-10-151-1/+7
| | | | | | * autoload.c (match_set_entries): We must not just intern match-error, but load the function if it is referenced. Likewise, we must register an autoload for sys:match-pat-error.
* vim: bug: recognize char escapes in quasilit.Kaz Kylheku2023-10-141-1/+1
| | | | | | | * genvim.txr (txr_quasilit): Fix gaping omission here: the quasiliteral region does not contain any of the character escapes, screwing up the syntax highlighting if any of them occur.
* build: misspelled PLATFORM_LDLIBS.Kaz Kylheku2023-10-061-1/+1
| | | | | | * Makefile (TXR_LDLIBS): Fix PLAFORM_LDLIBS typo in definition of variable. This typo renders ineffective the --platform-ldlibs option of the configure script.
* New: length-list-<, length-<Kaz Kylheku2023-10-055-0/+138
| | | | | | | | | | | | | | | | | | | | | | These are functions for testing whether a list or sequence is shorter than a given integer. This is cheaper than calculating the length of lists, which is in some cases impossible if they are infinite. A length-str-< function already exists, useful with lazy strings. length-< uses length-list-< or length-str-< as appropriate * lib.[ch] (length_list_lt, length_lt): New functions. * eval.c (eval_init): length-list-< and length-< intrinsics registered. * tests/012/seq.tl: New tests. * txr.1: Documented.
* doc: small omission in flatcar.Kaz Kylheku2023-10-051-0/+4
| | | | | * txr.1: Document that flatcar and flatcar* accept an atom argument, which is returned.
* tests for flatcar and flatcar*.Kaz Kylheku2023-10-011-0/+24
| | | | * tests/012/seq.tl: New tests.
* flatten*: fix two bugs.Kaz Kylheku2023-09-303-14/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (lazy_flatten_scan): Fix a problem which results in cases like (()), ((())) ... to incorrectly flatten to (nil). The do loop in this function which iteratively descends into a nested left-nesting of a list does not handle all cases, and therefore the function may not return at that point. Removing the return fixes the problem, but so does removing the loop so that in that case we just descend one level into the nested list, and continue in the main loop. What is incorrect is that when the consp(a) test fails and the do loop terminates, we need to distinguish the cases off a being an atom versus nil. Continuing in the loop does that. This bug was spotted by a reviewer in the comp.lang.c Usenet newsgroup. (lazy_flatten): We neglect to handle the case here that the input is an empty list, resulting in (flatten* nil) returning (nil) rather than nil. The flatten function is correct. * tests/012/seq.tl: New tests. * txr.1: Documentation improved. In particular, these functions don't handle improper lists. Also, it needs to be documented that the argument may be an atom.
* Integration with setjmp/longjmp.Kaz Kylheku2023-09-279-1/+315
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Defining libpng bindings, with longjmp catching, is now possible. * autoload.c (ffi_set_entries): Add setjmp symbol, which is a new macro in stdlib/ffi.tl. * ffi.c (jmp_buf_s): New symbol variable. (mk_jmp_buf, rt_setjmp, longjmp_wrap): New functions. (ffi_init): Initialize jmp_buf_s. Register sys:rt-setjmp and longjmp intrinsics. * ffi.h (jmp_buf_s): Declared. * stdlib/ffi.h (setjmp): New macro. Rather than introducing a new special operator, we use a run-time support function called sys:rt-setjmp, which takes functional arguments. * unwind.[ch] (uw_snapshot, uw_restore): New functions. The rt_setjmp function needs these to restore our unwind frame stack into a sane state after catching a longjmp, which bails without unwinding it, leaving the pointers referring to frames that no longer exist. * tests/017/setjmp.tl, * tests/017/setjmp.expected: New files. * txr.1: Documented.
* New hist-sort function.Kaz Kylheku2023-09-255-4/+75
| | | | | | | | | | | | | | | * eval.c (eval_init): Register hist-sort intrinsic. * lib.c (gt_f): New global variable. (hist_succ_f): New static variable. (hist_succ): New static function. (hist_sort): New function. * lib.h (gt_f, hist_sort): Declared. * tests/012/sort.tl: New tests. * txr.1: Documented.
* New T mode for open-file.Kaz Kylheku2023-09-233-4/+70
| | | | | | | | | | | | | | | The T mode uses O_TMPFILE to create an unlinkd temporary file. * stream.h (struct stdio_mode): New flag, tmpfile. (stdio_mode_init_blank, stdio_mode_init_r, stdio_mode_init_rpb): Updated to cover new bitfield member. * stream.c (w_open_mode): If tmpfile flag is on, add O_TMPFILE. (do_parse_mode): Recognize "T" mode selector and set all appropriate mode bits. If we are not on a platform that has O_TMPFILE, set the maformed flag. * txr.1: Documented.
* New function: rlink.Kaz Kylheku2023-09-233-4/+55
| | | | | | | | | | | | | | | This uses the linkat function to implement a variant of link which resolves the source object if it is a symlink. * configure: test for linkat. * sysif.c (link_wrap_common): New static function, used by both link_wrap and rlink_wrap. (link_wrap): Now a one-liner which calls link_wrap_common. (rlink_wrap): New static function. (sysif_init): Register rlink intrinsic. * txr.1: Documented.
* doc: awk: records and fieldsKaz Kylheku2023-09-221-1/+1
| | | | | * txr.1: the awk macro divides input into records and fields, not records or fields.
* doc: fix "uninterested symbols".Kaz Kylheku2023-09-221-1/+1
| | | | | * txr.1: in description of weak packages, fix "uninterested" symbols to "discarded".
* doc: fix wording problem in hash-map.Kaz Kylheku2023-09-221-5/+9
| | | | | * txr.1: Fix hash-map being described as constructing a function. It returns a hash table. Revise wording.
* build: set DELETE_ON_ERROR in Makefile.Kaz Kylheku2023-09-221-0/+2
| | | | | | | * Makefile (.DELETE_ON_ERROR): Special target added. The GNU Make manual says that this is what we always want. Without this, a partially generated txr-manpage.html target is not removed if the recipe happens to die.
* doc: fix instances arguments-apply-to-function wording.Kaz Kylheku2023-09-221-21/+27
| | | | | | | | * txr.1: Revise all wording which says that arguments are applied to a function, or other object being used as a function. I seem to remember taking the same initiative some years ago, but wrong usages have snuck in. I even found some in the definition of the apply function.
* New functions: nested-vec-of and nested-vec.Kaz Kylheku2023-09-217-20/+185
| | | | | | | | | | | | | | | * eval.c (eval_init): Register nestd-vec-of and nested-vec intrinsics. * lib.[ch] (vec_allocate, vec_own, vec_init): New static functions. (vector, copy_vec): Expressed in terms of new functions. (nested_vec_of_v, nested_vec_v): New functions. * args.[ch] (args_cat_from): New function. * tests/010/vec.tl: New tests. * txr.1: Documented.
* doc: glob*: spellingKaz Kylheku2023-09-131-2/+2
| | | | * txr.1: Typos in recently added paragraphs.
* glob*: Solaris fixes.Kaz Kylheku2023-09-132-26/+29
| | | | | | | | | | | | | * glob.c (glob_wrap): #ifdef GLOB_BRACE around code that removes the flag. (super_glob_find_inner): Initialize pst. The older compiler I'm using on Solaris 10. isn't smart enough to figure out that it is not used uninitialized. * tests/018/glob.t: Skip the ...\/** test on Solaris. It takes a long time, and produces nil in the end. We don't care how it behaves, only that we pass through that pattern to glob without interpreting it as a double star.
* glob*: skip tests on Cygwin.Kaz Kylheku2023-09-131-0/+4
| | | | * tests/018/glob.tl: exit successfully on Cygwin.
* glob*: fix buggy sort comparison function.Kaz Kylheku2023-09-132-91/+97
| | | | | | | | * glob.c (glob_path_cmp): Compare bytes as unsigned. After the loop, don't test whether the pointer are null; they never are. Test whether they point to null. * tests/018/glob.tl: Expected data replaced.
* glob*: do not recognize trailing \/**.Kaz Kylheku2023-09-132-1/+31
| | | | | | | * glob.c (super_glob_rec): Do not recognize a trailing /** if it is preceded by a backslash. * tests/018/glob.tl: Test case added.
* New place-mutating macro ensure.Kaz Kylheku2023-09-133-1/+56
| | | | | | | | | * autload.c (place_set_entries): Add ensure as an autoload trigger symbol for the place module. * stdlib/place.tl (ensure): New macro. * txr.1: Documented.
* chdir: support stream and fd argument via fchdir.Kaz Kylheku2023-09-123-8/+47
| | | | | | | | | | | * configure: new test for fchdir resulting in HAVE_FCHDIR. * sysif.c (get_fd): Define for HAVE_FCHDIR also. (chdir_wrap): If HAVE_FCHDIR, handle non-string arguments via fchdir, with help of get_fd. * txr.1: Documented.
* New glob* function.Kaz Kylheku2023-09-126-5/+610
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The glob* function supports brace expansion, the ** pattern for matching zero or more path components, as well as a sane sort for path names. glob* relies on brace expansion written in Lisp; the ** processing and sorting is done by a glob-compatible C function called super_glob that uses glob. * autoload.c (glob_set_entries, glob_instantiate): New static functions. (autoload_init): Register autoload of stdlib/glob module. * glob.c (GLOB_XNOBRACE, GLOB_XSTAR): New macros. (glob_wrap): Call super_glob instead of glob if GLOB_XSTAR is present in flags. Avoid passing extension flags to glob. (super_glob_find_inner, super_glob_rec, glob_path_cmp, glob_str_cmp, super_glob): New static functions. (glob_init): Register sys:glob-xstar, and glob-xnobrace. sys:glob-xstar is used by glob* to request support for the ** pattern from glob. * stdlib/glob.tl: New file. * tests/018/glob.tl: New file. * txr.1: Documented.
* Use vargs typedef instead of struct args *.Kaz Kylheku2023-09-0518-257/+256
| | | | | | | | | | | | | | | | | | | | | | | | | | | The vargs typedef is underused. Let's use it consistently everywhere. * args.c, * args.h, * args.c, * args.h, * arith.c, * eval.c * ffi.c, * gc.c, * hash.c, * lib.c, * lib.h, * parser.c, * stream.c, * struct.c, * struct.h, * syslog.c, * syslog.h, * unwind.c, * vm.c, * vm.h: All "struct args * declarations replaced with existing "varg" typedef that comes from lib.h.
* crypt: newly proposed test still fails on Musl.Kaz Kylheku2023-09-031-1/+1
| | | | | | | | * tests/018/crypt.tl: replace (crypt "a" "*$") test with (crypt "a" "::"). Musl's crypt treats all unrecognized hashes through DES, and the DES module accepts almost anything as salt characters, except '\0', '\n' and ':', since those characters would wreck the password file.
* json: allow integers and lists.Kaz Kylheku2023-09-033-9/+30
| | | | | | | | | | | | * lib.c (out_json_rec): Handle NUM and BGNUM cases same as FLNUM so integers get printed. The restriction against integers has been largely unhelpful and bothersome. Handle LCONS together with CONS. Lists that are not special notation fall through to the VEC case, which now uses seq_iter_t iteration to handle vectors and lists. * tests/010/json.tl: New tests. * txr.1: Documented support for printing integers and lists.
* crypt: detect error tokens more weakly; drop some tests.Kaz Kylheku2023-09-033-4/+24
| | | | | | | | | | | | | | | | | | | | | | | | It has been reported by user cielesti that some of our crypt tests fail on the Musl library. Musl has some additional agorithms so it yields a meaningful hash for a "$0$" salt, as well as for "$9$". Musl uses "*" and "x" as error tokens rather than "*0" and "*1". We need to change how we detect error tokens. * sysif.c (crypt_wrap): Detect error tokens only by their length: if a string emerges from crypt or crypt_r, whose length is less than 13, it's an error token. * tests/018/crypt.tl: Drop the tests that require :error for salts "$0$" and "$9$", replacing them with a test for a salt that is almost certainly invalid in all C libraries on Linux. * txr.1: Document that crypt throws an error exception and under what circumstances (when the C library function does what).
* chksum: fix misleading comment.Kaz Kylheku2023-09-011-4/+1
| | | | | * chksum.c: Fix incorrect comment stating that the crc32 functions are generated.
* New functions for shell escaping.Kaz Kylheku2023-09-013-0/+125
| | | | | | | | | | | * stream.c (sh_esc, sh_esc_all, sh_esc_dq, sh_esc_sq): New static functions. (stream_init): sh-esc, sh-esc-all, sh-esc-dq, sh-esc-sq: Intrinsics registered. * tests/018/sh-esc.tl: New file. * txr.1: Documented.
* New function: str-esc.Kaz Kylheku2023-09-015-0/+98
| | | | | | | | | | * lib.[ch] (str_esc): New function. * eval.c (eval_init): str-esc intrinsic registered. * tests/015/esc.tl: New file. * txr.1: Documented.
* awk: prn returns nil.Kaz Kylheku2023-08-263-1/+17
| | | | | | | | | * stdlib/awk.tl (awk-state prn): Return nil in the no-argument case instead of returning whatever put-string returns. * tests/015/awk-misc.tl: New file. * txr.1: Documented.
* New macros opf and lopf.Kaz Kylheku2023-08-234-1/+89
| | | | | | | | | | | | | | These remove repetitive (op ...) syntax from the arguments of functional combinators. * stdlib/opt.tl (opf, lopf): New macros. * autoload.c (op_set_entries): Register opf and lopf as autoload triggers. * tests/012/op.tl: New tests. * txr.1: Documented.
* genman: guard against symbol hash collisions.Kaz Kylheku2023-08-221-6/+10
| | | | | | | | * genman.txr (process-ambiguities): Keep track of calculated hashes and error out when there is a duplicate. When the time comes, we will have to resolve those somehow, and also change the doc function to do it the same way.
* genman: move all hashes into do block.Kaz Kylheku2023-08-221-3/+3
| | | | | | * genman.txr (symhash, tagma, tochash): Define in @(do ...) block with defvar for consistency ith other hashes.
* genman: remove special handling of "NAME".Kaz Kylheku2023-08-221-2/+0
| | | | | | | | | * genman.txr: remove the manual insertion of the mapping of the "lbAB" tag to the new hash for "NAME", the first section of the man page. This is an outdated dud that does nothing. The tag is being properly processed without this hack and the new hash-title function will assign it to a different hash.
* load-args-process: bugfix: :compile action must load.Kaz Kylheku2023-08-222-3/+12
| | | | | | | | | | * stdlib/load-args.tl (load-args-process): When compile-update-file doesn't do anything due to the compiled file being up-to-date, the file must be loaded, so that the effect is similar to compiling. Otherwise subsequent files may fail to compile due to missing definitions such as packages. * txr.1: Documented.
* doc: new hashing scheme for navigation, doc lookup.Kaz Kylheku2023-08-223-2390/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is not an easy change to make because it breaks the validity of existing URLs in the wild which point to specific sections of the TXR manual. Some of my recent changes to capitalization of numerous headings have already broken many URLs, so we might as well bite the bullet and do this now. The problem with the current scheme is that entire section titles are hashed: all the words of a title, not just the names of functions. Whenever we add a new function, macro or variable which is documented together with related functions in the same paragraph under the same heading, the heading changes, and the hash changes. For instance, the hash for the hash-map identifier is actually the hash of the string "Function <tt>hash-map</tt>". Under the new scheme, section titles are hashed in a more complicated way that is robust against most edits. If a title contains any symbols marked up with <tt>, then the leftmost such symbol is taken as the title. Otherwise, the whole title is mapped to lower case. There is no longer a stdlib/doc-syms.tl file, and the special disambiguated "D-<HEX>" codes are also gone. Symbols are no longer associated with section hashes or disambiguation section codes. The hash of a symbol is a 32 bit CRC-32 checksum, expressed as S-<HEX> where <HEX> is 8 hex digits. A section which defines symbols has not only a <a name="..."> for its own hash but also additional <a name="...>" elements for each of the symbols that it defines. If a section defines an ambiguous symbol (one that is also defined with a different meaning in a different section), then that symbol is not linked to either section; it is mapped to the generated disambiguating section. * genman.txr (dupes): Renamed to dupe-hashes for clarity. (tagnum): Hash removed. (direct): New hash. Tracks the assocation between sections hashes and hashes of symbols that are defined only in those symbols (no ambiguity) and thus the symbol hashes can navigate directly to the sections. Serves as a complement to the disamb hash. (colli): There are no collisions now, so initialize this to empty. (hash-str): Function removed. (hash-title): This function becomes more complicated. If a title has at least one <tt>..</tt> item, then that is taken in its place. Either way, the title is transformed and enumerated against duplication and hashed with crc32 instead of the original custom hashing function. (enumerate): Function removed: enumeration of titles is done inside hash-title. All manipulations of symhash using material from HTML now use html-decode, so that we hash the original symbol name like "str<" and not "str&lt;". When filtering the BODY, we have a new case: whenever we see a <a name="...">, we now check the new direct hash to see if there is a list of symbol hashes for the given section. If so, we generate additional <a name="..."> definitions for all the symbol hashes. At the end of the file, the "missing from image" processing is condensed, and the generation of the stdlib/doc-syms.tl file is removed. * stdlib/doc-syms.tl: Removed. * stdlib/doc-lookup.tl: Don't load doc-syms. Use crc32 plus formatting to conver a symbol to the hash that is used in the document and try the lookup with that.