summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Version 235.txr-235Kaz Kylheku2020-04-126-81/+133
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* txr: spurious retention in @(next).Kaz Kylheku2020-04-111-3/+16
| | | | | | | | | | | | | | * match.c (mf_file_lazy): New static function. The lazy list is created here and stored directly into the data field of the context structure. Function is marked NOINLINE because on an older system with gcc 4.4.5, it didn't solve the problem. We need the function to have a stack frame so any spurious copies of the linked list go into a frame that disappears when the function returns. (v_next_impl): Use mf_file_lazy instead of mf_file_data. (open_data_source): Also make this function INLINE just in case because it contains calls to lazy_stream_cons.
* txr: avoid by-value match_files_ctx passing.Kaz Kylheku2020-04-111-117/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Passing the match_files_ctx structure by value looks nice in the code, but it is contributing to a long standing false retention issue. This test case runs in constant memory: $ yes | txr -c '@(skip) n' skip scans through the lazy list of "y" lines looking for an "n" that never comes. This version should also run in constant memory, but shows unbounded memory growth. $ yes | txr -c '@(next *stdin*) @(skip) n' This patch doesn't fix it, but it moves things in that direction. * match.c (mf_all, mf_args, mf_data, mf_spec, mf_spec_bindings, mf_file_data, mf_from_ml): Take pointer to structure which to initialize and return that pointer, instead of initializing a local structure and returning it by value. (match_files): Take pointer to context rather than copy. (h_call, do_match_line, v_fuzz, v_block, v_next_impl, v_parallel, v_gather, v_collect, v_bind, hv_trampoline, v_try, v_fun, v_if, v_assesrt, v_load, v_call, match_filter, match_fun, extract): Adjust to by-pointer context handling of mf_all, match_files and other functions.
* hash: bugfix: spurious retention in weak processing.Kaz Kylheku2020-04-112-38/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The algorithm for weak processing is not correct. In hash_mark, we must must simply not mark any of the entries, keys or values, of a weak table regardless of what type of weak table it is. If we do that, we cause spurious retention in situations that the keys and values have some kind of link together other than through the table. For instance, suppose keys are weak, but values happen to have references to keys. If we mark the values, we mark the keys and nothing will expire from the table. Such a situation happens in stream_parser_hash, which associates streams with parsers, and has weak keys. Parsers have references to streams. So entries in the hash never expire. Any stream that gets a parser is retained forever. The weak hashes used for binding in eval.c (top_vb, ...) are also affected, because the key is some symbol <sym> and the value is (<sym> . <val>). The key is weak, but the value references the sym. So these hashes also will not expire the keys: unreachable variable bindings will stick around. * hash.c (hash_mark): If a hash table has weak keys, values, or both, then only mark its vector if the count is zero. If it has one or more entries, we just add it to the reachable_weak_hashes list to be processed in do_weak_tables.
* gc: add argument to sys:gc.Kaz Kylheku2020-04-102-3/+16
| | | | | | | | * gc.c (gc_wrap): Takes argument for requesting full garbage collection. (gc_late_init): Update registration of gc intrinsic. * txr.1: Documented.
* parser: eliminate struct list_accum.Kaz Kylheku2020-04-102-47/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | As a final round of this recent work, we observe that since the accumulator structure has been reduced to two members, we can eliminate one of them by using a cons cell as the accumulator, and threading the second value through the cdr. That is to say, the listacc grammar rule's semantic value will now be the tail cons of the list being constructed. The cdr of this cons will, temporarily, be a back pointer to the head (making the list temporarily circular). The n_exprs reduction will fix this up; it will put the correct terminating atom in place of the head (either nil, or the dotted item if there is one), and yield the head as the semantic value. * lib.h (struct list_accum): Removed. (Thus, finding a better home for this would, after all, have been a waste of time). * parser.y (lacc, splacc): Static functions removed. (union YYSTYPE): lacc membber removed. (n_exprs): Adjust to new semantic value coming from listacc. (listacc): Now of type val again. Yields pointer to tail cons as semantic value, whose cdr points to the head of the list.
* parser: move cons dot handling to higher rule.Kaz Kylheku2020-04-102-19/+3
| | | | | | | | | | | | | | * lib.h (struct list_accum): dot member removed. * parser.y (misplaced_consing_dot_check): Function removed. The misplaced consing dot diagnostic is still provided as before by yybadtoken. (n_exprs): Production for CONSDOT is moved here out of listacc. There is no $1.dot member to deal with; the dot is very simply handled here. (listacc): Remove calls to misplaced_consing_dot_check. CONSDOT production moved to n_exprs. (lacc, splacc): Remove initialization of dot member.
* parser: streamline core list building.Kaz Kylheku2020-04-092-47/+63
| | | | | | | | | | | | | | | | | | | | | The r_expr grammar symbol is replaced with listacc which has a different type: a new Yacc node type that has three fields for building a list from left to right without nreverse, and the dotted pair item. * lib.h (struct list_accum): New struct type. Not a great place for it, but we don't have a parser-specific header that is included before y.tab.h: parser.h is included after y.tab.h. * parser.y (misplaced_consing_dot_check): The val argument is just the existing dotted item; if it is other than nao, the error is generated. (lacc, splacc): New static functions. (YYSTYPE): New union member, lacc of type struct list_accum. (r_exprs): Grammar symbol removed. (listacc): New grammar symbol of type listacc. The rules are those of r_exprs upgraded to construct the list in one pass.
* doc: stat/fstat: bad syntax formatting.Kaz Kylheku2020-04-091-2/+2
| | | | * txr.1: > should be >>.
* repl: improve dotfile security tests.Kaz Kylheku2020-04-093-6/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We test the .txr_history file for bad permissions also, not only .txr_profile. Though commands are not automatically executed out of .txr_history, a user could execute a harmful command due to not noticing the malicious modification. An additional useful diagnostic is added: if a dotfile is found to have the wrong permission, it's possible that this is due to a poor umask setting. We check for a weak umask and warn the user. Note: the .txr_history check doesn't use the open stream, therefore it is vulnerable to TOCTTOU race condition: the file looks good, but between the time we verify this and open the file to load it, the file has been replaced by a malicious one. * parser.c (report_security_problem): New static function, factored out of load_rcfile. Includes umask test. (load_rcfile): Call report_security_problem if the .txr_profile is writable to others. Also, no need to call stat any more; the path testing function now takes a stream argument. (repl): Check .txr_history for inappropriate writepermissions also and call report_security_problem if so. * sysif.c (umask_wrap): Change static function to external linkage. * sysif.c (umask_wrap): Declaration updated.
* path testing functions: accept stream argument.Kaz Kylheku2020-04-092-18/+32
| | | | | | | * share/txr/stdlib/path-test.tl (do-path-test): Check also for the argument being a stream, and pass to statfun. * txr.1: Documentation updated and improved.
* tags: @(bind) should generate variable tags.Kaz Kylheku2020-04-071-1/+1
| | | | | * tags.tl (process-clause): Symbols from @(bind) should be recorded as variable tags, not function tags.
* doc: read, iread: document lineno parameter.Kaz Kylheku2020-04-071-5/+14
| | | | | | | | * txr.1: The read and iread functions have an optional parameter for overriding the starting line number. It is now documented. read and lisp-parse got this parameter in 2015, in TXR 123. iread was introduced with this parameter in TXR 124.
* doc: bad grammer compilation section.Kaz Kylheku2020-04-071-1/+1
| | | | | * txr.1: Replace "apperas to compiles" typo with better wording.
* exceptions: improve non-error @(throw) and @(assert).Kaz Kylheku2020-04-072-3/+42
| | | | | | | | | | | | | | | When @(throw) generates a non-error exception that is unhandled, we just want it to continue. In the same situation, an @(assert) should behave as a failed match; that is, the failure of the query material that follows the assert, which activated it, should propagate through the assert. * match.c (v_throw): Return next_spec_k if uw_rthrow returns. (v_assert, h_assert): Return nil if uw_rthrow returns. * txr.1: Expanded @(throw) and @(assert) documentation with discussion of unhandled exceptions.
* exceptions: use uw_rthrow for non-error exceptions.Kaz Kylheku2020-04-074-13/+13
| | | | | | | | | | | | | | | | | | | * eval.c (eval_exception): This function is shared by warnings and errors. Use uw_throw. The eval_error caller already has an abort() after its eval_exception call, which makes that code path continue to be equivalent to uw_throw. The behavior changes for the other caller, eval_warn, which will now return if the warning is not handled. (eval_defr_warn, gather_free_refs, gather_free_refs_nw): Throw non-error exception with uw_rthrow. * match.c (v_throw, v_assert, h_assert): Use uw_rthrow for these directives, just like the throw function. * parser.c (repl_intr, repl_warning): Use uw_rthrow. * unwind.c (uw_muffle_warning, uw_release_deferred_warnings): Likewise.
* warning cleanup: GNU C++ initializer warnings.Kaz Kylheku2020-04-067-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | | This is the eight and final round of an effort to enable GCC's -Wextra option. The C++ compiler, with -Wextra, doesn't like C's universal struct initializer { 0 }, individually complaining about all the remaining members not being initialized. What works in C++ is the { } initializer. Conditional definition to the rescue. * lib.h (all_zero_init): New macro which expands to { } under C++, and { 0 } under C. * lib.c (make_time_impl, epoch_tm, time_string_meth, time_parse_meth): Use all_zero_init. * parser.c (prime_parser): Likewise. * socket.c (sock_mark_connected): Likewise. * sysif.c (fcntl_wrap): Likewise. * termios.c (encode_speeds, decode_speeds): Likewise. * configure (diag_flags): Add -Wextra.
* exceptions: unhandled non-error exceptions now return.Kaz Kylheku2020-04-063-43/+161
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes a fundamental change in exception behavior. Going forward, if an exception that is not derived from error is not handled (no catch intercepts it, and no handler accepts it) then the throw call simply returns nil to the caller instead of unwinding and terminating the process. For error exceptions, the behavior is the same: the *uhandled-hook* is called, if it exists, and if it doesn't exist or returns, unwinding and termination with diagnostics ensues. The rationale for not treating non-error exceptions fatally is that this simplifies the use of code that throws exceptions for non-error situations like progress updates. The code can be used without the caller having to establish a handler. * txr.1: Documentation updates and comaptibility notes. * unwind.c (uw_rthrow): New returning throw function based on the implementation of uw_throw. (uw_rthrowv, uw_rthrowvf): New functions. (uw_throw): Now a wrapper for uw_rthrow. Because uw_throw still does not return, it calls abort if uw_rthrow returns. uw_throw is used internally only for error exceptions. (uw_throwv, uw_throwfv): Functions removed. (uw_late_init): Register throw and throwf to the new functions uw_rthrowv an uw_rthrowfv. * unwind.h (uw_rthrow, uw_rthrowv, uw_rthrowfv): Declared. (uw_throwv, uw_throwfv): Declarations removed.
* warning cleanup: suspicious switch fallthrough cases.Kaz Kylheku2020-04-056-4/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the seventh round of an effort to enable GCC's -Wextra option. Warnings about switch fallthrough situations are addressed. GCC now has a diagnostic for this that is enabled by -Wextra in such a way that if a fallthrough comment is present, the diagnostic is suppressed. In much of the code, we have such a comment. It's missing in a few places, or misplaced. There are also some real bugs. * hash.c (hash_buf): Add fallthrough comments to intentional fallthrough cases. (hash_hash_op): bugfix: add break statement. The 32 and 64 bit cases are independent (at compile time). * lib.c (cdr, nullify, list_collect, empty): Add fallthrough comment. (int_str): Add missing break. This has not caused a bug though because setting the octzero flag in the zerox case is harmless to the logic which follows. * linenoise.c (edit): Move misplaced fallthrough. * sysif.c (fcntl_wrap): Bugfix: add missing break, without which errno is tampered to hold EINVAL, in spite of a successful F_SETLK, F_SETLKW or F_GETLK operation. * unwind.h (jmp_restore): Declare noreturn, so that GCC does not issue a false positive warning about a fallthrough in uw_unwind_to_exit_point. * utf8.c (utf8_from_buf, utf8_decode): Move a fallthrough comment outside of preprocessing, so it is properly processed by GCC's diagnostic.
* warning cleanup: missing member initializers.Kaz Kylheku2020-04-056-27/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the sixth round of an effort to enable GCC's -Wextra option. Warnings about uninitialized members are addressed. I am not happy with what had to be done in linenoise.c. We just need a dummy circular list node for the lino_list, which we achieved with a dummy all zero struture, with statially initialized next and prev pointers. There are way too many members to initialize, including one that has struct termios type containing a nonportable set of members. On the plus size, the lino_list structure now moves into the BSS section, reducing the executable size slightly. * lib.c (cptr_ops): Initialize using cobj_ops_init, which has all the initializers already, and should have been used for this in the first place. * linenoise/linenoise.c (lino_list): Remove initializer, which eliminates the warning about some members not being initialized. (lino_init): Initialize the next and prev pointers here. * parser.c (parser_ops): Initialize with cobj_ops_init. * stream.h (stdio_mode_init_blank, stdio_mode_init_r, stdio_mode_init_rpb): Add initializer corresponding to redir array member of struct stdio_mode. * sysif.c (cptr_dl_ops): Use cobj_ops_init. * tree.c (tree_iter_init): Add initializer for the path array member of struct tree_iter. (tr_rebuild): Initialize all fields of the dummy object. Since it's a union, we just have to deal with the any member. There are two layouts for the obj_common fields based on whether CONFIG_GEN_GC is enabled. This is ugly, but occurs in one place only.
* warning cleanup: empty do/while style.Kaz Kylheku2020-04-051-2/+2
| | | | | | | | | | This is the fifth round of an effort to enable GCC's -Wextra option. * signal.h (sig_save_enable, sig_save_disable): Fix the compiler warning about do ; while (0) benefiting from braces around the empty statement. I agree with this; I was momentarily confused myself by that semicolon.
* warning cleanup: unsigned < 0 comparisons.Kaz Kylheku2020-04-052-7/+7
| | | | | | | | | | | | | | | This is the fourth round of an effort to enable GCC's -Wextra option. Instances of code that test whether an unsigned quantity is negative are repaired. Real bugs are found. * itypes.c (c_u32, c_uint, c_ulong): Remove useless comparison for < 0 that was copy-pasted from the signed cases. * linenoise/linenoise.c (show_help, edit): Do not test the return value of the getch_fn callback for negative. It returns wint_t, which may be unsigned. Test for the WEOF value. This is a bug because since the original comparison is always false, the code fails to catch the WEOF return.
* warning cleanup: signed/unsigned in ternaries.Kaz Kylheku2020-04-055-6/+6
| | | | | | | | | | | | | | | | | | | | | This is the third round of an effort to enable GCC's -Wextra option. Instances of signed/unsigned mismatch between the branches of ternary conditionals are addressed. * ffi.c (pad_retval): Add cast into the consequent of the conditional so it yields size_t, like the alternative. * lib.c (split_str_keep): Likewise. (vector): Cast -1 to ucnum so it has the same type as the alloc_plus opposite to it. * parser.c (lino_getch): Add a cast to wint_t to match return value and opposite WEOF operand. * stream.c (generic_get_line): Likewise. * sysif.c (c_time): Convert both consequent and alternative to time_t to silence warning.
* warning cleanup: remove unused parameters.Kaz Kylheku2020-04-059-31/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the second round of an effort to enable GCC's -Wextra option. All function parameters that are unused and are removable are removed. They are eliminated from the function defintions, declarations, callers, and any related function pointer variables or structure members. * arith.c (nary_simple_op): Remove unused self parameter. See lib.c: maxv, minv. * chksum.c (crc32_buf, crc32_str): Remove unused self parameter. (crc32): Don't pass self to the above functions. * eval.c (copy_env_handler, copy_bh_env_handler): Remove unused parent parameter. See unwind.c. (supplement_op_syms): Remove unused max parameter. (me_op): Don't pass max to supplement_op_syms. * lib.c (seq_iter_rewind): Remove unused self parameter. (lazy_flatten_func): Remove unused env parameter. (lazy_flatten): Use func_n1 to create non-environment-carrying funtion out of lazy_flatten_func. (maxv, minv): Don't pass self parameter to nary_simple_op. (middle_pivot): Remove unused lessfun param. (quicksort): Don't pass lessfun to middle_pivot. (diff, isec): Don't pass self to seq_iter_rewind. * lib.h (seq_iter_rewind, nary_simple_op): Declarations updated. * struct.c (get_super_slots): Remove unused self parameteer. (make_struct_type): Don't pass self to get_super_slots. * sysif.c (flock_unpack): Remove unused self parameter. (fcntl_wrap): Don't pass self to flock_unpack. * unwind.c (uw_push_cont_copy): Remove parent parameter from function pointer parameter. See eval.c: copy_env_handler. (call_copy_handlers): Remove parent parameter and don't pass that argument to the indirect call via pointer to the copy handler function. (revive_cont, capture_cont): Don't pass 0 value to removed parent parameter of call_copy_handlers. * unwind.h (struct uw_cont_copy): Function pointer member copy loses parent parameter. (uw_push_cont_copy): Declaration updated.
* warning cleanup: add casts for unused parameters.Kaz Kylheku2020-04-0513-4/+283
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the first round of an effort to enable GCC's -Wextra option. All function parameters that are unused an that we cannot eliminate are treated with a cast to void in the function body. * args.c (args_key_check_store): Cast unused param to void. * combi.c (perm_list_gen_fill): Likewise. * eval.c (op_error, op_meta_error, op_quote op_qquote_error, op_unquote_error, op_load_time_lit, me_each, me_for, me_quasilist, me_flet_labels, hash_min_max, me_ignerr, me_whilet, me_iflet_whenlet, me_dotimes, me_mlet, me_load_time, me_load_for): Likewise. * ffi.c (ffi_void_put, ffi_fixed_dynsize, *ffi_fixed_alloc, ffi_noop_free, ffi_void_get, ffi_simple_release, ffi_i8_put, ffi_i8_get, ffi_u8_put, ffi_u8_get, ffi_i16_put, ffi_i16_get, ffi_u16_put, ffi_u16_get, ffi_i32_put, ffi_i32_get, ffi_u32_put, ffi_u32_get, ffi_i64_put, ffi_i64_get, ffi_u64_put, ffi_u64_get, ffi_char_put, ffi_char_get, ffi_uchar_put, ffi_uchar_get, ffi_bchar_get, ffi_short_put, ffi_short_get, ffi_ushort_put, ffi_ushort_get, ffi_int_put, ffi_int_get, ffi_uint_put, ffi_uint_get, ffi_long_put, ffi_long_get, ffi_ulong_put, ffi_ulong_get, ffi_float_put, ffi_float_get, ffi_double_put, ffi_double_get, ffi_val_put, ffi_val_get, ffi_be_i16_put, ffi_be_i16_get, ffi_be_u16_put, ffi_be_u16_get, ffi_le_i16_put, ffi_le_i16_get, ffi_le_u16_put, ffi_le_u16_get, ffi_be_i32_put, ffi_be_i32_get, ffi_be_u32_put, ffi_be_u32_get, ffi_le_i32_put, ffi_le_i32_get, ffi_le_u32_put, ffi_le_u32_get, ffi_be_i64_put, ffi_be_i64_get, ffi_be_u64_put, ffi_be_u64_get, ffi_le_i64_put, ffi_le_i64_get, ffi_le_u64_put, ffi_le_u64_get, ffi_wchar_put, ffi_wchar_get, ffi_sbit_get, ffi_ubit_get, ffi_cptr_get, ffi_str_in, ffi_str_put, ffi_str_get, ffi_str_d_get, ffi_wstr_in, ffi_wstr_get, ffi_wstr_put, ffi_wstr_d_get, ffi_bstr_in, ffi_bstr_put, ffi_bstr_get, ffi_bstr_d_get, ffi_buf_in, ffi_buf_put, ffi_buf_get, ffi_buf_d_in, ffi_buf_d_put, ffi_buf_d_get, ffi_closure_put, ffi_ptr_in_in, ffi_ptr_in_d_in, ffi_ptr_in_out, ffi_ptr_out_in, ffi_ptr_out_out, ffi_ptr_out_null_put, ffi_ptr_out_s_in, ffi_flex_struct_in, ffi_carray_get, ffi_union_get, make_ffi_type_builtin, make_ffi_type_array, ffi_closure_dispatch, ffi_closure_dispatch_safe): Likewise. * gc.c (cobj_destroy_stub_op, cobj_destroy_free_op, cobj_mark_op): Likewise. * lib.c (seq_iter_get_nil, seq_iter_peek_nil): Likewise. * linenoise/linenoise.c (sigwinch_handler): Likewise. * parser.c (repl_intr, read_eval_ret_last, repl_warning, is_balanced_line): Likewise. * parser.y (yydebug_onoff): Likewise. * socket.c (dgram_close): Likewise. * stream.c (unimpl_put_string, unimpl_put_char, unimpl_put_byte, unimpl_unget_char, unimpl_unget_byte, unimpl_put_buf, unimpl_fill_buf, unimpl_seek, unimpl_truncate, unimpl_set_sock_peer, null_put_string, null_put_char, null_put_byte, null_get_line, null_get_char, null_get_byte, null_close, null_flush, null_seek, null_set_prop, null_get_error, null_get_error_str, null_clear_error, null_get_fd, dir_close): Likewise. * struct.c (struct_type_print): Likewise. * unwind.c (me_defex): Likewise.
* tags: handle macro-timeKaz Kylheku2020-04-051-1/+1
| | | | * tags.tl (process-form): Handle top-level macro-time form.
* tags: bugfix: process progn correctly.Kaz Kylheku2020-04-051-1/+1
| | | | | | * tags.tl (process-form): Use mappend for the recursive processing, not mapdo, and invoke pend on the result to add it to the accumulated list.
* tags: process only pkg clauses of load-for.Kaz Kylheku2020-04-051-1/+4
| | | | | | * tags.tl (process-package-influencing-form): When a load-for is encountered, only descend into fake-load if the clause kind is pkg, and the package doesn't exist.
* tags: use sys:make-anon-packageKaz Kylheku2020-04-051-1/+1
| | | | | | | * tags.tl (in-anon-package): Take advantage of the system function sys:make-anon-package which is used in the file compiler, instead of creating a package named "anon" which could plausibly clash with an existing package.
* tags: completely restore package list for each file.Kaz Kylheku2020-04-051-6/+4
| | | | | | | | * tags.tl (in-anon-package): Instead of the unwind-protect which deletes the anonymous package, let us save and restore the *package-alist* by dynamically binding it to its current value. This will roll back packages that were created by fake-load.
* tags: follow loads and define needed packages.Kaz Kylheku2020-04-051-1/+24
| | | | | | | | | | | | * tags.tl (*fake-load-path*): New special variable. (process-package-influencing-form, fake-load): New functions. (process-form): Pass each compound form to process-package-influencing-form in case it might be a defpackage or load. (collect-tags-tl): Bind *fake-load-path* to the file's path so fake-load will resolve relative paths relative to the file's own directory, similarly to how load works with *load-path*.
* tags: process files in anon package.Kaz Kylheku2020-04-041-4/+15
| | | | | | | | | | Let's process each file in an anonymous package, saving and restoring the *package* special. TXR files can mess with that variable. * tags.tl (in-anon-package): New macro. (collect-tags-tl, collect-tags-txr): Wrap parsing with in-anon-package macro.
* tags: wrong flattening function in @(bind) handling.Kaz Kylheku2020-04-041-1/+1
| | | | | * tags.tl (process-clause): Bugfix: flatcar must be used, not flatten, because the bindings can contain dotted notation.
* tags: grok Lisp definitions inside @(do ...).Kaz Kylheku2020-04-031-1/+9
| | | | | | | | | | | * tags.tl (unexpand): New function. (process-clause): Walk the forms enclosed in a @(do ...) directive that appears at the top level. Because all Lisp is macro-expanded right inside the TXR parser, we need to "unexpand" the forms by chasing their macro-ancestor chain, gaining access to the original forms like defun and defstruct. We can then turn these forms into tags using the process-form function.
* tags: first cut at handling .txr files.Kaz Kylheku2020-04-031-65/+114
| | | | | | | | | | | | | | | | | | | Handles only top-level define and bind. * tags.tl (with-tag-shorthand-macro): New macro: a robot for writing the the shorthand macrolet in collect-tags, so we can reuse it. (process-form): New function, made from the bulk of collect-tags. (collect-tags): Renamed to collect-tags-tl. The macrolet is replaced by invocation of with-tag-shorthand macro and the form case processing logic by a call to process-form. (process-clause, collect-tags-txr, collect-tags-guess): New functions. (toplevel): Help text updated. Process .txr files through collect-tags-txr. Also process unsuffixed files, if they are explicity mentioned on the command line, through collect-tags-guess, which looks for hash-bang lines containing the --lisp option.
* tags: backslashes require escape.Kaz Kylheku2020-04-031-1/+1
| | | | | | | * tags.tl (escape): Vim is failing to find tag entries when the search patterns are lines containing backslashes. Backslash must be added to the list of characters needing escaping in tag patterns.
* New function: txr-parse.Kaz Kylheku2020-04-024-0/+94
| | | | | | | | | | | | txr-parse provides a way for Lisp code to programmatically parse the TXR language and obtain the Lisp represenation. This has hitherto not been available. * eval.c (eval_init): Register txr-parse intrinsic. * parser.c (txr_parse): New function. * parser.h (txr_parse): Declared.
* linenoise: command to force submission of unbalanced line.Kaz Kylheku2020-03-282-2/+14
| | | | | | | | | | * linenoise.c (edit): Handle Ctrl-F in extended mode so that Ctrl-X Ctrl-F forces the line to be submitted without a balance check. * txr.1: Document previously undocumented balance check, including the flashing exclamation mark. Document Ctrl-X Ctrl-F.
* doc: revise descriptions under Listener.Kaz Kylheku2020-03-251-27/+34
| | | | | | | | | | | | | | The recent commit 7c40d5d6ef6832baed4a5ccd0a5d4235ed4f5ee3 states that the documentation has been updated. However, it contains no changes to txr.1 at all. I swear I made the changes, but they somehow disappeared. They are not in my reflog or stash or any file in the filesystem. Gone! Here, I reproduce those changes, with some additional improvements and fixes. * txr.1: Rewrite the description of Ctrl-D. Document the new effect that major deletion operations all copy into the clipboard. Fix "It's" typo that should be "Its".
* configure: allow variables to contain quotes.Kaz Kylheku2020-03-251-1/+1
| | | | | | | | | * configure: When generating the assignment that stores the value of the command line variable into the corresponding shell variable, interpolate $val between single quotes in such a way that single quotes occurring in $val are replaced by the pattern '\''. Thus, variables may contain any character whatsoever.
* configure: remove C diagnostic options under C++.Kaz Kylheku2020-03-251-0/+34
| | | | | | | * configure (cplusplus): New variable. Check ccname and cc for signs of C++; if so, set the new variable to 'y'. If the variable is set, then filter C-specific options out of diag_flags.
* Version 234.txr-234Kaz Kylheku2020-03-256-608/+669
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Regenerated.
* doc: typeof: missing BST types.Kaz Kylheku2020-03-241-0/+6
| | | | * txr.1: List tnode and tree types in typeof description.
* open-process: fix regression.Kaz Kylheku2020-03-241-1/+1
| | | | | | | TXR 228, which introduced open-subprocess, broke open-process. * stream.c (open_process): Pass args correctly as the fourth argument of open_subprocess, rather than the third.
* New contains function: near alias of search.Kaz Kylheku2020-03-234-1/+23
| | | | | | | | | | | | Harmonizes with starts-with and ends-with. * eval.c (eval_init): Register contains intrinsic. * lib.c (contains): New function. * lib.h (contains): Delared. * txr.1: Documented.
* method: use new dynamic args to avoid consing list.Kaz Kylheku2020-03-231-9/+10
| | | | | | | | * struct.c (method_args_fun): env parameter is now a dynamic args object. Code adjusted accordingly. (method): Duplicate args into a dyn_args object instead of a list. Because a dyn_args has a car and cdr field, we can eliminate the two conse as well.
* umethod: use new dynamic args to avoid consing list.Kaz Kylheku2020-03-233-7/+18
| | | | | | | | | | | | | * args.c (args_cat): New function. * args.h (args_cat): Declared. * struct.c (umethod_args_fun): env parameter is now a dynamic args object. Code adjusted accordingly. (umethod): Duplicate the args into a dynamic args object instead of consing up a list and also eliminate the temporary cons since we can pass the additional argument using the car field of the dynamic args.
* apf and ipf: take arguments that are inserted.Kaz Kylheku2020-03-222-9/+54
| | | | | | | | | | | | | | The apf and ipf functions now take arguments in addition to the function that is being wrapped. If specified, these arguments are inserted to the left the applied arguments. * eval.c (do_args_apf, do_args_ipf): New static functions. (apf, ipf): Use do_args_apf and do_args_ipf, respectively, for handling the case when arguments are present. Passing the stored arguments is done with the help of the new DARG type, instead of consing up a list. * txr.1: Documented new arguments of apf and ipf.
* New type args with DARG type code.Kaz Kylheku2020-03-227-2/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | An object of args type captures into the heap the "struct args" argument list that normally appears only on the stack. Such an object also has space for a car and cdr field, which can come in handy. * args.c (dyn_args): New function: hoist a struct args * into an args heap object. * args.h (dyn_args): Declared. * gc.c (finalize, mark_obj): Handle DARGS type code. * hash.c (equal_hash): Handle DARG via eq equivalence. * lib.c (args_s): New symbol variable. (code2type): Map DARG to args symbol. (equal): Handle DARG type, using eq equivalence for now. (obj_init): Initialize args_s with interned symbol. * lib.h (enum type, type_t): New type code, DARG. (struct dyn_args): New struct. (union obj): New member, a of type struct dyn_args. * txr.1: Documented args type under typeof.
* dump-compiled-objects: wrong self name.Kaz Kylheku2020-03-221-1/+1
| | | | | * share/txr/stdlib/compiler.tl (dump-compiled-objects): Fixed incorrect value of self variable.