summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* build: deal with the mess of new Bison warnings.Kaz Kylheku2020-01-102-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | Newer versions of Bison produce spurious warnings in Yacc mode about %pure-parser being not POSIX conforming and also deprecated. Plus some strange fluff about "fix-its" that can be applied if option --update is specified. Let's detect at configure time whether the Yacc program being used is actually Bison 3.0 or greater, and if so, give it some flags to shut up these warnings. * Makefile (YACC_FLAGS): New variable, conditionally set based on yacc_is_newer_bison, also new variable, that being generated into config.make. (y.tab.c): Invoke $(TXR_YACC) with $(YACC_FLAGS). (conftest.yacc-version): New phony target for running Yacc with --version, out of the configure script. * configure (yacc_is_newer_bison): New variable. (gen_config_make): Generate yacc_is_newer_bison make variable. New test for whether Yacc is Bison. If so, and the version is >= 3.0, sets the yacc_is_newer_bison variable to y.
* gc: obtain stack top using alloca.Kaz Kylheku2020-01-091-10/+5
| | | | | | | | | | | | | | | | This trick gets rid of the hack for aarch64. If we call alloca, the pointer we get should be below all frame information. Even if for the given target, the compiler-generated code happens to be saving callee-saved registers below the declared variables, any pointer we get from alloca must be below all of that still. * gc.c (STACK_TOP_EXTRA_WORDS): Macro removed. (mark): Don't subtract STACK_TOP_EXTRA_WORDS from gc_stack_top; take the top as-is. (gc): Don't allocate the machine context as an automatic variable; obtain the storage for it from alloca. That then also serves as the stack top.
* gc: consolidate top-of-stack and context handling.Kaz Kylheku2020-01-091-8/+2
| | | | | | | | * gc.c (mark): Eliminate mach_context_t * argument; just gc_stack_top is passed. (gc): Specify the base address of the machine context as the top of the stack. Still, on aarch64, STACK_TOP_EXTRA_WORDS is required, otherwise we get prematurely freed objects.
* aarch64: gc: mark farther beyond apparent stack.Kaz Kylheku2020-01-091-1/+1
| | | | | * gc.c (STACK_TOP_EXTRA_WORDS): Changing from 4 to 12 eliminates crashes.
* gcc: disable annoying code quoting.Kaz Kylheku2020-01-081-0/+27
| | | | | | | | | | | | | Newer versions of gcc add a lot of aggravating spewage to the diagnostics, by including copies of the lines of code where the error occurs followed by a line showing the error location with a caret and some tilde underlining. * configure: new test to see whether the compiler emits a caret line for a program that has a syntax error (missing closing brace). If so, we test whether the compiler accepts the option -fno-diagnostics-show-caret, and if so, we add that option to DIAG_FLAGS in config.make.
* tests: broken glob test cases crash under musl.Kaz Kylheku2020-01-083-7/+21
| | | | | | | | | | | | | | | | | | | | | | Among several issues, the main one is that these test cases use the str-d FFI type for strings. This type means that TXR will take ownership of the memory; it creates the Lisp strings for the Lisp array, and then assuming that it has owership of the C strings, it will free them. On musl, this causes an instant crash, probably because the strings might not be individually coming from malloc. The only documented interface for freing glob resources is globfree; programs cannot assume that the strings can be freed. * tests/017/glob-carray.expected: Updated. * tests/017/glob-carray.tl (glob-t): Add missing flags member of type int. Change the array element string type from str-d to str. * tests/017/glob-zarray.tl: Likewise, and also add a comment to explain why we are not calling globfree in this test case.
* config.h: double definition of FLO_MAX_DIGKaz Kylheku2020-01-071-0/+1
| | | | | | * configure: add missing break statement into the loop that determines the definition for FLO_MAX_DIG, so we don't add multiple definitions. This reproduces on the Musl library.
* ffi: fix non-libffi build on big endian.Kaz Kylheku2020-01-061-0/+1
| | | | | | | | This is cribbed from a patch by q66 <daniel@oct***rge.org>, commited recently to the Void Linux distro. * ffi.c (ffi_arg): Define this type when HAVE_FFI is not enabled. Some big-endian-specific code refers to it.
* builtin redefinition: better diagnostic message.Kaz Kylheku2020-01-061-6/+10
| | | | | | | | | | | | | | | | | | | The motivation here is that if we define, say, a macro whose name is the same as a built-in function, we get a warning which misleadingly uses the word "redefining". * eval.c (builtin_reject_test): Add a new parameter which indicates what kind of binding is being defined. This has the same values as the builtin hash. If the builtin hash reports that the symbol is a builtin, we can issue one of two diagnostic messages based on whether the one being defined is of the same kind or noto. (expand_macrolet): Pass the defmacro symbol to builtin_reject_test, since macros are being defined. (expand_fbind_vars): Pass the defun symbol symbol to builtin_reject_test. (do_expand): In the defun/defmacro case, pass the operator in question to builtin_reject_test.
* sysif.h: remove dependency on off_t.Kaz Kylheku2020-01-012-14/+6
| | | | | | | | | | | | | | The sysif.h header breaks on some systems because it references off_t, which requires <sys/types.h>. But the off_t materials in this header are unnecessary; we can remove them. * sysif.c (off_t_num, num_off_t): Extern functions become static, and are wrapped with #if HAVE_FSEEKO. These functions are only called from sysif.c, only from code relying on fseeko. * sysif.h (OFF_T_MAX, OFF_T_MIN): Macros not used anywhere are removed. (off_t_num, num_off_t): Declarations removed.
* Copyright year bump 2020.Kaz Kylheku2019-12-31121-123/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, alloca.h, args.c, args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, chksum.c, chksum.h, chksums/crc32.c, chksums/crc32.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lib.c, lib.h, linenoise/linenoise.c, linenoise/linenoise.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/asm.tl, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/compiler.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/debugger.tl, share/txr/stdlib/defset.tl, share/txr/stdlib/doloop.tl, share/txr/stdlib/error.tl, share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl, share/txr/stdlib/package.tl, share/txr/stdlib/param.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl, share/txr/stdlib/save-exe.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/trace.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/vm-param.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, socket.c, socket.h, stream.c, stream.h, struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, tree.c, tree.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, vm.c, vm.h, vmop.h, win/cleansvg.txr: Extended copyright notices to 2020.