summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* compiler: bug: diagnose excess args from apply list.Kaz Kylheku2021-06-292-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | When we compile an immediately applied lambda like (apply (lambda (a b c) ...) list), we are not emitting code to handle the run-time situation when there are too many elements in the list. This shows up in exception handling, for instance; the compiled version of this executes silently and returns 42: (catch (throw 'foo 5) (foo () 42))) foo is must have a parameter to capture the 5; interpreted code enforces this. * stdlib/compiler.tl (lambda-apply-transform): In the apply-list case, at the end of binding all the optional arguments, if the parameter list doesn't have a rest parameter to take any remaining items, we emit code to check that there aren't any; that everything has been popped out of the apply list, leaving it nil. If not, we call the run-time support function lambda-excess-apply-list. * stdlib/error.tl (lambda-excess-apply-list): New function.
* path-cat: becomes variadic.Kaz Kylheku2021-06-293-8/+103
| | | | | | | | | | | | | * stream.c (path_vcat): New static function. (stream_init): Register path-cat instrinsic to path_vcat rather than path_cat. * tests/018/path.tl: path-cat tests: all examples from documentation, plus others. * txr.1: Documented existing behaviors that were not clear, like when inputs are empty. Documented new variadic semantics. Examples added.
* path-cat: error if arguments are not strings.Kaz Kylheku2021-06-291-2/+2
| | | | | * stream.c (path_cat): Use length_str to enforce a type check. Otherwise, for instance, (path-cat #() "foo") will return "foo".
* doc: mistake in several path-cat examples.Kaz Kylheku2021-06-291-3/+3
| | | | | * txr.1: Corrections to three examples, where one operand is empty, and thus the other is returned.
* doc-lookup: use BROWSER variable; provide fallback.Kaz Kylheku2021-06-292-5/+40
| | | | | | | | | * stdlib/doc-lookup.tl (open-url): On non-Windows platforms, search for a program specified by the BROWSER variable, then by the URL-opening utility, and finally thorugh a fallback list of browsers. * txr.1: Documentation updated.
* New function: find-true.Kaz Kylheku2021-06-295-3/+86
| | | | | | | | | | | | | | | This is like find-if, but returns the value of the predicate function rather than the item. * eval.c (eval_init): Register find-true instrinsic. * lib.c (find_true): New function. * lib.c (find_true): Declared. * stdlib/doc-syms.tl: Updated. * txr.1: Documented.
* New function: path-search.Kaz Kylheku2021-06-295-1/+103
| | | | | | | | | | | | * lisplib.c (path_test_set_entries): Autoload on path-search. * stdlib/path-test.tl (path-search): New function. * tests/018/path-test.tl: New file. * txr.1: Documented. * stdlib/doc-lookup.tl: Updated.
* doc-lookup: handle xdg-open not terminating.Kaz Kylheku2021-06-291-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | It is common for web browsers like firefox not to fork themselves into the background when initially run from the command line. Only when an additional instance is executed does that instance terminate immediately, passing the URL to the existing instance. (Which also does not constitute forking into the background, but does have the effect of an immediate exit.) User Paul A. Patience reports that some installations of xdg-open have the isssue of not handling this situation; these versions of xdg-open wait for the browser to terminate, which causes xdg-open to hang until the browser is closed if it is the initial instance. * stdlib/doc-lookup.tl (detached-run): New function. Like run, but forks into the background, running the process in a detached grandchild whose parent terminates, so that it becomes an orphan parented to the init daemon. We redirect *stdout* to *stdnull* because the first instance of the browser can spit ugly, meaningless diagnostics when it terminates. (open-url): Use detached-run instad of run. Don't check the return value for zero; there is no integer exit status.
* doc-lookup: *doc-url* variable must be dynamic.Kaz Kylheku2021-06-281-1/+1
| | | | | * stdlib/doc-lookup.tl (*doc-url*): Define with defvar, not defvarl. Problem reported by Paul A. Patience.
* constantp: fully expand; recognize functions.Kaz Kylheku2021-06-285-56/+158
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch improves the constantp function dramatically. It now performs a full expansion of its argument, and recognizes all of the constant foldable functions that the compiler recognizes. * eval.c (const_foldable_s): New symbol variable. (const_foldable_hash): New static variable. (constantp_noex): Look up function in the hash table of const foldable functions, including in the case when it appears in a dwim form as in [+ 2 2] which is (dwim + 2 2). In this case, recursively check the arguments for constantp_noex. We get the hash table of foldable functions from the sys:%const-foldable% variable, which comes from an autoloaded module. (constantp): Fully expand the input form, not just m macroexpand. (eval_init): Register the const_foldable_s variable. * lisplib.c (constfun_instantiate, constfun_set_entries): New static functions. (lisplib_init): Register auto-loading of constfun module via new static functions. * stdlib/compiler.tl; Load the constfun module if %const-foldable% is not defined. (%const-foldable-funs%, %const-foldable%): Removed from here. * stdlib/constfun.tl: New file. (%const-foldable-funs%, %const-foldable%): Moved here. * txr.1: Documented changes to constantp.
* expander: use constantp_noex for expanded forms.Kaz Kylheku2021-06-281-4/+4
| | | | | | * eval.c (expand_progn, do_expand): Use the constantp_noex helper function of constantp on arguments that we have already fully expanded.
* regex: bugfix: print/read consistency of n-ary ops.Kaz Kylheku2021-06-271-2/+4
| | | | | | | | | | | | | | | | | | The regex-compile function accepts syntax in which certain operators like (or ...) can be n-ary. This representation is converted to the strictly binary form that is understood by the compiler internals (and which regex-parse outputs), as well as the regex printer. Unfrotunately, regex-compile is attaching the original form with the n-ary operators to the regex object, and the printer does not reat this; it renders the syntax with portions missing. It needs the binary form. * regex.c (regex_compile): Capture the intermediate result from calling reg_nary_to_bin, and use that as regex_source. The pass that through the remaining two optimization passes to obtain regex_sexp which is compiled.
* regex: exposing optimization pass a regex-optimizeKaz Kylheku2021-06-273-2/+53
| | | | | | | | | | | | * regex.c (regex_optimize): New static function, capturing the three optimization passes. (regex_compile): Code moved into regex_optimize. (regex_init): Remove sys:reg-optimize function. Register regex-optimize. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* regex-from-trie: correctly handle empty trie.Kaz Kylheku2021-06-272-2/+6
| | | | | | | | | | * filter.c (regex_from_trie): An empty trie matches nothing, so we must return the t regex syntax (match nothing), not nil (match empty string). A hash-based trie matches nothing if it is empty; but if it has user data, then it matches the empty string. * tests/015/trie.tl: Test cases added.
* regex-from-trie: bugs processing compressed trie.Kaz Kylheku2021-06-272-3/+10
| | | | | | | | | | * filter.c (regex_from_trie): If a hash key maps to a string, do not treat that as a trie; it is the value for that node. A value is only a trie if it is a cons or hash. Also, in this case do not make a compound regex. * tests/015/trie.tl: Add duplicate of regex test case using regex from compressed tree.
* filter: remove useless statement.Kaz Kylheku2021-06-271-2/+0
| | | | | | | * filter.c (trie_filter_string): There is no need to convert a character to string for passing it as a second argument to string_extend; it takes characters. Also this had beem coded in a silly way: if chrp is true that implies !stringp.
* regex-from-trie: bugfix: incomplete regex.Kaz Kylheku2021-06-272-1/+3
| | | | | | | | | | * filter.c (regex_from_trie): The code is neglecting to check whether there is a match of the input *at* the given hash table, which is true if it has user data. In that case, the empty regex must be added as a parallel branch. * tests/015/trie.tl: The first regex test case works now. The second one is incorrect and is replaced.
* filter: regex-from-trie produces bad or syntax.Kaz Kylheku2021-06-272-6/+58
| | | | | | | | | | This is not a complete fix yet; the test case still fails. * filter.c (regex_from_trie): The (or ...) operator in the regex language is strictly binary. Do not produce a variable-argument or expression. * tests/015/trie.tl: New file.
* signal: fix warning in older compilers.Kaz Kylheku2021-06-261-1/+1
| | | | | | | | * signal.c (sig_handler): Some older compilers cannot figure out that stack_lim is not used uninitialized, due to the conditional logic here, in which two separate code blocks are guarded by the same condition. Let's initialize the variable, like the others.
* tests: reduce time spent in stack overflow test.Kaz Kylheku2021-06-261-0/+1
| | | | | | * tests/012/stack2.txr: This test case can prove its point in a much smaller stack limit than the one derived from the system default. Let's cut it to 32 kilobytes.
* linenoise: end-of-line/buffer selection glitch.Kaz Kylheku2021-06-261-1/+1
| | | | | | | | | | | | | | | | | In inclusive selection mode, when the selection is reversed (end point is before start), and the starting character is the end of the line or of the buffer, that character is not included in the highlight, as if non-inclusive selection were in effect. This doesn't affect the semantics of the selection, only the way it is rendered visually; the character which is not highlighted is still included in the selection. * linenoise/linenoise.c (sync_data_to_buf): Remove two bogus conditions from the line which extends the visual selection by one character: we must not avoid executing this logic if the current character is zero (end of buffer) or CR (end of line).