summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Mistake in remq*, reqml* and remqual heading.Kaz Kylheku2016-06-031-1/+1
| | | | * txr.1: reqm was written instead of remq*.
* Drop between TXR and Lisp syms in HTML Doc.Kaz Kylheku2016-06-031-20/+9
| | | | | | | | | | | | | | | Dropping the document feature that hyperlinks in the TXR section resolve to TXR topics, and TXR Lisp hyperlinks go to TXR Lisp topics. All multiple uses of symbols are handled through the new mechanism of disambiguating topic navigators. * genman.txr (txrhash, txlhash, tgthash): Variables removed. (symhash): One variable, replacing those three. BODY collecting loop no longer collects LOOKUP variable, since body lines are not associated with a particular hash.
* Topic disambiguation "sub-pages" in HTML doc.Kaz Kylheku2016-06-031-3/+33
| | | | | | | | | | | | | | | | | | | | The purpose of this change is to handle situations where a symbol has multiple meanings, resulting in different topic areas of the document where we might want to navigate. For instance, there is an equal function in the TXR Lisp library, and an equal method that users can define. * genman.txr (tochash, disamb, dist-counter): New variables. (process-ambiguities): New Lisp function. When collecting symbol/jump-tag associations, collect the lists of jump tags rather than just the first jump tag. Then process the hash using process-ambiguities to handle the cases with multiple entries, which are prepared in the disamb hash. The contents of the disamb hash turn into HTML material at the end of the page. An in-line style sheet is now added; it adds vertical space between the navigation menus so they appear as if they were separate web pages.
* Adding special function from-list.Kaz Kylheku2016-06-012-1/+51
| | | | | | | | | | * lib.c (from_list_s): New symbol variable. (make_like): Handle a COBJ. If it's a structure with a from-list method, then use it, otherwise the default handling applies of returning the list. (obj_init): Initialize from_list_s. * txr.1: Documented.
* Describe special structure methods in new section.Kaz Kylheku2016-06-011-114/+158
| | | | | | | | * txr.1: Removing "Functors", "Equality Substitution", "Custom Pretty-Printing" and "Sequence Operations on Structures" paragraphs. Adding major section "Special Structure Functions" under which the special functions are described with syntax headings.
* ldiff uses equal for all non-list arguments.Kaz Kylheku2016-06-012-9/+8
| | | | | | | | | | | * lib.c (ldiff): Rather than checking specifically for strings and vectors to apply the special case behavior (comparison using equal), test specifically for lists and apply the traditional behavior. Every other object, not just strings and vectors, gets the altered behavior. * txr.1: Changed text in TXR Lisp introduction which touches on ldiff, and wording fix under ldiff.
* Methods for turning objects into sequences.Kaz Kylheku2016-06-015-2/+85
| | | | | | | | | | | | | | | | | | | | | | | | Struct objects can now define methods car, cdr and nullify. With these, they can participate in operations on sequences. * eval.h (car_s, cdr_s): Declared. * lib.c (nullify_s): New symbol variable. (car, cdr): Implement for struct objects via, respectively, their car and cdr methods. (tolist): Handle objects by mapping through identity. (nullify): Implement for objects optionally: if an object is a struct with a nullify method, use it, otherwise go through default case of just returning the object. (empty): Implement for objects that have nullify method. (obj_init): Initialize nullify_s. * struct.c (maybe_slot): New function. * struct.h (maybe_slot): Declared. * txr.1: Documented car, cdr and nullify method convention.
* Print method on objects.Kaz Kylheku2016-06-012-1/+18
| | | | | | | | | * struct.c (print_s): New symbol variable. (struct_init): Initialize print_s. (struct_inst_print): If pretty-printing, try to look up object's print method and use it. * txr.1: Documented pretty-printing via print method.
* Eliminating the ! $ and - file-opening hacks.Kaz Kylheku2016-05-313-36/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Going forward, the "!command" and "$dir" are no longer recognized, except with the backward-compatibility -C option. The "-" string denoting standard input is only recognized from the command line, not in the @(next) directive; and "-" cannot be used in @(output) to denote standard output. The main problem is that these are hacks which intrude into the namespace. (What if a file is named "-", or begins with "!" or "$"?) Secondly, they are possible security holes. These prefixes are recognized even in computed strings, like "@(next var)" where var contains "!command". * Makefile (tst/tests/002/%): Run tests in this directory with the -C 142 option in TXR_OPTS, because they use the ! mechanism. * match.c (complex_open): New argument, from_cmdline, indicating whether the file name came from the command line or is internal. Function now only treats "-" as denoting standard input, if that came from the command line. The "!" and "$" prefixes are only recognized in compatibility with 142 or earlier. (v_next): Suppress old strategy of handling string sources by pushing them to the file list to let match_files open them. This is now done only under 142 compatibility. Instead, open directly, produce the list, and recurse into match_files with ready data. This is not only simpler, but also prevents "-" from being recognized in @(next), because complex_open is invoked directly, and the from_cmdline argument is specified as nil. (v_output): Don't rely on "-" denoting standard output; rather use the stream directly, which can be passed to complex_open. Pass nil to the new from_cmdline parameter of complex_open, so "-" isn't recognized. (open_data_source): Pass t for the from_cmdline parameter of complex_open, to have "-" recognized as denoting standard input. * txr.1: Removed documentation referring to !, and use of - in the @(next) and @(output) directives. Added notes to COMPATIBILITY section.
* Version 142.txr-142Kaz Kylheku2016-05-296-98/+132
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Turn flags in struct stdio_handle into bitfields.Kaz Kylheku2016-05-291-3/+3
| | | | | * stream.c (struct stdio_handle): Members is_rotated, is_real_time and is_byte_oriented become bitfields.
* Use width of 8 for struct dgram boolean bitfields.Kaz Kylheku2016-05-291-2/+2
| | | | | | | | * socket.c (struct dgram): Members is_connected and is_byte_oriented widened from 1 to 8 bits. This allows byte-access instructions to be used on architectures like x86. All the flags still fit into a word, so the structure doesn't get bigger.
* Support byte oriented mode in dgram sockets.Kaz Kylheku2016-05-292-4/+20
| | | | | | | | | * socket.c (struct dgram_stream): New member, is_byte_oriented. (dgram_get_char): In byte oriented mode, just get one byte and convert to a character just like stdio_get_char: zero goes to U+DC00, and 0x01-0xFF go to U+0001 to U+FFFF. (dgram_get_prop, dgram_set_prop): Handle :byte-oriented property for getting and setting the is_byte_oriented flag.
* Rename struct dgram_stream member.Kaz Kylheku2016-05-291-5/+5
| | | | | | | * socket.c (struct dgram_stream): Member sock_connected renamed to is_connected. (make_dgram_sock_stream, dgram_flush, sock_connect, sock_mark_connected): Follow rename.
* Support ISO C stream direction switching rules.Kaz Kylheku2016-05-281-0/+58
| | | | | | | | | | | | | | | | * stream.c (CONFIG_STDIO_STRICT): New preprocessor symbol. (enum stdio_op): New enum. (struct stdio_handle): New member, last_op. (stdio_switch): New static function, or macro. (stdio_put_string, stdio_put_char, stdio_put_byte): Indicate possible switch to write mode via stdio_switch. (stdio_flush): If the last direction wasn't write, don't bother doing anything. (stdio_get_char, stdio_get_byte): Indicate possible switch to read mode. (tail_strategy): Set last mode to stdio_none whenever new FILE * stream is installed. (make_stdio_stream_common): Initialize last_op member.
* Use byte-oriented stream in binary editing utility.Kaz Kylheku2016-05-281-1/+2
| | | | | | | | * txr-embedded-arg.txr (stream-positioned-to-right-place): Call stream-set-prop to mark stream as byte oriented. This is for the sake of the MinGW port, where reading binary files with UTF-8 decoding can throw errors about unsupported Unicode characters (those beyond 0xFFFF).
* Add a byte mode to stdio streams.Kaz Kylheku2016-05-282-11/+51
| | | | | | | | | | | | | | | | | * stream.c (byte_oriented_k): New keyword symbol variable. (struct stdio_handle): New member, is_byte_oriented. (stdio_get_prop): Retrieve the value of is_byte_oriented when the :byte-oriented property is inquired. (stdio_set_prop): Map :byte-oriented to the is_byte_oriented flag. (stdio_get_char): Do not decode UTF-8 if is_byte_oriented is set; just read one character. (make_stdio_stream_common): Initialize is_byte_oriented to 0. (stream_init): Initialize byte_oriented_k. * txr.1: Document :byte-oriented property, along with some clean-up and clarification in the description of properties.
* Replace new hash limit constants with variables.Kaz Kylheku2016-05-282-11/+30
| | | | | | | | | | | | | | | | | | | * genman.txr: Call set-hash-str-limit to set a generous limit for string hashing, which restores the old hash values in the HTML document, preserving the validity of existing URLs. * hash.c (hash_str_limit, hash_rec_limit): New static variables. (HASH_STR_LIMIT, HASH_REC_LIMIT): Preprocessor symbols removed. (hash_c_str, equal_hash): Use hash_str_limit. (gethash_c, gethash, gethash_f, gethash_n, remhash, hash_equal): Use hash_rec_limit. (set_hash_str_limit, set_hash_rec_limit): New static functions. (hash_init): Register sys:set-hash-str-limit and sys:set-hash-rec-limit intrinsics.
* Move registration of hash module functions to hash.cKaz Kylheku2016-05-282-41/+42
| | | | | | | | | | | | | | | * eval.c (gethash_s): Global symbol variable removed, due to being used only in one place. (eval_init): Remove registration of make-hash, make-similar-hash, copy-hash, hash, hash-construct, hash-from-pairs, hash-list, inhash, sethash, pushhash, remhash, hash-count, get-hash-userdata, set-hash-userdata, hashp, maphash, hash-eql, hash-equal, hash-keys, hash-values, hash-pairs, hash-alist, hash-uni, hash-diff, hash-isec, hash-subset, hash-proper-subset, group-by, group-reduce, hash-update, hash-update-1, hash-revget, hash-begin, hash-next. * hash.c (hash_init): Registrations removed from eval_init moved here.
* Store hash values in hash entries.Kaz Kylheku2016-05-272-19/+93
| | | | | | | | | | | | | | | | | | | | | | | | Here, we augment the cons cells used for the hash chain assoc lists with one more field to store the hash value. This lets us grow hash tables without recalculating the hashes, and to perform hash searches with fewer equality comparisons. * hash.c (struct hash): assoc_fun and acons_new_c_fun function pointers get a new cnum hash argument. (hash_equal_op): Pass cell's hash value to assoc_fun. (hash_grow): No need to compute each hash entry's hash code; just pull it out from the cell, and mod it with the new modulus to get the chain index. (hash_assoc, hash_assql, hash_acons_new_c, hash_aconsql_new_c): New static functions. (make_hash): Store hash_assoc, hash_assql, hash_acons_new_c and hash_aconsql_new_c in place of assoc, assql, acons_new_c and aconsql_new_c. (gethash_c, gethash, gethash_f, gethash_n, remhash): Pass hash alue to assoc_fun or acons_new_c_fun. * lib.h (struct cons_hash_entry): New struct type. (union obj): New member ch.
* Reduce work done by hashing.Kaz Kylheku2016-05-274-37/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Curtail traversal of objects and strings. * hash.c (struct hash): hash_fun member takes int * parameter now. (HASH_STR_LIMIT, HASH_REC_LIMIT): New macros. (hash_c_str): Hash only HASH_STR_LIMIT characters. (equal_hash): Becomes extern function. Takes pointer-to-int count argument, which is decremented. Function stops recursing and returns zero when this hits zero. (eql_hash): Also takes int * param, for compatibility with function pointer in struct hash. This parameter is not used, though. (cobj_hash_op): Take pointer-to-count parameter, but ignore it. (hash_hash_op): Take pointer-to-count parameter, decrement and check that it has not hit zero, pass down to equal hash. (hash_grow, gethash_c, gethash, gethash_f, gethash_n, remhash): Initialize a counter to HASH_REC_LIMIT and pass down to hashing function. (hash_eql): Pass down a pointer to a dummy counter to eql_hash. (hash_equal): Initialize a counter to HASH_REC_LIMIT and pass down to hash_equal. * hash.h (equal_hash): Declared. * lib.h (cobj_ops): hash member takes int * parameter. (cobj_hash_op): Declaration updated with new param. * struct.c (struct_inst_hash): Takes new int * parameter for count. Calls equal_hash instead of hash_equal, eliminating c_num calls; pointer to count is passed to equal_hash.
* Fix 2011-11-17 regression.Kaz Kylheku2016-05-271-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This addresses a regression caused by commit 68ca87bc780e25dea1418019161d99727225d1ce, affecting a hundred releases of TXR from 42 to 141. The copy_alist call to deeply clone the variable bindings was carelessly replaced with copy_list, to address the problem that functions weren't able to mutate outer bindings. However, the parameter binding code depends on the deep cloning; it destructively manipulates bindings with the understanding that they are copies that will be thrown away. Test case: @(define f0 (var)) @(end) @(define f1 (out1 out2 var)) @ (bind out1 `a:@var`) @ (maybe) @ (f0 `b:@var`) @ (end) @ (bind out2 `a:@var`) @(end) @(f1 o1 o2 "z") This program incorrectly binds o1 and o2 to different strings, "a:z" and "a:b:z" respectively, because the f0 pattern function call has the unwanted effect of mutating var. Expected behavior is that both o1 and o2 are bound to identical strings, "a:z" and "a:z". * match.c (h_fun, v_fun): When binding arguments, extend the environment with new bindings instead of trying to re-use existing ones, because we do not have a copy of the binding cells, like we used to when bindings_cp was produced by a copy_alist call.
* Remove superfluous arg defaulting in drop functions.Kaz Kylheku2016-05-261-4/+2
| | | | | | * lib.c (drop_while, drop_until): No need to do default_arg on keyfun, since it is just passed to pos_if, which takes care of it.
* Bugfix: argument defaulting in take-until.Kaz Kylheku2016-05-261-2/+2
| | | | | | * lib.c (take_until): keyfun not defaulted in list cases. Needless defaulting of key in vector/string cases, since pos function already defaults.
* Check manual for .cblk/.cble pairing.Kaz Kylheku2016-05-262-4/+20
| | | | | | | | * checkman.txr (check-cblk): New pattern function, hooked into main scan. * txr.1: Fixed four instances of .cblk closed by .cblk instead of .cble.
* Provide the txr-embedded-arg.txr utility.Kaz Kylheku2016-05-252-1/+100
| | | | | | * txr-embedded-arg.txr: New file. * txr.1: Documented.
* Stand-alone application support.Kaz Kylheku2016-05-252-18/+150
| | | | | | | | | | | | | | | | | | | * txr.c (sysroot_init): Don't print "unable to calculate sysroot" error message in the fallback case, and use the absolute path of the executable directory as the sysroot in this case. (txr_main): Define static area prefixed by @(txr): header. If a string is present in this data area then process it as an argument. Treat the *args* variable carefully. If we use the stored string as the argument, save the args in orig_args variable, then later bind *args* to that. In the -e, -p and related options processing, we bind *args* to the original list so args are available to the expression being evaluated. If the expression mutates *args* then we keep the mutated args whether or not we are processing the stored string. * txr.1: Documented in new sction, STAND-ALONE APPLICATION SUPPORT.
* New variable: txr-path.Kaz Kylheku2016-05-252-0/+12
| | | | | | | * txr.c (dirname): New static function. (sysroot_init): Register txr-path variable. * txr.1: documented txr-path.
* Track origin across op/do expansion.Kaz Kylheku2016-05-231-0/+2
| | | | | | | | * eval.c (me_op): We tell a little lie here, by indicating that the "dwim body" is an expansion of the op operator. Of course, the entire lambda containing that body is that expansion. But in error messages, we need something useful for the user.
* Allow whitespace between @ and ; in comments.Kaz Kylheku2016-05-232-3/+3
| | | | | | | * parser.l (grammar): Recognize {WS}* between @ and ; (or the legacy #) in comments. * txr.1: Documentation updated.
* Don't use sleep function in tail streams.Kaz Kylheku2016-05-233-20/+9
| | | | | | | | | | | | | | | Let's use our usleep_wrap function which uses nanosleep. The old sleep can interact with SIGALRM. * stream.c (tail_calc): Calculate microseconds instead of seconds. (sleep): Wrapper for Windows gone. (tail_strategy): Rename sec variable to usec. Use usleep_wrap instead of sleep. * sysif.c (usleep_wrap): Change to extern. * sysif.h (usleep_wrap): Declaration updated.
* Optional argument on remove-path.Kaz Kylheku2016-05-233-8/+19
| | | | | | | | | | * stream.c (remove_path): New parameter, throw_on_error. (stream_init): Update registratino of remove_path intrinsic. * stream.h (remove_path): Declaration updated. * txr.1: Updated remove-path documentation to describe throw-on-error-p parameter.
* Bugfix: strange diagostic for -B-c.Kaz Kylheku2016-05-231-2/+7
| | | | | | * txr.c (txr_main): Diagnose unrecognized long option in if/else statement that handles long options, rather than clumsily in switch for non-clumping options.
* Few more drop_privilege calls in txr_main.Kaz Kylheku2016-05-231-0/+2
| | | | | | * txr.c (txr_main): Drop setuid privilege as soon as we know we are just going to exit, before producing any diagnostic output, like in existing cases.
* Neglected documentation about @(next).Kaz Kylheku2016-05-231-3/+8
| | | | | txr.1: It wasn't documented that expr in @(next expr) can produce a stream.
* Version 141.txr-141Kaz Kylheku2016-05-206-500/+581
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* No such word: expressivity.Kaz Kylheku2016-05-201-1/+1
| | | | * txr.1: Replace Expressivity with Expressiveness.
* Capitalize Boolean.Kaz Kylheku2016-05-201-23/+23
| | | | * txr.1: Capitalize Boolean everywhere.
* Implement listener variable for selection style.Kaz Kylheku2016-05-192-17/+49
| | | | | | | | | | | * parser.c (listener_sel_inclusive_p_s): New symbol variable. (repl): Install current value of *listener-sel-inclusive-p* variable into linenoise. (parse_init): Initialize the symbol variable and register the Lisp special variable. * txr.1: Documented special variable and selection mode semantics.
* linenoise: support inclusive selection.Kaz Kylheku2016-05-192-3/+23
| | | | | | | | | | | | | | * linenoise/linenoise.c (struct lino_state): New mode flag, selinclusive. (lino_set_selinclusive, lino_get_selinclusive): New functions. (sync_data_to_buf): Adjust rightmost endpoint when selection is reversed and inclusive mode is in effect, so that the included character will be visually highlighted. (yank_sel, delete_sel): Adjust endpoint of selection if in in inclusive mode. * linenoise/linenoise.h (lino_set_selinclusive, lino_get_selinclusive): Declared.
* Help text upkeep.Kaz Kylheku2016-05-181-0/+7
| | | | | * txr.c (help): Note the existence of --args and --eargs, without giving a full description.
* Grammar under Dot Position in Function Calls.Kaz Kylheku2016-05-181-2/+2
| | | | * txr.1: maybe -> may be.
* Streamline text about where Lisp is evaluated.Kaz Kylheku2016-05-181-16/+14
| | | | | | * txr.1: Just list directives that take Lisp; drop the details. Point out that no @ is needed for access to Lisp variable.
* Fix outdated example.Kaz Kylheku2016-05-181-1/+1
| | | | | * txr.1: @ is not required on Lisp variables.
* Formatting fix under make-random-stateKaz Kylheku2016-05-181-1/+1
| | | | * txr.1: Mistake in syntax markup.
* Use sys_load_s symbol variable.Kaz Kylheku2016-05-181-1/+1
| | | | | | * eval.c (eval_init): Use sys_load_s variable set up earlier in the function instead of redundant call to intern.
* New feature: self-load-path symbol macro.Kaz Kylheku2016-05-186-8/+94
| | | | | | | | | | | | | | | | | | | | | * eval.c (self_load_path_s): New symbol variable. (sys_load): Save, set-up and restore self-load-path around load. (set_get_symacro): New function. (eval_init): Register load function using sys_load_s instead of redundant intern. * eval.h (set_get_symacro): Declared. * match.c (v_load): Save, set-up and restore self-load-path macro. * parser.c (load_rcfile): Likewise. * txr.c (txr_main: Set up self-load-path when opening file. * txr.1: Documented self-load-path.
* Add notes about cursor shape and selection semantics.Kaz Kylheku2016-05-181-0/+23
| | | | | | | * txr.1: In Interactive Listener sections, note what "character under the cursor" means when a vertical cursor is in effect, and add notes about how the selection semantics pairs well with that style of cursor.
* New functions: at-exit-call and at-exit-do-not-call.Kaz Kylheku2016-05-183-0/+69
| | | | | | | | | | | | | | * sysif.c (at_exit_list): New static variable. (at_exit_call, at_exit_do_not_call): New functions. (at_exit_handler): New static function. (sysif_init): GC-protect at_exit_list. Register at_exit_handler with C atexit function. Register intrinsic functions at-exit-call and at-exit-do-not-call. * sysif.h (at_exit_call, at_exit_do_not_call): Registered. * txr.1: Documented.
* Handle integer overflow in length_list.Kaz Kylheku2016-05-181-2/+14
| | | | | | * lib.c (length_list): Count using cnum only up to INT_PTR_MAX, then switch to bignums.