summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* doc: file-get-buf opens a binary stream.Kaz Kyheku2020-02-051-2/+2
| | | | | * txr.1: It is wrongly documented that file-get-buf and comman-get-buf use text streams; they use binary streams.
* doc: fill-buf return value wrongly described.Kaz Kyheku2020-02-051-1/+2
| | | | | | * txr.1: The fill-buf function returns the position after the last byte that was read, not the position of that that last byte.
* fill-buf/fill-buf-adjust: incorrect return value.Kaz Kyheku2020-02-051-2/+2
| | | | | | | * stream.c (stdio_fill_buf): In the case of EOF, we must not return zero, but pos. Also, since pos and nread are cnum, we should use num to convert their sum to val. Converting to unum doesn't do anything for the overflow situation.
* chmod: type error in exception throw.Kaz Kyheku2020-02-051-2/+9
| | | | | | * sysif.c (chmod_wrap): The uw_throw expression contains an otal format specifier ~o which requires an integer argument; but the mode can be a string now. Split into two cases.
* repl: catch exceptions during completion.Kaz Kylheku2020-02-041-2/+14
| | | | | | | | | | | This fixes the issue that TXR exits if an exception occurs during Tab completion in the interactive listener. This could happen when loading a file fails for whatever reason, such as a corrupt or incomplete installation of the library files or whatever. * parser.c (provide_completions): Set up a catch all handler here around everything, like we already did in provide_atom.
* fstat: turn into true alias.Kaz Kylheku2020-02-043-12/+8
| | | | | | | | | | | | | | | | | | We can get rid of fstat_wrap entirely and make the lstat and fstat function bindings point to the same function. * parser.c (load_rcfile): Call stat_wrap instead of fstat_wrap. * sysif.c (stat_wrap): Static function becomes extern. Useless forward declaration removed. (fstat_wrap): Static function removed. (sysif_init): Bind fstat and lstat to the same function object. * sysif.h (fstat_wrap): Declaration removed. (stat_wrap): Declaration added.
* stat and fstat become equivalent.Kaz Kylheku2020-02-042-63/+79
| | | | | | | | | | | | * sysif.c (get_fd): Move this function higher in the file to avoid forward declarations. The do_fstatt code being moved into do_stat needs to call it. (do_stat): Provide stat and fstat functionality in one function. (do_fstat): Static function removed. (fstat_wrap): Call do_stat instead of do_fstat. * txr.1: Updated.
* doc: limitation, not limiting.Kaz Kylheku2020-02-041-1/+1
| | | | | | * txr.1: the Stream Output Limitation section is about the mechanism to limit output, not about limits of capability; the word we want is "Limiting".
* doc: stream-fd is nonexistent.Kaz Kylheku2020-02-041-1/+1
| | | | | * txr.1: Fix reference to a nonexistent stream-fd function; the correct name is fileno.
* New feature: symbolic chmod.Kaz Kylheku2020-02-032-11/+216
| | | | | | | | | | | | The chmod function can now take a string, which uses the same conventions as the symbolic mode argument of the chmod utility. * sysif.c (CHM_O, CHM_G, CHM_U): New preprocessor symbols. (enum chm_state, enum chm_op): New enums. (chmod_wrap): Allow argument to be a string, and in that case interpret the chmod symbolic permission language. * txr.1: Documented.
* New functions chmod-rec and chown-rec.Kaz Kylheku2020-01-313-0/+73
| | | | | | | | | | | * lisplib.c (copy_file_set_entries): Add chown-rec and chmod-rec to list of symbols that trigger auto-load of copy-file.tl. * share/txr/stdlib/copy-file.tl (chmod-rec, chown-rec): Neew functions. * txr.1: Documented.
* doc: missing catch** in heading.Kaz Kyheku2020-01-311-1/+1
| | | | | * txr.1: The catch section fails to mention the catch** operator in the section heading.
* doc: repeated "continues" under do directive.Kaz Kyheku2020-01-311-1/+1
| | | | * txr.1: fix repeated word.
* doc: defex does allow duplicate registration.Kaz Kyheku2020-01-311-13/+9
| | | | | | | | * txr.1: Fix wrong documentation about defex. It does allow registration of duplicate relationhips and updates that do not create cycles. Document a rule that is missing: that a subtype relationships can't be registered when the opposite relationship already exists.
* c_str: don't allow symbols.Kaz Kyheku2020-01-313-3/+15
| | | | | | | | | | | | | | | | | | | | | | | On 2009-10-02, prior to TXR 014, I made a change to the c_str function to allow symbolic arguments, so that c_str(sym) could be used in the code base instead of c_str(symbol_name(sym)). This was a bad idea, and is allowing numerous functions that operate on strings to accept symbols also. That behavior is not documented and not consistently supported. Ironically, I completely forgot about this and have been consistently using symbol_name(sym) anyway. Let us remove this. Compat support is required because this will break user code that accidentally depends on this undocumented behavior. * lib.c (c_str): If the object is type SYM, only return the symbol_name if compatibility with 231 or older is requested, otherwise fall through to the error case. * match.c (dump_var): Fix one case where a symbol is passed directly to put_string. This fails one of the test cases. More testing is required to see if any other such cases occur. * txr.1: New entry in the compatibility notes.
* open-files: add mode string argument.Kaz Kyheku2020-01-312-7/+26
| | | | | | | | | | | | The open-files and open-files* functions are missing a mode string argument, which makes it impossible to, say, open all of the files in "rb" mode on a platform where that matters. * stream.c (open_files, open_files_star): Take mode as a third optional parameter. If it is present, then pass it to open_file. * txr.1: Document mode string parameter for the two functions.
* doc: remove-path copy-paste error.Kaz Kyheku2020-01-301-1/+1
| | | | * txr.1: Under rename-path, remove-path is wrongly referenced.
* copy-file: detect directory before opening.Kaz Kylheku2020-01-301-10/+13
| | | | | | | | * share/txr/stdlib/copy-file.tl (copy-file): Detect that from-path is a directory before attempting to open it. The issue is that the open will succeed for a directory, and only the subsequent read will fail. By that time we have opened created the target file.
* New: file copy, recursive copy, recursive delete.Kaz Kylheku2020-01-293-0/+511
| | | | | | | | | | | | | * lisplib.c (copy_file_instantiate, copy_file_set_entries): New static functions. (lisplib_init): Register auto-load of copy-file.tl via new functions. * share/txr/stdlib/copy-file.tl: New file. * txr.1: New section Unix Filesystem Complex Operations. Here copy-file, copy-files, copy-path-rec and remove-path-rec are documented.
* New retry and skip exceptions under restart hierarchy.Kaz Kyheku2020-01-302-1/+20
| | | | | | | * unwind.c (uw_late_init): Register retry and skip symbols as exception subtypes of restart. * txr.1: Document retry and skip restarts.
* build: drop config.log in favor of reconfigureKaz Kyheku2020-01-292-12/+43
| | | | | | | | | | | | | | | | | | | | | | | The configure command line is now turned into an executable script called reconfigure which can be invoked to repeat the config. * Makefile (distclean): Whether in a configured or state or not, try to remove reconfigure. In the configured state, don't remove config.log. (If distclean is invoked when not configured, the config.* pattern will remove config.log). * configure: rewrite the logic which turns the command line into text. It is now robust against spaces, quotes and meta-charaters. Moreover, the printed representation is chosen according to good heuristics to minimize unnecessary quoting and escaping. The config line is written into an executable script called reconfigure. This is now done twice; it is done immediately, so that we save the command line even if the configure subsequently fails. A comment is added to reconfigure indicating that configure didn't succeed. Then after a successful run through the tests, we save it again, without the cautionary comment. Help texts updated.
* packages: no default argument in several functions.Kaz Kyheku2020-01-291-3/+3
| | | | | | | * eval.c (eval_init): bugfix: for the functions package-symbols, package-local-symbols and package-foreign-symbols, make the package parameter optional, as is specified in the documentation.
* New function: merge-delete-package.Kaz Kyheku2020-01-294-0/+44
| | | | | | | | | | | | | | | | | | | | | This is a useful function which supports the use of temporary packages over the scope of file compilation units. A file can be read under a temporary package which provides usefully customized symbol visibility consisting of an arrangement of symbols from various other packages. Then, in a single operation, thanks to this new function, that packag can be deleted and all of its local symbols (those having been newly interned over the course of the file) are transferred to some other, more permanent package. * eval.c (eval_init): merge-delete-package intrinsic registered. * lib.c (merge_delete_package): New function. * lib.h (merge_delete_package): Declared. * txr.1: Documented.
* compiler: bug in catch: frame level mismatch.Kaz Kylheku2020-01-281-2/+2
| | | | | | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-catch): Compile the try expression and the description in the newly extended environment rather than the original environment. This is necessary because the compiled code for both of these is is placed into the frame level corresponding to the new environment. Other than the level, the only difference between the two environment is that nenv has a couple of gensyms. Thus it is hygienic w.r.t. the try and desc code; the extended environment can safely be used.
* vm: more info in frame level mismatch.Kaz Kylheku2020-01-281-1/+3
| | | | | | * vm.c (do_frame): In frame level mismatch diagnostic, identify vm descriptor, instruction offset and the expected and actual level.