summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* paths: new tests.Kaz Kylheku2021-07-151-0/+46
| | | | | * tests/018/path.tl: test coverage for abs-path-p and portable-abs-path-p.
* lib: default_arg_strict becomes macro.Kaz Kylheku2021-07-141-4/+1
| | | | | | | | | | | * lib.h (default_arg_strict): Inline function converted to macro, so that we can suppress the evaluation of the default expression if it is not required. The default_arg_strict idiom is being used all over the stream library now. The common default value expressions like std_out are macros that access the dynamic variable by symbol. We don't want to be wastefully doing that on each stream operation, whether or not a stream argument has been supplied.
* build: recompile txr.c if build_id changes.Kaz Kylheku2021-07-141-2/+9
| | | | | | | | | | | | | | | | | | With this change, it is possible to make build_id=abcd to rebuild TXR with the given build ID. Any changes in the value of a dynamic, git-generated build_id will likewise trigger a rebuild. * Makefile (old_build_id): New variable. We read the old build ID from a file called .build_id in the build directory. If it differs from the current expanded ID, build_id_exp, we remove the object files affected by build_id. In all cases, we then write the current build ID into the .build_id file. (clean, distclean): Remove .build_id.
* sysif: create rlim struct even without HAVE_RLIM.Kaz Kylheku2021-07-141-3/+1
| | | | | | | | | | The reason for this change is that we don't want syntax like #S(rlim cur 0 max 0) to fail to read in a build of TXR that happens not to have detected getrlimit. * sysif.c (rlim_s, cur_s, max_s, rlim_st): Define variables unconditionally. (sysif_init): Initialize variables unconditionally.
* tests: fix stack overflow test case for old gmake.Kaz Kylheku2021-07-141-2/+7
| | | | | | | | | | | | | | | * tests/012/stack.tl: The (if stack-limited ...) test is not correct because even if gerlimit indicates an unlimited stack, we impose a defualt limit, and so (get-stack-limit) returns a an integer value. The idea here was to try to skip this test case when the stack usage is unlmited, which happens under older versions of GNU make, before posix_spawn was introduced. Instead, let's execute this test case only if we have setrlimit. In the forked child, we try to impose a small stack limit that will give use the stack overflow crash we are testing for. The objective of the test case is to validate that when (set-stack-limit 0) is called, the child will abort due to a signal, rather than (recur) returning :so.
* doc: warm-up-period argument of make-random-state.Kaz Kylheku2021-07-131-7/+14
| | | | | | * txr.1: Add missing requirement: warm-up is also not performed if make-random-state is a vector. Improve the wording overall.
* rand: support buffers as random seeds.Kaz Kylheku2021-07-133-6/+129
| | | | | | | | | * rand.c (make_random_state): Recognize buffer object as sources of bits for seeding. * tests/013/rand.tl: New file. * txr.1: Documented.
* rand: remove unnecessary type check.Kaz Kylheku2021-07-131-2/+1
| | | | | | * rand.c (make_random_state): We dn't have to use cobj_handle here because the object isn't an argument; we just instantiated in the same scope, with the correct type.
* New functions: getrlimit, setrlimit.Kaz Kylheku2021-07-134-1/+170
| | | | | | | | | | | | | | | | * stdlib/doc-syms.tl: Updated. * sysif.c (rlim_s, cur_s, max_s): New symbol variables. (rlim_st): New variable. (getrlimit_wrap, setrlimit_wrap): New functions. (sysif_init): gc-protect rlim-st. Initialize symbol vsariables. Create rlim struct type. Register getrlimit and setrlimit intrinsics. Register variables rlim-saved-max, rlim-saved-cur, rlim-infinity, rlimit-core, rlimit-cpu, rlimit-data, rlimit-fsize, rlimit-nofile, rlimit-stack and rlimit-as. * txr.1: Documented under new Unix Resource Limits section.
* sysif: bug: bogosity in protect call.Kaz Kylheku2021-07-131-1/+1
| | | | | * sysif.c (sysif_init): The address of dirent_st must be registered with protect, not the value.
* configure: tone down language.Kaz Kylheku2021-07-131-1/+1
|
* tests: guix fixes.Kaz Kylheku2021-07-135-4/+11
| | | | | | | | | | | | | | | | * tests/002/query-1.txr: Skip test if an executable /bin/sh doesn't exist, rather than the bogus reasons. * tests/010/json.tl: Change the condition for the command-put-json tests: not whether cat is found in the search path but whether /bin/sh exists and is executable. * tests/017/realpath.tl: Also quit if /usr/bin doesn't exist. * tests/018/path-test.tl: Exit succesfully if /bin/sh does not exist. Revert the earlier change. * tests/018/process.tl: Quit if no executable /bin/sh exists.
* Version 266.txr-266Kaz Kylheku2021-07-047-1323/+1365
| | | | | | | | | | | | | | * 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.
* tests: weaken condition in path search for sh.Kaz Kylheku2021-07-121-1/+1
| | | | | | | * tests/018/path-test.tl: In the Guix build environment, the shell might be found at a path not ending in bin. Let's ust test for ending in /bin. Reported and investigated by Paul A. Patience.
* 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.