| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
mp_shift takes an int argument, but we decode bits to
a cnum, leaving possible room for overflow, such as
when cnum is 64 bits and int is 32. If the value
* arith.c (ash): Check that the value is in the range
of INT_MIN to INT_MAX.
|
|
|
|
|
| |
* arith.c (ash): Refer to ash in error messages rather than
ashift.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Multi-line expressions can now be entered just using
Enter for line breaks without Ctrl-V.
Multi-line mode becomes default.
* parser.c (is_balanced_line): New static function.
(repl): Install is_balanced_line as enter callback
in linenoise object.
(parse_init): Default *listener-multi-line-p* variable to t.
* txr.1: Documentation about multi-line mode updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The idea is that when the user types Enter to submit a line,
it can be checked whether it is complete syntax using a
callback. If the callback indicates that the syntax is
incomplete (there are open expressions, string literals or
whatever), then Enter is inserted verbatim. This is active
in multi-line mode only.
* linenoise.c (struct lino_state): New members, enter_callback
and ce_ctx.
(lino_set_enter_cb): New function.
(edit): If enter is issued, and multi-line mode is in effect,
and there is an enter callback, then call it. If the callback
returns false, then just insert the character.
* linenoise.h (lino_enter_cb_t): New typedef.
(lino_set_enter_cb): Declared.
|
|
|
|
|
|
| |
* lib.c (toseq, reverse, nreverse): Classify the
sequence with seq_info, and simplify the code by
just dealing with the sequence kinds.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This will help simplify writing generic sequence code, while
allowing lists and vectors to be handled specially.
* lib.h (enum seq_kind, seq_kind_t): New enum and typedef.
(struct seq_info, seq_info_t): New struct and typedef.
(seq_kind_tab, seq_info): Declared.
* lib.c (seq_kind_tab): New global array.
(seq_info): New function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
With this change, nreverse is possible on a struct,
if it has lambda, lambda-set and length methods.
* lib.c (length_s): New symbol variable.
(length): Check for length method and call it,
in preference to checking for car method and falling
back on cdr-based length.
(empty): If object has a length method, call it and
compare result to zero.
(obj_init): Initialize length_s.
* txr.1: Documented. We now have the concepts of structs
being vector-like sequences or list-like sequences.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (ref, refset): Check for lambda and lambda-set,
respectively, and use it.
* txr.1: Documented.
* tests/012/aseq.tl (add lambda): Fix previously unused
broken method which now causes test to go into infinite
recursion.
|
|
|
|
|
|
|
|
| |
* lib.c (reverse): Support COBJ via list
operations, but handle carray via vector case.
(nreverse): Support COBJ via vector case.
This will work for carray. Fixes are needed in
ref and refset to work with structs.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (copy_carray): New function
(ffi_init): Register copy-carray intrinsic.
* ffi.h (copy_carray): Declared.
* lib.c (copy): Call copy_array for carray objects.
* txr.1: Documented copy-carray and updated
copy description.
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (put_carray, fill_carray): New functions.
(ffi_init): put-carray and fill-carray intrinsics
registered.
* ffi.h (put_carray, fill_carray): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (carray_unum, carray_num, unum_carray, num_carray):
New functions.
(ffi_init): New intrinsics registered: carray-unum,
carray-num, unum-carray, num-carray.
* ffi.h (carray_unum, carray_num, unum_carray, num_carray):
Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (sign_extend): After taking the two's complement
which works at the granularity of digits, not the exact
number of bits, we must truncate the number to the
exact number of bits before negating. Otherwise we end up
with an excessively large value. For instance if a bignum
like #x80... is sign extended tightly to the upper
1 bit, the resulting value is something like #-xFFFF80...,
rather than #x-80... as it should be. There are extra
1 bits padding up to the bignum digit. These must be
chopped away.
|
|
|
|
|
|
|
|
| |
* mpi/logtab.h, mpi/mpi-config.h mpi/mpi-types.h mpi/mpi.c,
mpi/mpi.h mpi/mplogic.c mpi/mplogic.h: Reformatted comments.
Removed useless comments. Removed superfluous blank lines and
whitespace. Added space between C keywords if, for, while,
sizeof and opening parens. Removed #if 0 blocks. Tabs to spaces.
|
|
|
|
| |
* txr.c (banner): Text updated.
|
|
|
|
|
| |
* linenoise/linenoise.c (show_help): New static function.
(edit): Call show_help on Ctrl-X ?.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (ffi_set_entries): Register carray-sub
for autoload.
* share/txr/stdlib/ffi.tl (carray-sub): New place
macro, aliases to sub. This is not 100% correct since
that means it will admit non-carray objects, but
the alternative is to clone the entire sub expander
with a few changes, or else factor out sub expansion
into a shared routine. Bleh ...
* txr.1: Documented. We don't cover up the ruse we
perpetrated, and reveal that it's just a place macro
targetting sub.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
TXR Lisp doesn't autoload the definition of places.
For instance if a (set (foo x) y) appears out of the
blue and foo is keyed for autoload, it doesn't happen.
The right place to fix this is to do the autload check
in the place macro expander, since every place form is
tried as a macro.
We need to expose the lisplib_try_load function as a Lisp
intrinsic.
* lisplib.c (lisplib_init): Register sys:try-load
intrinsic, mapped to lisplib_try_load.
* share/txr/stdlib/place.tl (sys:get-place-macro):
New function.
(sys:pl-expand): Use sys:get-place-macro instead of
direct lookup in *place-macro* hash. The new function
tries to autoload the symbol if it finds no place
macro for it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (make_ffi_type_struct): When there is no room in the
current bitfield, two mistakes are made. When bit_offs is
reset to zero in this case, the dependent variable bits_alloc
that was calculated from it (bits allocated to current unit)
must also be reset. The subsequent shift depends on it.
Secondly, when we establish the memb[i].offs field, that
must come from offs, not from unit_offs, because unit_offs
is always the base offset of the existing cell (which doesn't
have room for the new bitfield in this case); the main offset
variable offs is what gets gets adjusted to the cell which has
room for the new bitfield.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim, protsym.c: Regenerated.
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_generic_sbit_put, fi_generic_sbit_get,
ffi_generic_ubit_put, fi_generic_ubit_get): Add needed
coerce from zalloca to mem_t *.
(make_ffi_type_struct): Fix signed/unsigned comparison.
* lib.c (vector): Fix signed/unsigned comparison.
|
|
|
|
|
| |
* genprotsym.txr: Sort groups so that the protsym.c
deltas, going forward, are more stable.
|
|
|
|
|
|
| |
* genprotsym.txr: use @(first) directive trick to
eliminate leading blank lines in front of items
that are not controlled by a preprocessor symbol.
|
|
|
|
|
|
|
|
|
| |
* buf.c (bufp): New function.
(buf_init): Registered bufp intrisic.
* buf.h (bufp): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/conv.tl (sys:conv-let): New
local functions c and cz, using the new #\c
radix conversion.
* txr.1: Documented new extension under the fconv
awk macro. Also fixed a typo here; the b conversion
was exemplified as (c str).
|
|
|
|
|
|
|
|
|
| |
* lib.c (int_str): Support #\c base, recognizing
0x as hex and leading 0 as octal. We don't rely on
the wcstol function's ability to do this conversion,
but scan it ourselves.
* txr.1: Documented.
|
|
|
|
|
| |
* txr.1: Put carray and buf cases into the description of
the indexing notation under the dwim operator.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (make_ffi_type_struct): Use chk_xalloc instead of
chk_malloc.
(make_ffi_type_array): Use chk_xalloc. Since there are
multiple callers, take a self argument to pass down to
chk_xalloc.
(ffi_type_compile): Pass self down to make_ffi_type_array.
(ffi_make_call_desc): Use chk_xalloc.
(carray_ensure_artype): Take a self argument and pass down to
make_ffi_type_array.
(carray_get_common, carray_put_common): Pass self down to
carray_ensure_artype.
|
|
|
|
|
|
|
|
|
| |
* stream.c (open_process): Check that manipulations of nargs
do not overflow int type. Use chk_xalloc. Allocation is
done before pipe so we have no file descriptors to clean up
if chk_xalloc throws.
(run): In both versions of run, check that manipulations of
nargs don't overflow int and use chk_xalloc.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* sysif.c (excec_wrap): Check that our nargs manipulation
doesn't exceed INT_MAX. Use chk_xalloc to allocate the
argument vector, providing an overflow check. Use self
variable in place function name embedded in literal.
(getgroups_wrap): Use chk_xalloc instead of chk_malloc,
so multiplication overflow is checked. Use self variable
in place function name embedded in literal.
(setgroups_wrap): Revamp existing overflow check. Use
ucnum for the size, check that it can convert to size_t
and back without loss of value, and use chk_xalloc
instead of chk_malloc.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (vector): Bugfix: we are checking whether
length + 2 is negative, not length. Check the original
value, and simplify everything using check_mulloc.
(list_vec, sub_vec): Use chk_xalloc just in case. There
shouldn't be any overflow if the vector was constructed and
manipulated properly.
(replace_vec): Replace division-based oveflow check with
a simple test that total + 2 doesn't overflow; then
rely on chk_xalloc to do the multiplication overflow
check.
|
|
|
|
|
| |
* lib.c (chk_wmalloc): Drop the incorrect multiplication
overflow test, and just call chk_xalloc.
|
|
|
|
|
|
|
|
|
| |
This will simplify code that allocates an array-like
object whose size is the product of two numbers.
* lib.c (chk_xalloc): New function.
* lib.h (chk_xalloc): Declared.
|
|
|
|
|
|
|
|
| |
* ffi.c (carray_dup): Do size multiplication using unsigned
type, then coerce back to signed. Check for overflow correctly
by first testing result for negative, then doing division check.
(carray_replace): Add check for negative size, which confirms
overflow.
|
|
|
|
|
|
|
|
|
| |
* ffi.c (carrayp): New function.
(ffi_init): Register carrayp intrinsic.
* ffi.h (carrayp): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Thanks to this (set [ca from..to] list) works.
* ffi.c (carray_replace): New function.
(ffi_init): Register carray-replace intrinsic.
* ffi.h (carray_replace): Declared.
* ffi.c (replace): Hook in carray_replace.
* txr.1: Mention carray under replace, and document
carray-replace.
|
|
|
|
|
|
|
|
|
| |
* ffi.c (carray_pun): New function.
(ffi_init): Registered carray-pun intrinsic.
* ffi.h (carray_pun): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Thus, [ca 3..5] syntax works for slice extraction.
However, this works referentially, not by making a copy.
The extracted subarray points to the original memory,
until carray-dup is invoked on it.
* ffi.c (carray_sub): New function.
(ffi_init): carray-sub intrinsic registered.
* ffi.h (carray_sub): Declared.
* lib.c (sub): Handle carray via carray_sub.
* txr.1: Documented changes in sub.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Thus (select ca '(0 3 4 ...)) works and so does the
sytnax [ca '(0 3 4 ...)]. This is inefficiently implemented.
The selected elements are extracted to a list which is then
converted to a carray of the same kind agan.
* ffi.c (carray_list): New function.
(ffi_init): Register carray-list intrinsic.
* ffi.h (carray_list): Declared.
* lib.c (make_like): Add carray case, so we can turn
a list into a carray based on an example carray.
This uses carray_list, with the type pulled from the
original carray. The target isn't null terminated.
(sel): Handle carray via vector case.
* txr.1: Document changes in select and make-like.
|
|
|
|
| |
* lib.c (generic_funcall, ref, refset): Handle BUF.
|
|
|
|
|
|
| |
* lib.c (length): Handle COBJ of carray type.
* txr.1: Documented.
|
|
|
|
|
| |
* txr.1: Restructure the length documentation to use
definition-style paragraphs, and add buf.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (struct carray): New member, artype.
(carray_mark_op): Mark artype member.
(make_carray): Initialize artype to nil.
(carray_ensure_artype, carray_get_common, carray_put_common):
New static functions.
(carray_get, carray_getz, carray_put, carray_putz): New
functions.
(ffi_init): Register intrinsics carray-get, carray-getz,
carray-put, carray-putz.
* ffi.h (carray_get, carray_getz, carray_put, carray_putz):
Declared.
* txr.1: Documented new functions.
|
|
|
|
|
|
|
|
| |
* ffi.c (carray_get): Renamed to carray_ptr.
(ffi_carray_put): Follow rename.
* ffi.h (carray_get): Declaration removed.
(carray_put): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The FFI module is more than just foreign calls and callbacks;
it provides a type system and operations for working with
binary data. None of it depends on libffi being present and so
shouldn't be disabled if libffi is not available.
* Makefile (ffi.o): Unconditionally link this object file,
not subject to the have_libffi variable.
* configure (have_libffi): Variable removed.
(gen_config_make): Do not generate a have_libffi
variable into config.make, since nothing needs it.
* ffi.c (ffi_type): Fake ffi_type defined if libffi is
missing.
(FFI_TYPE_STRUCT): Fake macro.
(ffi_type ffi_type_void, ffi_type_pointer, ffi_type_sint,
ffi_type ffi_type_schar, ffi_type_uchar, ffi_type
ffi_type_sshort, ffi_type_ushort, ffi_type ffi_type_sint,
ffi_type_uint, ffi_type ffi_type_slong, ffi_type_ulong,
ffi_type ffi_type_sint8, ffi_type_uint8, ffi_type
ffi_type_sint16, ffi_type_uint16, ffi_type ffi_type_sint32,
ffi_type_uint32, ffi_type ffi_type_sint64, ffi_type_uint64,
ffi_type ffi_type_float, ffi_type_double): Fake libffi type
objects, so that code which references these things will
build without modification.
(ffi_get_type): Function only defined if we have libffi.
(ffi_type_struct_destroy_op, ffi_struct_clone,
make_ffi_type_struct, ffi_array_clone, make_ffi_type_array):
Don't work with ffi_type's element array if we don't have
libffi; our fake ffi_type doesn't have such an array.
(struct txr_ffi_closure): Type only defined if we have libffi.
(ffi_closure_struct, ffi_closure_struct_checked,
ffi_closure_print_op, ffi_closure_destroy_op,
ffi_closure_mark_op, ffi_closure_put): Functions only defined
if we have libffi.
(ffi_closure_ops): Static structure only defined if we have
libffi.
(ffi_init_types): Don't register a closure type if we don't
have libffi.
(struct txr_ffi_call_desc): Don't define type if we don't have
libffi.
(ffi_call_desc, ffi_call_desc_checked, ffi_call_desc_print_op,
ffi_call_desc_destroy_op, ffi_call_desc_mark_op,
ffi_make_call_desc, ffi_call_wrap, ffi_closure_dispatch,
ffi_closure_dispatch_safe, ffi_make_closure,
ffi_closure_get_fptr): Functions only defined if we have
libffi.
(ffi_call_desc_ops): Static structure only defined if we have
libffi.
(ffi_init): Only register ffi-make-call-desc, ffi-call, and
ffi-make-closure if we have libffi.
* lib.c: Include "ffi.h" header unconditionally.
(generic_funcall, ref, refset, int): Remove #if HAVE_LIBFFI.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The problem is that the get semantics (zarray char)
produces a vector of characters, not a string. Ditto for
bchar and wchar.
* ffi.c (ffi_varray_null_term_in): Check for the char_conv,
wchar_conv or bchar_conv flag and delegate to
ffi_array_get_common.
(ffi_type_compile): Set char_conv, wchar_conv or bchar_conv
flag for incomplete zarray.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The problem is that if we have a typedef like (typedef x char)
then (array 256 x) will not do string conversion in the manner
of (array 256 char). This is because the raw syntax is checked
for the symbol char, rather than inspecting the type object.
* ffi.c (ffi_type_compile): When checking whether the array
element is a char, bchar or wchar, look at the syntax in
the compiled type object, not the raw syntax. The compiled
type object is the original type pulled from behind the
typedef alias and has the symbol char, bchar or wchar as
its syntax.
|
|
|
|
|
| |
* txr.1: forgotten documentation added: the carray-own
function can't be used on a carray which references a buf.
|
|
|
|
|
|
|
|
|
| |
* lib.c (generic_funcall): Handle carray object via
the same cas that handles vectors, lists and strings.
That in turn works via ref and other lower-level
functions (not all of which support carray yet).
(ref): Handle carray object via carray_ref.
(refset): Handle carray_object via carray_refset.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Bug: rng fails to activate when the to and from condition
are true for the same record.
* share/txr/stdlib/awk.tl (sys:awk-mac-let): Rename the flag-new
gensym holder to flag-act, since it indicates whether the range
is active, either from before or due to being activated by
the current record. A new gensym is added to indicate whether
the range is being deactivated in this record. The inclusive
rng range refers to this variable rather than flag-old.
But a bug emulation is provided to refer to the wrong variable.
* txr.1: Added compatibility note.
|