summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* New function, split*.Kaz Kylheku2016-01-174-8/+63
| | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register split*. * lib.c (split_star_func): New static function. (partition_split_common): Take pointer-to-function argument instead of boolean. Hoist this C function into the lazy cons. (partition): Pass pointer to partition_func ito partition_split_common, intsead of a flag requesting the use of partition_func. (split): Pass apointer to split_func into partition_split_common. (split_star): New function. * lib.h (split_star): Declared. * txr.1: Documented split*.
* Fix incorrect split examples.Kaz Kylheku2016-01-171-3/+3
| | | | | | | * txr.1: examples were calling split as if it were variadic, accepting multiple indices as separate arguments. This is not the case; a sequence of indices must be passed as one argument.
* partition* bugfix: ignore negative indices consistently.Kaz Kylheku2016-01-171-9/+14
| | | | | * lib.c (partition_star): Eliminate strange behaviors when a negative index is given as an argument.
* partition* bugfix: incorrect behavior for 0.Kaz Kylheku2016-01-171-1/+1
| | | | | | | lib.c (partition_star): In the special case that the indices argument is given as the integer zero, the function wrongly returned just the remaining piece of the sequence after zero, rather than a list containing this piece.
* Apply partition/split bugfix to partition*.Kaz Kylheku2016-01-171-4/+4
| | | | | | * lib.c (partition_star): The same issues that were addressed in TXR 126 in 2015-11-29 commits and 2015-11-24 commits must also be addressed here.
* Bugfix: env-hash discarding characters after =.Kaz Kylheku2016-01-171-2/+5
| | | | | * sysif.c (make_hash): Fix incorrect treatment of env values which contain equal signs, due to careless use of split_str.
* Version 132.txr-132Kaz Kylheku2016-01-156-549/+573
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Retroactively fix recent inconsistent formatting.Kaz Kylheku2016-01-151-10/+10
|
* New :mandatory keyword in until/last clauses.Kaz Kylheku2016-01-154-24/+132
| | | | | | | | | | | | | | | | | | | * match.c (mandatory_k): New keyword variable. (h_coll, v_gather, v_collect): Implement :mandatory logic. (syms_init): Initialize mandatory_k. * parser.l (grammar): The UNTIL and LAST tokens must be matched similarly to collect, without consuming the closing parenthesis, allowing a list of items to be parsed between the symbol and the closure, in the NESTED state. * parser.y (gather_clause, collect_clause, elem, repeat_parts_opt, rep_parts_opt): Adjust to new until/last syntax. In the matching productions, the abstract syntax changes to incorporate the options. In the output productions, we throw an error if options are present. * txr.1: Documented :mandatory for collect, coll and gather.
* Gather bugfix: support empty :vars.Kaz Kylheku2016-01-151-2/+5
| | | | | | | | * match.c (v_gather): Use getplist_f to distinguish the :vars nil case just like v_collect does. A :vars nil gather could be useful; it says none of the variables are strictly required. In any case, it is not correct to treat :vars nil as if :vars weren't there.
* Bugfix: *print-flo-format* used for integer output.Kaz Kylheku2016-01-141-0/+2
| | | | | * lib.c (obj_print_impl): Handle NUM and BGNUM separately from FLNUM, thorugh a hard-coded "~s" format.
* Improve n-ary minus like newly added division.Kaz Kylheku2016-01-141-3/+13
| | | | | | * lib.c (minusv): Avoid reduce_left overhead in common two-argument case, and just call binary minus function directly.
* Optimization in n-ary numeric functions.Kaz Kylheku2016-01-141-5/+12
| | | | | * lib.c (nary_op): Avoid the overhead of reduce_left in the two-argument case and just call the binary function.
* Fix omission: the / function becomes n-ary.Kaz Kylheku2016-01-134-3/+25
| | | | | | | | | | * eval.c (eval_init): Register / function to divv instead of divi. * lib.c (divv): New function. * lib.h (divv): Declared. * txr.1: Documented.
* bugfix: no location info for unbound var in dohash.Kaz Kylheku2016-01-131-5/+5
| | | | | | | * eval.c (do_expand): Add missing rlcp in the construction of the return value of the clause which expands a dohash. Let's make it a rlcp_tree. Test case: (dohash (a b c) d e) with c unbound.
* The identity function gets an alias: use.Kaz Kylheku2016-01-132-1/+23
| | | | | | * eval.c (eval_init): Register "use" as alias for identity. * txr.1: Documented use function.
* Pastes produced using :read are now numbered.Kaz Kylheku2016-01-131-4/+6
| | | | | | | | * parser.c (read_eval_read_last): New argument: counter. Incorporate counter into name of stream. (repl): Pass prev_counter into read_eval_read_last so the paste inherits the line number of the :read command.
* Support crypt function.Kaz Kylheku2016-01-133-0/+73
| | | | | | | | | | * configure: Check for availability of crypt, and what library must be used. * sysif.c (crypt_wrap): New static function. (sysif_init): Register crypt intrinsic. * txr.1: Documented crypt.
* Don't clobber conf_ldflags.Kaz Kylheku2016-01-131-1/+1
| | | | | * configure: the do-we-need-to-set-stack-size test shouldn't overwrite conf_ldflags, but add to it.
* Support extra linker flags.Kaz Kylheku2016-01-131-1/+1
| | | | | * Makefile (EXTRA_LDFLAGS): New variable, interpolated into LDFLAGS.
* Version 131.txr-131Kaz Kylheku2016-01-124-4/+32
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* Fix broken print of semicolon after ctrl char.Kaz Kylheku2016-01-121-1/+1
| | | | | | | | * lib.c (out_str_char): If semi-flag is true, we must issue a semicolon not only when the next character is a hex digit, but also when it is a semicolon, so that "\x1F;;" isn't rendered as "\x1F;" where the semicolon character has disappeared.
* Regex printing not escaping [ and ].Kaz Kylheku2016-01-121-1/+2
| | | | | * regex.c (print_rec): Handle '[' and ']' in backslash-adding switch.
* Print control chars in regexes using \x.Kaz Kylheku2016-01-123-54/+72
| | | | | | | | | | | | | | | | | | | | * lib.c (out_str_char): Static function becomes extern. * lib.h (out_str_char): Declared. * regex.c (puts_clear_flag, putc_clear_flag): New static functions. (print_class_char): Take semicolon flag argument. Use out_str_char to render characters not escaped locally. Clear the semicolon flag. (paren_print_rec): Take semicolon flag argument, and pass it down. Clear it when printing parentheses. (print_rec): Take semicolon flag argument, and pass down to lower level functions. Use putc_clear_flag and puts_clear_flag instead of put_string and put_char. Use out_str_char for char object not esaped locally. (regex_print): define semi_flag and pass it down to print_rec.
* Pretty-print DEL and U+DCxx str char using \xHEX.Kaz Kylheku2016-01-121-1/+1
| | | | | | * lib.c (out_str_char): Don't print all characters above space as themselves. Treat 7F and U+DCxx as control chars to be printed using hex escape.
* regex_print: [ and ] in char class must be escaped.Kaz Kylheku2016-01-121-1/+1
| | | | * regex.c (print_class_char): Add missing character cases.
* Remove redundant assert in mem allocation functions.Kaz Kylheku2016-01-101-3/+0
| | | | | | * lib.c (chk_strdup, chk_strdup_utf8, chk_copy_obj): No need to assert !async_sig_enabled since the lower level chk_malloc or chk_malloc does it.
* Reduce scope of variable in cat_str.Kaz Kylheku2016-01-101-2/+2
| | | | | * lib.c (cat_str): Unnecessarily scoped len variable moves to inner scope.
* New internal function scat: variable arg cat_str.Kaz Kylheku2016-01-104-7/+88
| | | | | | | | | | | | | | Avoids consing up list of strings. * lib.c (vscat): New static function. (scat): New function. (lazy_str): Use scat instead of cat_str. * lib.h (scat): Declared. * eval.c (format_field): Use scat instead of cat_str. * parser.c (open_txr_file, read_eval_stream): Likewise.
* GC-correct order in copy_lazy_str.Kaz Kylheku2016-01-101-2/+2
| | | | | | * lib.c (copy_lazy_str): Eliminate pointless initialization of ls.list and to nil. Make ls.prefix initialization the last step since it's the only operation which conses.
* Don't record form as its own macro origin.Kaz Kylheku2016-01-091-2/+2
| | | | | | | * eval.c (set_origin): Add form != origin to the condition for recording the ancestry. (expand_macro): Use set_origin function instead of direct call to sethash.
* Rework lazy string optimization done in TXR 118.Kaz Kylheku2016-01-091-26/+10
| | | | | | | | | | | | | This is also a bugfix. Padding up the index to be at least 1024 characters longer than the existing prefix was dumb and wrong; it changes the semantics of code which restores the list from the lazy string, like the @(freeform) directive. How much of the string is forced is visible to the caller! * lib.c (lazy_str_force, lazy_str_force_upto): Don't collect pieces from the lazy list and then catenate them in one pass. Instead, use the existing function string_extend, which grows the string exponentially.
* Use struct instead of cons for lazy string fields.Kaz Kylheku2016-01-093-20/+37
| | | | | | | | | | | | | | | | * gc.c (finalize): Must free the dynamic structure attached to the LSTR type now. (mark_obj): Must mark interior of LSTR type's props structure. * lib.c (lazy_sub_str, copy_lazy_str): Copy props structure. (lazy_str): Allocate and initialize props structure. (lazy_str_force, lazy_str_put, lazy_str_force_upto, lazy_str_get_trailing_list, out_lazy_str): Follow representation change. * lib.h (struct lazy_string_props): New struct type. (strut lazy_string): Member opts replaced with props pointer to struct lazy_string_props.
* New internal function for copying malloced object.Kaz Kylheku2016-01-092-0/+9
| | | | | | * lib.c (chk_copy_obj): New function. * lib.h (chk_copy_obj): Declared.
* Squash compiler complaint about _BSD_SOURCE.Kaz Kylheku2016-01-081-1/+1
| | | | | | | | | | | | Some glibc nincompoops have suddenly decided, in their infinite wisdom, that a wise move is to deprecate the _BSD_SOURCE feature selection macro with annoying preprocessor warnings insisting that _DEFAULT_SOURCE be used instead, even though the functions convered by _BSD_SOURCE still exist. * configure: Let's test for _DEFAULT_SOURCE ahead of _BSD_SOURCE.
* Fix Valgrind integration breakage.Kaz Kylheku2016-01-071-1/+1
| | | | | | * signal.c (sig_mask): Pass address of real_oldset to VALGRIND_MAKE_MEM_DEFINED, rather than a copy of the object itself.
* Version 130.txr-130Kaz Kylheku2016-01-056-324/+372
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Bad formatting under data directive.Kaz Kylheku2016-01-051-1/+1
| | | | txr.1: Improperly closed .cblk around example.
* Clarify same-sequence semantics of swap, rotate, shift.Kaz Kylheku2016-01-041-0/+42
| | | | | | * txr.1: Document what happens, or else what isn't specified, if swap, rotate or shift are used on ranges of the same sequence.
* Static slots mustn't trigger instantiation.Kaz Kylheku2016-01-041-2/+3
| | | | | | | | | It is already documented that accessing the instance slots (not static slots) of a lazy struct forces it to instantiate, thus this is a doc conformance bug. * struct.c (lookup_slot): Only call check_init_lazy_structs in the code paths where we calculate the location of an instance slot.
* Revert chr-isdigit/isxdigit, provide new functions.Kaz Kylheku2016-01-044-8/+32
| | | | | | | | | | | | | | | | | | | It was a mistake to change the semantics of the return value of chr-isdigit and chr-isdigit. It breaks code like [partition-by chr-isdigit ...]. The behavior of chr-isdigit and chr-isxdigit is restored to returning t and nil. New chr-digit and chr-xdigit functions are introduced for returning the digit value or nil. * eval.c (eval_init): Register chr-digit and chr-xdigit intrinsics. * lib.c (chr_isdigit, chr_isxdigit): Restore old behavior. (chr_digit, chr_xdigit): New functions. * lib.h (chr_digit, chr_xdigit): Declared. * txr.1: Everything documented.
* defstruct: order function slots before other static slots.Kaz Kylheku2016-01-032-15/+48
| | | | | | | | | | | | | | | | | This allows the initializer expressions for static slots to instantiate objects, and those instances can rely on methods being set up. * share/txr/stdlib/struct.tl (sys:prune-nil-inits): Recognize :function keyword as denoting a static slot. (defstruct): Represent methods and functions as (:function ...) items rather than (:static ...) so they can be distinguished. Function slots appear before other static slots in the static slot list, and their initializing code is placed into the the static-initfun lambda of the sys:make-struct-type call in this order. * txr.1: Documented.
* Better bad slot syntax diagnostic in defstruct.Kaz Kylheku2016-01-031-1/+4
| | | | | | * share/txr/stdlib/struct.tl (defstruct): Issue different error message for a slot specifier which isn't a symbol, and wasn't recognized as a special syntax.
* Bad formatting under destruct.Kaz Kylheku2016-01-021-1/+1
| | | | * txr.1: Missing .desc macro call.
* Bad formatting under RangesKaz Kylheku2016-01-021-0/+3
| | | | * txr.1: Add missing .desc macro invocations.
* Wording change in error_trace.Kaz Kylheku2016-01-021-2/+2
| | | | | * eval.c (error_trace): Change "possibly triggered by" to "during evaluation of".
* Use last-form-evaled mechanism for pattern language.Kaz Kylheku2016-01-023-6/+20
| | | | | | | | | | | | | | We need this now, since file system errors aren't handled in the pattern language any more, after the complex_open refactoring. * eval.c (set_last_form_evaled): New function. * eval.h (set_last_form_evaled): Declared. * match.c (do_match_line, match_files): Save, set up and restore last_form_evaled via set_last_form_evaled function.
* Bugfix: premature open of data source.Kaz Kylheku2016-01-011-1/+1
| | | | | | | | | match.c (open_data_source): complex_open was being called before the check against opening the data source because the query starting with a non-matching directive. This is moved down into a more nested scope. This bug was found thanks to complex_open now throwing exceptions.
* Handle nothrow semantics down in complex_open.Kaz Kylheku2016-01-011-37/+12
| | | | | | | | | * match.c (file_err): Static function removed. (complex_open): New argument, nothrow. Catch exceptions derived from error only if nothrow is true. (v_output, open_data_source): Pass nothrow flag down to complex_open. Eliminate unnecessary error checking.
* Hacky struct fpip gone; complex_open returns stream.Kaz Kylheku2016-01-011-74/+26
| | | | | | | | | | | | | | | * match.c (enum fpip_close): Removed. (struct fpip, fpip_t): Removed. (complex_open): Use high level Lisp library function to return appropriate stream type, and return it directly. Exceptions are turned to a nil return to emulate old behavior. (complex_open_failed, complex_snarf, complex_stream): Static functions removed. (v_output, open_data_source): Use new interface of complex_open. complex_open_failed is just a nile check. complex_stream is a noop, and complex_snarf is just lazy_stream_cons.