| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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, ftw.c, ftw.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/awk.tl, share/txr/stdlib/build.tl,
share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.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/socket.tl,
share/txr/stdlib/struct.tl, share/txr/stdlib/termios.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, socket.c, socket.h,
stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c,
syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c,
unwind.h, utf8.c, utf8.h: Revert to verbatim 2-Clause BSD.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have a problem not handling negative list indices
which index beyond the beginning of the list.
Such accesses are just storing and retrieving the
first element!
* lib.c (listref): If a negative index is still negative
after the length of the list is added to it, then
return nil. Do not return car(list)!
(listref_l): Similary, do not return car_l(list) if
the index is less than zero, so that an error
occurs for an out-of-range negative index.
* txr.1: Update the documentation for ref
to describe these indexing constraints, and also
to include hashes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The sys:regex internal symbol was historically used when
derivative-based regexes had a S-exp representation headed
by that symbol. It had to be a private symbol.
Now the regex symbol is only used as the COBJ class type
for regexes; it makes no sense for it to be in the sys
package. We want user code to be able to refer to this
type using a public symbol.
* lib.c (obj_init): Intern the regex symbol stored
in regex_s in user_package.
* txr.1: Include regex in the type graph in the
Object Type section, and in the type list under
the typeof function.
|
|
|
|
|
|
|
|
| |
* lib.c (generic_funcall): Add case for regexes.
Handle arguments in such a way that the string is always
rightmost, with a view to convenient partial application.
* txr.1: Documented in multiple places.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (tok_str): Only continue the loop if
the new position isn't past the end of the string.
This fixes the problem of recognizing an empty
token past the last character in the string.
Also, advance new_pos by one if there is a zero
length match. Then don't advance pos by one later
in that case. This fixes the bug that we collect
empty separator pieces *and* empty tokens,
and also prevents empty matches before the first
character of the string. Logic in tok_str is now very similar
to that in split_str_keep.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (split_str_keep): In the regex case, changing
to an infinite loop. The do/while is no longer needed because
the if statement includes a test of the position having
reached the end of the string. This is done before it is
incremented by len, so we avoid wrongly keeping a separator.
* txr.1: Clarified that an empty regex match
behaves like an sep which is an empty string,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register split-str to split_str_keep,
with optional argument.
* lib.c (split_str_keep): New function, formed from
split_str, with third argument.
(split_str): Reduced to wrapper around split_str_keep.
Thus we don't have to update umpteen existing calls
with an extra nil parameter.
* lib.h (split_str_keep): Declared.
* txr.1: Documented new optional argument of split-str.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (weave_while): Pass third arg to remq as nil.
(eval_init): Update registrations of remq, remql and
remqual.
* lib.c (remq, remql, remqual): Implement key function
argument.
* lib.h (remq, remql, remqual): Declarations updated.
* sysif.c (at_exit_call): Pass third arg to remq as nil.
* debug.c (debug): Pass third argument to remqual as nil.
* txr.1: Documentation updated.
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register keepq, keepql and keepqual
intrinsic functions.
* lib.c (keepq, keepql, keepqual): New functions.
* lib.h (keepq, keepql, keepqual): Declared.
|
|
|
|
|
|
|
|
| |
* lib.c (remq, remql, remqual, remove_if, keep_if): Bug:
functions don't work correctly for strings. Anyway,
the ldiff-based algorithm is ugly on vectors and strings.
Patching things upp by converting input to list with
tolist.
|
|
|
|
|
|
|
|
|
| |
* lib.c (trim_str): Trim only newlines and blanks,
not carriage returns, vertical tabs and form feeds.
This is subject to the compatibility option
* txr.1: Doc updated and compatibility note
added.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (time_parse_s): New symbol variable.
(tm_to_time_struct): New static function,
based on code moved out of broken_time_struct.
(broken_time_struct): Bulk of code replaced with call to
tm_to_time_struct.
(time_struct_to_tm): New parameter, strict. Indicates
whether nils in time struct are converted to zeros,
or whether they trigger errors.
(time_string_meth): Specify strict conversion
of argument time struct to to struct tm when
calling time_struct_to_tm.
(time_parse_meth): New static function.
(time_init): Initialize time_parse_s symbol variable;
add time-parse static slot to time struct;
initialize slot with new method.
* txr.1: Document time-parse method.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (time_string_s): New symbol variable.
(time_fields_to_tm, time_struct_to_tm): New static functions.
(make_time_impl): Replace bunch of code with call to
time_fields_to_tm.
(time_string_meth): New static function.
(time_init): Initialize time_string_s. Add time-string
static slot to time struct. Register time-string
method.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* configure: Test for strptime.
* eval.c (eval_init): register time-parse intrinsic.
* lib.c (time_parse): New function.
* lib.h (time_parse): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* lib.c (out_quasi_str): New static function.
(obj_print_impl): Handle sys:quasi and sys:quasilist
forms, reproducing a syntax similar to their read
notation.
|
|
|
|
|
| |
* lib.c (split_str): Fourth argument of search_regex is
Lisp boolean, so nil should be used to specify false.
|
|
|
|
|
|
|
| |
* lib.c (vector, copy_vec, sub_vec, cat_vec): Set the type
field of the object sooner. Do not malloc between obtaining
the object, and initializing it, because that could throw,
leaving an uninitialized object in the heap space.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Although we are garbage-collected, being able to clean up on
shutdown is nevertheless useful for uncovering leaks. Leaks
can occur, for instance, due to neglect to free out-of-heap
satellite data from objects that are reclaimed by gc.
This feature is long overdue.
* arith.c, arith.h (arith_free_all): New function.
* gc.c, gc.h (gc_free_all): New function.
* lib.c (init): Remove program name parameter and
redundant initialization of progname globl variable.
* lib.h (progname): Superfluous declaration removed.
This is already declared in txr.h.
(init): Declaration updated.
* regex.c (char_set_destroy): Do not check the static
allocation flag here; just destroy the object.
Do check for a null pointer, though.
(char_set_cobj_destroy): This cobj destructor now
checks the static flag of the char set object and
avoids freeing it. Thus our char set singletons are
left alone by gc, but our global freeing function
takes care of them.
(wide_cs): New static variable moved out of
wide_display_char_p to static scope.
(regex_free_all): New function.
* regex.h (regex_free_all): Declared.
* txr.c (progname): const qualifier and initializer removed.
(main): Ensure progname is always dynamically allocated, even
in the argv[0] == 0 case. Do not pass progname to init;
it doesn't take that argument any more.
(free_all): New static function.
(txr_main): Implement --free-all option.
* txr.h (progname): Declaration updated.
|
|
|
|
|
| |
* lib.c (length): In COBJ case, handle
structures which have a car slot.
|
|
|
|
|
|
| |
* lib.c (toseq): Handle OBJP case, and
implement behavior for struct objects that
have a car method.
|
|
|
|
|
|
|
|
|
| |
* lib.c (replace_list): Simplify treatment of items
on entry using toseq.
(replace_str, replace_vec): When a list or vector of
indices is given, use the itseq result of passing
items items through toseq function rather than
original items, for consistency with range assignment.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This eliminates the error which occurs when
a sequence implemented as a struct is nconced
or appended onto. The struct is converted to
a list, and so is the object on the right hand
side. As a result, more generic sequence code
works on structs.
* lib.c (list_collect_nconc, list_collect_append):
Handle tail of type COBJ by converting to a list,
storing that list back in the tail and then
destructively tacking onto that the obj
operand, also turned into a list.
|
|
|
|
|
|
|
| |
* lib.c (list_collect_nconc, list_collect_append):
Capture deref(ptail) subexpression in local var
and refer to that in all code where ptail isn't
modified from the original value.
|
|
|
|
|
|
| |
* lib.c (tolist): Use mapcar_listout, to avoid
the conversion of the resulting list to the object's type,
making this whole operation useless!
|
|
|
|
|
| |
* lib.c (vscat): Replace "cat-str" and "vcat"
with correct name "scat".
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (from_list_s): New symbol variable.
(make_like): Handle a COBJ. If it's a structure with a
from-list method, then use it, otherwise the
default handling applies of returning the list.
(obj_init): Initialize from_list_s.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (ldiff): Rather than checking specifically for
strings and vectors to apply the special case behavior
(comparison using equal), test specifically for lists and
apply the traditional behavior. Every other object,
not just strings and vectors, gets the altered behavior.
* txr.1: Changed text in TXR Lisp introduction which touches
on ldiff, and wording fix under ldiff.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Struct objects can now define methods car, cdr and nullify.
With these, they can participate in operations on sequences.
* eval.h (car_s, cdr_s): Declared.
* lib.c (nullify_s): New symbol variable.
(car, cdr): Implement for struct objects via, respectively,
their car and cdr methods.
(tolist): Handle objects by mapping through identity.
(nullify): Implement for objects optionally: if an object
is a struct with a nullify method, use it, otherwise go
through default case of just returning the object.
(empty): Implement for objects that have nullify method.
(obj_init): Initialize nullify_s.
* struct.c (maybe_slot): New function.
* struct.h (maybe_slot): Declared.
* txr.1: Documented car, cdr and nullify method
convention.
|
|
|
|
|
|
| |
* lib.c (drop_while, drop_until): No need to
do default_arg on keyfun, since it is just passed
to pos_if, which takes care of it.
|
|
|
|
|
|
| |
* lib.c (take_until): keyfun not defaulted in list cases.
Needless defaulting of key in vector/string cases, since pos
function already defaults.
|
|
|
|
|
|
| |
* lib.c (length_list): Count using cnum
only up to INT_PTR_MAX, then switch to
bignums.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Makefile (termios.o): New object file.
* lib.c (init): Call termios_init.
* lisplib.c (termios_set_entries, termios_instantiate): New
functions.
(lisplib_init): Register new functions in autoload table.
* share/txr/stdlib/termios.tl: New file.
* termios.c, termios.h: New files.
* txr.1: Documented termios.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (rcyc_pop): Just assume that *plist points to a cons
and access the fields directly.
(rcyc_cons): Don't bother with rplacd.
(rcyc_list): Don't bother with set macro.
* regex.c (read_until_match): Defensive coding: locally
ensure that rcyc_pop won't be called on a nil stack,
which will now segfault.
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (cons): When we recycle a cons, it could
be already in the mature generation. In that case,
baby objects stored in its car or cdr violate the
integrity of the heap. We must hint about this
to the garbage collector. Test case:
./txr --gc-debug -p "(list* 'foo (zip
'(a) (repeat '((gensym)))))"
|
|
|
|
|
|
|
|
|
| |
Improper handling of arguments in certain cases.
Test case: [[flipargs -] 2 1]. Should yield -1;
actual behavior is error.
* lib.c (minusv, divv): Correct test for more
arguments after extracting the leftmost one.
|
|
|
|
|
|
|
|
| |
* lib.h (default_arg): Inline function becomes macro,
so we can avoid evaluating the default value expression
when it is not needed.
* lib.c (default_arg): Declaration removed.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (panic_s): New symbol variable.
(obj_init): Initialize panic_s.
* lib.h (panic_s): Declared.
* unwind.c (uw_init): Register panic exception.
* unwind.h (panic): New macro.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|