summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* nuke trailing newlines from exception messages.Kaz Kylheku2016-10-073-8/+8
| | | | | | | | | * signal.c (set_signal_handler, get_sign_handler): Eliminate newline in exception messages. * stream.c (unimpl, formatv): Likewise. * unwind.c (uw_block_abscond): Likewise.
* small bug in format: handle missing format char.Kaz Kylheku2016-10-071-0/+2
| | | | | | | | * stream.c (formatv): When the format string ends at the point where the format character is expected to occur, do not emit an error about #\nul being an unknown format directive character; emit an error that the character is missing.
* bug: heap backpointer assignment in static-slot-ensure.Kaz Kylheku2016-10-071-1/+1
| | | | | | | | * struct.c (static_slot_ens_rec): Neglected use of set macro to store newval in freshly allocated slot, which means we corrupt garbage collection if this causes an old generation objet to point to a new generation object.
* bug: wrong way assert in static slot gc marking.Kaz Kylheku2016-10-071-1/+1
| | | | | | * struct.c (struct_type_mark): We must assert that sl->store is nil if we are not marking it, not that it is non-nil.
* Version 152.txr-152Kaz Kylheku2016-10-046-458/+498
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: ranges are immutable.Kaz Kylheku2016-10-041-2/+5
| | | | | * txr.1: document that ranges are immutable and expand the surrounding wording a bit.
* doc: small change under defstruct.Kaz Kylheku2016-10-041-1/+1
| | | | | * txr.1: describe slot specifier as (name init-form) rather than (symbol init-form).
* length and empty functions support ranges.Kaz Kylheku2016-10-042-11/+64
| | | | | | * lib.c (length, empty): Handle RNG in switch. * txr.1: Documented.
* New awk clauses :set and :set-file.Kaz Kylheku2016-10-042-3/+22
| | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-expander): Recognize :set and :set-file cases. * txr.1: Documented :set and :set-file, replacing some :begin uses with :set in the examples.
* New function rra.Kaz Kylheku2016-10-033-0/+113
| | | | | | | | | * regex.c (range_regex_all, regex_range_all): New functions. (regex_init): Register rra intrinsic function. * regex.c (range_regex_all, regex_range_all): Declared. * txr.1: Documented rra.
* Coding convention fix in plus function.Kaz Kylheku2016-10-031-3/+1
| | | | | * arith.c (plus): Eliminate compound statement braces around case that consists of one return statement.
* New rr function.Kaz Kylheku2016-10-033-5/+62
| | | | | | | | | | * regex.c (regex_range_search): New function. (regex_init): Register regex_range_search as rr intrinsic. * regex.h (regex_range_search): Declared. * txr.1: Documented rr, and added reference to it in description of regex-range.
* search-regex improvement: negative start and more.Kaz Kylheku2016-10-032-48/+110
| | | | | | | | | | | | * regex.c (search_regex): Handle negative starting positions according to the convention elsewhere and fail excessively negative ones. Consistently fail on starting positions exceeding the length of the string. Handle zero length matches by reporting them against the start position or position one past the last character, based on the value of from-end. * txr.1: search-regex documentation updated.
* doc: missing documentation on less over ranges.Kaz Kylheku2016-10-031-2/+22
| | | | | | * txr.1: Document how the less function operates on ranges, and that ranges rank between numbers and strings on the comparison precedence for dissimilar types.
* doc: update less on vectors text.Kaz Kylheku2016-10-031-3/+8
| | | | | * txr.1: Improve wording in the description of how the less function operates on vectors.
* Support arithmetic operations on ranges.Kaz Kylheku2016-10-022-0/+221
| | | | | | | * arith.c (plus, minus, neg, abso, mul, trunc, divi, zerop, gt, lt, ge, le, numeq): Support RNG type. * txr.1: Documented arithmetic properties of ranges.
* Synchronize license comments with LICENSE.Kaz Kylheku2016-10-0177-1237/+1314
| | | | | | | | | | | | | | | | | | | | * 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.
* Check for overflow in static slot counter.Kaz Kylheku2016-10-011-1/+8
| | | | | * struct.c (make_struct_type, static_slot_ens_rec): Throw an error if there are too many static slots.
* 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-305-124/+516
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* linenoise: bugfix: handle ESC in extended command.Kaz Kylheku2016-09-301-1/+2
| | | | | | | | | | | | If the user types Ctrl-X and then an arrow key, we don't want garbage. We let an ESC received in Ctrl-X extended command mode to be processed normally and cancel that mode. * linenoise.c (edit): Bypass the extended command switch if the character is ESC. Then down below in the ESC case of the regular command switch, clear extended mode.
* Version 151.txr-151Kaz Kylheku2016-09-276-660/+735
| | | | | | | | | | * 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-273-6/+10
| | | | | | | | | | * 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-273-2/+80
| | | | | | | | | * 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.
* Use *load-path* in load/include directive.Kaz Kylheku2016-09-262-2/+2
| | | | | | | | | | | | | | * match.c (v_load): Obtain parent load path from *load-path* variable, rather than from source location info associated with the directive. This changes the semantics of when a @(load ...) occurs in code included via @(include ...). That @(load ...) is processed in the *load-path* context of the parent, rather than the include. * tests/011/txr-case.txr: Load txr-case.txr from the standard library, rather than include it. Otherwise txr-case.txr looks for txr-case.tl in tests/011.
* Get rid of sys:load; load becomes function.Kaz Kylheku2016-09-263-30/+11
| | | | | | | | | | | | | | | | | * 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-266-71/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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^.
* Change misleading missing license diagnostic.Kaz Kylheku2016-09-261-3/+3
| | | | | | | * txr.c (license): Do not say that the TXR installation might be unlicensed; there is no such licensing condition that the license must be present at run-time. Just state the fact of being unable to display it.
* doc: regex examples.Kaz Kylheku2016-09-251-0/+21
| | | | * txr.1: Examples for f^$, f^ and f$.
* Flurry of regex bugfixes.Kaz Kylheku2016-09-251-11/+27
| | | | | | | | | | | | | | | | | | | | | | | | | * regex.c (match_regex): Bail if pos is too positive, beyond length of string. (match_regex_right): Include the pos == end case in the iteration, so we can match an empty suffix of the string. The inner loop guard takes care of not feeding any characters from the string into the regex machine in this case; we just feed the terminating zero to get the final state. (match_regst): Normalize a negative pos, otherwise the sub_str calculation will be junk, since match_regex returns a normalized position. After normalizing, check that if the position is still negative, the match must fail. (match_regst_right_old, match_regst_right): Use zero rather than t as the range end in sub_str. That way if len is zero and neg(len) produces zero, an empty string will be sliced out. For negative values, the zero serves as one position beyond the last char, just like t. (do_match_full_offs, regex_match_full, regex_range_full, regex_range_left): Fail match if normalized starting pos is negative. (regex_range_right): Fix completely bogus calculation of the returne range in the case when the end position defaults to the string length.
* doc: fconv examples.Kaz Kylheku2016-09-251-0/+25
| | | | * txr.1: New examples for awk macro fconv.
* regex.c: code formatting.Kaz Kylheku2016-09-251-1/+1
| | | | * regex.c (puts_clear_flag): Fix bad indentation.
* awk macro: code formatting.Kaz Kylheku2016-09-251-4/+4
| | | | | * share/txr/stdlib/awk.tl (awk): Fix indentation in two places.
* awk macro: proper fs semantics in paragraph mode.Kaz Kylheku2016-09-252-30/+39
| | | | | | | | | | | | | | | | | * 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-253-0/+23
| | | | | | | | | * regex.c (regex_source): New function. (regex_init): regex-source intrinsic registered. * regex.h (regex_source): Declared. * txr.1: Documented.
* Bugfix in regex printing: & operator.Kaz Kylheku2016-09-251-1/+1
| | | | | * regex.c (print_rec): Fix checking arg1 for consp but accessing arg2.
* awk macro: support paragraph mode.Kaz Kylheku2016-09-252-9/+57
| | | | | | | | | | | * 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: loop uses closure to read records.Kaz Kylheku2016-09-251-23/+27
| | | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state loop): Refactor code so that record-processing loop obtains a lambda which is called to extract a record. If rs and krs did not change, then the same lambda is obtained from a variable which caches it. The get-rec-reader local function thus encapsulates the whole record delimiting strategy as well as changes to the variables. With this structure, it will be relatively easy to add support for Awk's paragraph mode, which is notably missing in the implementation.
* awk macro: handle dynamic changes in rs variable.Kaz Kylheku2016-09-252-20/+40
| | | | | | | | * 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-243-0/+150
| | | | | | | | | | | | | | | | | | * 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-242-3/+32
| | | | | | | | | | * 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-242-5/+16
| | | | | | | | | | | * 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: exit if no cond-action clauses.Kaz Kylheku2016-09-241-12/+14
| | | | | | | | * share/txr/stdlib/awk.tl: If there are no cond-action clauses in the macro, do not generate the main record processing lambda, or the begin-file and end-file lambdas, and do not generate the call to the awk state object's loop method.
* awk macro: fconv conversions iz, xz, oz, bz and rz.Kaz Kylheku2016-09-242-1/+27
| | | | | | | * 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-244-0/+63
| | | | | | | | | | * 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.