summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Reduce header pollution caused by mpi.h.Kaz Kylheku2016-01-224-7/+12
| | | | | | | | | | | | | * eval.c: include <assert.h> that was previously coming via "mpi.h". * mpi/mpi.c: Includes of <stdio.h>, <ctype.h> and <assert.h> moved here. * mpi/mpi.h: Remove include of <stdio.h>, <ctype.h> and <assert.h>. Keeping <limits.h> for now; needed for CHAR_BIT. * mpi/mplogic.c: Needs <assert.h>
* Version 133.txr-133Kaz Kylheku2016-01-216-560/+586
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Support for Base 64 encoding.Kaz Kylheku2016-01-213-1/+208
| | | | | | | | | | | | | * filter.c (tobase64_k, frombase64_k): New keyword symbol variables. (col_check, get_base64_char, b64_code): New static functions. (base64_decode, base64_encode): New functions. (filter_init): Initialize new keyword symbol variables, and register base64-encode and base64-decode intrinsic functions. * filter.h (base64_encode, base64_decode): Declared. * txr.1: Documented base64-encode, base64-decode, as well as :tobase64 and :frombase64.
* bugfix: cached sigmask not populated from OS sigmask.Kaz Kylheku2016-01-191-3/+3
| | | | | | | | | | | | | | | This is responsible for behaviors like Ctrl-C being subsequently ignored after the first time a read is interrupted that way. * signal.c (sig_reload_cache): Eliminate the return statement which was making the memcpy expression unreachable! No warning from gcc. Also, since nobody checks the return value of this function and it doesn't provide one, let's make it void. There is no reason the sigprocmask would fail since the arguments are correct, but let's check its return value anyway.
* Add missing txr words to syntax highlighting.Kaz Kylheku2016-01-191-1/+2
| | | | | | * genvim.txr: Add missing single, first, last and other output repeat modifiers. Removing rep, since it's scraped from the table registration in match.c.
* Grammar fix under string quasiliterals.Kaz Kylheku2016-01-191-1/+1
| | | | * txr.1: "variables substitutions".
* Grammar fix under cadr function.Kaz Kylheku2016-01-191-1/+1
| | | | * txr.1: "They encodes" fixed.
* Fix regression: get-char on string input stream.Kaz Kylheku2016-01-191-2/+3
| | | | | | | | | | This happened on 2015-07-29, before TXR 111, "Deriving streams from the same base" commit. * stream.c (string_in_get_char): Must retrieve the character at the previous position, not the incremented one. Otherwise we lose the first character, and of course we blow up with an out of range access when we hit the end of the string.
* Relax input type constraint in vec-list.Kaz Kylheku2016-01-181-4/+1
| | | | | | | * lib.c (vec_list): Don't require input to be specifically a list, just any sequence that can be marched with cdr until nil. This commit also fixes the problem that the error message was still referring to the function as vector-list.
* New random-state-get-vec function.Kaz Kylheku2016-01-188-15/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | * arith.c (UINT_PTR_MAX_MP): New static variable. (biggnum_from_uintptr): New function. (in_uint_ptr_range): New static function. (c_uint_ptr_num): New function. (arith_init): Initialize UINT_PTR_MAX_MP. * arith.h (bignum_from_uintptr, c_uint_ptr_num): Declared. * eval.c (eval_init): Register random-state-get-vec. * mpi/mpi.c (mp_set_uintptr, mp_get_uintptr): New functions. (mp_set_intptr, mp_get_intptr): Expressed in terms of mp_set_uintptr and mp_get_uintptr. * mpi/mpi.h (mp_set_uintptr, mp_get_uintptr): Declared. * rand.c (make_random_state): Handle vector seed. (random_state_get_vec): New function. * rand.h (random_state_get_vec): Declared. * txr.1: Documented new feature in make-random-state and new random-state-get-vec function.
* random: wrong mask width for power-of-two moduli.Kaz Kylheku2016-01-184-61/+67
| | | | | | | | | | | | | | | | | | | | | | | This mistake causes wasteful behavior for power-of-two moduli in the random function, in both the bignum and fixnum cases. For instance, the modulus 16 is taken to be 17 bits wide. But we really want the width 16: the number of bits needed for values in the range [0, 16). The result isn't wrong, but the loop generates 17-bit random numbers, and then throws away those which equal or exceed the modulus, which is wasteful. * mpi/mpi.c (mp_is_pow_two): New function. * mpi/mpi.h (mp_is_pow_two): Declared. * rand.c (random): In bignum case, after counting bits in the modulus, subtract 1 if the modulus is a power of two. In the fixnum case, subtract 1 from the modulus and then count the bits in the reduced value. * tests/013/maze.expected: regenerate due to different prng behavior.
* Don't allow non-positive modulus in rand and random.Kaz Kylheku2016-01-182-20/+29
| | | | | | | | | | * rand.c (random): In fixnum case, allow only m >= 1. The code is restructured so that this check is done before we do some arithmetic with derived values, where the behavior can become undefined. * txr.1: Document the restriction on modulus range for rand and random.
* 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.