summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* sh: reduce scope of variables.Kaz Kylheku2021-07-061-1/+1
| | | | | * streamc (shell, shell_arg): External variables become internal.
* streams: do not close stderr.Kaz Kylheku2021-07-061-1/+1
| | | | | | | * stream.c (stdio_close): Recognize stderr, not only stdin and stdout, as one of the streams not to be closed. This fixes situations when stderr is closed and exception handling tries to use it.
* unwind: stop runaway recursion.Kaz Kylheku2021-07-061-1/+4
| | | | | | | | | | | | | | | Before uw_rthrow calls uw_unwind_to_exit_point, it decrements the reentry_count, so that function is not protected against re-entry. We could protect some of its internal code agains re-entry, like the use of a bad stderr stream, if we extend the scope of that variable. * unwind.c (reentry_count): New static variable, moved to file scope from uw_rthrow function. (uw_unwind_to_exit_point): Bump up the reentry count in two places where we print diagnostics and terminate. If the diagnostic code hits an exception, the uw_rthrow will see the positive reentry count and abort.
* unwind: refer to top-level *stderr* stream.Kaz Kylheku2021-07-063-9/+14
| | | | | | | | | | | | | | | | | | | | | Exception processing should refer to the original, top-level value of *stderr* rather than the current dynamic value, even if unwinding has not yet taken place. Using the dynamic value can not only cause critical output to disappear, but it leads to a false positive identification of the "unhandled exception in early initialization" situation, a diagnostic which is emitted on the C stderr if the Lisp one is unavailable, which is assumed to be due to initialization not having yet completed. * stream.c (top_stderr): New global variable. (stream_init): GC-protect top_stderr, and initialize it with the same object that goes into the *stderr* top-level binding. * stream.h (top_stderr): Declared. * unwind.c (uw_unwind_to_exit_point, uw_rthrow): Use top_stderr instead of std_error macro.
* regex-compile: argument defaulting issue.Kaz Kylheku2021-07-051-1/+1
| | | | | | | | | | | | | * regex.c (regex_compile): In the string case when regex_parse needs to be called, redundant argument defaulting is being performed on error_stream, defaulting it to nil. The regex_parse function doesn't like that; it no longer accepts nil as a facsimile of missing. The right thing to do here is nothing: just pass error_stream to regex_parse as-is and let it do the defaulting. And that is how the code was initially until commit a8b0e36b1760e51a8a3a25d4e22a325e407ef3d4 in March of 2014, which introduced the redundant defaulting. Reported by Paul A. Patience
* expander: use expand_error everywhere.Kaz Kylheku2021-07-051-66/+66
| | | | | | | | | | | | | | | All expand-time errors go through expand_error for compiler-stylen error reporting. * eval.c (not_bindable_error, dotted_form_error): Only expander helper functions call these helpers so they get switched to expand_error. (expand_opt_params_rec, expand_params_rec, expand_param_macr, expand_lisp1, expand_lisp1_value, expand_lisp1_setq, expand_setqf, expand_qquote_rec, expand_vars, expand_fbind_vars, me_case, me_whilet, me_iflet_whenlet, me_load_for, expand_catch_clause, expand_switch, me_l1_val, me_l1_setq): Use expand_error instead of eval_error.
* macro params: use compiler-style error reporting.Kaz Kylheku2021-07-051-27/+30
| | | | | | | | | | | | | | | | | * eval.c (bind_macro_params): Take the error reporting function as a functional argument which points either to eval_error or expand_error. Update all the recursive calls to pass it down. Replace all calls to eval_error with this function pointer. (me_interp_macro, op_mac_param_bind, op_mac_env_param_bind): Call bind_macro_params with expand_error as the function, so that under the right circumstances, the error will go to standard error, as well as being thrown as an exception. In the case of me_interp_macro, this is clear. The reason we do it for the other two is that their primary use case is inside macros. (op_tree_case, op_tree_bind): Pass eval_error to mac_param_bind, preserving existing behavior.
* expander: tighten up syntax checking.Kaz Kylheku2021-07-053-59/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_exception): New parameter distinguishes whether this function is called from expansion time. If so, it behaves similarly to the compile-error funtion in error.tl: if a recursive load is in effect, a there is no error handler, then deferred warnings are dumped to standard error, followed by the error message. Then the exception is thrown. (eval_error, eval_warn): Pass zero to eval_exception to indicate that this is not expansion time. (expand_error, missing_arg_error, excess_args_error, no_dot_check, syn_check): New static functions. (me_def_variable, me_each, me_for, me_gen, me_gun, me_delay, me_when, me_unless, me_while_until, me_whie_until_star, me_equot, me_case, me_dotimes, me_lcons, me_mlet, me_load_time, me_l1_val, me_l1_setq, me_assert): Add syntactic checks to built-in macros. (do_expand): Add syntactic checks for a number of special operators. * unwind.c (catch_frame_s): New symbol variable. (uw_late_init): Initialize catch_frame_s and use that in registering the catch-frame structure. * unwind.c (catch_frame_s): Declared.
* main: revise error-ignore strategy for Lisp file.Kaz Kylheku2021-07-051-8/+5
| | | | | | | | | | | | | | | | | | | txr can process a Lisp file specified on the command line and then enter into the listener. In order to always enter the listener, even if the file errors out, the execution of the file uses read_eval_stream_noerr, which was written for this purpose. But this causes a problem for error reporting which is sensitive to whether or not an error handler exists. (See the compile-error function, and how it uses find-frame.) * txr.c (txr_main): Because we already know whether we are going to be entering the listener, we can split the evaluation of the Lisp file into two cases: if we will be entering the listener, we evaluate it with ignored error exceptions. If we won't be entering the listener, we evaluate normally. With this, I can run "make tests" now and be taken to the locaton of certain errors, due to the messages appearing on standard error.
* tests: fix malformed chmod.tl.Paul A. Patience2021-07-051-11/+11
| | | | | | * tests/018/chmod.tl (os): Fix final parentheses of defvarl form accidentally encompassing the rest of the source file. Replace tabs with spaces.
* doc-lookup: add support for OpenBSD.Paul A. Patience2021-07-051-2/+3
| | | | | * stdlib/doc-lookup.tl (os-symbol): Add case for OpenBSD. (open-url): Same.
* genman, lib, tests: use defvarl where possible.Paul A. Patience2021-07-0510-40/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * genman.txr (dupes, tagnum): Replace defvar with defvarl. * stdlib/doc-lookup.tl (os-symbol): Same. * tests/011/macros-3.tl (x): Same. * tests/011/mandel.txr (x-centre, y-centre, width, i-max, j-max, n) (r-max, pixel-size, x-offset, y-offset): Same. (file, colour-max): Delete (unused) variables. * tests/012/circ.tl (x): Replace defvar with defvarl. * tests/012/stack.tl (stack-limited): Same. * tests/012/struct.tl (s): Same. * tests/013/maze.tl (vi, pa, sc): Delete variables. Use function arguments instead. (usage): Fix typo. * tests/014/dgram-stream.tl (family): Rename to... (*family*): ...this. * tests/014/socket-basic.tl (socktype): Rename to... (*socktype*): ...this. (%iters%): Replace defvar with defvarl.
* build: update some targets.Paul A. Patience2021-07-051-10/+15
| | | | | | | | | | | | * Makefile (tainted): Fix typo. Reword sentence. (rebuild): Remove obsolete references to repatch target. (clean, distclean): Remove tst directory. Separate directory removals from file removals. Remove txr-manpage.html and txr-manpage.pdf in both distclean targets. In non-configured distclean, correct the removal of .tlo files to be from the stdlib directory rather than from share (and limit the pattern to *.tlo rather than *.tlo*, since .tlo2 files are no longer generated); and explicitly remove config.h and config.make, just like the configured distclean.
* Version 265.txr-265Kaz Kylheku2021-07-047-933/+993
| | | | | | | | | | | | | | * RELNOTES: Updated. * configure (txr_ver): Bumped version. * stdlib/ver.tl (lib-version): Bumped. * txr.1: Bumped version and date. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* listener: treat unset and empty EDITOR the same.Paul A. Patience2021-07-042-2/+2
| | | | | | | * linenoise/linenoise.c (edit_in_editor): Treat empty EDITOR variable as if it were unset (i.e., do nothing). * txr.1: Documented.
* doc: check for spurious spaces.Paul A. Patience2021-07-042-4/+21
| | | | | | | | | | | * checkman.txr (check-spaces): New pattern function for checking for spurious spaces (i.e., two spaces or more in a row) in .meIP, .meti and .mets macros. * txr.1: Fix two instances of spurious spaces ("@\ newline" and "@\ space" examples). Conform the "@\x hex-digits" and "@\ octal-digits" examples to the fixed ones; this is more intuitive since there must be no space before the digits in the escape sequence.
* checkman: fix typos.Paul A. Patience2021-07-041-3/+2
| | | | | * checkman.txr (check-synb): Correct :min to :mintimes. (check-meti): Fix typo in comment.
* stack-limit: impose minimum limit.Kaz Kylheku2021-07-042-8/+18
| | | | | | | | | | | | | * gc.c (MIN_STACK_LIMIT): New preprocessor symbol. (gc_init): If the system stack limit is too low, don't treat that the same way as a missing or unlimited limit. Instead clamp to the minimum value and hope for the best. So that is to say, the system limit cannot be used as a mechanism to set a ridiculously low stack limit in TXR; the only way to do that is to use the set-stack-limit function. * txr.1: Documentation updated. Also fixed 326767 typo which should be 32767.
* stack-limit: always set a stack limit.Kaz Kylheku2021-07-041-0/+3
| | | | | | | | | | | Even if built without getrlimit, and even if getrlimit reports an unlimited stack size, set up a default limit. * gc.c (DFL_STACK_LIMIT): New preprocessor symbol, defined as 128 kilbytes for a small memory configuration, otherwise 16 megabytes. (gc_init): Set up a default stack limit unconditionally based on DFL_STACK_LIMIT before probing getrlimit.
* stack-limit: bug: not handling RLIM_INFINITY.Kaz Kylheku2021-07-042-7/+10
| | | | | | | | | | | | | | | | * gc.c (gc_init): We must check rlim_cur for the RLIM_INFINITY value indicating unlimited stack, and not misuse this value as a limit number, otherwise hilarity ensues. This reproduced on an older platform with make 3.81, which calls setrlimit to bring about an unlimited stack, passed on to child processes. Because of this txr segfaulted, as a consequence of a false positive. * tests/012/stack.tl (stack-limited): New variable which indicates whether there is a stack limit. If there isn't, we avoid running the fork-based test case. Also, we set the stack limit to 32768 so we have a limit against which to run some of the tests.
* autoload: missing lambda-excess-apply-list symbol.Kaz Kylheku2021-07-041-2/+2
| | | | | * lisplib.c (error_set_entries): Autoload error module on lambda-excess-apply-list, which was recently added.
* path-search: fix test for sh not being in /bin.Kaz Kylheku2021-07-041-1/+1
| | | | | * tests/018/path-test.tl: Check that the result of a path-search for "sh" only ends in "/bin/sh", not that it is precisely "/bin/sh".
* suffix functions: ignore trailing slashes.Kaz Kylheku2021-07-033-9/+27
| | | | | | | | | | | | | | | | Another requirements tweak to short-suffix and long-suffix: ignore one or more trailing slashes, instead of just one. This harmonizes with base-name, which does same, that requirement being copies from the POSIX basename utility. * stream.c (short_suffix, long_suffix): If sl points to a trailing slash which is the start of a suffix that consists of nothing but trailing slashes, then we pretend it isn't there. * tests/018/path.tl: Adjusted two existing test cases, and added more. * txr.1: Documented.
* doc: find-true spelling error.Kaz Kylheku2021-07-031-1/+1
| | | | | * txr.1: Fix "funtion" in description of new find-true function.
* doc: fix description and example of suffix funsPaul A. Patience2021-07-031-2/+2
| | | | | | | * txr.1: The suffix of path "abc." is ".". Fix the description for this case (which suggested the suffix was the empty string, which was the case before commit bf2e5199e8dbc4e6fd4fcac5dab1ea16f4ec5970) and one of the examples.
* doc: fix various issues.Paul A. Patience2021-07-033-619/+711
| | | | | | | | | | | | | | | | | | | * RELNOTES: Fix typos. * txr.1: Correct alist-remove and alist-nremove's argument lists (the keys are variadic). Remove "(the empty string)" from abs-path-p examples because it formats bizarrely in man output and is anyway mentioned in the description. Remove spurious spaces from .mets lines interfering with the formatting. Add some missing .code and .meta directives. Unitalicize words of Latin origin that have entered the dictionary ("de facto" and "vice versa"). Add hyphens to compound words used as adjectives. Remove hyphen from "non-matching". Move periods inside parentheses containing full sentences. Add missing words. Remove repeated words. Fix various other minor issues. * txr.c (help): Fix a typo. Clarify a description. Add missing periods. Make some other minor changes.
* compiler: inline lambda: fix : from apply-list caseKaz Kylheku2021-07-031-1/+2
| | | | | | | * stdlib/compiler.tl (lambda-apply-transform): When processing optional argument from apply-list, push an entry into check-opts, so the fixup code is generated for it. New test cases pass now.
* compiler: add failing inline lambda tests.Kaz Kylheku2021-07-031-0/+10
| | | | | * tests/012/lambda.tl: Add tests where apply list supplies : values to optional params, which must trigger defaulting.
* compiler: inline lambda: broken : args to optionals.Kaz Kylheku2021-07-031-5/+19
| | | | | | | | | | | | | | | The compiler test case fails on cases which pass a : value to an optional argument, which is supposed to trigger defaulting. * stdlib/compiler.tl (lambda-apply-transform): When processing an optional argument, if the argument is other than a constant expression evaluating to the : symbol, add an entry into a new check-opts list. This is later traversed to add code before the lambda body to check the optional parmeters for : values and do the init-form processing. The test cases pass with this, but it needs to be done in the case when optional values come from the apply list also; this is not being tested.
* compiler: inline lambda: not creating rest param.Kaz Kylheku2021-07-031-1/+1
| | | | | * stdlib/compiler.tl (lambda-apply-transform): In one case, the add call is missing to actually emit the rest parameter.
* tests: support for compiled test forms.Kaz Kylheku2021-07-032-23/+51
| | | | | | | | * tests/common.tl (*compile-test*): New variable. (vtest): Compile cases via compile-toplevel if *compile-test* is true, catching compile-time exceptions. * tests/012/lambda.tl: Set *compile-test* true and repeat file.
* compiler: typo in lambda error.Kaz Kylheku2021-07-021-1/+1
| | | | * stdlib/error.tl (lambda-too-few-args): Fix "inufficient".
* tests: include constp test in compile case.Kaz Kylheku2021-07-021-1/+1
| | | | * tests/012/compile.tl: Add const.tl file.
* tests: simplify file name handling in compile test.Kaz Kylheku2021-07-021-5/+5
| | | | | * tests/012/compile.tl: Remove suffixes from name list, and simplify code.
* lambda: tests.Kaz Kylheku2021-07-021-0/+88
| | | | * tests/012/lambda.tl: New file.
* constantp: tests.Kaz Kylheku2021-07-021-0/+23
| | | | * tests/012/const.tl: New file.
* tree: expose missing tnodep.Kaz Kylheku2021-07-021-0/+1
| | | | | | * tree.c (tree_init): Register tnodep as intrinsic function. This is documented! Another discrepancy found thanks to the new piece of code in genman.txr.
* signal: fix typo causing missing itimer-prof.Kaz Kylheku2021-07-021-1/+1
| | | | | | | | | | * signal.c (sig_init): Register ITIMER_PROF as the documented itimer-prof, not the undocumented itimer-prov. Anyone depending on this will have to fix their code to use the new variable, or else (defvarl itimer-prof itimer-prov). This was discovered due to Paul A. Patience's doc-syms scrubbing code recently added to genman.txr, which identifies documented symbols not present in the actual image.
* doc: cptr-put does not exist.Kaz Kylheku2021-07-022-6/+6
| | | | | | | | | | | * txr.1: There is no cptr-put function; it is called cptr-out. The last paragraph refers to cptr-out and it is referenced elsewhere. It has to be cptr-out because it implements the "out semantics" in FFI conversion which pairs with "put"; cptr-put would be a different function, which is not currently implemented. * stdlib/doc-syms.tl: Updated.
* doc: check the contents of doc-syms.Paul A. Patience2021-07-012-4/+23
| | | | | | | * genman.txr: Before generating stdlib/doc-syms.tl, check that the symbols going into that file (i.e., into the doc-syms variable) are actually contained in the TXR image (allowing for some exceptions). Also, reindent some lines.
* packages: find-symbol behaving like find-symbol-fb.Kaz Kylheku2021-07-021-11/+0
| | | | | | * lib.c (find_symbol): This function is identical to find_symbol_fb. The code for searching the fallback list must be removed.
* genvim.txr: remove unused variable pkg-name.Paul A. Patience2021-07-011-1/+0
|
* doc: fix various issues in .coNP lines.Paul A. Patience2021-07-013-131/+133
| | | | | | | | | | | * txr.1: Make consistent the style for ellipses in .coNP lines (i.e., without the word "and"). Emend some incorrectly named symbols. Fix various typos and other inconsistencies in .coNP lines. * checkman.txr (check-func): Add exception for caar. Add missing patterns for "Pattern macro", "Operator/function" and "Macro/function". * stdlib/doc-syms.tl: Updated.
* main: maintain -b option.Kaz Kylheku2021-07-011-13/+21
| | | | | | | | | | * txr.c (help): Remove -b help text which pertains to an ancient -b option that was deprecated in 2014. Add correct help text for -b. (txr_main): Use split_str for the argument of -b. If it fails to produce a two-element list, it means the equal sign is missing; issue an error message and exit. Thereby we avoid passing nil as the input source argument of lisp_parse.
* streams: tightening sloppy argument defaulting.Kaz Kylheku2021-07-014-54/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Numerous functions in TXR Lisp treat a nil argument for an optional parameter as if it were omitted. In the case of streams, this can cause problems. An accidental nil passed to an input function can cause it to read from standard input and hang. In this patch, argument defaulting is tighented for functions that perform I/O. It's mostly stream parameters, but not exclusively. * eval.c (prinl, pprinl): Use default_arg_strict to default the stream argument, and also re-use that value for the put_char call. * lib.c (lazy_stream_cons, print, pprint, put_json): Use default_arg_strict rather than default_arg. * parser.c (regex_parse, lisp_parse_impl, txr_parse): Tighten the defaulting of the input stream and error stream arguments, streamlining the logic at the same time. * stream.c (do_parse_mode): Use default_arg_strict for the mode string argument. (record_adapter, get_line, get_char, get_byte, get_bytes, unget_byte, put_buf, fill_buf, fill_buf_adjust, get_line_as_buf, put_string, put_char, put_byte, put_line, flush_stream, get_string): Use strict defaulting for stream argument. (mkstemp_wrap): Use strict defaulting for suffix.
* doc: include opt-error in diagram.Kaz Kylheku2021-06-301-0/+2
| | | | * txr.1: Exception hierarchy diagram now includes opt-error.
* getopts: autoload: opt-error not interned.Kaz Kylheku2021-06-301-1/+1
| | | | | | * lisplib.c (getopts_set_entries): Add opt-error to list of interned symbols. Without this, getopts throws sys:opt-error. Reported by Paul A. Patience.
* compiler: inline lambda: another apply-list diagnosis bug.Kaz Kylheku2021-06-301-2/+8
| | | | | | | | * stdlib/compiler.tl (lambda-apply-transform): There is a bug in the case when all required and optional parameters have been satisfied. In the sub-case when there are no fixed parameters, we need to handle the run-time situation of there being a non-empty apply list, but no rest variable.
* op: refactor do handling.Kaz Kylheku2021-06-301-19/+37
| | | | | | | | | | | | | | | * stdlib/op.tl (op-expand): The logic involving the multiple expansions of do is consolidated into one step, so that everything is taken care of by the time syntax-1 is produced. Immediately when the initial unsuffixed arguments expand successfully, we check or the presence of metas and add the @1 if metas are absent. In the case of expanding with the gensym, we immediately replace that with @1 without using symacrolet. The do-gen variable is gone. Later, when calculating lambda-interior, there are no hacky additional passes to deal with; that block of code just refers to syntax-2. The do case is folded together with the have-metas case. Also adding copious comments to this hard-to-follow logic.
* op: bug in do: must insert @1 into unexpanded form.Kaz Kylheku2021-06-292-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In the case when the do syntax has no metavariables, and it expands as-is without the addition of symbol in the tail position, we are doing something wrong: we are adding the @1 into the expanded version of the form, rather than the original. For instance: 1> (expand '(do pop a)) (lambda (#:arg-1-0017 . #:arg-rest-0016) (prog1 (car a) (sys:setq a (cdr a)) #:arg-1-0017)) Here, the @1 was inserted into the (prog1 ...) form which is the expansion of pop. This is incorrect; it must be inserted into the original (pop a) syntax as (pop a @1). * op.tl (op-expand): In this case when there are no metas and no do-gen that can be replaced by @1 via symacrolet, go back to the original args syntax, add the arg1 meta into that syntax, and process it from the beginning through parallel expansions steps. * tests/012/op.tl: Couple of tests added.