summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Fix errors found by new checkman.txr.Kaz Kylheku2016-04-261-21/+21
| | | | | | * txr.1: Fix incorrect function and variable description headings with spurious commas and inappropriate plurals. Fix missing .mets in syntax blocks.
* Adding manual page checker.Kaz Kylheku2016-04-262-1/+80
| | | | | | | * Makefile (txr-manpage.pdf): Invoke checkman.txr on the man page source. * checkman.txr: New file.
* Check man page for errors when generating PDF.Kaz Kylheku2016-04-261-1/+1
| | | | | | * Makefile (txr-manpage.pdf): Add -ww option to pdfroff to report all errors, such as uses of undefined macros.
* Pretty print filename in assertion.Kaz Kylheku2016-04-251-2/+2
| | | | | * match.c (v_assert, h_assert): Use ~a rather than ~s for c->curfile in assert message.
* Version 139.txr-139Kaz Kylheku2016-04-226-428/+471
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Spring cleaning: find wrong wrong troff macros.Kaz Kylheku2016-04-221-60/+61
| | | | | | * txr.1: Hunted down and fixed incorrect .code, .codn, .meta and .metn invocations. Added missing .desc macros after .coNP Variables ...
* Recycle temporary list-of-lists in mapping functions.Kaz Kylheku2016-04-221-3/+9
| | | | | | | | * eval.c (mapcarv, mappendv, mapdov): When done, we can recycle the conses used for the temporary copy of the list-of-lists, whose car-s are used for iterating over the lists in paralle. This is safe because the temporary list's conses aren't shared with any other function.
* Support list of paths in ftw.Kaz Kylheku2016-04-222-0/+59
| | | | | | | * ftw.c (ftw_wrap): Handle case when dirpath is a list, by recursion. * txr.1: Documented.
* Optimization in path-private-to-me-p.Kaz Kylheku2016-04-221-8/+8
| | | | | | | | | * share/txr/stdlib/path-test.tl (path-private-to-me-p): Use mlet to initialize the g variable lazily, so that getgrgid is only called when g is used. getgrid is a fairly heavy-weight function, and it's only used to resolve the case when a file is writable to the group owner (is the user the only member of that group?)
* Don't quote path in load and @(load) diagnostics.Kaz Kylheku2016-04-222-6/+6
| | | | | | | * eval.c (sys_load): Use ~a format specifier rather than ~s for the load path (if already known to be a string). * match.c (v_load): Likewise.
* Strengthen against resource leaks upon exceptions.Kaz Kylheku2016-04-216-23/+44
| | | | | | | | | | | | | | | | | | | | | | | * glob.c (glob_wrap): Perform argument conversions that might throw before allocating UTF-8 string. * parser.y (text): In the action for SPACE, the lexeme is not needed so free($1) right away. If regex_compile were to throw an exception, that lexeme will leak. * socket.c (getaddrinfo_wrap): Harden against leakage of node_u8 and service_u8 strings with an unwind block. For instance, the hints structure could contain bad values which cause addrinfo_in to throw. * stream.c (make_string_byte_input_stream): Perform possibly throwing argument conversions before allocating resources. * sysif.c (mkdir_wrap, mknod_wrap, chmod_wrap, symlink_wrap, link_wrap, setenv_wrap, crypt_wrap): Likewise. * syslog.c (openlog_wrap, syslog_wrapv): Likewise.
* Rename misleadingly named out_str_pretty function.Kaz Kylheku2016-04-211-5/+5
| | | | | | | | * lib.c (out_str_pretty): Rename to out_str_readable. This function is called from obj_print_impl precisely when the pretty flag is false: pretty means output textual things as the text they denote, rather than machine-readable Lisp. (out_lazy_str, obj_print_impl): Calls updated.
* Harmonize rules for string and character printing.Kaz Kylheku2016-04-211-9/+24
| | | | | | | | | | | | | | | | | In this patch we change which characters objects are printed using hex escapes, and which characters are printed as hex when printing string literals. * lib.c (obj_print_impl): Add DEL (U+7F) to the list of character objects which are printed as hex. In a string literal, it's already printed as \x7F. Use upper case hex rather than lower case. (out_str_char): Copy the rules used by obj_print_impl for deciding what string constituents to print as hex and how to print it. So for instance, U+80 to U+A0 will now print in hex as well as the U+D800 to U+DFFF range, rather than just U+DC00 to U+DCFF, and the BOM code U+FFFE, U+FFFF and anything higher.
* Handle non-UTF-8 byte in regex scanned from string.Kaz Kylheku2016-04-211-0/+6
| | | | | | | | The current behavior is that there is no lex rule for this, so such a byte gets echoed. parser.l (grammar): Add fallback rule to match one byte in SREGEX state and turn it into 0xDCxx character.
* Regex syntax errors trigger exception.Kaz Kylheku2016-04-211-1/+5
| | | | | * parser.c (regex_parse): Don't return nil if there were errors; throw a syntax-error exception.
* Diagnose out-of-range char to UTF-8 conversion.Kaz Kylheku2016-04-211-1/+3
| | | | | * utf8.c (utf8_encode): Don't return zero in the out-of-range case, but throw.
* Better job of diagnosing out-of-range char escapes.Kaz Kylheku2016-04-211-2/+9
| | | | | | * parser.l (num_esc): Check for converted value being out of the range of wchar_t or beyond 0x10FFFF, whichever is less.
* Integrating fnmatch.Kaz Kylheku2016-04-203-0/+127
| | | | | | | | | | | | * configure: new test for fnmatch, introducing HAVE_FNMATCH configure variable into config/config.h. * sysif.c (fnmatch_wrap): New function. (sysif_init): Register intrinsic variables fnm-pathname, fnm-noescape, fnm-period, fnm-leading-dir, fnm-casefold and fnm-extmatch. Register intrinsic function fnmatch. * txr.1: Documented.
* linenoise: g++ signed/unsigned warnings.Kaz Kylheku2016-04-201-4/+5
| | | | | | | | * linenoise/linenoise.c (free_completions): Use size_t for iterating over completions vector. (complete_line): Likewise. (edit_insert, edit_insert_str): Cast size_t value to int before comparing with l->dlen.
* ftw.c affected by g++/glibc issue __USE_GNU is defined.Kaz Kylheku2016-04-201-0/+2
| | | | | | | | | When compiling as C++, __USE_GNU is defined even though we use -ansi and don't specify -D_GNU_SOURCE anywhere. Glibc headers don't seem to respond to the C++ ANSI options. ftw.c: Workaround for compiler warning: only define __USE_GNU if it is not defined already.
* Recycle conses in unget-char and read-until-match.Kaz Kylheku2016-04-203-5/+9
| | | | | | | | | | | | * regex.c (ead_until_match): Use rcyc_pop instead of pop to move the conses to the recycle list. We know these are not shared with anything. Adding additional logic to completely recycle the stack. * socket.c (dgram_get_char): Use rcyc_pop to get the character from the push-back list. * stream.c (stdio_get_char): Likewise.
* Mechanism for recycling conses outside of GC.Kaz Kylheku2016-04-203-2/+52
| | | | | | | | | | | | * lib.c (recycled_conses): New static variable. (rcyc_pop, rcyc_cons, rcyc_list, rcyc_empty): New functions. (cons): Take a recycled cons, if available. * lib.h (rcyc_pop, rcyc_cons, rcyc_list, rcyc_empty): Declared. * gc.c (gc): Call rcyc_empty to make recycle_list unreachable.
* Bugfix: optional arg defaulting in get-string.Kaz Kylheku2016-04-201-1/+2
| | | | | * stream.c (get_string): The optional stream argument must be treated accordingly.
* 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.