summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* hash: bugfix: maintain counts in weak processing.Kaz Kylheku2020-03-091-4/+10
| | | | | | * hash.c (do_weak_tables): Update the count field of each weak hash to account for the entries that get removed by expiry. Also, loop variable moves into a tighter scope.
* Version 233.txr-233Kaz Kylheku2020-03-086-1063/+1126
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* strings: bugfix: broken inequality comparisons.Kaz Kylheku2020-03-072-5/+14
| | | | | | | | | | | | | | | | | | | | | Inequality comparisons of strings and symbols are broken due to assuming that cmp_str returns -1 or 1. cmp_str uses the C library function wscsmp, and is exposed as the Lisp function cmp-str. That is correctly documented as returning a negative or positive value. But a few function in lib.c assume otherwise. On newer glibc's, at least on x86, it seems that wcscmp does return 1, 0 or -1 consistently; perhaps the newer optimized assembly routines are ensuring this. It shows up on older glibc installations where the C version just returns the difference between the mismatching characters. * lib.c (cmp_str): Now returns -1, 0 or 1. * txr.1: Specify the stronger requirements on the cmp-str return value, adding a note that older versions conform to a weaker requirement.
* genvim: colon isn't keyword constituent any more.Kaz Kylheku2020-03-071-1/+1
| | | | | | | | | | | * genvim (iskeyword): Remove the : character from being a symbol constituent. This doesn't work well with tags, which are oblivious to packages. We would not only have to make tags.tl deal with packages, but in the tags file we would have to duplicate every entry with and without the package prefix. It doesn't make a lot of sense. Plus, packages themselves are tags, and if we put the cursor on the package part of a qualified symbol, we can jump to the package.
* tags: add --exclude option.Kaz Kylheku2020-03-071-9/+33
| | | | | | | | | | | | | * tags.tl (tags-opts): Cumulative exlude option added. (ftw-actionretval, ftw-continue, ftw-skip-subtree): These variables are missing if we are not on Glibc, so we define them as zero. These definitions help us take advantage of FTW_ACTIONRETVAL to skip recursing into exluded subtrees. (static-when): New macro. (toplevel): Implement exclude option. Skipping directories on platforms whose nftw function doesn't have FTW_ACTIONRETVAL is simulated by keeping a dynamic skip list, which is intelligently purged to keep it short.
* fnmatch: fix missing fnm-extmatch.Kaz Kylheku2020-03-071-1/+1
| | | | | * sysif.c (sysif_init): Fix misspelled FNM_EXTMATCH in #ifdef causing registration of fnm-extmatch being excluded.
* getopts: new feature: cumulative options.Kaz Kyheku2020-03-063-14/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An option declared as (cumul <type>) indicates that it is of type <type>, and that multiple occurrences of the option produce values that are accumulated into a list. The accumulation is in reverse order: the rightmost occurrence ends up the first in the list. * lisplib.c (getopts_set_entries): Add cumul to list of interned symbols, so that the getopts.tl code isn't mistakenly working with sys:cumul. * share/txr/stdlib/getopts.tl (opt-parsed): New slot, cumul. (opt-desc basic-type p, opt-desc list-type-p, opt-desc cumul-type-p): New methods. (opt-desc check): Rework type validity check using the new methods. (opt-parsed convert-type): Support 'cumul type by instantiating an opt-parsed object for the wrapped type, and stealing its converted argument into the current object, and setting the cumul flag. (opts add-opt, option-base add-opt): Support options that have the cumul flag set by accumulating list values. The code is different due to different amounts of encapsulation. The opts structure stores the raw opt-parsed objects, whereas option-base just takes the decoded values. (opthelp): Parse through the (cumul ...) type syntax, so cumulative options are printed in the help text the same way as if they were non-cumulative. * txr.1: Documented.
* getopts: bugfix in short option processing.Kaz Kyheku2020-03-061-6/+6
| | | | | | | | * share/txr/stdlib/getopts.tl (sys:opt-processor parse-shorts): There is a scoping mixup here with the opts argument shadowed by a same-named lexical variable, causing a referential mixup. Also fixed bad indentation.
* tags: handle option struct slots with more careKaz Kylheku2020-03-051-2/+4
| | | | | | | | * tags.tl (collect-tags): In proccessing a define-option-struct, don't record a tag for a long or short option that is nil. Each option definition defines only one slot. If both a long and short option are present (non-nil), then the long option names the slot.
* tags: implement merge with merge function.Kaz Kylheku2020-03-051-2/+2
| | | | | | | * tags.tl (write-tagfile): Since we can assume that the tags file is sorted, and the tags coming into this function are likewise sorted, we can just merge the sorted lists. Then, we don't have to sort the tags list a second time.
* tags: fix off-by-one line numbers for hash bang.Kaz Kylheku2020-03-051-1/+2
| | | | | | | | | * tags.tl (collect-tags): For hash-bang files, pop the dummy blank line that we inserted at the head of the line list to obtain 1-based numbering. If the parser starts working ater the #! line, it means the second line is 1, which is the same as zero-based numbering, so we can lose the dummy entry and all is well.
* tags: handle define-option-struct.Kaz Kylheku2020-03-051-0/+6
| | | | | | * tags.tl (collect-tags): Generate tags for the define-option-struct macro, indexing both the long and short forms.
* tags: add option processing.Kaz Kylheku2020-03-051-11/+46
| | | | | | | | | | | | * tags.tl (tag-opts): New option struct. (orig-tag): New struct. (write-tagfile): Take option struct as argument. Implement merge and append options. (toplevel): Parse arguments and provide usage text. Default to processing the current directory when no non-option arguments are given. Allow files that don't end in .tl, if they are explicititly specified; but directories are searched only for .tl files.
* tags: reduce repetition of tag construction with macrolet.Kaz Kylheku2020-03-041-76/+50
| | | | | * tags.tl (collect-tags): Use macrolet to sugar over the numerous new operator calls.
* tags: eliminate duplicated text methods.Kaz Kylheku2020-03-041-10/+13
| | | | | | | | | * tags.tl (tag): New slot, type; new method, text. (fun-tag, var-tag, struct-tag, type-tag): Override type slot with appropriate value ("f", "v", "s", "t"), and remove text method. (slot-tag): Override type; keep text method, and interpolate typee instead of hard-coded "m".
* TXR Lisp tag generation utility.Kaz Kylheku2020-03-041-0/+150
| | | | * tags.tl: New file.
* less: fix broken semantics for symbols.Kaz Kyheku2020-03-042-6/+82
| | | | | | | | | | | | | | | | | | | | | | | If a and b are symbols, then it's possible for (equal a b), (less a b) and (less b a) to all yield false, which makes no sense. This happens in the case when a and b are distinct symbols (thus not equal), and have the same name (so the stringwise comparison finds them to be equal and hence neither less than the other). * lib.c (less): Implement more complicated requirements for comparing symbols. If two distinct symbols have the same name, then one must be less than the other, and we use other information to determine this. If at least one of them has a home package, then we go by comparing packages: package names are compared as strings, and a missing package is less than a present package. If both same-named symbols have no package, then they are compared as pointers. * txr.1: Documented the properties of less as an antisymmetric, antireflexive and transitive relation. Documented the relationship with equal. Documented the treatment of symbols. Cleaned up some wording.
* doc: better wording on lisp compilation.Kaz Kylheku2020-02-291-16/+11
| | | | | * txr.1: Rewriting awkward language in overview of file compilation.
* doc: missing article under Lisp Compilation.Kaz Kylheku2020-02-291-1/+1
| | | | * txr.1: "refers to [a] processing step".
* New function: assq and rassq.Kaz Kyheku2020-02-246-12/+63
| | | | | | | | | | | | | | | | | | | | | TXR Lisp is henceforth a dialect in which (cdr (assq key a-list)) works exactly as shown, without substitution of assql or assoc. * eval.c (eval_init): Register assq and rassq intrinsics. * lib.c (assq, rassq): New functions. * lib.h (assq, rassq): Declared. * txr.1: Documented. * tests/012/ashwin.tl: New file. * tests/012/ashwin.expected: New file.
* New functions: meq, meql and mequal.Kaz Kylheku2020-02-224-0/+69
| | | | | | | | | | * eval.c (eval_init): Register meq, meql an mequal intrinsics. * lib.c (meq, meql, mequal): New functions. * lib.h (meq, meql, mequal): Declared. * txr.1: Documented.
* listener: if no new lines, don't save history.Kaz Kylheku2020-02-183-1/+7
| | | | | | | | | * linenoise/linenoise.c (lino_have_new_lines): New function. * linenoise/linenoise.h (lino_have_new_lines): Declared. * parser.c (hist_save): Do nothing if lino_have_new_lines returns false.
* listener: save history early with :save command.Kaz Kylheku2020-02-182-15/+36
| | | | | | | | | * parser.c (hist_save): New static function. (repl): Logic for savingn history when terminating has moved into hist_save. New save command also calls this function. * txr.1: Documented.
* doc: spelling under file-place-bufKaz Kylheku2020-02-181-1/+1
| | | | * txr.1: doees -> does.
* listener: append to .txr_history instead of clobbering.Kaz Kyheku2020-02-184-10/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch addresses the problem of history loss that occurs when a user juggles multiple TXR sessions that all clobber the same history file. * linenoise/linenoise.c (struct lino_state): New member, loaded_lines, keeping track of how many of the lines in the history came from loading the history file. Lines between [0] and [loaded_lines - 1] are loaded lines. New lines occur between [loaded_lines] and [history_len - 1]. (lino_hist_add): Reset loaded_lines to zero when creating history for the first time. Not really necessary since the structure starts zero-filled. When a line of history is erased, then it must be a loaded line, unless loaded_lines is zero. Thus, then decrement loaded_lines to account for a loss of a loaded line, but don't decrement below zero. (lino_hist_set_max_len): Setting the max length can cause history to be trimmed, so we must adjust loaded_lines to account for any loaded lines that get discarded. (lino_hist_save): Takes a new parameter which indicates whether to just save the new history by appending it to the given file, or to overwrite the file with the entire history. In either case, once we save the history, we assume that all of our lines are loaded lines and set loaded_lines to hist_len. In the future, this last step will help implement incremental saving mid-way through a sesssion. (lino_hist_load): Error out if there is already a history. With this loaded_lines logic, it really wouldn't make sense to read history more than once. After loading, set loaded_lines to hist_len. * linenoise/linenoise.h (enum lino_file_mode): New enumeration lino_append. (lino_hist_save): Declaration updated. * parser.c (repl): Implement new history saving protocol. The history file is read using a temporary instance of linenoise, which has the effect of trimming it to the required number of lines. This is written to a temporary file, to which the newly entered lines are appended, and which is finally renamed to replace the history file. (lino_mode_str): Add "a" entry corresponding to lino_append. (lino_open): Do the fchmod in the lino_append case also. * txr.1: Documented the new handling of the history file.
* cygwin: use spawnvp for run and sh.Kaz Kylheku2020-02-172-48/+102
| | | | | | | | | | | | | | | | | | | | | | | | We revive the dead _wspawnvp code that was used on MinGW, a platform that has not been supported for years, adapting it for Cygwin. * configure: Correct the _wspawnlp test; it should have been testing for _wspawnvp function, which is what is is actually used by the matching code. Moreover, the broken test was calling _wspawnlp with _wspawnvp style arguments. Anyway, this is moot because we will never detect this function in the foreseeable future. More importantly, adding a test for spawnvp, which exists on Cygwin. * stream.c: Include the <process.h> header if HAVE_WSPAWN or HAVE_SPAWN. This was missing before; how did the _wspawnvp call ever compile? (w_spawnvp): New static function. (run): spawn version now calls either _wspawwnvp or w_spawnvp if that is not available. We test for HAVE_WSPAWN or HAVE_SPAWN first, before HAVE_FORK_STUFF, so that we use the spawn function preferentially. On Cygwin, we have the fork stuff.
* crypt: refactor hardening a bit.Kaz Kylheku2020-02-151-17/+22
| | | | | | | | | | * sysif.c (validate_salt): Take const wchar_t * argument instead of val. Set errno and return null pointer instead of throwing, so we don't have two places that throw an exception related to crypt. (crypt_wrap): Put exception at the end. Return hash only if validate_salt returns a non-null pointer and so does crypt. In all other cases, reach exception call.
* crypt: harden against crashes.Kaz Kylheku2020-02-141-3/+60
| | | | | | | | | | | | | | | | | | | | The crypt function on glibc, and maybe other platforms, simply crashes when given a perfectly valid salt string that contains invalid salt syntax. This is nasty; we want TXR Lisp library functions to be robust; bringing down the image is not acceptable. Also, crypt may return a null pointer. glibc's crypt does this in certain situations, like when the "2a" (Blowfish) algorithm is specified when not available. We are not checking for this null return, in which case the ensuing crash is our fault. * sysif.c (salt_char_p, validate_salt): New functions. (crypt_wrap): Validate the salt via validate_salt. Check the return value from crypt/crypt_r; if null, then throw an exception that incorporates the errno information.
* @(line): get meaningful value in horizontal mode.Kaz Kylheku2020-02-131-1/+10
| | | | | | | | | | | | | | | When @(line var) is used in a horizontal match, line is bound to zero. This is because the line number isn't being propagated. * match.c (mf_from_ml): Both the file and line context structurs have a data_lineno, yet this function doesn't propagate it. Instead of using ml_all, whose name tells a subtle lie since it neglects the data_lineno, let's just do the member for member logic here. This function is used in one place, the hv_trampoline. So this fixes the line number for all vertical directives called out of horizontal context.
* compiler: remove useless consp test.Kaz Kylheku2020-02-131-56/+55
| | | | | * share/txr/stdlib/compiler.tl (compiler compile): If the form isn't an atom, then consp is implied.
* open-file: fix diagnostic referring to "o" mode.Kaz Kyheku2020-02-121-1/+1
| | | | | | | * stream.c (w_fopen_mode): Fix diagnostic to refer to "m" mode instead of "o" mode, adjusting the wording at the same time. This is only compiled on platforms without HAVE_FCNTL; basically nothing that TXR is commonly built for.
* copy-file.tl: mode change.Kaz Kyheku2020-02-121-0/+0
| | | | | | * share/txr/stdlib/copy-file.tl: Remove execute permissions that had been accidentally applied before this file was placed under version control.
* chmod tests: avoid sticky bit when not available.Kaz Kylheku2020-02-101-18/+25
| | | | | | | | | | | | | On Solaris, we can't set the sticky bit on a non-directory without special privilege. Let's detect whether we can set the sticky bit on our test object. If we can't, then we avoid executing tests that involve the sticky bit. * tests/018/chmod.tl (test-sticky): New variable. (cht): If test-sticky is false, only run the test if none of the inputs contain a 't'.
* chmod tests: use macro.Kaz Kylheku2020-02-101-3/+3
| | | | | | * tests/018/chmod.tl (mode-bits): Change body to correct quasiquote. (cht): Use previously unreferenced mode-bits macro.
* Version 232.txr-232Kaz Kylheku2020-02-096-687/+773
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* bugfix: regression in @(skip).Kaz Kylheku2020-02-091-4/+4
| | | | | | | | | | | | | | When @(skip :greedy) is used, there is an exception complaining that :greedy isn't an integer. Reported by a user "natrys" in the IRC channel. This was introduced in July 2016, by commit a208fafe0b0bf6dd5a78c939e55f0153f6bd6b19, "Address silly uses of fixnump". * match.c (h_skip, v_skip): Re-introduce the integer check that was indadvertently removed.
* ffi: varray: g++ signed/unsigned warning.Kaz Kylheku2020-02-081-1/+1
| | | | | | * ffi.c (ffi_varray_alloc): Add cast to this conversion. The idea here is we are checking for truncation when cnum is converted to size_t.
* chmod: ugo perms sees effects from same clause.Kaz Kylheku2020-02-082-0/+2
| | | | | | | | | This is Coreutils chmod behavior. * sysif.c (chmod_wrap): Sample cmode into oldm at the start of every assigment before punching the masked hole into cmode. * tests/018/chmod.tl: Breaking test case added.
* chmod: ugo must refer to unaltered perms.Kaz Kylheku2020-02-082-7/+14
| | | | | | | | | | | | | | | | | | | Within the same clause, permissions given by ugo must refer to the unaltered permissions, before the target bits were masked out, otherwise self-assignment like o=o just clears the permissions. The other self-referential perm is X: it checks for existing x permissions. That works with the current value. * sysif.c (chmod_wrap): Keep the old permissions in a new loop variable called oldm. The u, g and o perms refer to oldm rather than to the updated value in cmode. When we hit a comma, we update oldm to the current value. The code for this is now in one place with a goto. * tests/018/chmod.tl: New test case that fails in the absence of this fix. Test cases confirming that X refers to the current permissions.
* chmod: bug handling comma after right hand ugo.Kaz Kylheku2020-02-072-2/+2
| | | | | | | | | | | | * sysif.c (chmod_wrap): The chm_comma state is transitioned to after seeing a right hand side u, g or o. These do not combine with other letters, so ch_comma expects a comma after which a new permission clause we start,. Therefore the srcm and who variables must be rest. It's also a good idea to continue the loop. * tests/018/chmod.tl: New test case which exposed the above issue.
* chmod: setuid/setgid bit bugfix and new tests.Kaz Kyheku2020-02-072-9/+8
| | | | | | | | | | | | | | | | | | * sysif.c (chmod_wrap): Again, related to the = operator, we must not punch a hole in the suid and sgid bits for all non-directory objects. This was based on a misinterpretation of some coreutils documentation, and doesn't match the actual behavior. Rather, if the owner is a target (including implicitly) then we mask out suid; and if the group owner is a targe, then we mask out sgid. Thus when we are doing a permission set not targetting the owner we don't touch suid, and similarly for the group owner and setgid. * tests/018/chmod.tl: Failed test diagnostics now identify which mode string was used. Some existing tests involving the suid/sgid bits have to be revised because this commit reflects a correction in the requirements. One new test is added.
* chmod: bugfix and new tests.Kaz Kyheku2020-02-072-5/+14
| | | | | | | | | | | | * sysif.c (chmod_wrap): When processing set (=), only punch a hole in the target permission area once per clause, so as not to clobber previously set modes. We do this by checking for the chm_perm state. Whenever '=' is processed, the state machine enters into that state; when any permission letter is then processed, it transitions out of that state. This gets the "u=rwsx" test to pass. * tests/018/chmod.tl: New tests.
* New tests for chmod.Kaz Kyheku2020-02-074-0/+47
| | | | | | | | | | | | | | | | The chmod fixes in the previous several commits were caught by this. * Makefile (tst/tests/018/chmod.ok): Set up TXR_ARGS for this test to give it the location of the temporary file to use as the object for testing permissions. (tst/tests/018): Disable TXR_DBG_OPTS for new directory. * tests/018/chmod.tl: New file. * tests/018/chmod.expected: Likewise. * tests/perm.tl: Likewise.
* chmod: fix broken umask application for implicit all.Kaz Kylheku2020-02-071-9/+6
| | | | | | | | | * sysif.c (chmod_wrap): The umask logic is not activating after the first iteration through the loop, because when who is zero, we clobber it by adding the bits for u, g, and o. Then on subsequent iterations, who is no longer zero. Instead, let us leave the value of who alone, and in all the relevant places, check for it being zero.
* chmod: fix broken Coreutils-compatible sticky clear.Kaz Kylheku2020-02-071-1/+1
| | | | | * sysif.c (chmod_wrap): Clear the sticky bit from the right variable: cmode rather than bits.
* file-place-buf: bugfix: create file if doesn't exist.Kaz Kylheku2020-02-071-1/+1
| | | | | | | * share/txr/stdlib/getput.tl (file-place-buf): Instead of "r+" mode, use the new "mb" mode which will create the file without truncating it, and open for write mode. Also, bugfix: the "b" option was missing.
* New "m" file open mode: non-truncating "w".Kaz Kylheku2020-02-073-7/+45
| | | | | | | | | | | | | | | | | | | | | | | | | Quite surprisingly ISO C lacks a way in fopen to open a file for writing such that it is not truncated if it already exists, and not opened in append mode. (But you will be glad to know that ISO C is adding incredibly useful features in this area, like Microsoft's fopen_s!) Let us add modes "m" and "m+" which will be like "w" and "w+", but without the truncation to zero length (no O_TRUNC is passed to open). * stream.c (w_fopen_mode): New static function. (open_file, open_tail, tail_strategy): Use w_fopen_mode instead of directly calling w_fopen. (do_parse_mode): Handle 'm' and set new notrunc flag. * stream.h (struct stdio_mode): New member, notrunc flag. (stdio_mode_init_blank, stdio_mode_init_r, stdio_mode_init_rpb): Initializer macros updated to include initializer for notrunc flag. * txr.1: Documented "m" mode.
* file-put-buf: new argument; also, new file-place-bufKaz Kylheku2020-02-073-3/+27
| | | | | | | | | | | | | Like file-put-buf but doesn't overwrite the file. * lisplib.c (getput_set_entries): New autoload for file-place-buf. * share/txr/stdlib/getput.tl (file-put-buf): New argument for seeking into the file. (file-place-buf): New function. * txr.1: Documented.
* buf: bugfix: buf-set-length not setting bytes.Kaz Kylheku2020-02-062-34/+35
| | | | | | | | | | | | | | | | | | * buf.c (buf_grow): Function removed; logic merged into buf_do_set_len. The bug fixed is that buf_grow was initializing just the newly allocated bytes to init_val. The bytes that must actually be initialized are those which lie between the old and new length, not in the allocated area. (make_buf): In make_buf, we don't have to initialize the entire buffer, but only bytes 0 through len - 1. Now calloc is only used when the initializing value is zero, and the buffer's allocation size is the same as the length. When the length is increase to protrude into the allocated uninitialized area, buf_do_set_len will now properly initialize that to the value given at that time. * txr.1: Update make-buf documentation not to say that all the bytes of the buffer are initialized.
* file-get-buf: size limit, seek offset.Kaz Kyheku2020-02-052-15/+42
| | | | | | | | | | * share/txr/stdlib/getput.tl (sys:get-buf-common): Take two more arguments for maximum bytes to read and offset. Read loop simplified with fill-buf-adjust. (file-get-buf, command-get-buf): Take two new arguments, pass though to sys:get-buf-common. * txr.1: Documented.