summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* distat: bugfix: use lstat.Kaz Kylheku2020-07-201-8/+7
| | | | | | | | | | * 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-201-7/+25
| | | | | | | | | | | | | | | * 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.
* doc: wrong symbol under cptr-buf.Kaz Kylheku2020-07-131-1/+1
| | | | * txr.1: cptr-buf syntax wrongly refers to cptr-obj.
* 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-131-0/+131
| | | | | | | | | | | | | | | | | 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.
* Support weak semantics in symbol packages.Kaz Kylheku2020-07-121-1/+19
| | | | | | | | | | | | | | | | | | | | | 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-111-0/+19
| | | | | | | | | | | | * 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-091-5/+84
| | | | | | | | | | | | | | | | | | | 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-091-1/+36
| | | | | | | | | | | | | * 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.
* readdir: skip . and .. entriesKaz Kylheku2020-07-081-0/+9
| | | | | | | * sysif.c (readdir_wrap): If d_name is "." or ".." loop around and get another directory entry. * txr.1: Documented.
* 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-081-0/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* list_seq: return lazy list, not eager.Kaz Kylheku2020-07-081-0/+4
| | | | | | | | | * 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-071-2/+47
| | | | | | | | | | | | | | | | | | | 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.
* New: protocol for iteration with structs.Kaz Kylheku2020-07-071-1/+277
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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".
* New function: iterable.Kaz Kylheku2020-07-021-0/+24
| | | | | | | | | | | | * 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.
* crc32: add optional initial crc argument.Kaz Kylheku2020-06-301-4/+34
| | | | | | | | | | | | | | 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.
* New producting each operator family.Kaz Kylheku2020-06-281-0/+172
| | | | | | | | | | | | | * 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-281-7/+21
| | | | | | | | | | 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-281-0/+29
| | | | | | | | | | | | | | 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-271-0/+10
| | | | | | | | | | * 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-201-11/+13
| | | | | | | | | | * 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.
* Replace all strerror calls with wrapper.Kaz Kylheku2020-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-191-0/+17
| | | | | | | | | | | | * 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.
* doc: new >< operator.Kaz Kylheku2020-06-101-5/+23
| | | | | | | | * txr.1: Implementing new >< operator in the getm macro syntax. >< foo x bar renders as <foo>x<bar> in the nroff-ed man output; in HTML and PDF, foo and bar are italicized. This is put to use in the Built-In Syntactic Places section to correct the formatting of struct-obj.slot-name.
* doc: missing backslash in getm macro.Kaz Kylheku2020-06-101-1/+1
| | | | | | | | * txr.1: Fix missing backslash on font changing directive in the troff-oriented implementation of the <> operator. This makes no difference to the output. The HTML output is absolutely identical according to diff. Visual inspections of the groff-generated PDF also reveal no difference.
* doc: Buffers: subsectioning problem.Kaz Kylheku2020-06-091-3/+6
| | | | | * txr.1: Fix "Buffers" and "The buf type" being at equal section levels. Adjust the cptr type section to harmonize.
* Version 240txr-240Kaz Kylheku2020-06-061-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: fix param names in Sequence Manipulation.Kaz Kylheku2020-06-061-84/+93
| | | | | | * txr.1: Fix instances in which the sequence argument of a sequence manipulating function is called a list or object. Also fix some unnecessary abbreviation of sequence to seq.
* doc: relocate nullify.Kaz Kylheku2020-06-061-99/+99
| | | | | | | * txr.1: Relocate description of nullify from bottom of Sequence Manipulation to near the top, after the description of empty. This is very similar to the recent relocation of nullify in lib.c and lib.h.
* doc: relocate make-like.Kaz Kylheku2020-06-061-57/+57
| | | | | | | * txr.1: Move description of make-like from near the bottom of the Sequence Manipulation section to close to the top, just under the seqp description. Also, ref-sequence parameter is renamed to object.
* doc: relocate copy.Kaz Kylheku2020-06-061-80/+80
| | | | | * txr.1: Move description of copy function out of Sequence Manipulation and into Object Equivalence.
* doc: relocate apply/iapply.Kaz Kylheku2020-06-061-146/+146
| | | | | | * txr.1: Move the descriptions of apply and iapply out of Sequence Manipulation and into Functions, following the description of the call function.
* doc: update nullify documentation.Kaz Kylheku2020-06-051-39/+71
| | | | | * txr.1: Nullify documentation updated and clarified, with examples.
* doc: document functions that take iterable.Kaz Kylheku2020-06-051-91/+138
| | | | | | | | * doc: Add paragraphs uder Sequence Manipulation discussing support for sequences, iterables and hashes. Establish naming cnovention for arguments: iterables are called iterable or iter. Update descriptions of functions that work with iterables.
* doc: document each operators using iterables.Kaz Kylheku2020-06-051-8/+11
| | | | | | * txr.1: The init-forms in (each ...) must be suitable for iter-init and that is now documented. A (range 1 10) in the example is replaced with 1..11.
* doc: new Generalization of Iteration section.Kaz Kylheku2020-06-051-0/+120
| | | | | * txr.1: New section added under TXR LISP to introduce the new iteration concept.
* doc: update iter-begin documentation.Kaz Kylheku2020-06-051-8/+168
| | | | | * txr.1: Add more detail about list handling, and cover numbers and ranges.
* New style iteration functions.Kaz Kylheku2020-06-021-5/+157
| | | | | | | | | | | | | | | | | | | | | | | | iter-begin provides a paradigm for iteration that is more compatible with lists. If the sequence is a list, then the list itself is returned as the iterator, and the other functions are basicaly wrappers for car/cdr and null testing. Yet the API is defined in such a way that other objects can be iterated with good efficiency, at the cost of allocating a new iterator object (which can be re-used). * eval.c (eval_init): Register iter-begin, iter-more, iter-item, iter-step and iter-reset. * lib.c (seq_iter_init_with_info): New static function. (seq_iter_init): Now a thin wrapper for seq_iter_init_with_info. (iter_begin, iter_more, iter_item, iter_step, iter_reset): New functions. * lib.h (iter_begin, iter_more, iter_item, iter_step, iter_reset): New functions. * txr.1: Documented.
* Version 239.txr-239Kaz Kylheku2020-06-021-2/+2
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* doc: constantp syntax formatting.Kaz Kylheku2020-05-311-1/+1
| | | | * txr.1: Fix extra whitespace around env parameter.
* search, rsearch: rewrite using seq_info and bugfix.Kaz Kylheku2020-05-251-4/+16
| | | | | | | | | | | | | | | * lib.c (seq_getpos, seq_setpos): New functions. * lib.h (seq_getpos, seq_setpos): Declared. (search_list, rsearch_list): Static functions removed. (search_common): New static function. (search, contains, rsearch): These functions are now trivial wrappers around search_common. A requirement problem is fixed in rsearch: when the key is empty, the length of sequence is returned rather than zero, because zero is obviously not the right most place where an empty key matches. * txr.1: Documentation updated.
* Fix few typos reported from Fossies.Kaz Kylheku2020-05-231-2/+2
| | | | | | | | | | | | | Fossies administrator Jens alerted me to some typos. * txr.1: Fix two instances of alphanumeric being hyphenated, and one case of invocable being rendered as invokable. * linenoise/linenoise.c (struct lino_state): Misspelled "buffer" in a comment. One other comment typos in this file is from the original code, so it stays: who needs yet another merge conflict? Not touching the original typo in example.c, either.
* Version 238.txr-238Kaz Kylheku2020-05-181-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* New assert macro.Kaz Kylheku2020-05-181-0/+35
| | | | | | | | | | | | * eval.c (rt_assert_fail, me_assert): New static functions. (eval_init): assert macro and sys:rt-assert-fail function registered. * lib.c (func_n4ov): New function. * lib.h (func_n4ov): Declared. * txr.1: Documented.