summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* New sspl function.Kaz Kylheku2020-07-224-1/+17
| | | | | | | | | | | * eval (eval_init): Register sspl, an argument-reversed interface to split-str-set. * lib.c (sspl): New function. * lib.h (sspl): Declared. * txr.1: Documented.
* distat: bugfix: use lstat.Kaz Kylheku2020-07-202-9/+8
| | | | | | | | | | * sysif.c (dirstat): Call lstat_wrap, rather than stat_wrap. This function must report about the directory entry itself, not about what that entry points to if it happens to be a symlink. The d-type member of the dirent structure representing a symlink must be set to dt-lnk. * txr.1: Updated.
* stat, lstat and dirstat now take struct param.Kaz Kylheku2020-07-204-23/+41
| | | | | | | | | | | | | | | * ftw.c (ftw_callback): Pass nil to new parameter of stat_to_struct, to have a new stat struct allocated as before. * sysif.c (stat_to_struct, stat_impl, stat_wrap, lstat_wrap dirstat): New optional parameter that lets caller specify an existing struct object to fill. (sysif_init): Adjust registrations of stat, fstat, lstat and dirstat for new optional parameter. * sysif.h (stat_to_struct, stat_wrap): Declarations updated. * txr.1: Documented.
* doc: add an implementation note for exceptions.Kaz Kylheku2020-07-171-0/+24
| | | | | | * txr.1: Add remarks on the differences between how TXR Lisp and ANSI CL deal with unhandled exceptions/conditions of type error and warning.
* doc: exception handling wording improvements.Kaz Kylheku2020-07-171-9/+19
| | | | | * txr.1: Improved wording and fixed some grammar issues in the the paragraphs that introduce TXR Lisp exception handling.
* More reasonable fallback for self path: revisited.Kaz Kylheku2020-07-141-0/+5
| | | | | | | | | | | | | | | | This partially reverts and reworks commit c5afb01548c5b6bf4ec83373b5e2e09f14690b01 from May 4, 2018. I have no idea why I replaced fallback code which does something quite reasonable: invokes realpath on the value from argv[0]. The commit comment claims that this breaks when the program is not invoked with an absolute path, but how can that be, if realpath is used? * txr.c (get_self_path): Let's keep TXR_INST_PATH, and return that in the case that progname_u8 is null, because of a null argv[0]. Otherwise, let's revert to the original strategy of calling realpath on progname_u8.
* doc: wrong symbol under cptr-buf.Kaz Kylheku2020-07-131-1/+1
| | | | * txr.1: cptr-buf syntax wrongly refers to cptr-obj.
* cptr: bugfix: cptr-out must fall back on tft->put.Kaz Kylheku2020-07-131-1/+4
| | | | | * ffi.c (cptr_out): tft->out may be null, in which case tft->put must be used.
* doc: spurious word under Variables.Kaz Kylheku2020-07-131-1/+1
| | | | | * txr.1: "two three" should be three. Found thanks to the keen eyes of Ivor Horton.
* doc: fix some mistakes in ffi-get and ffi-out.Kaz Kylheku2020-07-131-9/+7
| | | | | | * txr.1: Fix repeated "this this", and an an incorrect insinuation that the ffi-get has an obj argument. Rather, it returns an object.
* cptr: new cptr-get and cptr-out functions.Kaz Kylheku2020-07-132-0/+166
| | | | | | | | | | | | | | | | | These functions are quite helpful in dealing with semi-opaque types, like the xmlNode type of libxml2. Such types must be treated as an opaque handle when passed to and returned from the API, and not subject to any encoding or decoding, which means that the appropriate representation for them is via the cptr family of types. However, semi-opaque types also have client-visible members that must be accessed directly. These new functions provide for that access in a convenient way. * ffi.c (ffi_type_lookup_checked): New static function. (cptr_getobj, cptr_out): New static functions. (ffi_init): Register cptr-get and cptr-out. * txr.1: Documented.
* tags: take advantage of weak packages.Kaz Kylheku2020-07-121-1/+1
| | | | | | | * tags.tl (in-anon-package): Pass t to sys:make-anon-package, so the resulting package won't hold on to symbols that the utility isn't interested in, just because it's holding on to other symbols that come from the smae package.
* Support weak semantics in symbol packages.Kaz Kylheku2020-07-124-16/+35
| | | | | | | | | | | | | | | | | | | | | A package is weak if it holds weak references to symbols, meaning that if there are no references to a symbol other than its entry in a weak package, it can be removed from the package and reclaimed by the garbage collector. * eval.c (eval_init): Update registrations for make-package and sys:make-anon-package to reflect new optional argument. * lib.c (make_package_common): New argument weak. If it is true then both the hashes will have weak values. (make_package, make_anon_package): New optional argument weak. (obj_init): Add nil argument to calls to make_package. All the standard packages are regular, not weak. * lib.h (make_package, make_anon_package): Declarations updated. * txr.1: Documented.
* listener: new *-1, *-2 ... *-20 macros.Kaz Kylheku2020-07-115-2/+36
| | | | | | | | | | | | * arith.h (minus_s): Declared. * eval.c (reg_symacro): Changing to external linkage. * eval.h (macro_time_s, reg_symacro): Declared. * parser.c (repl): Bind the *-1 to *-20 symbol macros. * txr.1: Documented.
* Add dirstat function.Kaz Kylheku2020-07-092-24/+130
| | | | | | | | | | | | | | | | | | | This function back-fills the missing d-type information in a dirent on platforms that don't provide d_type in the native dirent. * sysif.c (DT_FIFO, DT_CHR, DT_DIR, DT_BLK, DT_REG, DT_LNK, DT_SOCK): Define all these preprocessor symbols to their Linux values on platforms where DT_DIR is not defined. (DT_UNKNOWN): Make sure this symbol is #undef-d if DT_DIR is not defined, so the corresponding dt-unknown variable does not exist. (dirstat): New static function. (sysif_init): Register dirstat intrinsic. Register dt-fifo and the rest unconditionally now. Changing their order to increasing numeric. * txr.1: Documented.
* Add missing closedir.Kaz Kylheku2020-07-092-3/+57
| | | | | | | | | | | | | * sysif.c (opendir_free): Since d->dir may now be null, avoid calling closedir on it in that situation. Also, set d->dir to null after closedir. (closedir_wrap): New static function. (readdir_wrap): If the d->dir is null, safely treat that as a directory entry not being available; do not pass a null DIR pointer to readdir. (sysif_init): Register intrinsic function closedir. * txr.1: Documented, plus spelling error fix under readdir.
* opendir: gc-correctness.Kaz Kylheku2020-07-091-1/+2
| | | | | | * sysif.c (opendir_wrap): Store path into d->path after allocating the cobj, because d->path may be the only reference to that object, and the cobj call may trigger gc.
* readdir: skip . and .. entriesKaz Kylheku2020-07-082-14/+28
| | | | | | | * sysif.c (readdir_wrap): If d_name is "." or ".." loop around and get another directory entry. * txr.1: Documented.
* iter_item: bugfix/omission.Kaz Kylheku2020-07-081-0/+5
| | | | | * lib.c (iter_item): Fix neglect in this function to check for an oop iterator and use its iter-item method.
* doc: iter-more vs oop iterator.Kaz Kylheku2020-07-081-2/+14
| | | | | * txr.1: Document that iter-more returns t when an oop-iterator does not feature the iter-more method.
* Expose low-level opendir/readdir dir traversal.Kaz Kylheku2020-07-085-12/+258
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stream.c (UTF_DECL_OPENDIR): Macro defined, to enable w_opendir declaration in utf8.h. (w_opendir): Static function removed. * sysif.c (UTF_DECL_OPENDIR): Macro defined. (dir_s): Symbol defined unconditionally now, regardless of HAVE_PWUID. (dirent_s): New symbol. (dirent_st): New static variable. (struct dir): New struct type. (opendir_free, opendir_mark opendir_wrap, readdir_wrap): New static functions. (opendir_ops): New static structure. (sysif_init): Intern dirent symbol. Create dirent structure type. Register opendir and readdir intrinsic functions. Register variables dt-blk, dt-chr, dt-dir, dt-fifo, dt-lnk, dt-reg, dt-sock and dt-unknown. * utf8.c (UTF8_DECL_OPENDIR): Macro defined. (w_opendir): Function moved here from stream.c, and turned external. * utf8.h (w_opendir): Declared, conditionally on UTF8_DECL_OPENDIR being defined, so that most modules that include utf8.h don't have to include <dirent.h>. * txr.1: Documented. diff --git a/sysif.c b/sysif.c
* uref/qref: read-print consistency issue.Kaz Kylheku2020-07-081-4/+12
| | | | | | | | | | | | | | | | The printer for uref/qref doesn't check for symbols that contain digits in the name, and so for instance (qref a3 3a) comes out as a3.3a, which does not read back, due to looking like a cramped floating-point constant. It looks like the weakest rule we can make is that all symbols that can be preceded by a dot must not have a name starting with a digit. Thus (qref 3a b c) can render as 3a.b.c. But (qref a 3b c) must not render as a.3b.c; it must be (qref a 3b c). * lib.c (simple_qref_args_p): Enact the above rule. In all positions preceded by a dot, if the symbol starts with a digit, then return nil to indicate that the syntax must be rendered in the list form.
* uref/qref: printing bug.Kaz Kylheku2020-07-081-1/+1
| | | | | | | | | | | * lib.c (obj_print_impl): The simple_qref_args_p function is called with reversed values of pos. For uref, we want 1, because the first item occurs after the dot, and for qref we want 0, because the first item occurs before the dot. This mix up means that the degenerate syntax (qref X) incorrectly prints as just X instead of (qref X). Likewise, though harmlessly, (uref X) fails to render as .X, instead coming out as (uref X).
* genvim: take advantage of @(if) in @(output)Kaz Kylheku2020-07-081-10/+2
| | | | | * genvim.txr (generate): Use a single, undivided @(output) block instead of multiple blocks with :continue.
* parser: add missing cases in yybadtoken.Kaz Kylheku2020-07-081-0/+5
| | | | | * parser.y (yybadtoken): Add all unhandled token types once and for all: BLOCK, GATHER, MOD, MODLAST, SPLICE.
* list_seq: return lazy list, not eager.Kaz Kylheku2020-07-082-8/+22
| | | | | | | | | * lib.c (list_seq_func): New static function. (list_seq): Convert to lazy processing. The iterator is threaded through the lazy cons's car field, so we don't have to mutate the function's environment. * txr.1: Added note about list-seq producing a lazy list.
* txr: support @(if)/@(elif)/@(else) in @(output).Kaz Kylheku2020-07-073-5/+105
| | | | | | | | | | | | | | | | | | | This turns out to be way easier than I thought. * match.c (do_output_if): New static function. (do_output): Handle if via do_output_if. * parser.y (out_if_clause, out_elif_clauses_opt, out_else_clause_opt): New nonterminal symbols and grammar rules. (out_clause): Now produces out_if_clause. (not_a_clause): Remove ELIF and ELSE; these entries here cause conflicts now. Here, continue to recognize the Lisp if, which is distinguished by having at least two arguments. out_if_clause matches only a one-argument if, and a no-argumeent one that is diagnosed as erroneous. * txr.1: Documented.
* txr: factor repeat out of output.Kaz Kylheku2020-07-071-97/+107
| | | | | * match.c (do_repeat): New static function. (do_output): Repeat processing logic moved into do_repeat.
* New: protocol for iteration with structs.Kaz Kylheku2020-07-077-28/+529
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (seq_iterable): Return t if argument is a structure supporting the iter-begin method. (seq_iter_get_oop, seq_iter_peek_oop, seq_iter_get_fast_oop, seq_iter_peek_fast_oop): New static functions. (seq_iter_init_with_info): Handle COBJ case. If the COBJ is a structure which suports the iter-begin method, then retrieve the iterator object by calling it, and then prepare the iterator structure for either the fast or the canonical protocol based on whether the iterator supports iter-more. (seq_iter_mark): Mark the iter member if the iterator is a struct object. (iter_begin): Rearrange tests here to check object type first before sequence kind. If the object is a structure supporting the iter-begin method, then call it and return its value. (iter_more, iter_step): Check for struct object with corresponding special methods and return. (iter_reset): Similar change like in iter_begin. We check for the iter-reset special method and try to use it, otherwise fall back on the regular iter_begin logic. * lib.h (struct seq_iter): New member next of the ul union for caching the result of a peek operation. * struct.c (iter_begin_s, iter_more_s, iter_item_s, iter_step_s, iter_reset_s): New symbol variables; (special_sym): Pointers to new symbol variables added to array. (struct_init): New symbol variables initialized. (get_special_required_slot): New function. * struct.h (iter_begin_s, iter_more_s, iter_item_s, iter_step_s, iter_reset_s): Declared. (enum special_slot): New enum members iter_begin_m, iter_more_m, iter_item_m, iter_step_m, iter_reset_m. (get_special_required_slot): Declared. * txr.1: Documented. * tests/012/oop-seq.expected: New file. * tests/012/oop-seq.tl: New file.
* doc: grammar under pos-ifKaz Kylheku2020-07-061-1/+1
| | | | * txr.1: article missing: "satisfies [the] predicate function".
* seq_iter: reverse order of some tests.Kaz Kylheku2020-07-061-131/+129
| | | | | | | | | | | | | * lib.c (seq_iter_rewind, seq_iter_init_with_info): Reverse the order in which we perform some type tests. We check for some special types first, and then for the sequence kind. These situations are mutually exclusive now, so the order doesn't matter. The plan is to introduce the ability for a structure object to be iterable with special methods. Such an object won't necessarily be a sequence (seq_info may identify it as SEQ_NOTSEQ). This code will be prepared for it becuase it's now checking for the type first, before the sequence kind.
* New function: iterable.Kaz Kylheku2020-07-024-4/+69
| | | | | | | | | | | | * eval.c (eval_init): Register iterable intrinsic. * lib.c (seq_iterable): New static function. (nullify): Use seq_iterable to simplify function. (iterable): New function. * lib.h (iterable): Declared. * txr.1: Documented.
* struct: bugfix: autoload on instance slot also.Kaz Kylheku2020-07-021-1/+4
| | | | | | | | | | | | | | | | | * struct.c (slot_types): Try lisplib_try_load, just like in static_slot_types. The reason for this is that there is code like (or (sys:slot-types slot) (sys:static-slot-types slot)) which occurs in sys:check-slot, testing both hashes. This code gets fooled in the following way: the sys:slot-types slot reports nil for a particular slot being probed. It doesn't try autoloading, checking the hash just once. Next, sys:static-slot-types is called and triggers an autoload. The autoload instantiates the slot as an instance slot (but not as a static slot). Then sys:static-slot-types returns nil also because there is no such static slot. The effect is that the slot exists due to the autload, but since both functions yielded nil, the overall (or ...) expression yields nil, which is interpreted as the slot not existing.
* struct: wasteful double creation of slot_type_hash.Kaz Kylheku2020-07-021-1/+0
| | | | | * struct.c (struct_init): Delete uselessly repeated statement that generates a garbage hash object.
* crc32: add optional initial crc argument.Kaz Kylheku2020-06-303-17/+47
| | | | | | | | | | | | | | This allows a CRC-32 calculation over multiple objects in multiple steps. * chksum.c (crc32_stream, crc32_buf, crc32_str, crc32): Take additional argument. (chksum_init): Add optional argument to registration of crc32-stream and crc32 intrinsics. * chksum.h (crc32_stream, crc32): Declarations updated. * txr.1: Doc updated; two examples added.
* uint-buf: fix wrong self-name.Kaz Kylheku2020-06-301-1/+1
| | | | * buf.c (uint_buf): Copy and paste from int_buf fixed.
* c_num: now takes self argument.Kaz Kylheku2020-06-2933-673/+881
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The c_num and c_unum functions now take a self argument for identifying the calling function. This requires changes in a large number of places. In a few places, additional functions acquire a self argument. The ffi module has the most extensive example of this. Some functions mention their name in a larger string, or have scattered literals giving their name; with the introduction of the self local variable, these are replaced by references to self. In the following changelog, the notation TS stands for "take self argument", meaning that the functions acquires a new "val self" argument. The notation DS means "define self": the functions in question defines a self variable, which they pass down. The notation PS means that the functions pass down an existing self variable to functions that now require it. * args.h (args_count): TS. * arith.c (c_unum, c_num): TS. (toint, exptv): DS. * buf.c (buf_check_len, buf_check_alloc_size, buf_check_index, buf_do_set_len, replace_buf, buf_put_buf, buf_put_i8, buf_put_u8, buf_put_char, buf_put_uchar, buf_get_bytes, buf_get_i8, buf_get_u8, buf_get_cptr, buf_strm_get_byte_callback, buf_strm_unget_byte, buf_swap32, str_buf, buf_int, buf_uint, int_buf, uint_buf): PS. (make_duplicate_buf, buf_shrink, sub_buf, buf_print, buf_pprint): DS. * chskum.c (sha256_stream_impl, sha256_buf, crc32_buf, md5_stream_impl, md5_buf): TS. (chksum_ensure_buf, sha256_stream, sha256, sha256_hash, md5_stream, md5, md5_hash): PS. (crc32_stream): DS. * combi.c (perm_while_fun, perm_gen_fun_common, perm_str_gen_fun, rperm_gen_fun, comb_vec_gen_fun, comb_str_gen_fun, rcomb_vec_gen_fun, rcomb_str_gen_fun): DS. * diff.c (dbg_clear, dbg_set, dbg_restore): DS. * eval.c (do_eval, gather_free_refs, maprodv, maprendv, maprodo, do_args_apf, do_args_ipf): DS. (op_dwim, me_op, map_common): PS. (prod_common): TS. * ffi.c (struct txr_ffi_type): release member TS. (make_ffi_type_pointer): PS and release argument TS. (ffi_varray_dynsize, ffi_array_in, ffi_array_put_common, ffi_array_get_common, ffi_varray_in, ffi_varray_null_term): PS. (ffi_simple_release, ffi_ptr_in_release, ffi_struct_release, ffi_wchar_array_get, ffi_array_release_common, ffi_array_release, ffi_varray_release): TS. (ffi_float_put, double_put, ffi_be_i16_put, ffi_be_u16_put, ffi_le_i16_put, ffi_le_u16_put, ffi_be_i32_put, ffi_be_u32_put, ffi_le_i32_put, ffi_sbit_put, ffi_ubit_put, ffi_buf_d_put, make_ffi_type_array, make_ffi_type_enum, ffi_type_compile, make_ffi_type_desc, ffi_make_call_desc, ffi_call_wrap, ffi_closure_dispatch_save, ffi_put_into, ffi_in, ffi_get, ffi_put, carray_set_length, carray_blank, carray_buf, carray_buf_sync, carray_cptr, carray_refset, carray_sub, carray_replace, carray_uint, carray_int): PS. (carray_vec, carray_list): DS. * filter.c (url_encode, url_decode, base64_stream_enc_impl): DS. * ftw.c (ftw_callback, ftw_wrap): DS. * gc.c (mark_obj, gc_set_delta): DS. * glob.c (glob_wrap): DS. * hash.c (equal_hash, eql_hash, eq_hash, do_make_hash, hash_equal, set_hash_traversal_limit, gen_hash_seed): DS. * itypes.c (c_i8, c_u8, c_i16, c_u16, c_i32, c_u32, c_i64, c_u64, c_short, c_ushort, c_int, c_uint, c_long, c_ulong): PS. * lib.c (seq_iter_rewind): TS and becomes internal. (seq_iter_init_with_info, seq_setpos, replace_str, less, replace_vec, diff, isec, obj_print_impl): PS. (nthcdr, equal, mkstring, mkustring, upcase_str, downcase_str, search_str, sub_str, cat_str, scat2, scat3, fmt_join, split_str_keep, split_str_set, trim_str, int_str, chr_int, chr_str, chr_str_set, vector, vecref, vecref_l, list_vec, copy_vec, sub_vec, cat_vec, lazy_str_put, lazy_str_gt, length_str_ge, length_str_lt, length_str_le, cptr_size_hint, cptr_int, out_lazy_str, out_quasi_str, time_string_local_time, time_string_utc, time_fields_local_time, time_fields_utc, time_struct_local, time_struct_utc, make_time, time_meth, time_parse_meth): DS. (init_str, cat_str_init, cat_str_measure, cat_str_append, vscat, time_fields_to_tm, time_struct_to_tm, make_time_impl): TS. * lib.h (seq_iter_rewind): Declaration removed. (c_num, c_unum, init_str): Declarations updated. * match.c (LOG_MISMATCH, LOG_MATCH): PS. (h_skip, h_coll, do_output_line, do_output, v_skip, v_fuzz, v_collect): DS. * parser.c (parser, circ_backpatch, report_security_problem, hist_save, repl, lino_fileno, lino_getch, lineno_getl, lineno_gets, lineno_open): DS. (parser_set_lineno, lisp_parse_impl): PS. * parser.l (YY_INPUT): PS. * rand.c (make_random_state): PS. * regex.c (print_rec): DS. (search_regex): PS. * signal.c (kill_wrap, raise_wrap, get_sig_handler, getitimer_wrap, setitimer_wrap): DS. * socket.c (addrinfo_in, sockaddr_pack, fd_timeout, to_connect, open_sockfd, sock_mark_connected, sock_timeout): TS. (getaddrinfo_wrap, dgram_set_sock_peer, sock_bind, sock_connect, sock_listen, sock_accept, sock_shutdown, sock_send_timeout, sock_recv_timeout, socketpair_wrap): DS. * stream.c (generic_fill_buf, errno_to_string, stdio_truncate, string_out_put_string, open_fileno, open_command, base_name, dir-name): DS. (unget_byte, put_buf, fill_buf, fill_buf_adjust, get_line_as_buf, formatv, put_byte, test_set_indent_mode, test_neq_set_indent_mode, set_indent_mode, set_indent, inc_indent, set_max_length, set_max_depth, open_subprocess, run ): PS. (fds_subst, fds_swizzle): TS. * struct.c (make_struct_type, super, umethod_args_fun): PS. (method_args_fun): DS. * strudel.c (strudel_put_buf, strudel_fill_buf): DS. * sysif.c (errno_wrap, exit_wrap, usleep_wrap, mkdir_wrap, ensure_dir, makedev_wrap, minor_wrap, major_wrap, mknod_wrap, mkfifo_wrap, wait_wrap, wifexited, wexitstatus, wifsignaled, wtermsig, wcoredump, wifstopped, wstopsig, wifcontinued, dup_wrap, close_wrap, exit_star_wrap, umask_wrap, setuid_wrap, seteuid_wrap, setgid_wrap, setegid_wrap, simulate_setuid_setgid, getpwuid_wrap, fnmatch_wrap, dlopen_wrap): DS. (chmod_wrap, do_chown, flock_pack, do_utimes, poll_wrap, setgroups_wrap, setresuid_wrap, setresgid_wrap, getgrgid_wrap): PS. (c_time): TS. * sysif.h (c_time): Declaration updated. * syslog.c (openlog_wrap, syslog_wrap): DS. * termios.c (termios_pack): TS. (tcgetattr_wrap, tcsetattr_wrap, tcsendbreak_wrap, tcdrain_wrap, tcflush_wrap, tcflow_rap, encode_speeds, decode_speeds): DS. * txr.c (compato, array_dim, gc_delta): DS. * unwind.c (uw_find_frames_by_mask): DS. * vm.c (vm_make_desc): PS. (vm_make_closure, vm_swtch): DS.
* pattern lang: vertical-horizontal fallback regression.Kaz Kylheku2020-06-291-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Commit c9cab7138636c6c1d6e47f8d1a4053bec2dd0ad4, on Feb 1, 2019, breaks the following case: @(define horiz)whatever@(end) @(horiz) The code assumes that if v_fun returned :decline, then the function doesn't exist. That is false, because the function may have a horizontal definition, as in the above example. That's why in the original code, nothing was done in this case to just allow the flow to proceed to the horizontal fallback, where the call will be tried as a horizontal function. The small problem with that was lack of a diagnosis when the function actually doesn't exist (neither vertical nor horizontal). In that case, the horizontal fallback will expect a line of data. If no data arrives, then the undefined function call is undiagnosed. The idea behind c9cab7138636c6c1d6e47f8d1a4053bec2dd0ad4 was to provide a diagnostic immediately. The right way to do that is to check for a horizontal definition of the function. If there isn't one, then error out, otherwise fall back on the horizontal processing.
* New producting each operator family.Kaz Kylheku2020-06-283-0/+265
| | | | | | | | | | | | | * lisplib.c (each_prod_instantiate, each_prod_set_entries): New static functions. (lisplib_init): Register autoload of each-prod.tl via new functions. * share/txr/stdlib/each-prod.tl: New file. * txr.1: Documented. Also, under the existing collect-each family of operators, added the equivalence to mapping with lambda to help clarify the semantics.
* New function: maprodo.Kaz Kylheku2020-06-282-7/+33
| | | | | | | | | | maprodo is like maprod, but doesn't collect or return anything. It's the Cartesian product analog of mapdo. * eval.c (collect_nothing, maprodo): New static functions. (eval_init): Register maprodo intrinsic. * txr.1: Documented.
* doc: parameter of length and empty is "iterable".Kaz Kylheku2020-06-281-43/+4
| | | | | | * txr.1: In length and empty, don't refer to an "object" parameter since the syntax calls it "iterable". Simplified description of length.
* New functions: list-seq, ved-seq and str-seq.Kaz Kylheku2020-06-284-0/+81
| | | | | | | | | | | | | | These functions convert any iterable to a list, vector or string. * eval.c (eval_init): Registered list-seq, vec-seq and str-seq intrinsics. * lib.c (list_seq, vec_seq, str_seq): New functions. * lib.h (list_seq, vec_seq, str_seq): Declared. * txr.1: Documented.
* New function strsignal.Kaz Kylheku2020-06-273-0/+46
| | | | | | | | | | * configure: detect strsignal, producing HAVE_STRSIGNAL symbol in config.h. * sysif.c (strsignal_wrap): New function. (sysif_init): Register strsignal intrinsic. * txr.1: Documented.
* exit: argument becomes optionalKaz Kylheku2020-06-202-13/+17
| | | | | | | | | | * sysif.c (exit_wrap): Check for missing status argument, and map to EXIT_SUCCESS. (sysif_init): Register exit as having optional argument. * txr.1: Update documentation regarding optional argument of exit. Also, EXIT_SUCCESS and EXIT_FAILURE are no longer mentioned, only that t maps to succes and nil to failure.
* structs: bugfix: wrong warning about no such static slotKaz Kylheku2020-06-201-2/+5
| | | | | | | | | | | | * struct.c (static_slot_types): If a symbol is attached to an empty type list in the static slot hash, then try triggering auto-load on it. This function's result is relied on by the struct macros for generating warnings; if we don't probe the autload, we get spurious warnings about symbols not being the name of any static slot. (static_slot_type_reg): Copy and paste bug: store the type into the correct, static slot type hash instead of the instance slot type hash.
* Replace all strerror calls with wrapper.Kaz Kylheku2020-06-207-72/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All string_utf8(strerror(x)) calls are replaced with errno_to_str(x). * sysif.c (errno_to_str): New function. (strerror_wrap): Now implemented via call to errno_to_str. (mkdir_wrap, ensure_dir, chdir_wrap, getcwd_wrap, rmdir_wrap, mknod_wrap, mkfifo_wrap, chmod_wrap, do_chown, symlink_wrap, link_wrap, readlink_wrap, close_wrap, exec_wrap, stat_impl, do_utimes, pipe_wrap, poll_wrap, getgroups_wrap, setuid_wrap, seteuid_wrap, setgid_wrap, setegid_wrap, setgroups_wrap, getresuid_wrap, getresgid_wrap, setresuid_wrap, setresgid_wrap, crypt_wrap, uname_wrap): Use errno_to_str. * sysif.h (errno_to_str): Declared. * ftw.c (ftw_wrap): Use errno_to_str. * socket.c (dgram_get_byte_callback, dgram_flush, sock_bind, open_sockfd, sock_connect, sock_listen, sock_accept, sock_shutdown, sock_timeout, socketpair_wrap): Likewise. * stream.c (errno_to_string): Likewise, and don't handle zero case any more; pass down to errno_to_str. (stdio_close, pipe_close open_directory, open_file, open_fileno, open_tail, fds_subst, open_command, open_subprocess, run, remove_path, rename_path): Use errno_to_str. * termios.c (tcgetattr_wrap, tcsetattr_wrap, tcsetattr_wrap, tcsendbreak_wrap, tcdrain_wrap, tcflush_wrap, tcflow_wrap): Likewise. diff --git a/termios.c b/termios.c
* New function: strerrorKaz Kylheku2020-06-193-0/+65
| | | | | | | | | | | | * configure (have_strerror_r): New variable. Detect whether we have strerror_r and which flavor: GNU or POSIX. Define HAVE_STRERROR_GNU or HAVE_STRERROR_POSIX in config.h. * sysif.c (strerror_wrap): New function. (sysif_init): Register strerror intrinsic. * txr.1: Documented.
* itypes: remove silly itypes_little_endian.Kaz Kylheku2020-06-194-21/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Curiously, the itypes_little_endian variable was introduced in April 2017, in a the first commit implementing buffers. The variable was initialized, but never referenced. About a month after that, I introduced HAVE_LITTLE_ENDIAN config.h macro, which is always present and defined as 0 or 1. This was used right away in the implementation of FFI bitfields, and later on in other FFI work. In spite of HAVE_LITTLE_ENDIAN, almost exactly a year after itypes_little_endian was introduced, I mistakenly put that variable to use instead of recognizing it as superfluous and removing it in favor of using HAVE_LITTLE_ENDIAN. That is what I'm doing now. * itypes.c (itypes_little_endian): Variable removed. (itypes_init): Function removed, since its only job is to initialize this variable. * itypesl.h (itypes_little_endian, itypes_init): Declarations removed. * lib.c (init): Call to itypes_init removed. * parser.c (read_file_common): Instead of itypes_little_indian, use HAVE_LITTLE_ENDIAN, which the configuration script always exists and is defined as 0 or 1.
* listener: perms complaint for missing .txr_historyKaz Kylheku2020-06-191-2/+4
| | | | | | | | | * parser.c (repl): The listener wrongly complains that .txr_history has bad permissions when it doesn't exist. New users of TXR won't have a history file, so this looks sloppy. Since we load the history file regardless of the check, let's do the check in the case when the file has successfully loaded.
* Support MIPS64.Kaz Kylheku2020-06-192-1/+36
| | | | | | | * jmp.S (jmp_save, jmp_restore): Defined for MIPS64. * unwind.h (struct_jmp): Provide same definition for 32 and 64 by #ifdef-ing on just __mips__.