summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* New function: csort-group.Kaz Kylheku2023-08-175-2/+26
| | | | | | | | | | | | | * autoload.c (csort_set_entries): Register csort-group as autoload trigger for stdlib/csort.tl. * stdlib/csort.tl (csort-group): New function. * tests/012/sort.tl: Tests for sort-group and csort-group. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* windows: don't require admin privilege.Kaz Kylheku2023-08-161-5/+20
| | | | | | | | | | | | | | * inst.nsi (RequestExecutionLevel): Use the value "highest" instead of "admin", so that privilege is required for users that have it, otherwise not. (AccountType): New variable. (.onInit): Obtain the account type and store it in AccountType. Default the installation directory to $LOCALAPPDATA. If the user is admin, change the default to the appropriate Program Files directory. (TXR): If the user isn't admin, add TXR to the current user's PATH rather than the system PATH for everyone. (Uninstall): Remove TXR from the appropriate PATH.
* doc: massive revision of capitalization in headings.Kaz Kylheku2023-08-163-189/+195
| | | | | | | | | | | | | | | | | | | | | | | | | | In this patch we change the convention of uncapitalized words occurring in headings such as "Special variable *foo*". * checkman.txr (check-var, check-func): Consolidated into a single pattern function called check-coNP. This now enforces capitalization, and also has a giant fall-back clause which explicitly recognizes .coNP headings that are not specially checked by the previous rules, after which there is an error case, so that unclassified .coNP headings are diagnosed. A bug is fixed here in the handling of Special Variable and Variable headings. The pattern match was wrong, so these were not being properly recognized. Without the error case at the end, a number of errors occur in the document where the .desc is missing after a Variable or Special Variable. * txr.1: (.dir, .dirs): Fix capitalization of Directive and Directives in headings generated by this macro. Fix capitalization in numerous .coNP headings. * stdlib/doc-syms.tl: Updated. Unfortunately, many symbols change their hash value because it's based on the entire heading.
* doc: typo in *stdnull* example.Kaz Kylheku2023-08-161-1/+1
| | | | | * txr.1: Fix misspelled *stderr* in example demonstrating binding of *stderr* to *stdnull*.
* doc: capitalize User-defined in heading.Kaz Kylheku2023-08-161-1/+1
| | | | * txr.1: Fix "User-defined Patterns" heading to "User-Defined".
* math: tofloat and toint in user-defined arithmetic.Kaz Kylheku2023-08-145-126/+172
| | | | | | | | | | | | | | | | | | * arith.c (tofloat_s, toint_s): New symbol variables. (tofloat, toint): If the argument is a COBJ, handle it via do_unary_method. (arith_init): Initialize new symbol variables. The functions tofloat, toint, tofloatz and tointz. are now registered here, rather than eval_init. * eval.c (eval_init): Remove registrations of tofloat, toint, tofloatz and tointz. * tests/016/ud-arith.tl: New tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* math: add tests for new user-defined arith functions.Kaz Kylheku2023-08-141-1/+89
| | | | | | * tests/016/ud-arith.tl (numbase): Add methods for the newer functions: cbrt, erf, ... Add tests covering these.
* tree: bug: tree-delete-specific-node doesn't use key funKaz Kylheku2023-08-142-2/+10
| | | | | | | | | | | * tree.c (tr_delete_specific): We cant' juse use key(node) as the search key; we must apply the tree's key function to the node key field to retrieve the correct search key. * tests/010/tree.tl: New test case which fails without this bugfix: a node which is the left subtree of the root node doesn't get deleted since the search is led astray by the wrong key object.
* listener: auto compound expression mode.Kaz Kylheku2023-08-143-2/+39
| | | | | | | | | | | | | * parser.c (listener_auto_compound_s): New symbol variable. (repl): If *listener-auto-compound-p* is true, then evaluate multiple forms directly as a compound expression, without inserting progn at the head. (parse_init): Initialize symbol variable and register the *listener-auto-compound-p* special. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* listener: change *listener-sel-inclusive-p* default.Kaz Kylheku2023-08-131-1/+1
| | | | | | * parser.c (parse_init): Set the initial value of *listener-sel-inclusive-p* to t instead of nil, since terminals tend to have block cursors by default.