summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* make-struct-type: fix far-fetched gc/stability issue.Kaz Kylheku2019-06-191-2/+2
| | | | | | | * struct.c (make_struct_type): The length and plus operations can cons if the number of static slots doesn't fit into a fixnum. Let's move that operation out of the sensitive object construction region.
* structs: gc bug due to derived hook.Kaz Kylheku2019-06-191-3/+5
| | | | | | | | | | | * struct.c (make_struct_type): The static slot lookup for for a derived method in the supertype can potentially allocate a cons cell when there is a cache miss, which can trigger gc. So we can't be doing this while a the new type object object is partially initialized, because then the garbage collector will visit uninitialized memory. We move the derived method lookup down farther to where that value is needed to do the derived call, just before we return the new type.
* buffers: bug: wrong object in format arguments.Kaz Kylheku2019-06-181-1/+1
| | | | | | | | | * buf.c (buf_strm_seek): index is a BSD function; we want to refer to the local variable npos here. This was fortuitiously caught by GNU C++ which is obtains multiple overloaded declarations of index from somewhere, and so in this variable argument list situation thinks that there isn't enough context to resolve the overload.
* logcount: crash in 64 bit build.Kaz Kylheku2019-06-181-1/+1
| | | | | | | * arith.c (logcount): NUM case doesn't have a return statement in 64 bit build, statement causing fall-through to BGNUM case where the integer object is treated as a bignum. This bug has existed in the function ab initio.
* New function: bitset.Kaz Kylheku2019-06-183-1/+122
| | | | | | | | | | | * arith.c (bitset_s): New symbol variable. (bitset): New function. (arith_init): bitset_s initialized, bitset intrinsic registered. * lib.h (bitset): Declared. * txr.1: Documented bitset function and method.
* carray-replace: use seq_iter.Kaz Kylheku2019-06-181-15/+5
| | | | | * ffi.c (carray_replace): Use generic sequence iteration for range replacement instead of separate list/vector code.
* sub-list, sub-vec, sub-str: becoming accessors.Kaz Kylheku2019-06-173-5/+107
| | | | | | | | | | | * lisplib.c (defset_instantiate): Add sub-list, sub-vec and sub-str symbols as autoload triggers for defset.tl. * share/txr/stdlib/defset.tl (sub-list, sub-vec, sub-str): New syntactic places defined with defset. * txr.1: sub-list, sub-vec and sub-str documented as accessors.
* expander: relax sys:setq and lisp-1 stringency.Kaz Kylheku2019-06-171-23/+21
| | | | | | | | | | | | | | | | | | | | | | | | The motivation here is that there are behaviors in the expander which hinder symbol-macro-based renaming techniques. For instance (expand '(symacrolet ((x y)) (sys:setq x x))) throws. The right hand side of the setq is fine, but the left hand one is a forbidden symbol macro. Yet, we would just like this to expand to (sys:setq y y). The original idea was that sys:setq occurs as a result of macro-expansion. Therefore, if its argument is a symbol macro, something must be wrong; it didn't get expanded. That reasoning is wrong in the face of explicit expansion techniques that make multiple expansion passes. For instance (set a b) can become something like (sys:setq #:g0005 #:g0007) when the intent that in another round of renaming these gensyms will be defined as symbol macros which perform one more renaming. * eval.c (expand_lisp1_value, expand_lisp1_setq): Macro-expand the symbol and work with the expanded one. We still keep the check for a symbol macro; these situations can arise if a symbol macro cannot expand due to circularity. (do_expand): When checking sys:setq for a bad symbol or symbol macro, work with the expanded argument.
* buf, carray: accessors must eval new value once.Kaz Kylheku2019-06-171-2/+6
| | | | | | * share/txr/stdlib/ffi.tl (carray-sub, sub-buf): Unfortunately, defset doesn't arrange for the new value to be evaluated once; we must do it.
* defset: code tidying.Kaz Kylheku2019-06-171-1/+1
| | | | | | * share/txr/stdlib/defset.tl (defset-expander): Reduce (,*params) to ,params, which is parallel with the ,args that it matches.
* defset: fix non-hygienic Lisp-1 evaluation.Kaz Kylheku2019-06-171-7/+7
| | | | | | | | * share/txr/stdlib/defset.tl (defset-expander): In code that binds user-supplied variables and contains a user-supplied form that refers to those variables, we can't use code like (op list (gensym)) or [mapcar car ...]. These are susceptible to capture of the symbols list and car.
* defset: gensyms needed for hygiene.Kaz Kylheku2019-06-171-21/+22
| | | | | | | | * share/txr/stdlib/defset.tl (defset-expander): In a scope where we are binding the user-supplied params, we cannot be binding variables like gpf-pairs that don't have anonymized names. All these locals must be gensymed, otherwise they are visible to the store form.
* defset: add tests.Kaz Kylheku2019-06-172-0/+11
| | | | | | * tests/012/defset.tl: New file. * tests/012/defset.expected: New file.
* buffers: comment added in buf_shrink.Kaz Kylheku2019-06-171-1/+1
| | | | | * buf.c (buf_shrink): It's not immediately obvious why len is incremented by one if it is zero.
* buffers: sub-buf becomes accessor.Kaz Kylheku2019-06-173-2/+21
| | | | | | | | | | * lisplib.c (ffi_set_entries): Register autoload for sub-buf symbol. * share/txr/stdlib/ffi.tl (sub-buf): Syntactic place defined via defset. * txr.1: Updated sub-buf documentation.
* doc: sub place semantics described wrongly.Kaz Kylheku2019-06-171-4/+36
| | | | | | * txr.1: Documentatation for sub accessor fails to specify that the seq variable is updated with the value returned by replace.
* carray-sub: improved accessor.Kaz Kylheku2019-06-172-5/+14
| | | | | | | | | | | | | * share/txr/stdlib/ffi.tl (carray-sub): We use defset to define a carray-sub place that updates via carray-replace, rather than using a place macro to defer to the generic sub accessor. This results in a more efficient implementation. This new accessor doesn't require the carray argument to be a place; unlike sub, it doesn't have to capture the return value of carray-replace and store it back into the carray variable. * txr.1: Updated doc.
* doc: defset short form is like define-accessorKaz Kylheku2019-06-161-3/+17
| | | | | | * txr.1: Add mentions of the forgotten define-accessor macro in text that lists ways of defiing places. Cross-reference short form of defset and define-accessor.
* doc: nftw typo.Kaz Kylheku2019-06-161-1/+1
| | | | * txr.1: Fix ftw function being mistakenly called nftw.
* doc: reduce amount of "This function" wording.Kaz Kylheku2019-06-161-26/+76
| | | | | | * txr.1: Numerous library functions whose Description paragraph begins with "This function" are now introduced by their name.
* doc: listp and proper-list-p are list only.Kaz Kylheku2019-06-161-0/+6
| | | | * txr.1: Clarify that list-like sequences are not lists.
* doc: improvements in sub + replace variants.Kaz Kylheku2019-06-161-43/+34
| | | | | | | | | | | | * txr.1: The wording is improved in the description of sub-list, replace-list and all the other type specific specializations of sub and replace. We avoid starting the descriptions with "This function", and vague wording such as "is like the sub function". Superfluous, obvious text like "for a description of the semantics, see the sub function" is removed. Also we avoid saying that the sub-list and replace-list functions operate strictly on lists, since they in fact operate on anything that supports list operations.
* doc: carray-pun copy-paste issue.Kaz Kylheku2019-06-151-1/+1
| | | | | * txr.1: Fix syntax section for carray-pun wrongly showing carray-sub function name.
* buffers: expose sub-buf and replace-buf.Kaz Kylheku2019-06-152-0/+61
| | | | | | | * buf.c (buf_init): Intrinsics sub-buf and replace-buf registered. * txr.1: Documented.
* Replace lt(x, zero) pattern.Kaz Kylheku2019-06-156-39/+39
| | | | | | | | | | | | | | | | | | | | | | | | | This slight inefficiency occurs in some 37 places in the code. In most places we replace lt(x, zero) with minusp(x). In a few places, !plusp(x) is used and surrounding logic is simplified. In one case, the silly pattern lt(x, zero) ? t : nil is replaced with just minusp(x). * buf.c (sub_buf, replace_buf): Replace lt. * combi.c (perm, rperm, comb, rcomb): Likewise. * eval.c (do_format_field): Likewise. * lib.c (listref, sub_list, replace_list, split_func, split_star_func, match_str, lazy_sub-str, sub_str, replace_str, sub_vec, replace_vec): Likewise. * match.c (weird_merge): Likewise. * regex.c (match_regex, match_regex_right_old, match_regex_right, regex_prefix_match, regex_range_left, regex_range_right): Likewise.
* compile-file: translate --lisp option in hash bang.Kaz Kylheku2019-06-142-2/+9
| | | | | | | | * share/txr/stdlib/compiler.tl (usr:compile-file): Edit the hash-bang line to replace the --lisp option with --compiled. This supports the situation when a TXR Lisp hash bang script that is unsuffixed is compiled to an unsuffixed compiled script.
* cat-str, split-str: sep can be character.Kaz Kylheku2019-06-142-7/+29
| | | | | | | * lib.c (cat_str, split_str_keep): Support single character separator. * txr.1: Documented.
* select: maintenance.Kaz Kylheku2019-06-142-41/+56
| | | | | | | | | * lib.c (sel): Function converted to seq_info and iterators. Negative indices handled in list case. Self-name corrected to select; the C function is called sel just to avoid clashing with POSIX select. * txr.1: Documentation updated.
* buffers: support negative indexing from end.Kaz Kylheku2019-06-141-16/+18
| | | | | | | | | | | | | * buf.c (buf_check_index): Take struct buf p * parameter, to be able to displace negative values using the buffer length. (buf_put_bytes, buf_put_i8, puf_put_u8, but_put_char, buf_put_uchar, buf_get_bytes, buf_get_i8, buf_get_u8, buf_strm_get_byte_callback): Pass struct buf pointer to buf_check_index. In buf_put_bytes, we use the returned value instead of the original pos. (buf_strm_seek): Don't use buf_check_index for validating the position, since the negative indexing logic doesn't apply to stream seek operations.
* carray-refset: bugfix: support negative indexing.Kaz Kylheku2019-06-141-0/+3
| | | | | | * ffi.c (carray_refset): Support negative indexing by adding the length of the array to a negative index value. This is already done in carray_ref.
* replace-list: negatives in index-list follow convention.Kaz Kylheku2019-06-142-5/+15
| | | | | | | | | | The index-list replacement isn't following the convention that negative index values reference from the end of the target sequence. Let's fix that. * lib.c (replace_list): Likewise. * txr.1: Documentation updated.
* replace-str, replace-vec: remove call to len.Kaz Kylheku2019-06-131-2/+2
| | | | | | * lib.c (replace_str, replace_vec): Remove redundant calculation of input sequence length; there is a len variable bound on entry into the function.
* carray-replace: missing functionality.Kaz Kylheku2019-06-131-7/+24
| | | | | * ffi.c (carray_replace): add missing index list assignment semantics required by documentation.
* buffers: replace operation.Kaz Kylheku2019-06-123-1/+91
| | | | | | | | * buf.c (replace_buf): New function. * buf.h (replace_buf): Declared. * lib.c (replace): Wire in.
* Makefile: non-configured distclean removes tlo's.Kaz Kylheku2019-06-121-1/+1
| | | | | | * Makefile (distclean): distclean target for not-configured state removes .tlo files by wildcard, including the old .tlo2 files that we used to generate once.
* sub-vec: optimize no-op case.Kaz Kylheku2019-06-122-2/+3
| | | | | | | | | | * lib.c (sub_vec): If range covers entire vector, just return it. * txr.1: Clarify that the output of sub may share structure with the input regardless of type, not only when the input is a list. This should have been updated when the optimizatin was done in sub-str.
* toseq: remove unused function.Kaz Kylheku2019-06-122-16/+0
| | | | | | * lib.c (toseq): Function removed. * lib.h (toseq): Declaration removed.
* replace-vec, replace-str: refactor with sequence iteration.Kaz Kylheku2019-06-121-97/+53
| | | | | | | * lib.c (replace_vec, replace_str): Don't use dubious toseq on input items, which converts non-sequence atoms into lists of one. Use sequence iterators to reduce number of cases in the code.
* doc: no such thing as varray.Kaz Kylheku2019-06-121-6/+6
| | | | | | * txr.1: carray is contrasted with the FFI type varray; but there is no such type. varray is a name used internally in the implementation; it means "variable-length zarray".
* doc: clarifications under zarrayKaz Kylheku2019-06-121-6/+17
| | | | | * txr.1: Clarify how the null element in the C array is generated for the dimensioned and undimensioned zarray.
* ffi: adjust in semantics of variable zarray.Kaz Kylheku2019-06-122-7/+3
| | | | | | | | | | | | | | | | | The replace function now returns a list if a nil object's is replaced with a range, rather than just returning the original item sequence. This breaks the variable array in operation, causing it to produce a list. We fix this sproblem, and also the nonsense semantics of the operation also; the operation should replace the original sequence, with the array, similarly to how null terminated strings work. * ffi.c (ffi_varray_null_term_in): If the original Lisp object isn't nil, then assume it's a sequence and replace it with the items gathered in the vector. Otherwise, replace it with the vector. * txr.1: Adjust documentation.
* replace_list: revise, fixing several bugs.Kaz Kylheku2019-06-121-49/+37
| | | | | | | | | | | * lib.c (replace_list): Avoid using the dubious toseq function which turns a non-sequence object into a list of one item. This is not documented. Rewrite the assign-to-multiple-indices logic into one loop that uses sequence iterators. A bug is fixed here: failing to step the indices and items in parallel. Don't use list_vec on items; it fails on strings. Strings are now supported properly: they expand into a list of items that is spliced.
* seq iterators: new peek operation.Kaz Kylheku2019-06-122-0/+42
| | | | | | | | | | | | * lib.c (seq_iter_peek_nil, seq_iter_peek_list, seq_iter_peek_vec, seq_iter_peek_hash): New static functions. (seq_geti): New function. (seq_iter_init): Initialize new peek member of seq_iter structure. * lib.h (struct seq_iter): New member, peek. (seq_peek): New inline function. (seq_geti): Declared.
* buffers: allow sub operation.Kaz Kylheku2019-06-113-1/+40
| | | | | | | | | * buf.c (sub_buf): New function. * buf.h (sub_buf): Declared. * lib.c (sub): Hook in BUF type. (replace): Diagnose BUF specially as unsupported.
* New function: hash-peek.Kaz Kylheku2019-06-113-8/+52
| | | | | | | | | * hash.c (hash_peek): New function. (hash_init): hash-peek intrinsic registered. * hash.h (hash_peek): Declared. * txr.1: Documented.
* hash: remove unnecessary test.Kaz Kylheku2019-06-111-1/+1
| | | | | | * hash.c (hash_next): We know after the loop that hi->cons is not nil, because the loop contains no break, and is guarded by hi->cons being nil.
* regression: unsuffixed cmdline arg treated as Lisp.Kaz Kylheku2019-06-101-8/+14
| | | | | | | | | | | | | | | | | | This broke in TXR 216. TXR files with no suffix run using #!/path/to/txr stopped working due to being interpreted as Lisp. The rearrangement done in open_txr_file function didn't respect the hacky treatment of the *txr_lisp_p flag, which depended on the original order. The flag ends up being set to t, because we tried (unsuccessfully) opening a .tl suffix, and that then falsely indicates "Lisp" when the unsuffixed file is open. That logic worked when we tried the unsuffixed file first, and fell back on the added suffixes last. * parser.c (open-txr_file): Instead of repeatedly testing for in == 0, we execute a forward goto when we successfully open a file. Only in those successful cases, set *txr_lisp_p to the appropriate value, not touching it otherwise.
* Version 217.txr-217Kaz Kylheku2019-06-107-489/+586
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* Adding errno constants.Kaz Kylheku2019-06-092-0/+105
| | | | | | | | | | | | | | | | | | | | * sysif.c (sysif_init): registering variables e2big, eacces, eaddrinuse, eaddrnotavail, eafnosupport, eagain, ealready, ebadf, ebadmsg, ebusy, ecanceled, echild, econnaborted, econnrefused, econnreset, edeadlk, edestaddrreq, edom, edquot, eexist, efault, efbig, ehostunreach, eidrm, eilseq, einprogress, eintr, einval, eio, eisconn, eisdir, eloop, emfile, emlink, emsgsize, emultihop, enametoolong, enetdown, enetreset, enetunreach, enfile, enobufs, enodata, enodev, enoent, enoexec, enolck, enolink, enomem, enomsg, enoprotoopt, enospc, enosr, enostr, enosys, enotconn, enotdir, enotempty, enotrecoverable, enotsock, enotsup, enotty, enxio, eopnotsupp, eoverflow, eownerdead, eperm, epipe, eproto, eprotonosupport, eprototype, erange, erofs, espipe, esrch, estale, etime, etimedout, etxtbsy ewouldblock and exdev. * txr.1: Documented.
* Adding fcntl interface.Kaz Kylheku2019-06-093-2/+311
| | | | | | | | | | | | | | | | | | | * configure: changing HAVE_FCNTL_H to HAVE_FCNTL. * sysif.c (flock_s, type_s, whence_s, start_s, len_s, pid_s): New symbol variables. (flock_pack, flock_unpack, fcntl_wrap): New static functions. (sysif_init): Initialize new symbol variables. Create flock struct type. Register new intrinsic variables: o-accmode, o-rdonly, o-wronly, o-rdwr, o-creat, o-noctty, o-trunc, o-append, o-nonblock, o-sync, o-async, o-directory, o-nofollow, o-cloexec, o-direct, o-noatime, o-path, f-dupfd, f-dupfd-cloexec, f-getfd, f-setfd, fd-cloexec, f-getfl, f-setfl, f-getlk, f-setlk, f-setlkw, f-rdlck, f-wrlck, f-unlck, seek-set, seek-cur and seek-end. Register fcntl intrinsic function. * txr.1: Documented.