| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
| |
* lib.c (out_str_char): If semi-flag is true, we must
issue a semicolon not only when the next character is
a hex digit, but also when it is a semicolon, so that
"\x1F;;" isn't rendered as "\x1F;" where the semicolon
character has disappeared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (out_str_char): Static function becomes extern.
* lib.h (out_str_char): Declared.
* regex.c (puts_clear_flag, putc_clear_flag): New static
functions.
(print_class_char): Take semicolon flag argument.
Use out_str_char to render characters not escaped locally.
Clear the semicolon flag.
(paren_print_rec): Take semicolon flag argument, and pass it
down. Clear it when printing parentheses.
(print_rec): Take semicolon flag argument, and pass
down to lower level functions. Use putc_clear_flag and
puts_clear_flag instead of put_string and put_char.
Use out_str_char for char object not esaped locally.
(regex_print): define semi_flag and pass it down
to print_rec.
|
|
|
|
|
|
| |
* lib.c (out_str_char): Don't print all characters
above space as themselves. Treat 7F and U+DCxx
as control chars to be printed using hex escape.
|
|
|
|
|
|
| |
* lib.c (chk_strdup, chk_strdup_utf8, chk_copy_obj):
No need to assert !async_sig_enabled since the lower
level chk_malloc or chk_malloc does it.
|
|
|
|
|
| |
* lib.c (cat_str): Unnecessarily scoped len variable
moves to inner scope.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Avoids consing up list of strings.
* lib.c (vscat): New static function.
(scat): New function.
(lazy_str): Use scat instead of cat_str.
* lib.h (scat): Declared.
* eval.c (format_field): Use scat instead of cat_str.
* parser.c (open_txr_file, read_eval_stream): Likewise.
|
|
|
|
|
|
| |
* lib.c (copy_lazy_str): Eliminate pointless initialization of ls.list
and to nil. Make ls.prefix initialization the last step since
it's the only operation which conses.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is also a bugfix. Padding up the index to be at least
1024 characters longer than the existing prefix was dumb
and wrong; it changes the semantics of code which restores the
list from the lazy string, like the @(freeform) directive.
How much of the string is forced is visible to the caller!
* lib.c (lazy_str_force, lazy_str_force_upto): Don't
collect pieces from the lazy list and then catenate them
in one pass. Instead, use the existing function string_extend,
which grows the string exponentially.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* gc.c (finalize): Must free the dynamic structure attached
to the LSTR type now.
(mark_obj): Must mark interior of LSTR type's props structure.
* lib.c (lazy_sub_str, copy_lazy_str): Copy props structure.
(lazy_str): Allocate and initialize props structure.
(lazy_str_force, lazy_str_put, lazy_str_force_upto,
lazy_str_get_trailing_list, out_lazy_str): Follow
representation change.
* lib.h (struct lazy_string_props): New struct type.
(strut lazy_string): Member opts replaced with props
pointer to struct lazy_string_props.
|
|
|
|
|
|
| |
* lib.c (chk_copy_obj): New function.
* lib.h (chk_copy_obj): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It was a mistake to change the semantics of the return value
of chr-isdigit and chr-isdigit. It breaks code like
[partition-by chr-isdigit ...]. The behavior of chr-isdigit
and chr-isxdigit is restored to returning t and nil. New
chr-digit and chr-xdigit functions are introduced for
returning the digit value or nil.
* eval.c (eval_init): Register chr-digit and chr-xdigit
intrinsics.
* lib.c (chr_isdigit, chr_isxdigit): Restore old behavior.
(chr_digit, chr_xdigit): New functions.
* lib.h (chr_digit, chr_xdigit): Declared.
* txr.1: Everything documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* LICENSE, METALICENSE, Makefile, args.c, args.h, arith.c,
arith.h, cadr.c, cadr.h, combi.c, combi.h, configure,
debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c,
gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h,
lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h,
parser.l, parser.y, rand.c, rand.h, regex.c, regex.h,
share/txr/stdlib/cadr.tl, share/txr/stdlib/except.tl,
share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl,
share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl,
share/txr/stdlib/struct.tl, share/txr/stdlib/txr-case.tl,
share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl,
share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl,
signal.c, signal.h, stream.c, stream.h, struct.c, struct.h,
sysif.c, sysif.h, syslog.c, syslog.h, txr.1, txr.c, txr.h,
unwind.c, unwind.h, utf8.c, utf8.h: Add 2016 copyright.
* linenoise/LICENSE, linenoise/linenoise.c,
linenoise/linenoise.h: Bump one principal author's copyright
from 2014 to 2015. The code is based on a snapshot of 2015
upstream work.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (name_s): Defined here now.
(obj_init): name_s initialized here.
* lib.h (name_s): Declared.
* match.c (name_s): Definition removed.
(syms_init): Initialization of name_s removed.
* sysif.c (name_s): Definition removed.
(sysif_init): Initialization of name_s removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (obj_print_impl): Instead of hard-coded "~s", obtain
the format string for floats from the *print-flo-format*
special variable, whose default value is "~s".
* stream.c (print_flo_digits_s, print_flo_format_s): New symbol
variables.
(formatv): Use *print-flo-digits* value for default precision
for ~f and ~e, rather than hard-coded 3.
(stream_init): Initialize print_flo_digits_s and print_flo_format_s, and
register special variables under those symbols.
* stream.h (print_flo_digits_s, print_flo_format_s): Declared.
* txr.1: Documented new specials.
|
|
|
|
| |
* lib.c (lazy_str_force): Remove trailing whitespace.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The #<lazy-string ...> print syntax is gone. Lazy strings are
now printed by traversing their structure, without forcing
them to the flat representation.
* lib.c (lazy_str_put): New function.
(out_str_char, out_str_pretty, out_lazy_str): New static functions.
(obj_print_impl): Use out_str_pretty for standard-printing
regular strings. Use lazy_put_str for pretty-printing lazy
strings, and out_lazy_str for standard-printing them.
* lib.h (lazy_str_put): Declared.
* stream.c (put_string): Check for a lazy string and route
to lazy_str_put, so the string doesn't get forced
(though of course the underlying list does, if it is lazy).
|
|
|
|
|
|
|
|
|
|
|
| |
This is caused by the ("str0" "str1" .. "strn" nil)
representation put out by the interactive style lazy list.
The lazy string force function doesn't like the nil.
Quick and dirty fix applied here.
* lib.c (lazy_str_force, lazy_str_force_upto): If a nil comes
out of lstr->ls.list, break out of the loop as if the list
ended.
|
|
|
|
|
|
|
|
| |
* lib.c (chr_isdigit, chr_isxdigit): Return the integer value
rather than the symbol t, which can be exploited to write
more compact scanning code.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
| |
We must preserve ambiguity-free read-print consistency.
* lib.c (simple_qref_args_p): New static function.
(obj_print_impl): Check for qref and print as
dot notation if its argument list satisfies
simple_qref_args_p.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Structs can now have code which executes after an object is
initialized, which is useful for doing work like registering
objects in global lists and whatever, when those actions need
access to the initialized slots of the object.
* share/txr/stdlib/struct.tl (defstruct): Handle :posinit
syntax, by generating lambda as eighth argument of sys:make-struct
call.
* struct.c (struct struct_type): New member, postinitfun.
(struct_init): Adjust registrations of make_struct_type
to account for new parameter. The user visible
make-struct-type is registered as having one optional
argument, for backward compat.
(make_struct_type): New argument, postinitfun. Store this
in the structure. For backward compatibility, the argument
is defaulted.
(struct_type_mark): Mark the new postinitfun member.
(call_postinitfun_chain): New static function.
(make_struct, lazy_struct_init): Call call_postinitfun_chain
after slots are initialized, and after the boa function is
called.
* struct.h (make_struct_type): Declaration updated.
* lib.c (time_init): Pass eighth argument to make_struct type.
* sysif.c (sysif_init): Likewise.
* unwind.c (uw_late_init): Likewise.
* tests/012/struct.tl: Update defstruct expansion test case.
* txr.1: Document new argument of make-struct-type,
and clarify ordering of initfun with regard to
other actions. Likewise, document :postinit, and clarify
ordering of :init actions with regard to other actions.
|
|
|
|
|
|
|
|
|
|
| |
* lib.h (enum functype): New member, N8.
(struct func): New members n8 and n8v in embedded f struct.
(func_n8, func_n8v, func_n70, func_n8o): Declared.
* lib.c (equal): Handle N8 in switch.
(func_n8, func_n8v, func_n70, func_n8o): New functions.
(generic_funcall): Handle N8 in two switches.
|
|
|
|
|
|
|
|
| |
* lib.c (dwim_set): When the range argument is a
vector or list, it is wrongly hangled through replace, even if
seq is a hash. replace throws since it doesn't handle hashes.
We must treat the vector or list as a hash key and
handle through sethash.
|
|
|
|
|
|
|
| |
* lib.c (replace_list, replace_str, replace_vec): The from
argument must be checked to be a list using listp not consp.
The legacy convention that nil is treated as missing does not
work in this function as it does in sub.
|
|
|
|
|
| |
* lib.c (less): Missing test for equality
before comparing to fields.
|
|
|
|
|
|
|
|
|
|
|
| |
* regex.c (range_regex): Return range.
(search_regst): Use appropriate accessors on
range returned by range_regex.
* lib.c (tok_where): Destructure range returned by
range_regex, using range_bind.
* txr.1: Documented changed behavior.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (env_vbind_special): Remove unused ctx_form
parameter.
(bind_args, bind_macro_params): Don't pass ctx_form to
env_vbind_special.
(apply): Remove unused ctx_form parameter.
(apply_intrinsic, applyv, mapcarv, mappendv,
lazy_mapcarv_func, mapdov, do_mapf): Don't pass nil third
argument to apply.
* eval.h (apply): Declaration updated.
* lib.c (do_juxt): Do not bind third argument of apply
to lin when currying; curry as two argument function.
(do_not): Do not pass third nil argument to apply.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (funcall_interp): Drop the env argument.
The fun argument is now the whole function object, not the
encapsulated code to be interpreted. We pull the
environment and code out of the object locally
and interpret as before.
* eval.h (funcall_interp): Declaration updated.
* lib.c (generic_funcall, funcall, funcall1, funcall2,
* funcall3, funcall4): Calls to funcall_interp simplified,
just passing fun.
|
|
|
|
|
|
|
|
|
| |
* eval.c (interp_fun): Function renamed to funcall_interp.
* eval.h (interp_fun): Declaration updated.
* lib.c (generic_funcall, funcall, funcall1, funcall2,
funcall3, funcall4): Calls to interp_fun updated.
|
|
|
|
|
|
|
|
| |
* lib.c (partition_split_common): nullify indices after
calling function, because function can put out an empty
sequence of non-list type. Use "not sequence" test
rather than "atom" on final index list, so that
vectors and strings can specify indices, as documented.
|
|
|
|
|
|
|
|
| |
* lib.c (transpose): This function turns an input list
into an argument list which ends up in an args structure,
which potentially destroys it to prevent spurious retention.
The list must be copied. We don't use copy-list because
the function supports vectors.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* args.h (args_set_fill): New inline function.
* eval.c (eval_init): Register window-map and window-mappend
intrinics.
* lib.c (wrap_k, reflect_k): New keyword variables.
(calc_win_size): New static function.
(window_map_list, window_map_vec): New static functions.
(window_map, window_mappend): New functions.
(obj_init): Initialize wrap_k and reflect_k.
* lib.h (window_map, window_mappend): Declared.
* txr.1: Documented window-map and window-mappend
|
|
|
|
|
|
|
|
|
|
| |
When the index argument is a function and it returns
an empty list, the functions behave incorrectly.
* lib.c (partition_split_common): Exchange order
of two operations. The handling of an empty indices list must
be done after testing for and calling the function which can
potentially produce that value.
|
|
|
|
|
|
|
| |
* lib.c (sub_list, replace_list): Use original list
variable instead of copying it to iter. Use gc_hint on list so
that the old value doesn't hang around on the stack, while a
register copy marches through the list.
|
|
|
|
|
|
| |
* lib.c (last): Handle non-list sequences via sub function.
* txr.1: Updated description of last.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the equal method is defined for structs, its return
value is used in their place for hashing and comparison.
* eval.h (eq_s, eql_s, equal_s): Declared.
* hash.c (equal_hash): If a COBJ defines an equalsub
function, we call it. If it returns non-nil, we
take the object in its place and recurse.
* lib.c (equal): Refactored to support equality substitution.
(less): Support equality substitution.
* lib.h (cobj_ops): New function pointer member, equalsub.
Only struct instances define this, currently.
(cobj_ops_init): Add null entry to initializer for equalsub.
(cobj_ops_init_ex): New initialiation macro for
situations when the equalsub member must be provided.
* struct.c (struct struct_type): new member eqmslot.
(make_struct_type): Initialize emslot to zero.
(static_slot_set, static_slot_ensure): If eqmslot is -1,
indicating positive knowledge that there is no equal method
static slot, we must invalidate that with a zero: it is no
longer known whether there is or isn't such a slot.
(get_equal_method, struct_inst_equalsub): New static functions.
(struct_inst_ops): Initialize the equalsub member using
new cobj_ops_init_ex macro.
* txr.1: Document equality substitution.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Allowing rankings among types which documentation says
are not comparable.
* lib.c (enum less_handling): New enum.
(less_tab): Elements are values of the less_handling enum.
(less_tab_init): Entries are renumbered. Everything that was
given precedence 5 or higher is now zero: not comparable.
Precedences 0 to 4 remap to 1 to 5. less_tab is populated
differently, since there are four values now. If either
the left or right type has 0 precedence, the value is
less_cannot: comparison is not possible.
(less): Only a less_tab value of less_compare now passes
control through to the switch statement. The less_cannot
value shortcuts to a cannot compare error.
Types that cannot occur in the switch now are removed,
and a default case goes to internal error.
|
|
|
|
|
|
|
|
| |
* lib.c (equal): We cannot pass both arguments to the
left object's equal function just because both arguments are
COBJ. We must make sure they are using the same operations.
The equal functions blindly assume that both arguments are
objects of the same type, and cast the pointers.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (lazy_conses, term, nthcdr, memq, memql, memqual,
member, member_if, remq, remql, remqual, remove_if, keep_if,
countqual, countql, countq, count_if, some_satisfy,
all_satisfy, none_satisfy, proper_listp, length_list,
getplist, do_and, do_or, mappend, find, find_if, posqual,
posql, posq, pos, pos_if): Use gc_hint on list parameter.
(find_max, pos_max, in, search_list, where): Restructure so
that list parameter is used as iterator. Use gc_hint on it.
|
|
|
|
|
|
| |
* lib.c (mapdo): gc_hint the list variable so that the list
march isn't entirely optimized into a register, leaving a
pointer to the top of the list on the stack.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Registered butlast intrinsic.
* lib.c (butlast): New function.
* lib.h (butlast): Declared.
* txr.1: Documented butlast.
|
|
|
|
|
|
|
| |
* lib.c (generic_funcall): If an object is used as a function,
get its lambda method and call that.
* txr.1: Document functors.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* debug.c (show_bindings): Use ~d for level, so as
not to be influenced by *print-base*.
(debug): Use ~d for line numbers.
* lib.c (gensym): Use ~d conversion specifier
for formatting gensym counter into symbol name.
* match.c (LOG_MISMATCH, LOG_MATCH): Use ~d for
line number references.
(h_skip, h_coll, h_fun, h_chr, match_line_completely, v_skip,
v_fuzz, v_gather, v_collect, v_output, v_filter, v_fun,
v_assert, v_load, v_line, h_assert, open_data_source): Use ~d
for line refs, number of iterations, errno values.
* parser.c (repl): Use ~d for prompt line numbers,
numbered variables and the expr-<n> string in error
messages.
* parser.l (yyerrorf, source_loc_str): Use ~d for line
numbers.
* stream.c (print_base_s): New symbol variable.
(formatv): Implement *print-base*.
(stdio_maybe_read_error, stdio_maybe_error, stdio_close,
pipe_close, open_directory, open_file, open_fileno, open_tail,
open_process, run, remove_path): Use ~d for errno values.
(stream_init): Initialize print_base_s and register
*print-base* special variable.
sysif.c (mkdir_wrap, ensure_dir, getcwd_wrap, mknod_wrap,
chmod_wrap, symlink_wrap, link_wrap, readlink_wrap,
excec_wrap, stat_impl, pipe_wrap, poll_wrap, getgroups_wrap,
setuid_wrap, seteuid_wrap, setgid_wrap): Use ~d for
errno values and system function results.
* txr.1: Documented *print-base* and ~d conversion specifier.
|
|
|
|
|
|
|
|
|
| |
* lib.c (obj_print_impl): When rendering quote,
quasiquote, unquote, splice, vector literals, and
meta-vars/meta-numbers into their read syntax, we must ensure
that these forms have the correct abstract syntax. If not, we
must print these as ordinary compound expressions. Otherwise
we throw errors, or don't print the complete object.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register revappend and nreconc
intrinsics.
* lib.c (list_collect_nreconc): New function.
(revlist): New static function.
(list_collect_revappend): New function.
(revappend, nreconc): New functions.
* lib.h (revappend, nreconc): Declared.
(list_collect_nreconc, list_collect_revappend): Declared.
* txr.1: Documented revappend and nreconc.
|
|
|
|
|
|
|
|
| |
* lib.c (nreverse): Handle strings and vectors
individually, and do strings and vectors in-place.
(reverse): Handle strings and vectors individually,
by duplicating and then in place. Handle lazy
strings by forcing, then reversing a copy.
|
|
|
|
|
| |
* lib.c (obj_print_impl): Handle rcons in same place
as other special syntax like sys:expr and quote.
|
|
|
|
|
|
| |
* lib.c (func_n6o): New function.
* lib.h (func_n6o): Declared.
|
|
|
|
|
|
| |
* lib.c (quicksort): Sort the shorter partition with real
recursion, then tail recurse with explicit goto to sort
the longer partition.
|
|
|
|
|
|
| |
* lib.c (med_of_three, middle_pivot): New static functions.
(quicksort): Use med_of_three to choose a pivot above a
threshold array size, otherwise just the middle element.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register intrinsic functions rcons,
rangep from and to.
(eval_init): Register rangep intrinsic.
* gc.c (mark_obj): Traverse RNG objects.
(finalize): Handle RNG in switch.
* hash.c (equal_hash, eql_hash): Hashing for for RNG objects.
* lib.c (range_s, rcons_s): New symbol variables.
(code2type): Handle RNG type.
(eql, equal): Equality for ranges.
(less_tab_init): Table extended to cover RNG.
(less): Semantics defined for ranges.
(rcons, rangep, from, to): New functions.
(obj_init): range_s and rcons_s variables initialized.
(obj_print_impl): Produce #R notation for ranges.
(generic_funcall, dwim_set): Recognize range objects for indexing
* lib.h (enum type): New enum member, RNG. MAXTYPE redefined
to RNG value.
(TYPE_SHIFT): Increased to 5 since there are now 16 type
codes.
(struct range): New struct type.
(union obj): New member rn, of type struct range.
(range_s, rcons_s, rcons, rangep, from, to): Declared.
(range_bind): New macro.
* parser.l (grammar): New rule for recognizing
the #R sequence as HASH_R token.
* parser.y (HASH_R): New terminal symbol.
(range): New nonterminal symbol.
(n_expr): Derives the new range symbol.
The n_expr DOTDOT n_expr rule produces rcons expression rather
than const.
* match.c (format_field): Recognize rcons syntax in fields
which is now what ranges translate to. Also recognize range
object.
* tests/013/maze.tl (neigh): Fix code which destructures
range as a cons. That can't be done any more.
* txr.1: Document ranges.
|