summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Overhaul where funtion.Kaz Kylheku2016-10-131-14/+43
| | | | | * lib.c (where): Implement faster ref-based access for vectors and strings. Support abstract sequence structs.
* doc: clarification under nullify method.Kaz Kylheku2016-10-131-1/+2
| | | | | | * txr.1: the nullify method need not return the object itself in the non-empty case; it may also return a sequence.
* Let some sequence functions work on structs.Kaz Kylheku2016-10-131-28/+32
| | | | | | * lib.c (in, sub, ref, search, rsearch, sel): These functions now accept struct objects that have the nullify, car and cdr methods.
* find-max and find-min support hashes.Kaz Kylheku2016-10-122-15/+76
| | | | | | | * lib.c (find_max): Restructured to implement separately for vectors and lists. Support hash tables. * txr.1: Document find-min and find-max for hashes.
* New accessor: hash-userdata.Kaz Kylheku2016-10-123-9/+51
| | | | | | | | | | | | | | The get-hash-userdata function is now deprecated in favor of hash-userdata, which is an accessor. * hash.c (hash_init): Register hash-userdata as a synonym for the same function as get-hash-userdata. * share/txr/stdlib/place.tl (hash-userdata): New defplace. * txr.1: Document new accessor, marking get-hash-userdata as a deprecated synonym. Replace references to get-hash-userdata with references to hash-userdata.
* listener: put each result into linenoise.Kaz Kylheku2016-10-121-0/+1
| | | | | | | | * parser.c (repl): After each successful command that produces a value, not only print the value but also call lino_set_result to install its string representation into the linenoise object, so it is available for insertion via Ctrl-X Ctrl-P.
* linenoise: Ctrl-X Ctrl-P edits result of command.Kaz Kylheku2016-10-122-0/+21
| | | | | | | | | | | | * linenoise/linenoise.c (struct lino_state): New member, result. (edit): Ctrl-P or p in extended mode cause result string to be inserted into the buffer. (lino_copy): Ensure result string in copy is null. (lino_cleanup): Free result string and set to null. (lino_set_result): New function. * linenoise/linenoise.h (lino_set_result): Declared.
* Include user data in hash read syntax.Kaz Kylheku2016-10-122-8/+40
| | | | | | | | | | | | | * hash.c (userdata_k): New keyword symbol variable. (hash_print_op): Print the userdata together with the hash flags as :userdata obj. (hashv): Parse out :userdata obj syntax from the argument list. This takes care of supporting it in the read notation and in the hash function. (hash_init): Initialize userdata_k. * txr.1: Documenting :userdata in hash read notation and hash function.
* Support gmtoff and zone in time struct.Kaz Kylheku2016-10-122-4/+52
| | | | | | | | | | | | | | * lib.c (gmtoff_s, zone_s): New symbol variables. (tm_to_time_struct): Copy tm_gmtoff and tm_zone into Lisp struct from struct tm, if the platform has these. (time_fields_to_tm): Zero/null-out the tm_gmtoff and tm_zone fields of the target structure, if the platform has them. (time_init): Intern the gmtoff and zone symbols, initializing the gmtoff_s and zone_s variables. Add the gmtoff and zone slots to the time struct. * txr.1: Documented new slots.
* doc: typo under html-encode*Kaz Kylheku2016-10-121-1/+1
| | | | * txr.1: necessary -> necessarily
* linenoise: bug in resubmit historic line when dupe.Kaz Kylheku2016-10-121-2/+4
| | | | | | | | | | | When Ctrl-X Enter is used to resubmit a line from the history, and it is a duplicate, it is not entered into the history. The position then doesn't advance to the next historic line. * linenoise/linenoise.c (lino_hist_add): Do add the line even if it is duplicate if the last submitted line was from the middle of the history.
* New function regex-from-trie.Kaz Kylheku2016-10-122-0/+78
| | | | | | | * filter.c (regex_from_trie): New static function. (filter_init): Register regex-from-trie intrinsic. * txr.1: Documented regex-from-trie.
* Support n-ary and and or operators in regex.Kaz Kylheku2016-10-101-1/+63
| | | | | | | | | | | Since much regex code assumes these are binary, the easiest and briefest approach is to implement a code transformation pass which rewrites n-ary forms into binary. * regex.c (reg_nary_unfold, reg_nary_to_bin): New functions. (regex_compile): Put raw sexp through reg_nary_to_bin to expand the nary syntax.
* Simplify some regex tree walking code.Kaz Kylheku2016-10-101-18/+10
| | | | | | | | | | * regex.c (reg_expand_nongreedy, reg_compile_csets): Generalize the compound_s case slightly by referring to sym rather than hard-coded compound_s. Then handle most of the regex operators under this same case. Their semantics are not relevant to the expansions being performed in these functions: all their arguments are regexes to be recursed over.
* Support curried args in method and meth.Kaz Kylheku2016-10-096-18/+115
| | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (meth): Take trailing arguments and pass them down to method, which now accepts them. * struct.c (struct_init): Register method intrinsic to the function method_args instead of the method function. (method_args_fun): New static function. (method_args): New function. Behaves like method function if args is empty, otherwise creates a function by means of method_args_fun. * struct.h (method_args_fun): Declared. * tests/012/oop.tl: New test case. * tests/012/oop.expected: Updated. * txr.1: Documented new features in method and meth, revising the documentation in the process.
* Support curried arguments in umethod and umeth.Kaz Kylheku2016-10-096-14/+71
| | | | | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (umeth): accept variadic arguments. Evaluate them using the dwim brackets and pass to umethod. The (fun umethod) trick is used to refer to the umethod in the function namespace even if it is shadowed by a variable. * struct.c (struct_init): Update registration of umethod to reflect its new variadic argument signature. (umethod_args_fun): New static function. (umethod): Return a function based on umethod_fun, as before, if there are no variadic args. Otherwise, use umethod_args_fun which deals with them. * struct.h (umethod): Declaration updated. * tests/012/oop.tl: Modest testcase for umeth with curried argument. * tests/012/oop.expected: Updated. * txr.1: Updated documentation of umeth and umethod.
* New function: args_cat_zap_from.Kaz Kylheku2016-10-092-0/+11
| | | | | | * args.c (args_cat_zap): New function. * args.c (args_cat_zap): Declared.
* Bugfix: wrong memset size in args_cat_zap.Kaz Kylheku2016-10-091-4/+5
| | | | | | | | | | | | | | | * args.c (args_copy): Use from->arg and from->fill in calculating the memcpy size. It doesn't matter in this function because the to and from are the same; however, this may be the origin of the copy and paste error that led to args_cat_zap problem. (args_copy_zap): Similar change to args_copy: be consistent in using the from side expressions. (args_cat_zap): Bugfix: the total size of the to arguments was used to zap the from side. This writes zeros past the end of the from arguments. Fixing by calculating the size in one place and using the calculated size.
* Version 153.txr-153Kaz Kylheku2016-10-074-4/+19
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* gc issues in clear_struct and replace_struct.Kaz Kylheku2016-10-071-0/+3
| | | | | | | * struct.c (clear_struct, reset_struct): Inform the garbage collector that the structure has been mutate, using the mut macro. This is required for correctness because the structure may be a mature object receiving young generation values.
* Check for self-assignment in replace_struct.Kaz Kylheku2016-10-072-12/+27
| | | | | | | | | * struct.c (replace_struct): If target and source are the same object, just do nothing and return target. * txr.1: Document self-assignment and return value of replace-struct.
* doc: mistakes in introduction of do operator.Kaz Kylheku2016-10-071-3/+3
| | | | | | * txr.1: Where do is being introduced, fix a statement that about op, which should be about do. Plus fix verb agreement.
* 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^.