summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
* Synchronize license comments with LICENSE.Kaz Kylheku2016-10-011-18/+19
| | | | | | | | | | | | | | | | | | | | * Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.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, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Revert to verbatim 2-Clause BSD.
* doc: two "a any" typos.Kaz Kylheku2016-10-011-2/+2
| | | | | * txr.1: fix one "a any" in structs and one in notes on exotic regexes.
* Revision of static slot inheritance.Kaz Kylheku2016-09-301-64/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixing the broken static slot handling in TXR Lisp's "OOP structs" object system. Inherited static slots are now shared with the base type; only static slots explicitly defined in a derived type have a distinct global instance in that type. * share/txr/stdlib/struct.tl (sys:prune-nil-inits): Function removed. (sys:prune-missing-inits): New function. We now handle static slot forms with missing inits specially, not those with nil or missing inits. (defstruct): Translate a (word name) form to (word name) rather than (word name nil) if word is :static, because we need this nuance for non-shared static slots, so they can inherit the value from the base struct. For the purposes of generating the static init function, prune away all the static slot forms that do not have an initializer; we let those default. * struct.c (struct stslot): New struct for representing a static slot. (stslot_loc, stslot_place): New macros. (struct struct_type): Member eqmslot changes to a pointer to a struct stslot. The stslot dynamic array is no longer an array of val, but an array of stslot structs. (call_stinitfun_chain): The superclass chain of static init functions is now called only in compatibility mode. Otherwise only the type's own static init fun is called, which defclass uses to initialize just the new or repeated static slots. Inherited static slots are completely left alone; they do not require initialization. (static_slot_home_fixup): New static function; needed to fix some internal pointers within the static slot arrays if they are realloc'ed. (make_struct_type): Considerably revised to implement new scheme, while providing backward compatibility switching. New slots live in the struct stslot in which they are allocated. Inherited slots have home pointers to within the array in the base. (struct_type_mark): When walking the static slots, mark only the store cells of those which live in this array. Those that live elsewhere should have store cells that are nil; let's assert on it. (lookup_slot): Static slot lookup code has to retrieve slots in the new way, indirecting through the home pointer, which is hidden behind the stslot_loc macro. (lookup_static_slot_desc): New function, like lookup_static_slot, but returning a pointer to the struct stslot. Formed from the guts of lookup_static_slot. (lookup_static_slot): Gutted and turned into a wrappar around lookup_static_slot_desc. (static_slot_set): Simple change here: add cast because of the pointer type of eqmslot. (static_slot_home_fixup_rec): New static function. Fixes up the cached home in slot arrays in an entire type hierarchy rooted at a given type, which has to be done when its static slot has been reallocated, so all those inherited static slot pointers in the derived types are invalid. (static_slot_rewrite_rec): New static function: rewrites a particular inherited static slot in an inheritance hierarchy to point to a different slot. (static_slot_ens_rec): New static function: factored out recursive logic of static_slot_ensure. Substantially rewritten to handle new static slot scheme, plus support backward compatibility. There is a bug fixed here: if an instance slot is encountered in the no_error_p mode, it looks like we were dereferencing through an invalid ptr through the set(ptr, newval) line. (static_slot_ensure): A wrapper now for static_slot_ens_rec. (get_equal_method): Rework the logic related to the eqmslot member of the struct_type structure, in terms of it being a pointer now rather than an integer. The value -1 cast to a pointer serves the previous -1 sentinel value which indicates that it is confirmed (for the time being) that this type doesn't have an equal method. * txr.1: All documentation related to static slots updated, and compatibility notes added. * tests/012/oop.tl, tests/012/oop.expected: New files.
* Version 151.txr-151Kaz Kylheku2016-09-271-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Change criterion for *load-path*-relative loading.Kaz Kylheku2016-09-271-4/+8
| | | | | | | | | | * eval.c (load): Do not resolve all relative paths relative to the current *load-path*, only pure relative ones. * match.c (v_load): Likewise. * txr.1: Update doc for @(load)/@(include) and load function.
* New function pure-rel-path-p.Kaz Kylheku2016-09-271-2/+48
| | | | | | | | | * stream.c (plp_regex): New static variable. (pure_rel_path_p): New function. (stream_init): gc-protect plp_regex. Register pure-rel-path-p intrinsic. * txr.1: Document pure-rel-path-p and slightly revise abs-path-p.
* Get rid of sys:load; load becomes function.Kaz Kylheku2016-09-261-2/+2
| | | | | | | | | | | | | | | | | * eval.c (sys_load_s): Variable removed. (sys_load): Function removed. (load): Body of function taken from sys_load. There is no sloc argument; the *load-path* variable is sampled via new load_path macro. (me_load): Static function removed. (eval_init): Remove initialization of sys_load_s Remove registration of load macro and sys:load function. Register load function. * eval.h (load_path): New macro. * txr.1: Change documentation of load from macro to function.
* Overhaul of self-load-path mechanism.Kaz Kylheku2016-09-261-42/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The self-load-path symbol macro is as of now deprecated. It simply expands to *load-path*. *load-path* is a new special variable which is dynamically bound to the path of a file being loaded. * eval.c (self_load_path_s): Global variable renamed to load_path_s. (sys_load): Bind *load-path* around processing of loaded file. (me_load): Expand (load x) simply to (sys:load x *load-path*). (set_get_symacro): Function removed. (reg_symacro): New static function. (eval_init): Initialize renamed load_path_s with interned symbol having the name *load-path*. Register the *load-path* special variable. Set up the sel-load-path symbol macro aliasing for *load-path*. * eval.h (self_load_path_s): Declaration renamed. * match.c (v_load): Bind *load-path* around loading or inclusion. * parser.c (load_rcfile): Bind *load-path* around loading of .txr_profile file. * txr.c (txr_main): Bind *load-path* instead of self-load-path symbol macro. * txr.1: Updated documentation for @(load) directive and load macro. Replaced documentation of self-load-path with *load-path*.
* doc: new regsub example.Kaz Kylheku2016-09-261-0/+3
| | | | * txr.1: Left-anchored match in regsub with r^.
* doc: regex examples.Kaz Kylheku2016-09-251-0/+21
| | | | * txr.1: Examples for f^$, f^ and f$.
* doc: fconv examples.Kaz Kylheku2016-09-251-0/+25
| | | | * txr.1: New examples for awk macro fconv.
* awk macro: proper fs semantics in paragraph mode.Kaz Kylheku2016-09-251-17/+12
| | | | | | | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): New slots: par-mode, par-mode-fs, par-mode-prev-fs. (sys:awk-state rec-to-f): In paragraph mode, detect that fs has changed since the last call. In that case, take the user's fs and add to it a newline match. If it is a regex, take the source, add the syntax and recompile the regex. If it's a string, build regex around it and compile. (sys:awk-state loop): Maintain the par-mode-t variable in the state structure as the rs value triggers transitions into or out of paragraph mode. * txr.1: Updated documentation for rs.
* New function: regex-source.Kaz Kylheku2016-09-251-0/+15
| | | | | | | | | * regex.c (regex_source): New function. (regex_init): regex-source intrinsic registered. * regex.h (regex_source): Declared. * txr.1: Documented.
* awk macro: support paragraph mode.Kaz Kylheku2016-09-251-0/+35
| | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state loop): If the rs variable is nil, provide a record reader which reads paragraphs, like under Awk's paragraph mode when RS is blank. This does not support the requirement that newline is always a field separator, regardless of the value of FS. * txr.1: Documented paragraph mode.
* awk macro: handle dynamic changes in rs variable.Kaz Kylheku2016-09-251-0/+12
| | | | | | | | * awk.tl (sys:awk-state loop): The loop now notices when rs or krs changes and switches to a new record-adapter or to the raw stream as necessary. * txr.1: Notes added about changes to rs and krs.
* New strlist list input stream type.Kaz Kylheku2016-09-241-0/+12
| | | | | | | | | | | | | | | | | | * stream.c (struct strlist_in): New struct type. (strlist_in_stream_mark, strlist_in_get_line, strlist_in_get_char, strlist_in_unget_char, strlist_in_get_prop, strlist_in_get_error_str): New static functions. (strlist_in_ops): New static struct. (make_strlist_input_stream): New function. (stream_init): Register make-strlist-input-stream intrinsic. * stream.h (make_strlist_input_stream): Declared. * txr.1: Documented make-strlist-input-stream. Call fill_stream_ops on new strlist_in_ops struct to fill in common default stream operations.
* doc: add to fconv documentation.Kaz Kylheku2016-09-241-0/+14
| | | | | * txr.1: Documenting effect of fconv on rec, and its return value.
* doc: take advantage of orec in awk example.Kaz Kylheku2016-09-241-0/+7
| | | | | * txr.1: POSIX-derived example 1 can be made to conform to the original with orec.
* awk macro: add orec variable.Kaz Kylheku2016-09-241-1/+28
| | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): New slot, orig-rec. (sys:awk-state loop): Initialize orig-rec after reading each record. (sys:awk-let): Provide orec symbol macro. * txr.1: Document orec variable.
* doc: add awk macro examples.Kaz Kylheku2016-09-241-0/+213
| | | | | * txr.1: Adding 19 examples, converted from POSIX standard's Awk eamples.
* awk macro: use range test logic for clause conditions.Kaz Kylheku2016-09-241-1/+11
| | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:range-test): Function renamed to sys:awk-test, since it's not just for ranges. (sys:awk-let): Uses of sys:range-test follow rename. sys:awk-test introduced into expansion of cond parts of cond-action clauses. * txr.1: Documented new behavior (conditions can produce a function or regex, which is implicitly invoked on rec).
* doc: use .coSS only for headings with identifiers.Kaz Kylheku2016-09-241-2/+2
| | | | * txr.1: Change .coSS to .SS* in two places.
* awk macro: fconv conversions iz, xz, oz, bz and rz.Kaz Kylheku2016-09-241-0/+16
| | | | | | | * share/txr/stdlib/conv.tl (sys:conv-let): New flets iz, oz, xz, bz and rz. * txr.1: Documented under fconv.
* New functions: tofloatz and tointz.Kaz Kylheku2016-09-241-0/+43
| | | | | | | | | | * arith.c (tofloatz, tointz): New functions. * arith.h (tofloatz, tointz): Declared. * eval.c (eval_init): Register tofloatz and tointz intrinsics. * txr.1: Documented new functions.
* Bugfix: out-of-range negative indices into lists.Kaz Kylheku2016-09-231-4/+36
| | | | | | | | | | | | | | | | | | We have a problem not handling negative list indices which index beyond the beginning of the list. Such accesses are just storing and retrieving the first element! * lib.c (listref): If a negative index is still negative after the length of the list is added to it, then return nil. Do not return car(list)! (listref_l): Similary, do not return car_l(list) if the index is less than zero, so that an error occurs for an out-of-range negative index. * txr.1: Update the documentation for ref to describe these indexing constraints, and also to include hashes.
* awk macro: support regexes better in ranges.Kaz Kylheku2016-09-231-1/+29
| | | | | | | | | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-compile-time): New slot, rng-rec-temp. Specifies the name of a temporary variable which is scoped over the evaluation of ranges, and which caches a reference to the current record string. (sys:range-test): New function. (awk:let): Rename the original rng macrolet to sys:rng, and introduce rng as a wrapper around it which inserts the logic for calling the regex or function that might emerge from the evaluation of from-expr or to-expr. (awk): If ranges are present in the syntax, then bind the temporary variable which caches the record around the evaluations of the ranges. * txr.1: Document new special behavior of rng w.r.t functions and regexes. Add admonition against modifying rec and some other awk variables from range expressions.
* Switch regex type from sys:regex to regex.Kaz Kylheku2016-09-231-0/+5
| | | | | | | | | | | | | | | | | The sys:regex internal symbol was historically used when derivative-based regexes had a S-exp representation headed by that symbol. It had to be a private symbol. Now the regex symbol is only used as the COBJ class type for regexes; it makes no sense for it to be in the sys package. We want user code to be able to refer to this type using a public symbol. * lib.c (obj_init): Intern the regex symbol stored in regex_s in user_package. * txr.1: Include regex in the type graph in the Object Type section, and in the type list under the typeof function.
* New regex functions: m^$, m^, m$, and others.Kaz Kylheku2016-09-231-0/+233
| | | | | | | | | | | | | | | | | | | * regex.c (do_match_full, do_match_full_offs, do_match_left, do_match_left_offs, do_match_right, do_match_right_offs): New static functions. (regex_match_full_fun, regex_match_right_fun, regex_match_full, regex_match_left, regex_match_right, regex_range_full, regex_range_left, regex_range_right): New functions. (regex_init): Register f^$, f^, f$, m^$, m^, m$, r^$, r^ and r$ intrinsics. * regex.h (regex_match_full_fun, regex_match_right_fun, regex_match_full, regex_match_left, regex_match_right, regex_range_full, regex_range_left, regex_range_right): Declared. * txr.1: Documented new functions.
* doc: add regex intro paragraph.Kaz Kylheku2016-09-231-0/+13
| | | | | * txr.1: New paragraph added under the Regular Expressions Library minor section.
* Semantics change in match-regex-right.Kaz Kylheku2016-09-221-19/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | The way the end-position argument works in match-regex-right and match-regst-right is poorly considered. It basically enforces a constraint that there is a match which ends at that position and does not go beyond. This patch changes it work right: the functions test that the regex matches up to that position, as if the string ended there. * regex.c (match_regex_right_old): New static function, identical to the previous match_regex_right. Since we won't ever be using this inside TXR from any other module, we don't make it external. (match_regex_right): Rewritten to new semantics. (match_regst_right_old): New static function; provides the semantics of the old match_regst_right based on match_regex_right_old. (regex_init): Register match-regex-right and match-regst-right intrinsics to the match_regex_right_old and match_regst_right_old functions if compatibility <= 150 is requested. Otherwise they go to the rewritten new functions. * txr.1: Documentation updated, and compat notes added.
* Fix match-regex not conforming to documentation.Kaz Kylheku2016-09-221-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation says that match-regex returns the length. Actually, it returns the position after the last character matched. This makes a difference when the match doesn't begin at character zero. The actual behavior is that of the match_regex C function which has behaved that way since the dawn of TXR, and internals depend on it behaving that way. So the internal function is being retained, and a new function is being registered as the match-regex intrinsic. The choice of binding for match-regex is subject to the compatibility option. The behavior of match-regst is also being fixed since its return value is incorrect due to this issue. Since its return value makes no sense at all (does not represent the matched text), it is not subject to the compatibility option; it is just fixed to conform with the documentation. * regex.c (match_regex_len): New function. (match_regst): Keep using match_regex, but use its return value properly. This simplifies the range extraction code, which is why match_regex works that way in the first place. (regex_init): Register match-regex to match_regex_len, unless compatibility <= 150 is requested; then register to match_regex. * regex.h (match_regex_len): Declared. * txr.1: Compatibility notes added.
* doc: fix regex function not mentioned in heading.Kaz Kylheku2016-09-221-1/+1
| | | | | * txr.1: search-regst added to heading of section which describes it.
* Regexes now callable as functions.Kaz Kylheku2016-09-221-6/+94
| | | | | | | | * lib.c (generic_funcall): Add case for regexes. Handle arguments in such a way that the string is always rightmost, with a view to convenient partial application. * txr.1: Documented in multiple places.
* Support functional argument in regsub.Kaz Kylheku2016-09-221-4/+18
| | | | | | | | | * regex.c (regsub): Allow the second argument to be a function, which is called with str as an argument, and returns a range which indicates what part of the string is to be replaced, or else nil. * txr.1: Documented functional argument of regsub.
* Support negative positions in regex matching funs.Kaz Kylheku2016-09-211-1/+20
| | | | | | | | | * regex.c (match_regex, match_regex_right): Detect a negative start or end position, respectively, and add the string length to it. If it is still negative, bail with nil. * txr.1: Documented.
* doc: about assignment to nonexistent awk fields.Kaz Kylheku2016-09-211-0/+10
| | | | | * txr.1: Adding remark that assignment to nonexistent fields isn't permitted, unlike in Awk.
* doc: revised descrs of awk vars fs, ft an kfs.Kaz Kylheku2016-09-211-121/+65
| | | | | | | | * txr.1: fs and ft are described in one simplified section. The default behavior when they are both nil is described simply as token extraction, which is how it is now implemented. Some verbiage is reduced in the krs description.
* New library feature: imperative list building.Kaz Kylheku2016-09-201-0/+299
| | | | | | | | | | | * lisplib.c (build_set_entries, build_instantiate): New static functions. (dlt_register): Register dynamic loading of build.tl via the two new functions. * share/txr/stdlib/build.tl: New file. * txr.1: Documented everything.
* Version 150.txr-150Kaz Kylheku2016-09-181-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* New awk operator: fconv.Kaz Kylheku2016-09-181-0/+113
| | | | | | | | | * 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.
* New awk variable: krs.Kaz Kylheku2016-09-171-4/+24
| | | | | | | | | | | * 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.
* New awk variables: ft and kfs.Kaz Kylheku2016-09-161-9/+152
| | | | | | | | | | * 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-161-2/+7
| | | | | | | | | | | * 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-161-1/+13
| | | | | | | | | | | | | | | * 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.
* key function argument on remq, remql and remqual.Kaz Kylheku2016-09-151-7/+18
| | | | | | | | | | | | | | | | | * 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-151-0/+43
| | | | | | | | | * 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-141-14/+5
| | | | | | | | * 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.