summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* tests: json: skip tests relying on cat, if missing.Kaz Kylheku2021-07-121-7/+9
| | | | | | | * tests/010/json.tl: skip several test cases which rely on the cat utility for testing command-put-json, if the cat utility is not found in the search path. Reported and investigated by Paul A. Patience.
* tests: json: fix accidentally excluded tests.Kaz Kylheku2021-07-121-2/+2
| | | | | | * tests/010/json.tl: Fix several tests being excluded from the (mtest ...) form to which they are expected to belong, one of them having an extra quote in the expected value, too.
* tests: 002 group: skip test if utils missing.Kaz Kylheku2021-07-121-0/+2
| | | | | | * tests/002/query-1.txr: Terminate with status 13 if the needed utils cannot be found in the search path. Reported and investigated by Paul A. Patience.
* tests: .txr tests can skip using exit code 13.Kaz Kylheku2021-07-121-5/+6
| | | | | * Makefile (tst/%.ok): If a .txr test terminates with status 13, that indicates that it should be skipped.
* doc: interchange first two args of json put funs.Paul A. Patience2021-07-111-6/+6
| | | | | | txr.1: Interchange the first and second arguments of file-put-json, file-put-jsons, file-append-json, file-append-jsons, command-put-json and command-put-jsons.
* txr: fix inappropriate "takes no argument".Kaz Kylheku2021-07-111-5/+43
| | | | | | | | | | | | | | txr is reporting "option --<foo> takes no argument" for any unknown option <foo>, which is silly. * txr.c (no_dbg_support): Drop setuid privilege here before doing the output. (txr_main): Block that diagnoses "takes no argument" is now reachable only by goto. Every no-argument option tests the org variable and branches there if there are arguments. Some rearrangement of drop_privilege() calls and insertion of missing ones via it now being called in no_dbug_support.
* configure: adjust comment in config.make.Kaz Kylheku2021-07-111-1/+2
| | | | | | * configure (gen_config_make): Maintenance in comment above top_srcdir. It obviously does not hold an absolute path in the case when it is blank.
* New: build-id feature.Kaz Kylheku2021-07-114-0/+51
| | | | | | | | | | | | | | | | | | | | | | A build-id is a string optionally embedded into TXR at build time which can be displayed with a command line option. It can help developers who are juggling multiple builds in their workspace to identify what they are running. * Makefile (txr.o, txr-win.o): If a build_id has been defined, then define the TXR_BUILD_ID macro on the command line when compiling these object files. * configure (build_id): New variable. (help) Describe build_id. (gen_config_make): Generate build_id and build_id_exp make variables. * txr.1: Documented --build-id option. * tsr.c (build_id): Conditionally defined global variable. (help): Brief help string for --build-id. (txr_main): Process --build-id option.
* doc: fix in --version option.Kaz Kylheku2021-07-111-1/+2
| | | | | * txr.1: Revise description of --version command line option for grammar and accuracy.
* compiler: disallow trailing slashes in path.Kaz Kylheku2021-07-101-1/+3
| | | | | * stdlib/compiler.tl (open-compile-streams): If in-path end in a path separator character, throw an error.
* doc: finish incomplete sentence about hlet.Kaz Kylheku2021-07-101-1/+7
| | | | | | * txr.1: In a paragraph about the differences between compiled and interpretd behavior, complete a sentence about hlet/hlet* variables. Spotted by Paul A. Patience.
* doc: improve.Paul A. Patience2021-07-102-89/+101
| | | | | | | | | | | | * RELNOTES: Fix minor issues. * txr.1: Fix various grammatical errors, typos and other issues. Notably, use en dashes rather than hyphens for ranges of numbers; replace "exponential notation" with "E notation", which is more commonly used (according to Wikipedia; see https://en.wikipedia.org/wiki/Scientific_notation#E_notation); clarify that with-stream is better than with-resources for opening exactly one stream; and use past tense in the Compatibility Version Values section.
* doc-lookup: ignore BROWSER when empty.Paul A. Patience2021-07-102-11/+12
| | | | | | | | | * stdlib/doc-lookup.tl (open-url): Treat empty BROWSER variable as if it were unset (i.e., ignore it). Otherwise the doc function silently fails rather than falling back to alternative URL-opening methods. * txr.1: Documented.
* New function: add-suffix.Kaz Kylheku2021-07-105-0/+149
| | | | | | | | | | | * stream.c, stream.h (add_suffix): New function. (stream_init): add-suffix intrinsic registered. * tests/018/path.tl: Tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New functions: trim-short-suffix, trim-long-suffix.Kaz Kylheku2021-07-107-0/+191
| | | | | | | | | | | | | | | * lib.c, lib.h (chk_substrdup): New function. * stream.c, stream.h (trim_short_suffix, trim_long_suffix): New functions. (stream_init): trim-short-suffix and trim-long-suffix intrinsics registered. * tests/018/path.tl: New tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* suffix functions: new test cases.Kaz Kylheku2021-07-101-1/+3
| | | | | * tests/018/path.tl: New cases covering dotted name situation, which is not a suffix, but can have a suffix.
* lib: tests for keep-if, remove-if, separate.Kaz Kylheku2021-07-101-0/+42
| | | | * tests/012/seq.tl: New tests.
* lib: new function separate.Paul A. Patience2021-07-095-5/+131
| | | | | | | | | | | | * lib.c (separate): New function. * lib.h (separate): Declared. * eval.c (eval_init): Register separate intrinsic. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* compiler: remove case of ad-hoc path catenation.Kaz Kylheku2021-07-091-2/+1
| | | | | * compiler.tl (open-compile-streams): Use path-cat instead of quasiliteral.
* compiler: use short-suffix.Paul A. Patience2021-07-091-15/+10
| | | | | | | | | * stdlib/compiler.tl (open-compile-streams): Replace usage of %file-suff-rx% with a call to short-suffix. Streamline (subjectively) the obtention of ip-nosuff. Replace calls to ends-with with a casequal on the suffix. Actually make use of ip-nosuff. (%file-suff-rx%): Delete (now unused) variable.
* lib: c++ fix.Kaz Kylheku2021-07-091-1/+1
| | | | | | | lib.c (built_in_type): Use i for stepping over the enumeration, because type_t has no postfix ++ operator for i++. The code2type function takes an int, and so no cast is required.
* defstruct: diagnose built-in type being redefined.Kaz Kylheku2021-07-097-9/+25
| | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register built-in-type-p intrinsic. * lib.c (buitin_type_p): Rename to built_in_type_p since the word built-in is hyphenated. The function also tests whether the argument is a COBJ class. (cobj_class_exists): Function removed. * stdlib/doc-syms.tl: Updated. * stdlib/struct.tl (defstruct): Add built-in-type-p check. * struct.c (make_struct_type): Call only built_in_type_p; cobj_class_exists is gone. * txr.1: Document built-in-type-p.
* struct: rework stype_handle change.Kaz Kylheku2021-07-092-29/+34
| | | | | | | | | | | | | | | | | | | | | | | The change which allows stype_handle to recognize struct instances, and obtain their type, has some possibly unwanted ramifications, since the function is widely used. Let's refactor things so that, for now, only the struct_type_name function takes advantage of this flexibility. * struct.c (stype_handle_impl): New static function, copy of stype_handle, but taking an obj_ok Boolean argument to indicate whether an object instance is an acceptable argument, whose type should be fetched. (stype_handle): Now a wrapper around stype_handle_impl passing nil for the obj_ok argument. (stype_handle_obj): New static function. Passes t for the ok_obj argument of stype_handle_impl. (struct_type_name): Call stype_handle_obj instead of stype_handle. (super): Take advantage of stype_handle_obj to reduce code. * txr.1: Update documentation of struct-type-name, and improve that of super.
* subtypep: handle COBJ inheritance.Kaz Kylheku2021-07-092-10/+50
| | | | | | | | | | | | | | | | | | * lib.c (class_from_sym): New static function. (subtypep): Remove special case handling of stream versus stdio-stream. If the two types are not both structures, then check whether they are both cobj classes. If so, check if they are in an inheritance relationship via the cobj_hash. (cobj_populate_hash): Map each symbol to a fixnum integer which gives class handle'position in the cobj_class table. (cobj_class_exists): Style: compare to nil instead of 0. (obj_init): Do not call cobj_populate_hash here, it is far too early: only a couple of COBJ types exist at this point. Moreover, hash_init has not been called so hash_cls and hash_iter_cls still have null symbols. (init): Call obj_populate_hash here, as the last step. * tests/012/type.tl: New file.
* gc: don't mark COBJ cls_sym.Kaz Kylheku2021-07-091-1/+1
| | | | | | * gc.c (mark_obj): We don't need to mark this because it's necessarily a protected symbol handled by prot_sym. Waste of cycles.
* type: disallow structs using built-in type names.Kaz Kylheku2021-07-0830-271/+451
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a big commit motivated by the need to clean up the situation with built-in type symbols, COBJ objects and structs. The struct type system allows struct types to be defined for symbols like regex or str, which are used by built-in or cobj types. This is a bad thing. What is worse, structure instances are COBJ types which identify their type using the COBJ class symbol mechanism. There are places in the C implementation which assume that when a COBJ has a certain class symbol, it is of a certain expected type, which is totally different from and incompatible form a struct instance. User code can define a structure object which will fool that code. There are multiple things going on in this patch. The major theme is that the COBJ representation is changing. Instead of a class symbol, COBJ instances now carry a "struct cobj_class *" pointer. This pointer is obtained by registration via the cobj_register function. All modules must register their class symbols to obtain these class handles, which are then used in cobj() calls for instantiation. The CPTR type was identical to COBJ until now, except for the type tag. This is changing; CPTR objects will keep the old representation with the class symbol. commit 20fdfc6008297001491308849c17498c006fe7b4 Author: Kaz Kylheku <kaz@kylheku.com> Date: Thu Jul 8 19:17:39 2021 -0700 * ffi.h (carray_cls): Declared. * hash.h (hash_cls): Declared. (hash_early_init): Declared. * lib.h (struct cobj_class): New struct. (struct cobj): cls member changing to struct cobj_class *. (struct cptr): New struct, same as previous struct cobj. (union obj): New member cp of type struct cptr, for CPTR. (builtin_type): Declared. (class_check): Declaration moved closer to COBJ-related functions and updated. (cobj_register, cobj_register_super, cobj_class_exists): New functions declared. (cobjclassp, cobj_handle, cobj_ops): Declarations updated. * parser.h (parser_cls): Declared. * rand.h (random_state_cls): Declared. * regex.h (regex_cls): Declared. * stream.h (stream_cls, stdio_stream_cls): Declared. * struct.h (struct_cls): Declared. * tree.h (tree_cls, tree_iter_cls): Declared. * vm.h (vm_desc_cls): Declared. * buf.c (buf_strm, make_buf_stream): Pass stream_cls functions instead of stream_s class symbol. * chksum.c (sha256_ctx_cls, md5_ctx_cls): New static class handles. (sha256_begin, sha256_hash, sha256_end, md5_begin, md5_hash, md5_end): Pass class handles to instead of class symbols. (chksum_init): Initialize class handle variables. * ffi.c (ffi_type_cls, ffi_call_desc_cls, ffi_closure_cls, union_cls): New static class handles. (carray_cls): New global variable. (ffi_type_struct_checked, ffi_type_print_op, ffi_closure_struct_checked, ffi_closure_print_op, make_ffi_type_builtin, make_ffi_type_pointer, make_ffi_type_struct, make_ffi_type_union, make_ffi_type_array, make_ffi_type_enum, ffi_call_desc_checked, ffi_call_desc_print_op, ffi_make_call_desc, ffi_make_closure, carray_struct_checked, carray_print_op, make_carray, cptr_getobj, cptr_out, uni_struct_checked, make_union_common): Pass class handles instead of class symbols. (ffi_init): Initialize class handle variables. * filter.c (regex_from_trie): Use hash_cls class handle instead of hash_s. * gc.c (mark_obj): Split COBJ and CPTR cases since the representation is different. * hash.c (hash_cls, hash_iter_cls): New class handles. (make_similar_hash, copy_hash, gethash_c, gethash_e, remhash, clearhash, hash_count, get_hash_userdata, set_hash_userdata, hashp, hash_iter_init, hash_begin, hash_next, hash_peek, hash_reset, hash_reset, hash_uni, hash_diff, hash_symdiff, hash_isec): Pass class handles instead of class symbols. (hash_early_init): New function. (hash_init): Set the class symbols in the class handles that were created in hash_early_init at a time when these symbols did not exist. * lib.c (nelem): New macro. (cobj_class): New static array. (cobj_ptr): New static pointer. (cobj_hash): New static hash. (seq_iter_cls): New static class handle. (builtin_type_p): New function. (typeof): Struct instances now all carry the same symbol, struct, as their COBJ class symbol. To get their type, we must call struct_type_name. (subtypep): Rearrangement of two cases: let's make the reflexive case first. Adjust code for different location of COBJ class symbol. (seq_iter_init_with_info, seq_begin, seq_next, seq_reset, iter_begin, iter_more, iter_item, iter_step, iter_reset, make_like, list_collect, do_generic_funcall): Use class handles instead of class symbols. (class_check, cobj, cobjclassp, cobj_handle, cobj_ops): Take class handle argument instead of class symbol. (cobj_register, cobj_register_super, cobj_class_exists): New functions. (cobj_populate_hash): New static function. (cobj_print_op): Adjust for different location of class (cptr_print_op, cptr_typed, cptr_type, cptr_handle, cptr_get): cptr functions now refer to obj->cp rather than obj->co. (copy, length, sub, ref, refset, replace, dwim_set, dwim_del, obj_print): Use class handles for various COBJ types rather than class symbols. (obj_init): gc-protect cobj_hash. Initialize seq_iter_cls class symbol and cobj_hash. Populate cobj_hash as the last initialization step. (init): Call hash_early_init immediately after gc_init. diff --git a/lib.c b/lib.c * match.c (do_match_line): Refer to regex_cls class handle instead of regex_s.. * parser.c (parser_cls): New global class handle. (parse, parser_get_impl, lisp_parse_impl, txr_parse, parser_errors): Use class handles instead of class symbols. (parse_init): Initialize parser_cls. * rand.c (random_state_cls): New global class handle. (make_state, random_state_p, make_random_state, random_state_get_vec, random_fixnum, random_float, random): Use class handles instead of class symbols. (rand_init): Initialize random_state_cls. * regex.c (regex_cls): New global class handle. (chset_cls): New static class handle. (reg_compile_csets, reg_derivative, regex_compile, regexp, regex_source, regex_print, regex_run, regex_machine_init): Use class handles instead of class symbols. (regex_init): Initialize regex_cls and chset_cls. * socket.c (make_dgram_sock_stream): Use stream_cls class symbol instead of stream_s. * stream.c (stream_cls, stdio_stream_cls): New class handles. (make_null_stream, stdio_get_fd, make_stdio_stream_common, stream_fd, sock_family, sock_type, sock_peer, sock_set_peer, make_dir_stream, make_string_input_stream, make_string_byte_input_stream, make_strlist_input_stream, make_string_output_stream, make_strlist_output_stream, get_list_from_stream, make_catenated_stream, make_delegate_stream, make_delegate_stream, stream_set_prop, stream_get_prop, close_stream, get_error, get_error_str, clear_error, get_line, get_char, get_byte, get_bytes, unget_char, unget_byte, put_buf, fill_buf, fill_buf_adjust, get_line_as_buf, format, put_string, put_char, put_byte, flush_stream, seek_stream, truncate_stream, get_indent_mode, test_set_indent_mode, test_neq_set_indent_mode, set_indent_mode, get_indent, set_indent, inc_indent, width_check, force_break, set_max_length, set_max_depth): Use class handle instead of symbol. (stream_init): Initialize stream_cls and stdio_stream_cls. * struct.c (struct_type_cls, struct_cls): New class handles. (struct_init): Initialize struct_type_cls and struct_cls. (struct_handle): Static function moved to avoid forward declaration. (stype_handle): Refer to struct_type_cls class handle instead of struct_type_s symbol. Handle instance objects in addition to types. (make_struct_type): Throw error if a built-in type is being defined as a struct type. Refer to class handle instead of class symbol. (find_struct_type, allocate_struct, make_struct_impl, make_lazy_struct, copy_struct): Refer to class handle instead of class symbol. * strudel.c (make_struct_delegate_stream): Refer to stream_cls class handle instead of stream_s symbol. * sysif.c (dir_cls): New class handle. (poll_wrap): Use typep instead of subtypep, eliminating access to class symbol. (opendir_wrap, closedir_wrap, readdir_wrap): Use class handles instead of class symbols. (sysif_init): Initialize dir_cls. * syslog.c (make_syslog_stream): Refer to stream_cls class handle instead of stream_s symbol. * tree.c (tree_cls, tree_iter_cls): New class handles. (tree_insert_node, tree_lookup_node, tree_delete_node, tree_root, tree_equal_op, tree, copy_search_tree, make_similar_tree, treep, tree_begin, copy_tree_iter, replace_tree_iter, tree_reset, tree_next, tree_peek, tree_clear): Use class handle instead of class symbol. (tree_init): Initialize tree_cls and tree_iter_cls. * unwind.c (sys_cont_cls): New static class handle. (revive_cont, capture_cont): Use class handle instead of class symbol. (uw_late_init): Initialize sys_cont_cls. * vm.c (vm_desc_cls): New global class handle. (vm_closure_cls): New static class handle. (vm_desc_struct, vm_make_desc, vm_closure_struct, vm_make_closure, vm_copy_closure): Use class handle instead of class symbol. (vm_init): Initialize vm_desc_cls and vm_closure_cls.
* type: MAXTYPE doesn't account for DARG.Kaz Kylheku2021-07-082-1/+2
| | | | | | | | * lib.h (enum type): Change MAX_TYPE to correctly alias the last type DARG, rather than the second-to-last TNOD type. * lib.c (seq_kind_tab): Include an entry for DARG, mapping to SEQ_NOTSEQ.
* streams: put-string, put-char: missing type check.Kaz Kylheku2021-07-071-2/+4
| | | | | | | * stream.c (put_string, put_char): Use cobj_handle to validate the object, rather than directly accessing stream->co.handle. This was reported as a (put-line "foo" nil) crash reported by Paul A. Patience.
* with-resources: undocumented nil skip behavior.Kaz Kylheku2021-07-073-4/+54
| | | | | | | | | | | | | | | Paul A. Patience discovered the hidden "feature" of with-resourcers, that the three-argument form of the binding (var init cleanup) causes the with-resources form to terminate if init returns nil. The (var init) syntax doesn't generate this logic. * stdlib/with-resources.tl (with-resources): Do not emit the when form unless <= 265 compatibility is in effect. * tests/012/oop-mac.tl: New file. * txr.1: Compat note added.
* doc: base-name: nil suffix defaulting, improvement.Kaz Kylheku2021-07-061-5/+52
| | | | | | * txr.1: Document that the suffix argument to base-name may be given as nil, which is the same as omitting it. Nearby wording improved. Give rationale for this, and add examples.
* sh: reduce scope of variables.Kaz Kylheku2021-07-061-1/+1
| | | | | * streamc (shell, shell_arg): External variables become internal.
* streams: do not close stderr.Kaz Kylheku2021-07-061-1/+1
| | | | | | | * stream.c (stdio_close): Recognize stderr, not only stdin and stdout, as one of the streams not to be closed. This fixes situations when stderr is closed and exception handling tries to use it.
* unwind: stop runaway recursion.Kaz Kylheku2021-07-061-1/+4
| | | | | | | | | | | | | | | Before uw_rthrow calls uw_unwind_to_exit_point, it decrements the reentry_count, so that function is not protected against re-entry. We could protect some of its internal code agains re-entry, like the use of a bad stderr stream, if we extend the scope of that variable. * unwind.c (reentry_count): New static variable, moved to file scope from uw_rthrow function. (uw_unwind_to_exit_point): Bump up the reentry count in two places where we print diagnostics and terminate. If the diagnostic code hits an exception, the uw_rthrow will see the positive reentry count and abort.
* unwind: refer to top-level *stderr* stream.Kaz Kylheku2021-07-063-9/+14
| | | | | | | | | | | | | | | | | | | | | Exception processing should refer to the original, top-level value of *stderr* rather than the current dynamic value, even if unwinding has not yet taken place. Using the dynamic value can not only cause critical output to disappear, but it leads to a false positive identification of the "unhandled exception in early initialization" situation, a diagnostic which is emitted on the C stderr if the Lisp one is unavailable, which is assumed to be due to initialization not having yet completed. * stream.c (top_stderr): New global variable. (stream_init): GC-protect top_stderr, and initialize it with the same object that goes into the *stderr* top-level binding. * stream.h (top_stderr): Declared. * unwind.c (uw_unwind_to_exit_point, uw_rthrow): Use top_stderr instead of std_error macro.
* regex-compile: argument defaulting issue.Kaz Kylheku2021-07-051-1/+1
| | | | | | | | | | | | | * regex.c (regex_compile): In the string case when regex_parse needs to be called, redundant argument defaulting is being performed on error_stream, defaulting it to nil. The regex_parse function doesn't like that; it no longer accepts nil as a facsimile of missing. The right thing to do here is nothing: just pass error_stream to regex_parse as-is and let it do the defaulting. And that is how the code was initially until commit a8b0e36b1760e51a8a3a25d4e22a325e407ef3d4 in March of 2014, which introduced the redundant defaulting. Reported by Paul A. Patience
* expander: use expand_error everywhere.Kaz Kylheku2021-07-051-66/+66
| | | | | | | | | | | | | | | All expand-time errors go through expand_error for compiler-stylen error reporting. * eval.c (not_bindable_error, dotted_form_error): Only expander helper functions call these helpers so they get switched to expand_error. (expand_opt_params_rec, expand_params_rec, expand_param_macr, expand_lisp1, expand_lisp1_value, expand_lisp1_setq, expand_setqf, expand_qquote_rec, expand_vars, expand_fbind_vars, me_case, me_whilet, me_iflet_whenlet, me_load_for, expand_catch_clause, expand_switch, me_l1_val, me_l1_setq): Use expand_error instead of eval_error.
* macro params: use compiler-style error reporting.Kaz Kylheku2021-07-051-27/+30
| | | | | | | | | | | | | | | | | * eval.c (bind_macro_params): Take the error reporting function as a functional argument which points either to eval_error or expand_error. Update all the recursive calls to pass it down. Replace all calls to eval_error with this function pointer. (me_interp_macro, op_mac_param_bind, op_mac_env_param_bind): Call bind_macro_params with expand_error as the function, so that under the right circumstances, the error will go to standard error, as well as being thrown as an exception. In the case of me_interp_macro, this is clear. The reason we do it for the other two is that their primary use case is inside macros. (op_tree_case, op_tree_bind): Pass eval_error to mac_param_bind, preserving existing behavior.
* expander: tighten up syntax checking.Kaz Kylheku2021-07-053-59/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_exception): New parameter distinguishes whether this function is called from expansion time. If so, it behaves similarly to the compile-error funtion in error.tl: if a recursive load is in effect, a there is no error handler, then deferred warnings are dumped to standard error, followed by the error message. Then the exception is thrown. (eval_error, eval_warn): Pass zero to eval_exception to indicate that this is not expansion time. (expand_error, missing_arg_error, excess_args_error, no_dot_check, syn_check): New static functions. (me_def_variable, me_each, me_for, me_gen, me_gun, me_delay, me_when, me_unless, me_while_until, me_whie_until_star, me_equot, me_case, me_dotimes, me_lcons, me_mlet, me_load_time, me_l1_val, me_l1_setq, me_assert): Add syntactic checks to built-in macros. (do_expand): Add syntactic checks for a number of special operators. * unwind.c (catch_frame_s): New symbol variable. (uw_late_init): Initialize catch_frame_s and use that in registering the catch-frame structure. * unwind.c (catch_frame_s): Declared.
* main: revise error-ignore strategy for Lisp file.Kaz Kylheku2021-07-051-8/+5
| | | | | | | | | | | | | | | | | | | txr can process a Lisp file specified on the command line and then enter into the listener. In order to always enter the listener, even if the file errors out, the execution of the file uses read_eval_stream_noerr, which was written for this purpose. But this causes a problem for error reporting which is sensitive to whether or not an error handler exists. (See the compile-error function, and how it uses find-frame.) * txr.c (txr_main): Because we already know whether we are going to be entering the listener, we can split the evaluation of the Lisp file into two cases: if we will be entering the listener, we evaluate it with ignored error exceptions. If we won't be entering the listener, we evaluate normally. With this, I can run "make tests" now and be taken to the locaton of certain errors, due to the messages appearing on standard error.
* tests: fix malformed chmod.tl.Paul A. Patience2021-07-051-11/+11
| | | | | | * tests/018/chmod.tl (os): Fix final parentheses of defvarl form accidentally encompassing the rest of the source file. Replace tabs with spaces.
* doc-lookup: add support for OpenBSD.Paul A. Patience2021-07-051-2/+3
| | | | | * stdlib/doc-lookup.tl (os-symbol): Add case for OpenBSD. (open-url): Same.
* genman, lib, tests: use defvarl where possible.Paul A. Patience2021-07-0510-40/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * genman.txr (dupes, tagnum): Replace defvar with defvarl. * stdlib/doc-lookup.tl (os-symbol): Same. * tests/011/macros-3.tl (x): Same. * tests/011/mandel.txr (x-centre, y-centre, width, i-max, j-max, n) (r-max, pixel-size, x-offset, y-offset): Same. (file, colour-max): Delete (unused) variables. * tests/012/circ.tl (x): Replace defvar with defvarl. * tests/012/stack.tl (stack-limited): Same. * tests/012/struct.tl (s): Same. * tests/013/maze.tl (vi, pa, sc): Delete variables. Use function arguments instead. (usage): Fix typo. * tests/014/dgram-stream.tl (family): Rename to... (*family*): ...this. * tests/014/socket-basic.tl (socktype): Rename to... (*socktype*): ...this. (%iters%): Replace defvar with defvarl.
* build: update some targets.Paul A. Patience2021-07-051-10/+15
| | | | | | | | | | | | * Makefile (tainted): Fix typo. Reword sentence. (rebuild): Remove obsolete references to repatch target. (clean, distclean): Remove tst directory. Separate directory removals from file removals. Remove txr-manpage.html and txr-manpage.pdf in both distclean targets. In non-configured distclean, correct the removal of .tlo files to be from the stdlib directory rather than from share (and limit the pattern to *.tlo rather than *.tlo*, since .tlo2 files are no longer generated); and explicitly remove config.h and config.make, just like the configured distclean.
* Version 265.txr-265Kaz Kylheku2021-07-047-933/+993
| | | | | | | | | | | | | | * RELNOTES: Updated. * configure (txr_ver): Bumped version. * stdlib/ver.tl (lib-version): Bumped. * txr.1: Bumped version and date. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* listener: treat unset and empty EDITOR the same.Paul A. Patience2021-07-042-2/+2
| | | | | | | * linenoise/linenoise.c (edit_in_editor): Treat empty EDITOR variable as if it were unset (i.e., do nothing). * txr.1: Documented.
* doc: check for spurious spaces.Paul A. Patience2021-07-042-4/+21
| | | | | | | | | | | * checkman.txr (check-spaces): New pattern function for checking for spurious spaces (i.e., two spaces or more in a row) in .meIP, .meti and .mets macros. * txr.1: Fix two instances of spurious spaces ("@\ newline" and "@\ space" examples). Conform the "@\x hex-digits" and "@\ octal-digits" examples to the fixed ones; this is more intuitive since there must be no space before the digits in the escape sequence.
* checkman: fix typos.Paul A. Patience2021-07-041-3/+2
| | | | | * checkman.txr (check-synb): Correct :min to :mintimes. (check-meti): Fix typo in comment.
* stack-limit: impose minimum limit.Kaz Kylheku2021-07-042-8/+18
| | | | | | | | | | | | | * gc.c (MIN_STACK_LIMIT): New preprocessor symbol. (gc_init): If the system stack limit is too low, don't treat that the same way as a missing or unlimited limit. Instead clamp to the minimum value and hope for the best. So that is to say, the system limit cannot be used as a mechanism to set a ridiculously low stack limit in TXR; the only way to do that is to use the set-stack-limit function. * txr.1: Documentation updated. Also fixed 326767 typo which should be 32767.
* stack-limit: always set a stack limit.Kaz Kylheku2021-07-041-0/+3
| | | | | | | | | | | Even if built without getrlimit, and even if getrlimit reports an unlimited stack size, set up a default limit. * gc.c (DFL_STACK_LIMIT): New preprocessor symbol, defined as 128 kilbytes for a small memory configuration, otherwise 16 megabytes. (gc_init): Set up a default stack limit unconditionally based on DFL_STACK_LIMIT before probing getrlimit.
* stack-limit: bug: not handling RLIM_INFINITY.Kaz Kylheku2021-07-042-7/+10
| | | | | | | | | | | | | | | | * gc.c (gc_init): We must check rlim_cur for the RLIM_INFINITY value indicating unlimited stack, and not misuse this value as a limit number, otherwise hilarity ensues. This reproduced on an older platform with make 3.81, which calls setrlimit to bring about an unlimited stack, passed on to child processes. Because of this txr segfaulted, as a consequence of a false positive. * tests/012/stack.tl (stack-limited): New variable which indicates whether there is a stack limit. If there isn't, we avoid running the fork-based test case. Also, we set the stack limit to 32768 so we have a limit against which to run some of the tests.