summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* New awk operator: fconv.Kaz Kylheku2016-09-183-1/+201
| | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-let): Add new symbol macro, fconv. * share/txr/stdlib/conv.tl: New file. * txr.1: Documented fconv.
* doc: typo in section on setuid operation.Kaz Kylheku2016-09-171-1/+1
| | | | * txr.1: "require user id" -> "required user id".
* doc: mention USERPROFILE.Kaz Kylheku2016-09-171-7/+14
| | | | | | | * txr.1: Document that on Windows, the home directory is determined from USERPROFILE for finding the ~/.txr_history file as well placing the temporary file for the edit-in-editor interactive feature.
* linenoise: use USERPROFILE for home dir on Cygnal.Kaz Kylheku2016-09-171-1/+18
| | | | | | | * linenoise/linenoise.c (get_home): New static function. (edit_in_editor): Call get_home instead of getenv("HOME").
* New awk variable: krs.Kaz Kylheku2016-09-172-7/+30
| | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): New slot, krs. (sys:awk-state loop): Use record-adapter if krs is true, even if the default fs is in effect. Pass value of krs to record-adapter function. (sys:awk-let): Provide krs "awk variable" symbol macro. * txr.1: Documented krs. Clarified semantics of rs being those of both separation and termination.
* Tests for tok-str.Kaz Kylheku2016-09-172-0/+73
| | | | * tests/015/split.tl: New cases added.
* Adding tests for split-str.Kaz Kylheku2016-09-173-0/+127
| | | | | | | | * Makefile (TXR_DBG_OPTS): Disable for tst/tests/015. * tests/common.tl (mtest): New macro. * tests/015/split.tl: New file.
* Bugfix in tok-str: empty-match regexes.Kaz Kylheku2016-09-161-10/+7
| | | | | | | | | | | | | | * lib.c (tok_str): Only continue the loop if the new position isn't past the end of the string. This fixes the problem of recognizing an empty token past the last character in the string. Also, advance new_pos by one if there is a zero length match. Then don't advance pos by one later in that case. This fixes the bug that we collect empty separator pieces *and* empty tokens, and also prevents empty matches before the first character of the string. Logic in tok_str is now very similar to that in split_str_keep.
* New awk variables: ft and kfs.Kaz Kylheku2016-09-162-14/+164
| | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): New slots, ft and kfs. (sys:awk-state rec-to-f): Implement ft and kfs semantics. (sys:awk-let): Provide ft and kfs as "awk variable" via symbol macros. * txr.1: Documented ft and kfs.
* doc: fs variable.Kaz Kylheku2016-09-161-5/+17
| | | | | * txr.1: Improve some wording in the description of the awk fs variable.
* Bugfix in split-str: empty-match regexes.Kaz Kylheku2016-09-162-6/+12
| | | | | | | | | | | * lib.c (split_str_keep): In the regex case, changing to an infinite loop. The do/while is no longer needed because the if statement includes a test of the position having reached the end of the string. This is done before it is incremented by len, so we avoid wrongly keeping a separator. * txr.1: Clarified that an empty regex match behaves like an sep which is an empty string,
* split-str gains ability to keep separating pieces.Kaz Kylheku2016-09-164-3/+29
| | | | | | | | | | | | | | | * eval.c (eval_init): Register split-str to split_str_keep, with optional argument. * lib.c (split_str_keep): New function, formed from split_str, with third argument. (split_str): Reduced to wrapper around split_str_keep. Thus we don't have to update umpteen existing calls with an extra nil parameter. * lib.h (split_str_keep): Declared. * txr.1: Documented new optional argument of split-str.
* regex: optimize double complement.Kaz Kylheku2016-09-161-40/+46
| | | | * regex.c (reg_optimize): Implement ~~R -> R reduction.
* Merge macro expanders for while and until.Kaz Kylheku2016-09-161-27/+14
| | | | | | | | | | | * eval.c (me_while, me_until, me_while_star, me_until_star): Functions removed. (me_while_until, me_while_until_star): New functions. Here we just check the form symbol and add the negation to the test. Also: use of (zap flag) in the while* and until* expansion has been replaced with (set flag nil), because zap wastefully arranges to yield the prior value, which is not used at all.
* fix broken while* and until*.Kaz Kylheku2016-09-161-2/+2
| | | | | eval.c (me_while_star, me_until_star): for loop test must be a sequence of forms, not a single form.
* regex: add case to complement optimization.Kaz Kylheku2016-09-151-0/+2
| | | | | | | | * regex.c (reg_optimize): Based on the reasoning in the previous commit, we can also statically optimize a complement whose argument is the t regex: match nothing. We convert that to match everything: the .* regex. Now (regex-compile "~[]") -> #/.*/.
* regex: fix broken complement operator.Kaz Kylheku2016-09-151-1/+3
| | | | | | | | | | | | | | | | | | | The form (match-regex "xy" #/~ab/) should return 2 (full match) because "xy" is in the complement of the set { "ab" }. It wrongly returns 1. * regex.c (reg_derivative): Handle the case when the derivative of the complement's constituent expression yields nil. This means that the complemented regex matches the input. In this case, the complement must lapse to the .+ regex: match one or more characters. That is to say, if the input has at least one more character, there is a match, which covers all such characters. Otherwise there is no match: the input matches the complemented regex. In the t case, the return value is also wrong. If the complemented regex hits a brick wall (matches nothing, not even the empty string), the correct complement is "match everything": the .* regex. Not the match empty string regex!
* key function argument on remq, remql and remqual.Kaz Kylheku2016-09-156-23/+48
| | | | | | | | | | | | | | | | | * eval.c (weave_while): Pass third arg to remq as nil. (eval_init): Update registrations of remq, remql and remqual. * lib.c (remq, remql, remqual): Implement key function argument. * lib.h (remq, remql, remqual): Declarations updated. * sysif.c (at_exit_call): Pass third arg to remq as nil. * debug.c (debug): Pass third argument to remqual as nil. * txr.1: Documentation updated.
* New keepq, keepql and keepqual functions.Kaz Kylheku2016-09-154-0/+110
| | | | | | | | | * eval.c (eval_init): Register keepq, keepql and keepqual intrinsic functions. * lib.c (keepq, keepql, keepqual): New functions. * lib.h (keepq, keepql, keepqual): Declared.
* awk macro: don't bind *stdout* if :output missing.Kaz Kylheku2016-09-142-15/+7
| | | | | | | | * share/txr/stdlib/awk.tl (awk): Bind *stdout* only if awc.output is not nil; i.e. :output has been specified (with a non-nil argument). * txr.1: Revised :output documentation.
* New place-mutating macro: upd.Kaz Kylheku2016-09-143-1/+40
| | | | | | | | * lisplib.c (place_set_entries): Add upd to the auto-load list for place.tl. * share/txr/stdlib/place.tl (upd): New macro. * txr.1: Documented.
* doc: improve lset documentation.Kaz Kylheku2016-09-141-7/+15
| | | | | | | * txr.1: Add missing lset to summary of place-mutating macros. lset actually needs a sequence, not specifically a list: (lset a b c "123") works, and assigns characters. It is now documented accordingly.
* Fix broken keep/remove functions.Kaz Kylheku2016-09-141-19/+10
| | | | | | | | * lib.c (remq, remql, remqual, remove_if, keep_if): Bug: functions don't work correctly for strings. Anyway, the ldiff-based algorithm is ugly on vectors and strings. Patching things upp by converting input to list with tolist.
* Version 149.txr-149Kaz Kylheku2016-09-126-362/+422
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* awk macro: revise how implicit block works, and name.Kaz Kylheku2016-09-122-31/+45
| | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-expander): Check that :name designates a symbol, and that it isn't nil. (awk): Move the implicit block to the outermost scope so it encloses all of the clauses. Default to the name awk for the block, rather than nil. * txr.1: Document that the implicit awk block is called awk by default, and that nil is not allowed as a block name.
* awk macro: more Awk-like treatment of prn args.Kaz Kylheku2016-09-122-1/+20
| | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state prn): Use loop instead of simple interpolation, so that we we can individually interpolate each arg into a quasistring. This way if an arg is nil, it turns into nothing rather than the word "nil". * txr.1: Documented this behavior of prn.
* awk macro: fix: rebind *stdout* in broader scope.Kaz Kylheku2016-09-122-13/+44
| | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state loop): Do not bind *stdout* around the call to the main record-processing function. (awk): Re-bind *stdout* around all of the user code, just after the run-time awk state object is constructed. * txr.1: Correct the lies written about :output.
* doc: hyphenation of shorthand.Kaz Kylheku2016-09-121-2/+2
| | | | | * txr.1: Replace a few occurrences of short-hand with shorthand.
* awk macro: new local macros ff and mf.Kaz Kylheku2016-09-122-1/+70
| | | | | | | * share/txr/stdlib/awk.tl (sys:awk-let): New local macros. * txr.1: Documented.
* doc: fix some broken uses of .code and .metaKaz Kylheku2016-09-122-23/+15
| | | | | | | | | | * checkman.txr (check-code): Move match for space after code/meta after the assert, so it is an error if that is missing. * txr.1: Numerous inappropriate or misformatted instances of .code and .meta replaced, removed or adjusted.
* awk macro: don't use cat-str to update rec.Kaz Kylheku2016-09-111-1/+1
| | | | | | * share/txr/stdlib/awk.tl (sys:awk-state f-to-rec): Use quasiliteral to combine fields to reconstitute rec; cat-str works only with characters and strings.
* awk macro: field splitting more Awk-like.Kaz Kylheku2016-09-112-17/+58
| | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): Initialize fs to nil rather than the default regex. (sys:awk-state rec-to-f): If fs is nil then operate on a version of rec that is filtered through trim-str. Thus fs being nil is like the Awk special case when fs is a space. * txr.1: Description of fs updated.
* Semantics change in trim-str function.Kaz Kylheku2016-09-112-7/+18
| | | | | | | | | * lib.c (trim_str): Trim only newlines and blanks, not carriage returns, vertical tabs and form feeds. This is subject to the compatibility option * txr.1: Doc updated and compatibility note added.
* doc: italicize meta-identifers in nroff mode.Kaz Kylheku2016-09-111-7/+7
| | | | | | | | | | | * txr.1 (meta, metn, gets): In nroff mode, don't just add angle brackets around meta symbols, but also typeset them in italic using \fI...\fP. This is useful because the output of man can be colorized when viewed using the less pager. If these symbols are italicized, then they get colored differently from surrounding text. We keep the angle brackets because it helps these words stand out as "meta" in the absence of color.
* doc: spurious blank line.Kaz Kylheku2016-09-111-1/+0
| | | | * txr.1: Remove extra blank line above Macro flip section.
* Replace some rlet and slet uses with alet.Kaz Kylheku2016-09-111-13/+15
| | | | | | | | | | | * share/txr/stdlib/place.tl (nthcdr): Fix a potentially wrong order of evaluation by using a temporary symbol for the list and using alet. If the list form could potentially modify the index, then we now avoid a bug here. (vecref, chr-str, ref, gethash, slot): Optimise the expansion of these two-expression places using alet. If both expressions are symbols, which is often the case, temporaries are avoided.
* New alet macro.Kaz Kylheku2016-09-113-1/+32
| | | | | | | | | * lisplib.c (place_set_entries): Add alet symbol to autoload list for place.tl. * share/txr/stdlib/place.tl (alet): New macro. * txr.1: Documented alet.
* rlet cleanup: replace safe with let or slet.Kaz Kylheku2016-09-113-71/+71
| | | | | | | | | | | | | * gencadr.txr: Use let instead of useless rlet that will just reduce to let. * share/txr/stdlib/cadr.tl: Regenerated. * share/txr/stdlib/place.tl (sys:var, car, cdr, errno): Replace rlet with slet where safe. (nthcdr): Replace useless let* with let. Replace one safe-looking rlet with slet. (dwim): Replace useless rlet with let.
* doc: Fix issue of missing collapse UI on Awk section.Kaz Kylheku2016-09-111-0/+3
| | | | | * genman.txr: Recognize the form of the table-of-contents line with the extra blank line generated by the .coSS macro.
* awk macro: don't use record stream if rs is "\n".Kaz Kylheku2016-09-111-6/+7
| | | | | | * share/txr/stdlib/awk.tl (sys:awk-state loop): Take input stream directly without a record adapter, if the record separator is the string "\n".
* awk macro: implement :begin-file and :end-file.Kaz Kylheku2016-09-102-48/+135
| | | | | | | | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-compile-time): New slots, begin-file-actions and end-file-actions. (sys:awk-state loop): Take two additional functional arguments for the begin file and end file actions, and do the calls in the right places. unwind-protect triggers the end file function. (sys:awk-expander): Parse out :begin-file and :end-file actions. (awk): Generate lambdas for begin-file and end-file actions, if they are defined. Pass these to the loop method. The code is refactored here to do one big sys:awk-let around everything. * txr.1: Documented :begin-file and :end-file, revising the :begin and :end documentation in the process.
* awk macro: move expander values into compile-time struct.Kaz Kylheku2016-09-101-26/+25
| | | | | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-compile-time): New slots: inputs, output, name, lets, begin-actions, end-actions, cond-actions. (sys:awk-expander): Use just one local variable, an awk compile time. Instead of the previous local variables, use the slots of this structure and return just that structure. Note that pattern-actions has been renamed cond-actions. This is per the terminology used in the newly-written documentation. (awk): Adjust to sys:awk-expander returning just the awk compile-time structure. No need to set up numerous locals; just refer to struct.
* doc: awk macroKaz Kylheku2016-09-101-0/+696
| | | | * txr.1: New section on the awk macro.
* doc html: TOC indentation issue on Chrome.Kaz Kylheku2016-09-091-1/+1
| | | | | | | | * genman.txr: Hack: put <dd> before nested <dl> element in table of contents. Without this, the nested lists are rendered flush left by Google Chrome. With this, they are indented. Chrome adds ugly whitespace around the embedded definition lists, but it's better than no identation.
* awk macro: don't use zap.Kaz Kylheku2016-09-091-1/+1
| | | | | * share/txr/stdlib/awk.tl (sys:awk-state rec-to-f): Don't use zap macro when the return value is not used.
* awk macro: fix buggy range semantics.Kaz Kylheku2016-09-091-5/+9
| | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-let): The closing expression of an awk range only applies when the range is active. Refactor generated code with local flags to eliminate duplicating the end range expression. Avoid evaluating the start range expression if the range is already active.
* awk macro: better code for rng with placelet.Kaz Kylheku2016-09-091-1/+1
| | | | | | | * share/txr/stdlib/awk.tl (sys:awk-let): Use our wonderful placelet macro instead of symacrolet for binding the flag alias to the flag place. This removes the duplicate evaluations of the slot access.
* awk macro: revise rng eval strategy.Kaz Kylheku2016-09-081-24/+43
| | | | | | | | | | | | | | | | | | | | | | | | | awk ranges must evaluate out-of-band after the record is read, before the patterns and actions are evaluated. * share/txr/stdlib/awk.tl (sys:awk-compile-time): New slots, rng-expr-temps and rng-exprs. (sys:awk-let): Stash the code for evaluating a range into the compile-time info into the rng-exprs list, and associate it with a gensym in the parallel rng-expr-temps list. Then emit that gensym as the expansion for the rng form. (awk): Process the pattern code in two steps. First, expand it, to get it to drop the rng-exprs into the awk compile-time info structure. Then when generating the final lambda, wrap an let* around the generated code which binds the rng-temps with the rng-exprs. This resolves the gensym references that replaced the ranges. let* is is used and its bindings are reversed into discovery order because this supports nested rng syntax. Given (rng x (rng y z)), the (rng y z) is expanded first, and so its code and temp gensym are pushed onto their respective lists firsts. The outer rng's code will thus contain a temp referring to the code of the inner one.
* awk macro: handle string typed output.Kaz Kylheku2016-09-081-1/+3
| | | | | * share/txr/stdlib/awk.tl (sys:awk-state): if output is a string, open file.
* awk macro: support ors (output record separator).Kaz Kylheku2016-09-081-2/+4
| | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): New slot, ors. (sys:awk-state prn): Use put-string to output the record rather than put-line, and stick the ors at the end. (sys:awk-let): Provide ors local symbol macro.