summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* read-until-match can optionally keep matched text.Kaz Kylheku2016-04-205-38/+50
| | | | | | | | | | | | | | | | | | | | * regex.c (read_until_match): New argument, include_match. Three times repeated termination code refactored into block reached by forward goto. (regex_init): Registration of read-until-match updated. * regex.h (read_until_match): Declaration updated. * stream.c (struct record_adapter_base): New member, include_match. (record_adapter_get_line): Pass match to read_until_match as new argument. (record_adapater): New argument, include_match. (stream_init): Update registration of record-adapter. * stream.h (record_adapter): Declaration updated. * txr.1: Updated.
* Fix broken read_until_match.Kaz Kylheku2016-04-191-17/+51
| | | | | * regex.c (read_until_match): Completely rewrite broken, unsalvageable, garbage logic.
* Allow unlimited character pushback in unget-char.Kaz Kylheku2016-04-193-22/+25
| | | | | | | | | | | | | | | | Fixing read_until_match will require this feature. * socket.c (dgram_get_char): Treat unget_c as a cons-based stack; pop a character from it if available. (dgram_unget_char): Push the character onto unget_c rather than storing the characer into unget_c. * stream.c (stdio_get_char, stdio_unget_char): Closely analogous changes to the ones in dgram_get_char and dgram_unget_char, respectively. * txr.1: Documentation improved and updated.
* Incorrect format args in string stream code.Kaz Kylheku2016-04-191-1/+1
| | | | | * stream.c (string_in_unget_char): Missing argument in uw_throwf call.
* Fix broken unget_char over string input streams.Kaz Kylheku2016-04-191-1/+1
| | | | | | * stream.c (string_in_unget_char): Store the updated position into the stream, rather than the original value, which does nothing.
* Bugfix: allow newline in regex parsing from string.Kaz Kylheku2016-04-181-1/+7
| | | | | | | * parser.l (grammar): The newline character is incorrectly handled by the same rule under the SREGEX and REGEX states. In the SREGEX state, just return it as a REGCHAR, not forgetting to increment the line number.
* Trailing whitespace.Kaz Kylheku2016-04-181-1/+1
| | | | * parser.l: Remove trailing whitespace.
* Bugfix: @(if expr) not macro-expanding expr.Kaz Kylheku2016-04-181-2/+2
| | | | | * parser.y (if_clause, elif_clauses_opt): Add missing expand calls.
* Fix inconsistency of Lisp var visibility in TXR.Kaz Kylheku2016-04-172-41/+69
| | | | | | | | | | | | | | | | | | | Numerous places in match.c are using assoc(sym, bindings) logic to access a variable, which doesn't see the Lisp globals, as we would like. For example, if foo is defined using (defvar foo), @(set foo "A") doesn't work. This is subject to the compatibility option. * match.c (tx_lookup_var): New static function. (dest_set, h_var, h_coll, h_parallel, h_fun, v_next, v_parallel, v_gather, v_collect, v_flatten, v_cat, v_output, v_filter, v_fun, match_filter): Use tx_lookup_var instead of assoc for all lookups that see the full variable scope. Only variable lists known to be locally consed up are scanned with just assoc. * txr.1: Documented new rules and added compatibility notes.
* Bugfix: @(output) not expanding some Lisp exprs.Kaz Kylheku2016-04-171-1/+1
| | | | | | | * parser.y (make_expr): This function is part of a hack for converting some hard-coded syntax like @(if ...) or @(and ...) in an @(output) block to a to a Lisp expression. Alas, the crucial step of expanding the Lisp form was neglected.
* Valgrind support in continuations.Kaz Kylheku2016-04-161-1/+18
| | | | | | | * unwind.c (revive_cont): When scanning the stack of the revived continuation to fix up pointers, we can save the Valgrind validity bits of each word, mark it defined, and then restore the validity bits.
* Put notes into cadr sources that they are generated.Kaz Kylheku2016-04-164-0/+12
| | | | | | * gencadr.txr: Insert notice about generation. * cadr.c, cadr.h, share/txr/stdlib/cadr.tl: Regenerated.
* Version 138.txr-138Kaz Kylheku2016-04-166-318/+391
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Improve sock-peer documentation.Kaz Kylheku2016-04-161-19/+20
| | | | | | * txr.1: Remove factually incorrect statements that only sockets connected with sock-connect or sock-accept have a peer address. Broadly revise wording.
* Block absconds across foreign frames.Kaz Kylheku2016-04-161-0/+4
| | | | | * unwind.c (uw_block_abscond): If a UW_GUARD frame occurs in the search for the abscond point, throw an error.
* Doc for sys:abscond* references nonexistent sym.Kaz Kylheku2016-04-161-1/+1
| | | | | * txr.1: Incorrect reference to sys:return* should of course be to sys:abscond*.
* Notes on glob and exceptions.Kaz Kylheku2016-04-151-0/+19
| | | | | | * txr.1: Document that glob's error-func callback can be terminated by a non-local exit, but may not capture continuations across glob.
* Fix internal error: bug in data stream opening logic.Kaz Kylheku2016-04-151-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Test case: txr -c '@(bind x 1)A' name The problem here is that the specline has multiple elements, so when processing the bind, rest(specline) isn't nil. This means that control passes through to horizontal matching logic. No data source is open yet; just before that logic executes, open_data_source is called. However, open_data_source refuses because @(bind) is a directive that doesn't require data. So we end up in the internal error case, because we a data source, and no attempt was made to open one. The fix is for open_data_source to also check rest(specline). It cannot skip opening the data source just because the first_spec is a non-matching directive, according to the non_matching_directive_table. This criterion should only apply if it is the *only* directive, however. A spec line with multiple items must match a line of data; that's how the TXR language works. * match.c (open_data_source): Add a condition for classifying the directive as non-matching: it must be the only directive in the line (rest(specline) must be nil).
* Glob-related variables wrongly documented as special.Kaz Kylheku2016-04-151-1/+1
| | | | | * txr.1: glob-err, glob-mark and others are global lexical variables, not special.
* Close source files after parsing.Kaz Kylheku2016-04-154-2/+17
| | | | | | | | | | | | | * eval.c (sys_load): close stream in all cases. * match.c (v_load): Likewise. * parser.c (load_rcfile): Close stream in unwind block, if open. * txr.c (txr_main): Close stream after parsing in all cases. If stream is std_input, or a string stream, close_stream does nothing.
* glob bugfix: always clear callback global.Kaz Kylheku2016-04-151-2/+2
| | | | | | | | | * glob.c (glob_wrap): Move c_num call outside of the section of code where s_errfunc is assigned. We don't want to do anything here which throws, because then control escapes without evaluating "s_errfunc = nil", possibly leaving s_errfunc with a non-nil value that blocks further uses of glob.
* Adding ftw function.Kaz Kylheku2016-04-156-0/+444
| | | | | | | | | | | | | | * Makefile (ftw.o): Add to OBJS-y conditionally. * configure (have_ftw): New variable. New configure test for nftw. (gen_config_make): Set up have_ftw make variable. * ftw.c, ftw.h: New files. * lib.c (init): Call ftw_init, if compiled in. * txr.1: Documented.
* Expose stat_to_struct outside of sysif.Kaz Kylheku2016-04-152-1/+5
| | | | | | * sysif.c (stat_to_struct): Change to external linkage. * sysif.h (stat_to_struct): Declared.
* Add five-arg variant of add_args.Kaz Kylheku2016-04-151-0/+12
| | | | * args.h (args_add5): New inline function.
* Fix memory leak in glob.Kaz Kylheku2016-04-151-1/+4
| | | | | * glob.c (glob_wrap): Must free the temporary UTF-8 version of the search pattern.
* Macros obtain* and obtain*-block.Kaz Kylheku2016-04-153-0/+89
| | | | | | | | | | * lisplib.c (yield_set_entries): Add obtain* and obtain*-block to autoload list. * share/txr/stdlib/yield.tl (obtain*, obtain*-block): New macros. * txr.1: Documented.
* Fix proper-listp to proper-list-p.Kaz Kylheku2016-04-145-12/+27
| | | | | | | | | | | | | | | | | | | | This is really a gratuitous incompatibility with Common Lisp and other dialects. Let's fix it internally also, but keep the proper-listp function binding for backwards compatibility. * eval.c (dot_to_apply, me_op): Update proper_listp call to proper_list_p. (eval_init): Register proper-list-p to the same C function as proper-listp, and that C function is now called proper_list_p. * lib.c (proper_listp): Renamed to proper_list_p. * lib.h (proper_listp): Declaration updated. * parser.y (define_transform): Update proper_listp call. * txr.1: Replace all occurrences of proper-listp with proper-list-p. Add note explaining the rename situation.
* Remove @(do) from Lisp examples.Kaz Kylheku2016-04-141-17/+15
| | | | * txr.1: example for delay and gen doesn't need @(do).
* Fix incorrect example under umeth.Kaz Kylheku2016-04-141-2/+2
| | | | | * txr.1: Functions bound to variables must be invoked using DWIM brackets or call function.
* Make open_socket static and register in socket.c.Kaz Kylheku2016-04-144-8/+3
| | | | | | | | | | | | | | * lisplib.c (sock_set_entries): Add auto-load entry for open-socket. * socket.c (open_socket): Change to static. (sock_load_init): Register open-socket intrinsic here rather than in stream.c. * stream.c (stream_init): Remove registration of open-socket intrinsic. * stream.h (open_socket): Declaration removed.
* Make open_sockfd static.Kaz Kylheku2016-04-142-22/+21
| | | | | | | | | The open_sockfd function is only called within socket.c * socket.c (open_sockfd): More function up and change to static. * stream.h (open_sockfd): Declaration removed.
* New open-socket-pair function.Kaz Kylheku2016-04-143-1/+87
| | | | | | | | | | | * lisplib.c (sock_set_entries): Add open-socket-pair to autoload list. * socket.c (sock_mark_connected, socketpair_wrap): New static functions. (sock_load_init): Register open-socket-pair intrinsic. * txr.1: Documented.
* Consolidate repeated address unpacking code.Kaz Kylheku2016-04-141-14/+16
| | | | | | * socket.c (sockaddr_unpack): New static function. (sock_accept): Use sockaddr_unpack instead of two copies of if/else code.
* Fix error handling in dgram case of sock-accept.Kaz Kylheku2016-04-141-10/+11
| | | | | | | * socket.c (sock_accept): Reduce scope of unwind catch around recvfrom call. Add missing check nbytes == -1. Branch to failed label in dup failed case, instead of throwing exception with truncated "unable to" message.
* Socket mode strings defaulted and checked.Kaz Kylheku2016-04-141-6/+12
| | | | | | | | | | | | * stream.c (do_parse_mode): New static function. (parse_mode): Logic moved into do_parse_mode, leaving this function as a wrapper for do_parse_mode. Check added for malformed mode, so functions which call parse_mode now have the check. Added defaulting for mode_str argument, inside do_parse_mode. (normalize_mode): Call do_parse_mode instead of parse_mode. Don't default mode_str argument, since do_parse_mode does that.
* Adding fmt function.Kaz Kylheku2016-04-143-0/+24
| | | | | | | | * stream.c (fmt): New function. * stream.h (fmt): Declared. * txr.1: Documented.
* Trace expansion more in expansion-time errors.Kaz Kylheku2016-04-131-5/+32
| | | | | | * eval.c (error_trace): If an error occurs during the expansion of a form, that form may be the result of expansions. Dump those expansions.
* Bugfix: track origin for built-in macros.Kaz Kylheku2016-04-131-0/+1
| | | | | | | | | | | This fix is no longer that important, since due to the previous commit, expand now tracks expansion origins thoroughly, which hides this bug. However, expand_macro is directly called from a few other functions, like macroexpand, which don't benefit from that fix. * eval.c (expand_macro): Add forgotten set_origin call in the case when the native C expander is called.
* More thorough job of tracking expansion origins.Kaz Kylheku2016-04-131-7/+6
| | | | | | | | | | | | | This promotes better diagnostics. Simple test case: [(ret @5) 1]. * eval.c (do_expand): Manual tail recursion via backwards goto is removed; the function recurses now, and it recurses through the expand wrapper rather than by calling itself. That is needed in order to properly install the origin tracking for each expansion. (expand): Record origin for each expansion that already doesn't have one.
* Improved window-map doc.Kaz Kylheku2016-04-131-6/+6
| | | | * txr.1: Better wording introducing the semantics.
* Fix wrong documentation for window-map.Kaz Kylheku2016-04-131-7/+5
| | | | | * txr.1: window-map doesn't require the function to return sequences, and doesn't append.
* Broken argument handling in umethod.Kaz Kylheku2016-04-131-2/+3
| | | | | | * struct.c (umethod_fun): Use proper args interfaces to check whether there is an object argument, and to extract it.
* lib-version variable doesn't autoloadKaz Kylheku2016-04-121-1/+1
| | | | | * lisplib.c (ver_set_entries): Add lib-version to autoload list.
* Formatting in defstruct documentation.Kaz Kylheku2016-04-121-10/+1
| | | | | | * txr.1: remove spurious blank lines before .meIP blocks. After the indented section end, return to the correct indentation with .IP rather than .PP.
* Don't expand replacements of symbol macros.Kaz Kylheku2016-04-122-5/+8
| | | | | | | | | * eval.c (expand_symacrolet, do_expand): Don't expand the replacement form of a global or lexical symbol macro at the time it is bound to its symbol. This is almost certainly wrong in situations where it makes a difference. * txr.1: Noted in compatibility section.
* Harden glob: continuations, exceptions, re-entry.Kaz Kylheku2016-04-112-1/+38
| | | | | | | | | | | | | | | | | | | * glob.c (s_exit_point): New static variable. (errfunc_thunk): Set up a continuation guard frame, so the error function cannot capture a continuation across glob's stack frames. Intercept all unwinding with a simple unwind block, save the exit point in the global variable and then stop the unwinding by setting the unwind frame's exit point to null. (glob_wrap): Check for glob being re-entered and throw error if so. If the glob callback bailed due to unwinding (as seen by a non-null value in the exit point global variable), clean up the glob memory with globfree and continue the unwinding to the exit point. unwind.h (uw_curr_exit_point): New macro for accessing saved exit point in pure unwind frame.
* Remove frame popping action from uw_continue.Kaz Kylheku2016-04-112-6/+4
| | | | | | | | | | | | * unwind.c (uw_continue): Don't take the current frame as an argument and consequently don't pop the current frame. This function currently has only one use, the uw_catch_end macro. * unwind.h (uw_continue): Declaration updated. (uw_catch_end): Slight code rearrangement: pop the frame unconditionally before the test for whether uw_continue must be called.
* Typo in comment.Kaz Kylheku2016-04-111-1/+1
| | | | | * unwind.c (uw_unwind_to_exit_point): Misspelled "execute".
* Better handling of dot position function calls.Kaz Kylheku2016-04-112-31/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | The expander now actually produces apply forms for dot position function call and dwim forms. This allows symbol macros to work naturally. * eval.c (sys_apply_s): New symbol variable. (imp_list_to_list, dot_to_apply): New static functions. (expand_forms, expand_forms_lisp1): We now throw an error if a non-nil atom terminates a form, Except in compatibility mode with TXR 137 or less, whereby we emulate the old behavior of not expanding this atom. (do_expand): Perform the dot_to_apply transformation on the arguments of the dwim form. Perform the dot_to_apply transformation on an entire function call form. (eval_init): Initialize sys_apply_s and register sys:apply function (using the same function object that is registered under apply). * txr.1: Documented that both DWIM forms and regular function call forms work as if by a transformation to apply form, removing verbiage which separately described the DWIM handling. Documented that symbol macros work properly in dot position.
* Fix more macro name misspellings in manual.Dave Love2016-04-101-10/+10
| | | | | * txr.1: A few occurrences of .codn misspelled .cond are are fixed and one .cod fixed to .code.