| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (copy): Pass new second argument to make_random_state.
* rand.c (random_warmup): New macro.
(random_warmup_s): New symbol variable.
(make_random_state): New warmup argument. Code restructured to
avoid copy flag. Fill code and initialization of r->cur made
common.
(rand_compat_fixup): Pass second argument to
make_random_state.
(rand_init): Pass second argument to make_random_state.
Initialize random_warmup_s with interned symbol. Register
*random-warmup* special variable. Fix registration of
make-random-state to two-argument function type.
* rand.h (make_random_state): Declaration updated.
* txr.1: Document *random-warmup* variable and warup
argument of make-random-state.
|
|
|
|
|
|
|
|
| |
* lib.c (out_str_pretty): Rename to out_str_readable.
This function is called from obj_print_impl precisely when the
pretty flag is false: pretty means output textual things
as the text they denote, rather than machine-readable Lisp.
(out_lazy_str, obj_print_impl): Calls updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In this patch we change which characters objects
are printed using hex escapes, and which characters
are printed as hex when printing string literals.
* lib.c (obj_print_impl): Add DEL (U+7F) to the
list of character objects which are printed as hex.
In a string literal, it's already printed as \x7F.
Use upper case hex rather than lower case.
(out_str_char): Copy the rules used by obj_print_impl
for deciding what string constituents to print as hex
and how to print it. So for instance, U+80 to U+A0 will
now print in hex as well as the U+D800 to U+DFFF range,
rather than just U+DC00 to U+DCFF, and the BOM
code U+FFFE, U+FFFF and anything higher.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (recycled_conses): New static variable.
(rcyc_pop, rcyc_cons, rcyc_list, rcyc_empty): New functions.
(cons): Take a recycled cons, if available.
* lib.h (rcyc_pop, rcyc_cons, rcyc_list,
rcyc_empty): Declared.
* gc.c (gc): Call rcyc_empty to make recycle_list
unreachable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Makefile (ftw.o): Add to OBJS-y conditionally.
* configure (have_ftw): New variable. New configure test
for nftw.
(gen_config_make): Set up have_ftw make variable.
* ftw.c, ftw.h: New files.
* lib.c (init): Call ftw_init, if compiled in.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is really a gratuitous incompatibility with Common Lisp
and other dialects. Let's fix it internally also, but keep the
proper-listp function binding for backwards compatibility.
* eval.c (dot_to_apply, me_op): Update proper_listp
call to proper_list_p.
(eval_init): Register proper-list-p to the same C function as
proper-listp, and that C function is now called proper_list_p.
* lib.c (proper_listp): Renamed to proper_list_p.
* lib.h (proper_listp): Declaration updated.
* parser.y (define_transform): Update proper_listp call.
* txr.1: Replace all occurrences of proper-listp with
proper-list-p. Add note explaining the rename situation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The main aim here is to pave the way for conversion between
arbitrary buffers of bytes (that may include embedded NUL
characters) and a wide string.
Also, a potential security hole is closed. When we convert a
TXR string to UTF-8 for use with some C library API, any
embedded pnul characters (U+DC00) turn into NUL
bytes which effectively cut the UTF-8 string short, and
silently so. The C library function receives a shortened
string. This could be exploitable in some situations.
* lib.c (int_str): Use utf8_dup_to_buf instead of
utf8_dup_to_uc. Pass 1 to have the buffer null-terminated,
since mp_read_radix depends on it.
* stream.c (make_string_byte_input_stream): Use
utf8_dup_to_buf. This gives us the size, soo we don't have to
call strlen. The buffer is no longer null terminated, but the
byte input stream implementation never relied on this.
* utf8.c (utf8_from_buf): Replacement fors utf8_from_uc
which doesn't assume that the buffer of bytes is
null-terminated. It can produce a wide string containing
U+DC00 characters corresponding to embedded nulls in the
original buffer.
(utf8_from): Calculate length of null-terminated string and use
utf8_from_buf.
(utf8_to_buf): Replacement for utf8_to_uc. Can produce
a buffer which is or is not null-terminated, based on new
argument.
(utf8_to): Use utf8_to_buf, and ask it to null-terminate,
thus preserving behavior.
(utf8_dup_from_uc): This function was not used anywhere
and is removed.
(utf8_dup_to_buf): Replacement for utf8_dup_to_uc which
takes an extra agrgument, whether to null-terminate
or not.
(utf8_dup_to): Apply security check here: is the resulting
string as long as utf8_to says it should be? If not,
it contains embedded nulls. Throw an exception.
* utf.h (utf8_from_uc, utf8_to_uc, utf8_dup_from_uc,
utf8_dup_to_uc): Declarations removed.
(utf8_from_buf, utf8_to_buf, utf8_dup_to_buf): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Registered intrinsics rmemq, rmemql,
rmemqual, rmember, rmember-if, rposqual, rposql, rposq,
rpos, rpos-if, rfind, rfind-if and rsearch.
* lib.c (rmemq, rmemql, rmemqual, rmember, rmember-if,
rposqual, rposql, rposq, rpos, rpos-if, rfind, rfind-if,
rsearch): New functions.
(rsearch_list): New static function.
(search): Omit unreachable return statement.
* lib.h (rmemq, rmemql, rmemqual, rmember, rmember-if,
rposqual, rposql, rposq, rpos, rpos-if, rfind, rfind-if,
rsearch): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (time_local_s, time_utc_s): New symbol variables.
(time_meth): New static function.
(time_init): Initialize new symbol variables. Create the
time struct with two static slots, and initialize those
static slots to be methods.
* txr.1: Introduce "the epoch" term. Document the
new methods.
|
|
|
|
|
| |
* lib.c (lazy_str_put, out_lazy_str): Decrement lim
variable in loop body.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (timeout_error_s): New symbol variable.
(obj_init): Intern timeout-error, init new variable.
* lib.h (timeout_error_s): Declared.
* socket.c (sock_timeout, sock_send_timeout,
sock_recv_timeout): New static functions.
(sock_load_init): Register sock-send-timeout and
sock-recv-timeout intrinsics.
* stream.c (stdio_maybe_read_error, stdio_maybe_error):
Convert EAGAIN into timeout_error_s.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* lib.c (bounding_pow_two): Eliminate bogus zero versus
non-zero case check in return which causes the function
to wrongly map 1 to 0, so that chk_manage_vec is then
not able to adjust a vector to size 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (subtypep): Handle subtype check here between
stream and stdio-stream as a special case, since streams
aren't structures related by inheritance, but built-ins.
(class_check): If the type of obj doesn't match the class
exactly, use a subtypep check. We need this because stream
functions use this check, and stdio streams are not of the
stream type now.
* stream.c (stdio_stream_s): New global symbol variable.
(make_stdio_stream_common): Use stdio_stream_s symbol for the
type of stdio streams.
(stream_init): Intern the stdio-stream symbol, and store in
stdio_stream_s variable.
(streamp): Replace exact check with typep.
* stream.h (stdio_stream_s): Declared.
|
|
|
|
|
|
|
| |
* lib.c (vec_list): Don't require input to be specifically a
list, just any sequence that can be marched with cdr until
nil. This commit also fixes the problem that the error message
was still referring to the function as vector-list.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register split*.
* lib.c (split_star_func): New static function.
(partition_split_common): Take pointer-to-function argument
instead of boolean. Hoist this C function into the lazy cons.
(partition): Pass pointer to partition_func ito
partition_split_common, intsead of a flag requesting the use
of partition_func.
(split): Pass apointer to split_func into
partition_split_common.
(split_star): New function.
* lib.h (split_star): Declared.
* txr.1: Documented split*.
|
|
|
|
|
| |
* lib.c (partition_star): Eliminate strange behaviors
when a negative index is given as an argument.
|
|
|
|
|
|
|
| |
lib.c (partition_star): In the special case that the indices
argument is given as the integer zero, the function wrongly
returned just the remaining piece of the sequence after zero,
rather than a list containing this piece.
|
|
|
|
|
|
| |
* lib.c (partition_star): The same issues that were addressed
in TXR 126 in 2015-11-29 commits and 2015-11-24 commits
must also be addressed here.
|
|
|
|
|
| |
* lib.c (obj_print_impl): Handle NUM and BGNUM separately from
FLNUM, thorugh a hard-coded "~s" format.
|
|
|
|
|
|
| |
* lib.c (minusv): Avoid reduce_left overhead in
common two-argument case, and just call binary
minus function directly.
|
|
|
|
|
| |
* lib.c (nary_op): Avoid the overhead of reduce_left in the
two-argument case and just call the binary function.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register / function to divv instead of divi.
* lib.c (divv): New function.
* lib.h (divv): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
| |
* 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.
|