summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* place macros: adjustment to expansion strategy.Kaz Kylheku2019-06-052-25/+37
| | | | | | | | | | * share/txr/stdlib/place.tl (sys:pl-expand): At each expansion round, repeatedly expand the form as a place macro until that can no longer be done and only then try macroexpand-1, instead of just trying one place macro expansion. * txr.1: Updated and revised description of expansion under define-place-macro.
* arith: INT_PTR_MIN overflow bugfix.Kaz Kylheku2019-06-031-1/+1
| | | | | * arith.c (int_flo): Don't subtract one from INT_PTR_MIN any more, since it is now the most negative integer already.
* bugfix: list length: off-by-one error huge lists.Kaz Kylheku2019-05-311-0/+2
| | | | | | | | | | | | * lib.c (length_list, length_proper_list): Fix off-by-one bug when calculating lengths of lists that overflow the cnum type. Note that we will never see regular lists which hit this situation, because there are more values in the range [0, INT_PTR_MAX] then there are possible pointers in the system, However, lazy lists can be that long or longer, because as we calculate the length of a lazy list, the part we have already traversed can be garbage-collected under the right circumstances.
* posix: add close function.Kaz Kylheku2019-05-302-0/+39
| | | | | | | * sysif.c (close_wrap): New static function. (sysif_init): close intrinsic registered. * txr.1: Documented.
* doc: missing word under mask.Kaz Kylheku2019-05-291-1/+1
| | | | * txr.1: add missing "or" to make "bitwise or".
* doc: typo under ldiff.Kaz Kylheku2019-05-291-1/+1
| | | | * txr.1: Misplaced comma nudged left.
* doc: formatting of sident charsKaz Kylheku2019-05-291-3/+3
| | | | * txr: use .verb block instead of .mono block.
* path-private-to-me-p: bugfix: not including superuser.Kaz Kylheku2019-05-292-22/+41
| | | | | | | | | | | | * share/txr/stdlib/path-test.tl (path-private-to-me, path-strictly-private-to-me): These functions were neglecting to trust the root user, as documented. If the file is owned by root, we treat it as if it were owned by the caller. Furthermore, if we have to process the group membership, we allow the group to contain the superuser's name. * txr.1: Documentation improved, and the treatment of groups documented.
* mpi: avoid additive inverse of most negative integer.Kaz Kylheku2019-05-251-3/+6
| | | | | | | | | * mpi.c (mp_set_int, mp_set_intptr, mp_set_double_intptr): When the signed input is negative, do not simply calculate its inverse with unary minus, because it could be the most negative value that has no additive inverse. Instead, convert to unsigned first, then apply the unary minus to the unsigned type, which calculates the two's complement.
* bugfix: c_num won't convert most negative value.Kaz Kylheku2019-05-253-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | This bug causes a problem particularly in FFI. THe conversion of an integer to the FFI int type begins by conversion via c_num to the cnum type, which is at least as wide as int. Alas, the INT_MIN value (e.g. #x-80000000 on 32 bits) will not convert! Fixing this has a ripple effect. We alter the INT_PTR_MIN constant to include this value. This causes the derived NUM_MIN to also include the extra negative value, extending the fixnum range by one value. Everything seems to be okay. * configure: Decrease value of INT_PTR_MIN and DOUBLE_INTPTR_MIN constants by one to include the most negative two's complement value. * ffi.c (make_ffi_type_enum): We must not subtract 1 from INT_PTR_MIN here any more. * mpi.c (mp_in_range): If the bignum is negative, then extend the range check by one value, so that we don't reject the most negative two's complement value.
* lib: remove unused numeric macros.Kaz Kylheku2019-05-251-2/+0
| | | | * lib.h (maxint, minint): Remove unused macros.
* nsis: fixes for file assoc module from NSIS Wiki.Kaz Kylheku2019-05-251-2/+11
| | | | * win/fassoc.nsh: Patch applied.
* windows: register file associations.Kaz Kylheku2019-05-252-0/+146
| | | | | | | | | Add registration of .txr, .tl and .tlo suffixe. * inst.nsi: Include fassoc.nsh file. Associate .txr, .tl and .tlo with txr-win.exe * win/fassoc.nsh: New file.
* placelet: add comment.Kaz Kylheku2019-05-231-1/+13
| | | | | | | * share/txr/stdlib/place.tl (sys:placelet-1): Adding comment explaining why the explicit expansion and temporary proxy place are necessary, even though in most cases it can work fine without them.
* asm: remove unused symbol macro.Kaz Kylheku2019-05-221-2/+0
| | | | | * share/txr/stdlib/asm.tl (%oc-list%): Unused global symbol macro removed.
* Version 216.txr-216Kaz Kylheku2019-05-207-1025/+1111
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* doc: missing deindent under Function FiltersKaz Kylheku2019-05-201-1/+1
| | | | * txr.1: .PP added.
* compile-file: input path harmonized with load.Kaz Kylheku2019-05-202-31/+101
| | | | | | | | | | | | | | * share/txr/stdlib/compiler.tl (open-compile-streams): The input file is now determined in a manner similar to the load function. If the path is relative and there is a *load-path* binding, then it is now considered relative to *load-path*. It is considered suffixed only if ending in .tl or .txr. If unsuffixed, then it is first tried with the .tl suffix. (usr:compile-file): Bind *load-path* to the actual path used for loading the file, rather than the input path. * txr.1: Documented.
* load: always bind *load-path* to actual path.Kaz Kylheku2019-05-202-15/+28
| | | | | | | | | | | * eval.c (load): Bind *load-path* to the real path that was used to open the file, not to the tentative path to which the .tl suffix was added, subject to compatibility option. * txr.1: Documentation for load revised for better wording and to document the above change. Fixed *load-path* being wrongly called a macro, and also load being called a macro. Compat note added.
* oop: derived hook.Kaz Kylheku2019-05-153-13/+75
| | | | | | | | | | | * struct.c (derived_s): New symbol variable. (struct_init): Initialize derived_s symbol. (make_struct_type): Check for derived method in parent, and invoke. * struct.h (derived_s): Declared. * txr.1: Documented.
* oop: new new* and lnew* macros.Kaz Kylheku2019-05-153-26/+64
| | | | | | | | | | | | * lisplib.c (struct_set_entries): Add autoload entries for new* and lnew* symbols. * share/txr/stdlib/struct.tl (sys:new-type, sys:new-expander): New functions. (new, lnew): Macros now implemented using sys:new-expander. (new*, lnew*): New macros. * txr.1: Documented.
* oop: new function: struct-type-name.Kaz Kylheku2019-05-153-0/+22
| | | | | | | | | * struct.c (struct_init): Register struct-type-name intrinsic. (struct_type_name): New function. * struct.h (struct_type_name): Declared. * txr.1: Documented.
* structs: eliminate declaration of nonexistent var.Kaz Kylheku2019-05-111-1/+1
| | | | * struct.h (static_slot_s): Dangling declaration removed.
* debugger: use window-mapdo.Kaz Kylheku2019-05-031-2/+2
| | | | | | * share/txr/stdlib/debugger.tl (print-backtrace): Use the new window-mapdo instead of window-map, to avoid consing a list that is throw away.
* interpreter: small code tidying in me_interp_macro.Kaz Kylheku2019-05-021-2/+1
| | | | | | * eval.c (me_interp_macro): Combine initialization and assignment into one. There was previously code between the two that got removed when the old debugger was scrubbed.
* interpreter: don't bother with dot position.Kaz Kylheku2019-05-021-6/+1
| | | | | | * eval.c (do_eval_args): Since function call expressions all undergo the dot-to-apply transform, there is no need look for a form in the dot position.
* bugfix: apply regression.Kaz Kylheku2019-05-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | Refactorings to apply released TXR 192 broke it, causing apply to fail to treat non-list sequences as individual arguments, as documented. This affects dotted application as well. ;; wrong (list . "abc") -> "abc" ;; correct (list . "abc") -> (#\a #\b #\c) With some misgivings, I'm not making the behavior subject to the -C compat option. * eval.c (applyv): Two things are wrong here: we moved the last fixed argument into args->list without turning it into a one-element list. Secondly, we didn't pass this list through apply_intrinsic_frob_args. We can combine both actions into just calling tolist, which is what apply_intrinsic_frob_args will do with the car of a one-element list.
* C99: get rid of useless inline instantiations.Kaz Kylheku2019-05-024-36/+0
| | | | | | | | | | | * hash.c, lib.c, parser.y, unwind.c: Remove useless declarations that were believed to be C99 inline instantiations. This was mistakenly added at the time the Solaris issue was discovered that _XOPEN_SOURCE values of 600 or greater require compiling in C99 mode. We use "static inline" under C99 for inline functions; instantiation is not applicable at all to inline functions that don't have external linkage.
* loading: try unsuffixed files directly last.Kaz Kylheku2019-05-012-96/+145
| | | | | | | | | | | | | | | | | | | | | | | | | In this patch we change the strategy for resolving unsuffixed paths in load and @(load). In load, an unsuffixed name is tried with a .tlo suffix, then .tl and only if those don't resolve to a file it is tried as-is. The previous order is as-is, .tlo, .tl. Similarly in @(load), but unsuffixed paths are tried as .txr, then .tlo, then .tl. The motivation for this is to avoid probing the filesystem multiple times the optimized case that we care about: loading .tlo files from Lisp. * parser.c (open_txr_file): Rearrange the probing strategy. Also recognize .txr_profile as a suffix, treating it like .tl. This is so that we don't probe for .txr_profile.tlo and .txr_profile.tl before finding the profile. (load_rcfile): Take advantage of the new path-not-found exception. We avoid wastefully checking with path-exists-p to avoid calling open_txr_file. We just let open_txr_file throw an exception if the file doesn't exist, and then distinguish the non-existence case in the handler. * txr.1: Updated @(load) and load documentation.
* lib: more nuanced file access errors.Kaz Kylheku2019-05-019-66/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several new more specific exception types are derived from file-error and used. Error handlers can distinguish unexpected non-existence, unexpected existence and permission errors from each other and other errors. * lib.c (path_not_found_s, path_exists_s, path_permission_s): New symbol variables. (obj_init): New variables initialized. * lib.h (path_not_found_s, path_exists_s, path_permission_s): Declared. * parser.c (open_txr_file): Use new errno_to_file_error function to convert errno to exception symbol. * socket.c (open_sockfd): Likewise. * stream.c (open_directory, open_file, open_fileno, open_command, open_process, run, remove_path, rename_path): Likewise, and process-error is used in open_process and run instead of file-error for problems related to creating the process. * sysif.c (errno_to_file_error): New function. (mkdir_wrap, ensure_dir, chdir_wrap, getcwd_wrap, mknod_wrap, chmod_wrap, symlink_wrap, link_wrap, readlink_wrap, stat_impl, umask_wrap, ): Use errno_to_file_error to convert errno to exception symbol. (exec_wrap): Use process-error instead of file-error. * sysif.c (errno_to_file_error): Declared. * unwind.c (uw_init): Register path-not-found, path-exists and path-permission as subtypes of file-error. * txr.1: Documented.
* build: allow $(pwd)/configure to work.Kaz Kylheku2019-04-292-2/+13
| | | | | | | | | | | | | | | | | | | | | When the build is being done in the source directory, allow the configure script to be executed via path names other than just ./configure, such as an absolute path. Some distros use this. * configure (build_in_srcdir): New variable. (inode): New function. Rather than checking whether "$source_dir" is ".", we test whether they are the same inode. If they are the same, we now also set the build_in_srcdir variable in addition to generating the usual warning. (gen_config_make): Propagate the build_in_srcdir into config.make. * Makefile: use the build_in_srcdir variable from config.make to determine whether we are building in the source directory, rather than relying on top_srcdir being blank.
* debugger: expand frames.Kaz Kylheku2019-04-295-37/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds special unwind frames for backtracing expansions. With this, we can get rid of the global variable last_form_expanded, since to get the last form expanded, we just search for the most enclosing expand frame. * eval.c (last_form_expanded): Global variable removed. (error_trace): Use uw_last_form_expanded() instead of last_form_expanded. (expand_eval): No need to save and restore last_form_expanded any more. (expand_lisp_setq, expand_setqf, expand_lisp1, do_expand): Use uw_last_form_expanded(). (expand, do_macroexpand_1): Push and pop expand frame. This fixes a bug: do_macroexpand_1 was not recording last_form_expanded. Evaluation of top-level forms uses explicit macroexpansion, therefore top-level evaluation was neglecting to set last_form_expanded. This explains weird behavior I saw in the listener from time to time, when errors would report against the expansion of the wrong form. (eval_init): Remove reference to last_form_expanded variable. * eval.h (last_form_expanded): Declaration removed. * share/txr/stdlib/debug.tl (expand-frame print-trace, expand-frame loc): New methods. (print-backtrace): Include uw-expand frames in the backtrace. * unwind.c (expand_frame_type): New static variable. (uw_find_frames_by_mask): Handle UW_EXPAND. (uw_last_form_expanded, uw_push_expand): New functions. (uw_late_init): Register expand-frame struct type. * unwind.h (enum uw_frtype): New enum member, UW_EXPAND. (uw_last_form_expanded, uw_push_expand): Declared.
* backtrace: check next frame for nil.Kaz Kylheku2019-04-291-1/+1
| | | | | * share/txr/stdlib/debug.tl (fcall-frame print-trace): Don't invoke .(loc) method on nx-fr, if it is nil.
* debugger: move uw-* symbols into sys package.Kaz Kylheku2019-04-291-9/+9
| | | | | | * unwind.c (uw_late_init): Move uw-block, uw-captured-block, uw-menv, uw-catch, uw-handle, uw-cont-copy, uw-guard, uw-fcall and uw-eval into the system package.
* bugfix: source lineno off by one under hash bang.Kaz Kylheku2019-04-214-4/+20
| | | | | | | | | | | | | | * eval.c (load): When we read and discard a hash bang line, we must set the parser line number to two. * parser.c (parser_set_lineno): New function. * parser.h (parser_set_lineno): Declared. * txr.c (check_hash_bang): New argument, occurs. (txr_main): Track whether hash bang has occurred in a new local variable hb_occurs. Then, before parsing, if hash bang has occurred, set the line number to two.
* parser: always use stream-associated parser for parse_once.Kaz Kylheku2019-04-216-26/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This refactoring is needed for fixing the off-by-one line number bug when the hash bang line is processed. * eval.c (load): Don't define parser locally; ensure there is one in the stream and use it. * match.c (v_load): Likewise. * parser.c (get_parser_impl): Renamed to parser_get_impl and changed from internal to external linkage. (ensure_parser): Changed to external linkage. (lisp_parser_impl, read_file_common): Follow rename of get_parser_impl. * parser.h (parse_once): Declaration updated. (parser_get_impl, ensure_parser): Declared. * parser.y (parse_once): Take self parameter; drop parser parameter. Ensure a parser to the stream, rather than declaring one locally. Don't clean up the parser when done, just let the stream clean it up. * txr.c (parse_once_noerr): Parser argument is dropped and not passed to parse_once. Program name is passed as self argument to parse_once. (txr_main): When parsing the TXR pattern query, don't define a parser locally; ensure there is one in the stream and use it, like in load and v_load.