summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* regex: accept-folding optimization.Kaz Kylheku2017-09-121-0/+23
| | | | | | | | | | | | In this optimization, we identify places in the NFA graph where empty states transition to accept states. We eliminate these transitions and turn the empty states into accept states. Accept states which thereby become unreachable from the start state are pruned away. * regex.c (nfa_fold_accept): New static function. (nfa_optimize): Add a pass which applies nfa_fold_accept to all states.
* regex: eliminate nfa_accept state type.Kaz Kylheku2017-09-121-20/+26
| | | | | | | | | | | | | | | | | | | | | | | | | Acceptance states are instead represented by adding an accept flag to nfa_empty states. This will support an optimization which eliminates accept states that are referenced only by empty states. * regex.c (nfa_kind_t): Enum member nfa_accept removed. (struct nfa_state_accept): Renamed to nfa_state_any. (struct nfa_state_empty): New member, accept. (union nfa_state): Member a changes from struct nfa_state_accept to struct nfa_state_any. (nfa_accept_state_p): New macro. (nfa_state_accept): Now makes an nfe_empty type state, with no transitions out and the accept flag set. (nfa_state_empty): Initialize accept flag to zero. (nfa_state_empty_convert): Set the accept flag to zero. (nfa_state_merge): Use new macro in assertion. (nfa_map_states): Remove nfa_accept switch case. (nfa_thread_epsilons): We must not eliminate an empty state which is an acceptance state, even if it meets the other conditions. (nfa_closure): Use a local variable to eliminate repetition of set[i] expression. Test for accept state using new macro. (nfa_move_closure): Test for accept state using new macro.
* regex: epsilon-threading optimization on NFA graph.Kaz Kylheku2017-09-121-1/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is something done for the sake of faster NFA simulation. I think it's glossed over in regex literature because it makes no difference in a NFA to DFA transformation. Fewer states in the graph means less work in the nfa_move_closure function at regex run time. In the NFA graph, there can occur empty states which are useless. These are states which hold only one epsilon transition. Those states can be replaced by whatever state their epsilon transition points to. The terminology is inspired by "jump threading" in code optimization, whereby if a branch takes place to an instruction which holds an unconditional branch, the original branch can be retargetted to go to the ultimate target. I.e. we turn: x e S0 ---> S1 ----> S2 where e denotes an epsilon transition, and x represents any kind of transition to: x S0 ---> S2 We can also eliminate empty states which have no transition; those can be replaced by a null pointer. I suspect these do not actually occur. * regex.c (nfa_thread_epsilons, nfa_noop, nfa_optimize): New static functions. (regex_compile): Invoke nfa_optimize on the results of nfa_compile_regex.
* regex: elide needless increments of visited counter.Kaz Kylheku2017-09-121-5/+5
| | | | | | | | | | | | | * regex.c (nfa_run): Start with the existing value of the visited counter and pre-increment it when calling nfa_closure and nfa_move_closure. Thus it is incremented only as many times as those functions are called: one fewer than before. (regex_machine_reset): regm->n.visited is already incremented, since 1 was added to the prior value; there is no need to increment it again. (nfa_handle_wraparound): More prudent approach here. If we get within 8 increments of wraparound, we fast forward to UINT_MAX and then 0.
* regex: bugfix: incorrect use of nfa_move_closure.Kaz Kylheku2017-09-121-1/+1
| | | | | | | | | | | | | | This goes back to November 2, 2009 commit, "Start of implementation for freestyle matching", 6191fbb2ca7a9ac339dd3994bdea8273ceb0a24d It is exposed if we perform an epsilon threading optimization on the NFA graph. * regex.c (regex_machine_feed): We must pass the new, incremented value of the visited counter, to nfa_move_closure. States have already been tagged with the old value before the call to regex_machine_feed, so we risk failing to visit some states and include them in the closure.
* regex: new function, regex-prefix-match.Kaz Kylheku2017-09-113-0/+118
| | | | | | | | | | | | | | | | | This new function allows a program to determine whether a given string is the prefix of any of the strings denoted by a regular expression; or, in alternative words, whether a given string is the prefix of a possibly longer string which matches a regular expression. * regex.c (regex_machine_infer_init_state): New static function. (regex_prefix_match): New function. (regex_init): regex-prefix-match intrinsic registered. regex.h (regex_prefix_match): Declared. * txr.1: Documented.
* regex: remove nfa_reject representation.Kaz Kylheku2017-09-111-40/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reject states are no longer explicitly represented in the NFA graph. Any transition that previously would have led to a reject state is just a null pointer now: no transition. This just means we have to check one place for a null pointer. This change fixes a flaw in nfa_closure: the function was propagating nfa_reject states to the closure set. When the input set consisted only of reject states (or rather exactly one reject state in that special case), it would add it to the output set and return 1, making it seem as if the regex is one that can potentially match something. * regex.c (nfa_kind_t): Enum member nfa_reject removed. (nfa_state_reject): Static function removed. (nfa_compile_regex): Compile a t regex (match nothing) to a NFA graph with no transition at all into any start state; effectively an empty graph with no state nodes. (nfa_map_states): Remove nfa_reject case from switch. Also, stylistic change; state pointers are tested as Booleans elsewhere rather than by comparison to null pointer. (nfa_count_states, nfa_handle_wraparound): Handle null state pointer. (nfa_move_closure): Test the mov transition for null; anything can potentially now have a null transition, not only epsilon nodes. (nfa_run, regex_machine_reset): Handle nfa.start being null indicating an empty NFA graph. In that case we don't have to calculate the closure; we just have an empty set of states and set nfa.nclos to zero. The visited disambiguation counter is irrelevant since there are no states to visit. (regex_machine_feed): Don't try to propagate visited counter stored in regex machine to empty NFA graph which has no states.
* parser: fix precedence of DOTDOT.Kaz Kylheku2017-09-073-2/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is that a.b .. c.d parses as (qref a b..c d), which is useless and counterintuitive. Let's fix it, but with a backward compatibility switch to give more leeway to any hapless people out there whose code happens to depend on this unfortunate situation. We basically use two token numbers for the .. token: OLD_DOTDOT, and DOTDOT. Both are wired into the grammar. In backward compatibility mode, the lexer pumps out OLD_DOTDOT. Otherwise DOTDOT. * parser.l (grammar): When .. is scanned, return OLD_DOTDOT when in compatibility with 185 or earlier. Otherwise DOTDOT. * parser.y (OLD_DOTDOT): New terminal symbol; introduced at the same high precedence previously occupied by DOTDOT. (DOTDOT): Changes precedence to lower than '.' and UREFDOT. (n_expr): Two productions added involving OLD_DOTDOT. These are copy and paste of the existing productions involving DOTDOT; the only difference is that OLD_DOTDOT replaces DOTDOT. (yybadtoken): Handle OLD_DOTDOT. * txr.1: Compat notes added.
* linenoise: visual feedback for incomplete entry.Kaz Kylheku2017-09-071-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a line of input is incomplete and the cursor is at the end of that line, hitting Enter causes an uncomfortable ambiguity. Although the cursor moves to the next line, it is not clear whether that is because the input is being accepted, or whether the expression which was entered is executing. For instance, these appear to behave the same way: > (while t[Enter][Enter]... > (while t)[Enter][Enter]... One is just waiting for more input; the other is sitting in an infinite loop just echoing the newline characters. To partially address this issue, we introduce a visual feedback mechanism. When Enter is issued at the end of an incomplete line, then immediately after the insertion of Enter, the character ! is flashed twice, alerting the user that the line is incomplete. In other situations, there isn't any feedback. An infinite loop or lengthy calculation like (while t) looks the same as code which is reading input like (get-line). * linenoise/linenoise.c (LINNOISE_FLASH_DELAY): New macro. (flash): New static function. (edit): Call flash to flash the ! character when Enter is issued at the end of an incomplete line, and we are not in paste mode.
* linenoise: bugfix: cancel extended mode on Enter.Kaz Kylheku2017-09-071-0/+1
| | | | | | | | | | * linenoise/linenoise.c (edit): If Enter is processed while in Ctrl-X extended command mode, that mode must be explicitly canceled by resetting the extended local flag. Not doing this became an issue when the Enter callback mechanism was introduced to detect incomplete lines. At that point, entering Ctrl-X Enter on an incomplete line caused linenoise to insert a newline, but stay in extended mode.
* txr -i honored despite parse-time exception.Kaz Kylheku2017-09-063-9/+38
| | | | | | | | | | | | | | | | | | | | | If an error is thrown while parsing a .txr file or while reading and evaluating the forms of a .tl file. * parser.y (parse_once, parse): Wording change in message when exception is caught. Only exceptions derived from error are caught. * txr.c (parse_once_noerr, read_eval_stream_noerr): New static functions. (txr_main): Use parse_once_noerr and read_eval_stream_noerr instead of parse_once and read_eval_stream. Don't exit if a TXR file has parser errors; in that situation, exit only if interactive mode is not requested, otherwise go interactive. Make sure *self-path* is registered to the name of the input source in this case also. * unwind.h (ignerr_func_body): New macro.
* New functions for polynomial evaluation.Kaz Kylheku2017-09-053-0/+156
| | | | | | | | | * arith.c (poly, rpoly): New functions. (arith_init): Registered intrinsics poly and rpoly. * arith.h (poly, rpoly): Declared. * txr.1: Documented.
* new: macroexpand-lisp1 and macroexpand-1-lisp1.Kaz Kylheku2017-08-312-4/+67
| | | | | | | | | | | | | | | | * eval.c (do_macroexpand_1, do_macroexpand): New static functions; take symbol macro lookup function poiner as argument. (macroexpand_1): Reimplemented as wrapper around do_macroexpand_1. (macroexpand): Reimplemented as wrapper around do_macroexpand. (macroexpand_1_lisp1, macroexpand_lisp1): New static functions. (eval_init): Registered intrinsics macroexpand-1-lisp1 and macroexpand-lisp1. * txr.1: Documented.
* New function: inverse of cumulative normal dist.Kaz Kylheku2017-08-314-0/+45
| | | | | | | | | | * arith.c (inv_cum_norm): New function. * arith.h (inv_cum_norm): Declared. * eval.c (eval_init): Register inv-cum-norm intrinsic. * txr.1: Documented.
* Version 185.txr-185Kaz Kylheku2017-08-307-738/+783
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* bugfix: places: handling of lisp1 contexts.Kaz Kylheku2017-08-301-3/+3
| | | | | | | | | * share/txr/stdlib/place.tl (sys:l1-val): Use the expanded version of the place in the resulting form, because some of the operators like sys:lisp1-value will not expand it. Previously we were getting away with (sys:l1-val @1) expanding to (sys:lisp1-value @1) because the op expander would traverse through this blindly and replace @1.
* doc: wrong symbol under unique function.Kaz Kylheku2017-08-291-1/+1
| | | | | * txr.1: Fix syntax synopsis for unique identifying the function as uniq.
* doc: formatting under expand-leftKaz Kylheku2017-08-291-1/+1
| | | | * txr.1: Fix run-on period included in .meta formatting.
* Rewriting op/do macros in Lisp.Kaz Kylheku2017-08-294-28/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new implementation treats the @1, @2 ... @rest op arguments as local macros, leveraging the power of the macro expander to perform the substitution which renames these to gensyms. As a result, the implementation is correct. The old implementation blindly walks the tree structure doing the substitution, so that @1 is substituted even though it is in a quoted literal: [(op list '(@1)) 42] -> ((#:arg-01-0166)) under the new implementation, '(@1) is left alone: [(op list '(@1)) 42] -> ((@1) 42) * eval.c (expand_quasi): Because the new op macro doesn't rudely reach into quasi forms to substitute sys:var elements, relying on macro expansion, we must now macro-expand sys:var elements. The sys:var macro created by op is smart enough to skip the compound ones that have modifiers; they are handled via the inner expansion of the symbol. That is to say, `@@1` contains the structure (sys:var (sys:var 1)). The sys:var macro ignores the outer sys:var. But existing behavior in expand_quasi expands the inner (sys:var 1), so the substitution takes place. (eval_init): Do not register the hacky old op and do macros, except in compatibility mode with 184 or older. * lisplib.c (op_set_entries, op_instantiate): New functions. (dlt_register): Register auto-loads for op and do macros via new functions, except when in compatibility mode with 184 or older, in which case we want the old build-in hacky op to be used. * share/txr/stdlib/op.tl: New file. * txr.1: Fixed or removed no-longer-true text which hints at special hacks implemented in the op expander. Added compatibility notes for all new compat-switched op behaviors.
* doc: remove wrong/outdated claim under op macro.Kaz Kylheku2017-08-291-12/+1
| | | | | | * txr.1: the quasiliteral `rest: @rest` and `rest: @@rest` in fact produce the same result. Remove text which claims that the second one is erroneous.
* Allow sys:var and sys:expr redefinition.Kaz Kylheku2017-08-281-0/+2
| | | | | * eval.c (builtin_reject_test): Suppress warning if the symbol is sys:var or sys:expr.
* expander: do dot-to-apply for meta-expressions.Kaz Kylheku2017-08-282-9/+65
| | | | | | | | | | | | | | | | | | | The dot-to-apply transformation is now applied when meta-expressions like @foo and @(bar) apparently occur in the dot position. This change is made in anticipation of a rewrite of the op macro, in which the @1, @2, and @rest arguments will be implemented as macrolets, rather than the ad-hoc, hacky code walk currently performed in the transform_op function. * eval.c (dot_meta_list_p): New static function. (dot_to_apply): Detect the presence of a sys:var or sys:expr argument in a form. If found, then turn it and the remaining forms into a single compound form which replaces them. * txr.1: Update doc under Dot Position in Function Calls.
* trie filtering: ensure we don't misuse string_extend.Kaz Kylheku2017-08-241-0/+2
| | | | | | | | * filter.c (trie_filter_string): If a trie node is associated with a filter substitute object that isn't a character or string, then convert that to a string using tostringp. It could be an integer. If so and we feed that to string_extend, it will extend the string.
* bugfix: replace_str uses string_extend incorrectly.Kaz Kylheku2017-08-241-1/+1
| | | | | | | | | | | | | | | | | | | | One test case for this is that (append "ABC" "DEF") returns an "ABCDEF" string whose length reports as 9 instead of the correct 6. This will wreak various havoc. The bug was introduced in the very first version of replace_str, in commit d011fda9b6b078f09027eb65d500c8beffc99414 on January 26, 2012. In the same commit, the string_extend behavior is introduced of supporting an integer value specifying the number of characters by which to extend the string. This feature of string_extend is used in replace_str, but wrongly. * lib.c (replace_str): Pass just the size delta to string_extend; do not add the old length to the delta such that the total size is wrongly passed.
* Version 184.txr-184Kaz Kylheku2017-08-237-217/+317
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* Change return value spec for base64 stream functions.Kaz Kylheku2017-08-222-9/+27
| | | | | | | | | * filter.c (base64_stream_enc, base64_stream_dec): Count bytes encoded or decoded (using a fast integral counter which efficiently overflows to a Lisp value that may be a bignum). * txr.1: Doc updated.
* buffers: fix infinite loop in buf_grow.Kaz Kylheku2017-08-221-6/+8
| | | | | | | * buf.c (buf_grow): When size is zero and len is nonzero, the loop doesn't terminate. Replace silly loop with straightforward calculation: grow buffer by 25%, capped at INT_PTR_MAX, or grow to the length, whichever is larger.
* parser: bugfix: empty buf literal problem.Kaz Kylheku2017-08-221-1/+2
| | | | | | | * parser.y (buflit): Fix neglect to call end_of_buflit in the empty buffer literal case, which precipitates syntax errors when an empty buffer literal #b'' is embedded in other syntax.
* Default the length argument of truncate-stream.Kaz Kylheku2017-08-212-2/+19
| | | | | | | | | | * stream.c (truncate_stream): If the len argument is missing, default to the current position, obtained by using the seek operation. (stream_init): Fix up registration of truncate-stream for one optional argument. * txr.1: Documentation of truncate-stream updated.
* Update and expose base64 stream functions.Kaz Kylheku2017-08-183-22/+107
| | | | | | | | | | | | | | | | | | | * filter.c (base64_stream_enc): Change return value behavior. Return in unlimited mode, or number of bytes encoded. (get_base64_char): Stop reading when an invalid character is encountered, push it back and and return 0. (b64_code): Don't throw for invalid characters. This case now only occurs if 0 is passed in. (base64_stream_dec): Drop nchars argument. Read until get_base64_char returns 0 due to EOF or an invalid character. (base64_decode): Don't pass third arg to base64_stream_dec. (filter_init): base64-stream-enc and base64-stream-dec intrinsics registered. * filter.h (base64_stream_dec): Declaration updated. * txr.1: Documented.
* Revising out-of-memory handling.Kaz Kylheku2017-08-185-31/+20
| | | | | | | | | | | | | | | | | | | | | We don't want to be aborting on OOM, but throwing an exception. * lib.c (alloc_error_s): New symbol variable. (oom_realloc): Global variable removed. (oom): New static function. (chk_malloc, chk_malloc_gc_more, chk_calloc, chk_realloc): Call oom instead of removed oom_realloc handler. (env): Throw alloc-error rather than error by calling oom. (obj_init): Initialize alloc_error_s. (init): Drop function pointer argument; do not initialize removed oom_realloc. * lib.h (alloc_error_s): Declared. (oom_realloc): Declaration removed. (init): Declaration updated. * txr.1: Type tree diagram includes alloc-error.
* vec-set-length maintenance.Kaz Kylheku2017-08-171-4/+13
| | | | | | | * lib.c (vec_set_length): Check new length against INT_PTR_MAX rather than size_t limit. We want to keep the length a fixnum. If the allocation needs to increase, grow it by 25%, not by doubling it.
* Rewriting string-extend.Kaz Kylheku2017-08-171-26/+25
| | | | | | | | | | * lib.c (string_extend): Restructure internals with these goals: no loop: calculate needed space in one step; if the allocation needs to grow, then grow it by 25% or step it up to exactly the needed size, whichever of the two is larger. Overflow check against INT_PTR_MAX, since len and alloc fields of string are not fixnums but integers extracted with c_num.
* parser: fix byacc regression related to hash-semi.Kaz Kylheku2017-08-171-0/+1
| | | | | | | | | | | | | | | | | | | | The "byacc_fool" rule needed a small update when in November 2016 it became involved in newly introduced #; (hash semicolon) syntax for commenting out. The problem is that when a top-level nested list expression is followed by #; then a byacc-generated parser throws a syntax error. This is because the byacc_fool production only generates a n_expr, or empty. Thus only those symbols are allowed which may begin a n_expr. The hash-semicolon token isn't one of them. * parser.y (byacc_fool): Add a production rule which generates a HASH_SEMI. Thus HASH_SEMI is now one of the terminals that may legally follow any sentential form that matches a byacc_fool rule after it.
* parser: more efficient treatment of string literals.Kaz Kylheku2017-08-171-27/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this patch we switch the string literal parser from right recursion to left recursion, so that it doesn't require a Yacc stack depth proportional to the number of characters in the literal. Secondly, we build the string directly in a syntax-directed way, rather than building a list of characters and then walking the list to build a string. This was discovered as a byacc regression, though the fix is not for the sake of byacc but basic efficiency. The Sep 29, 2015 commit 111650e235ab2e529fa1529b1c9a23688a11cd1f "Implementation of static slots for structures." extended the string literal in the struct.tl test case in such a way that if the parser is generated by byacc rather than GNU Bison, the test case fails with a "yacc stack overflow". I haven't done any regression testing with byacc in over two years so I didn't notice this. Quasiliterals could use this treatment also. Word list literals benefit from this change, but they still use a Yacc stack depth proportional to the number of words, since the accumulation of words is right recursive. * parser.y (lit_char_helper): Static function removed. (restlitchar): New grammar nonterminal symbol. (strlit, quasi_item, wordslit): No need to call lit_char_helper. (litchars): A litchars is now either a single LITCHAR, or else a LITCHARS followed by a sequence of more. This sequence is a separate production rule called restlitchar, which is purely left recursive. (If litchars is made directly left recursive without this helper rule, intractable reduce/reduce and shift/reduce conflicts arise.)
* Get continuations working on aarch64.Kaz Kylheku2017-08-162-15/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * unwind.c (UW_CONT_FRAME_BEFORE, UW_CONT_FRAME_AFTER): New preprocessor symbols. (revive_cont): The "frame slack" zero-filled padding logic is replaced by capturing an actual part of the real stack before the uw_stack unwind frame. On aarch64, there is content there we must actually capture. Experiment shows that exactly 128 bytes is enough, and that corresponds to the frame_slack value. (capture_cont): Capture UW_CONT_FRAME_BEFORE bytes before the uw_stack unwind frame location. Also, the "capture_extra" is replaced by UW_CONT_FRAME_AFTER constant, to harmonize. * unwind.h (UW_FRAME_ALIGN): New preprocessor symbol. (union uw_frame): On aarch64, we ask the compiler, via a GCC-specific attribute syntax, to align the address of frame objects to a 16 byte boundary. This solves a crash in the continuation code. Continuation capture is keyed to unwind frame addresses. When a captured continuation is revived onto the stack, the delta between its original address and the revive address must be a multiple of 16. The reason is that this preserves the stack and frame pointer alignment. Certain instructions on the aarch64, require the stack pointer to be 16 byte aligned. There are other ways we could achieve this, but the easiest is to align the original frames to 16 bytes.
* Port to aarch64 (ARM 8).Kaz Kylheku2017-08-163-2/+72
| | | | | | | | | | | | Continuations don't work yet. * gc.c (STACK_TOP_EXTRA_WORDS): New macro. (mark): On aarch64, we must include four words above the stack top. Some live root pointers sometimes hide there which are not in any of the callee-saved register that end up in the machine context via jmp_save. * jmp.S (jmp_save, jmp_restore): Implement for aarch64.
* Allow character inputs in some bit operations.Kaz Kylheku2017-08-162-1/+43
| | | | | | | | | * arith.c (logand, logior, logxor): Allow one operand to be a character, if the opposite opernad is a fixnum integer. The result is a character. (bit): Allow the value being tested to be a character. * txr.1: Updated.
* ffi: new FFI type I/O functions.Kaz Kylheku2017-08-163-0/+139
| | | | | | | | | * ffi.c (put_obj, get_obj, fill_obj): New functions. (ffi_init): put-obj, get-obj, fill-obj intrinsics registered. * ffi.h (put_obj, get_obj, fill_obj): Declared. * txr.1: Documented.
* buf: provide way to work with on-stack buffers.Kaz Kylheku2017-08-162-3/+7
| | | | | | | | * buf.c (init_borrowed_buf): New function. (make_borrowed_buf): Reduced to wrapper around init_borrowed_buf. * buf.h (init_borrowed_buf): Declared.
* buf: new buffer stream.Kaz Kylheku2017-08-145-0/+397
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * buf.c (struct buf_strm): New struct type. (buf_strm_mark, int buf_strm_put_byte_callback, buf_strm_put_string, buf_strm_put_char, buf_strm_put_byte, buf_strm_get_byte_callback, buf_strm_get_char, buf_strm_get_byte, buf_strm_unget_char, buf_strm_unget_byte, buf_strm_seek, buf_strm_truncate, buf_strm_get_prop, buf_strm_set_prop, buf_strm_get_error, buf_strm_get_error_str): New static functions. (buf_strm_ops): New static struct. (buf_strm): New static function. (make_buf_stream, get_buf_from_stream): New functions. (buf_init): Register new intrinsic functiions make-buf-stream and get-buf-from-stream. Call fill_stream_ops on new buf_strm_ops to fill default operations in place of function pointers that have been left null. * buf.h (make_buf_stream, get_buf_from_stream): Declared. * lisplib.c (with_stream_set_entries): Add with-out-buf-stream and with-in-buf-stream to auto-load symbols for with-stream.tl module. * share/txr/stdlib/with-stream.tl (with-out-buf-stream, with-in-buf-stream): New macros. * txr.1: New section about buffer streams.
* buf: tiny code improvement.Kaz Kylheku2017-08-141-1/+1
| | | | | * buf.c (buf_grow): Use the previously calculated delta value, rather than re-evaluating the equivalent expression.
* bugfix: buf-put-ucharKaz Kylheku2017-08-141-1/+1
| | | | | * buf.c (buf_put_uchar): Fix wrong conversion that is causing this function to reject values in the 128-255 range.
* bugfix: seek-stream :from-end not working.Kaz Kylheku2017-08-141-1/+1
| | | | | * stream.h (enum strm_whence): Fix strm_end and strm_start being duplicate values; strm_end must map to SEEK_END.
* base64 funtions: factor out stream filtering internals.Kaz Kylheku2017-08-092-15/+37
| | | | | | | | | | | | | | | | The base64_encode and base64_decode functions internally work with streams. This change factors out those internals into separate functions (with the intent that these will be usefully exposed, in another commit). * filter.c (base64_stream_enc): New function, made out of the internals of base64_encode. (base64_encode): Simple wrapper for base64_stream_enc. (base64_stream_dec): New function, made out of the internals of base64_decode. (base64_decode): Simple wrapper for base64_stream_dec. * filter.h (base64_stream_enc, base64_stream_dec): Declared.
* ffi: new buf-carray function.Kaz Kylheku2017-08-083-0/+29
| | | | | | | | | * ffi.c (buf_carray): New function. (ffi_init): Registered buf-carray intrinsic. * ffi.c (buf_carray): Declared. * txr.1: Documented.
* New divides function.Kaz Kylheku2017-08-073-0/+53
| | | | | | | | | * arith.c (divides): New function. (arith_init): Intrinsic registered. * arith.h (divides): Declared. * txr.1: Documented.
* Make len a synonym for length.Kaz Kylheku2017-08-072-2/+10
| | | | | | | * eval.c (eval_init): Register the same function under length and len. * txr.1: Documented.
* New spl and tok: variants of tok-str and split-str.Kaz Kylheku2017-08-074-0/+86
| | | | | | | | * eval.c (eval_init): Register spl and tok intrinsics. * lib.c (spl, tok): New functions. * txr.1: Documented.
* tok-str requires two arguments, not just one.Kaz Kylheku2017-08-071-1/+1
| | | | * eval.c (eval_init): Fix incorrect registration of tok-str.