summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* ftw: throw exception on failure.Kaz Kyheku2020-01-282-11/+55
| | | | | | | | | | | | | | | | The ftw function just returns -1 if, for instance, given a bad path (nonexistent or no permissions). The documentation also has issues. * ftw.c (ftw_wrap): If the return value is -1, convert it to a file-error using errno_to_file_error and throw a diagnostic exception. This situation can, of course, arise if the callback function returns -1, in which case it should prepare a value in errno. * txr.1: Return value of callbackfn documented better. Documented exception throwing behavior, and failed termination if the callback returns -1.
* New function: rmdir.Kaz Kylheku2020-01-282-0/+36
| | | | | | | * sysif.c (rmdir_wrap): New static function. (sysif_init): rmdir intrinsic registered. * txr.1: Documented.
* New functions: chown, lchown.Kaz Kyheku2020-01-283-1/+141
| | | | | | | | | | * configure: New configure test for chown, fchown and lchown. * sysif.c (get_fd): Define for HAVE_CHOWN also. (do_chown, chown_wrap, lchown_wrap): New functions. (sysif_init): chown and lchown intrinsics registered. * txr.1: Documented.
* ensure-dir: return nil when exists.Kaz Kylheku2020-01-272-6/+12
| | | | | | | * sysif.c (mkdir_nothrow_exists): Return nil in the existence case, when the object is a directory or a symlink to one. * txr.1: Updated.
* ensure-dir: fail if exists and not dir.Kaz Kylheku2020-01-252-21/+34
| | | | | | | | | | | | | * sysif.c (do_stat, do_lstat): Functions relocated before mkdir_nothrow_exists. (mkdir_nothrow_exists): In the EEXIST case, call stat on the object. If it's not a directory or a symlink to a directory, then do not suppress the error; propagate it to the caller, where it will become an exception. * txr.1: Specify the behavior of ensure-dir more precisely: that it only supresses the existence error for directories and directory symlinks.
* New function: mkfifo.Kaz Kylheku2020-01-233-0/+73
| | | | | | | * configure: detect mkfifo. (sysif_init): Register mkfifo intrinsic. * txr.1: Documented.
* mknod: third arg must be optional.Kaz Kylheku2020-01-231-1/+1
| | | | | * sysif.c (sysif_init): Fix incorrect registration of mknod, whose third argument (dev) is documented as optional.
* New functions utimes, lutimes.Kaz Kylheku2020-01-213-1/+326
| | | | | | | | | | | | | * configure: Detect various functions for setting file timestamps. * sysif.c (get_fd): Define this function for use by utimes also. (timens, do_utimes): New static functions. (wrap_utimes, wrap_lutimes): New static functions. (sysif_init): Register utimes and lutimes intrinsics. * txr.1: Documented.
* New function: coded-length.Kaz Kylheku2020-01-184-0/+25
| | | | | | | | * eval.c (eval_init): Register coded-length intrinsic. * lib.c (coded_length): New function. * lib.h (coded_length): Declared.
* ffi: fix broken char handling in undimensioned arrays.Kaz Kylheku2020-01-173-36/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | The undimensioned (array <type>) and (zarray <type>) types are not doing UTF-8 conversion when <type> is char or zchar, or doing what they are supposed to with the FFI character types, which is inconsistent from their dimensioned counterparts. * ffi.c (ffi_varray_dynsize): if the element type is marked for character conversion, then do the size calculation for char and zchar by measuring the UTF-8 coded size. (ffi_varray_alloc): Call ffi_varray_dynsize to get the size, to benefit from the char handling. Thus when FFI allocates buffers for a variable length array, it will allocate correct size required for the UTF-8 encoded string. (ffi_varray_put, ffi_varray_in): Here we must call ffi_varray_dynsize and divide by the element type to get the proper numer of elements. Then we must check for character conversion and handle the cases. (ffi_varray_null_term_in): Check for character conversion cases and route those through ffi_varray_in, which handles null-terminated strings. * tests/017/ffi-misc.tl: New file. * tests/017/ffi-misc.expected: New file.
* sysif: fix inappropriate use of w_ convention.Kaz Kylheku2020-01-153-16/+15
| | | | | | | | | | | | | | | | | | | | | | | Some functions in utf8.c have w_ prefixes. They are wide character wrappers for functions that take multi-byte string inputs. The prefix is being inappropriately used in the names of a few sysif functions that should be named _wrap. * sysif.c (w_stat, w_lstat, w_fstat): Rename to do_stat, do_lstat and do_fstat, respectively. These are callbacks used with stat_impl. (statp, statl, statf): Rename to stat_wrap, lstat_wrap and fstat_wrap, following existing convention. Additionally, stat_wrap becomes static since nothing outside this file calls it. (sysif_init): Follow renames of statp, statl and statf. * sysif.h (statp): Declaration removed. (statf): Renamed to fstat_wrap. * parser.c (load_rcfile): Follow statf rename.
* fstat: take fd argument.Kaz Kyheku2020-01-152-15/+14
| | | | | | | * sysif.c (get_fd): Make available under HAVE_SYS_STAT. (fstat): Allow fd or stream argument using get_fd. * txr.1: Documented.
* with-resources: support multiple cleanup forms.Kaz Kyheku2020-01-152-15/+36
| | | | | | | | * share/txr/stdlib/with-resources.tl (with-resources): Rearrange tree-case cases to recognize a sequence of cleanup forms and insert into the output accordingly. * txr.1: Documented.
* chmod: work on streams and descriptors using fchmod.Kaz Kyheku2020-01-153-12/+59
| | | | | | | | | * configure: extend chmod detection to cover fchmod. * sysif.c (get_fd): New static functions. (chmod_wrap): Include fchmod wrapping for integer or stream argument. (sysif_init): Register fchmod intrinsic.
* Version 231.txr-231Kaz Kylheku2020-01-126-917/+952
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* hash: bug: not hashing key of tree node.Kaz Kylheku2020-01-121-1/+1
| | | | | | | * hash.c (equal_hash): Spurious semicolon in TNOD case causing part of expression that includes the key to be cut off. This was not diagnosed by the C compiler of GCC 4.x or 7.4.0. The GCC 7.4.0 C++ front end caught this bug.
* configure: don't try to remove phony target.Kaz Kylheku2020-01-101-1/+0
| | | | | | | * configure: there is no need to 'rm -f conftest.yacc' before requesting that target, because it's correctly marked as a phony target. Even if a file by that name exists, make will execute the rule.