| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
* lib.c (remove_if, keep_if): New functions.
* lib.h (remove_if, keep_if): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(in_int_ptr_range): New function.
(arith_init): Initialize INT_PTR_MAX_MP.
* arith.h (in_int_ptr_range): Declared.
* lib.c (c_num): Allow bignums to be converted to a cnum, if
they are in range, rather than allowing only fixnums.
* rand.c (make_random_state): Now that we have such a function,
initialize random seed using time value from time_sec_usec rather than
from time and clock. clock is bad for random seeding because it
measures virtual time since the start of the process.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (obj_init): Change spelling of nongreedy operator and put
it into the user package so that it is available for use with
regex-compile.
* regex.c (match_regex, search_regex): Bugfix: optional start
position argument argument not defaulting to zero.
* txr.1: Documented regex-compile and regexp.
* txr.vim: Highlighting regex-compile and regexp.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.h (bignum): Declared.
* configure: Added check for tm_gmtoff and tm_tmzone fields
being present in struct tm.
* eval.c (eval_init): New intrinsic functions: time, time-usec.
* lib.c (num): If the cnum is outside of the fixnum range, then
construct a bignum.
(time_sec, time_sec_usec): New functions.
* lib.h (mut): Slight change to macro to eliminate compiler warning.
(time_sec, time_sec_usec): Declared.
* txr.1: Stub section for time and time-usec.
* txr.vim: Highlighting for time and time-usec.
|
|
|
|
|
| |
<windows.h> section because that header is conditionally included
based on one of the config constants.
|
|
|
|
|
|
| |
which we can redefine out of the way in config.h.
* lib.c: config.h was being included before <windows.h>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
can walk table content in different ways.
* eval.c (op_dohash): Follow interface change of hash_next.
(eval_init): hash-keys, hash-values, hash-pairs and hash-alist
intrinsics introduced.
* filter.c (trie_compress): Follow interface change of hash_next.
* hash.c (hash_next): Silly interface which takes a pointer to
the iterator has changed to just take the iterator. The function
unambiguously returns nil when the iteration ends, so there
is no need to set the iterator variable to nil.
(maphash): Follows interface change of hash_next.
(hash_keys_lazy, hash_values_lazy, hash_pairs_lazy, hash_alist_lazy):
New static functions.
(hash_keys, hash_values, hash_pairs, hash_alist): New functions.
* hash.h (hash_next): Declaration updated.
(hash_keys, hash_values, hash_pairs, hash_alist): Declared.
* lib.c (make_half_lazy_cons): New way of constructing lazy cons,
with the car field specified. It simplifies situations when the
previous cons computes the car of the next one. Why hadn't I thought of
this before?
* lib.h (make_half_lazy_cons): Declared.
* txr.1: Doc stubs for new hash functions.
* txr.vim: Highlighting for new hash functions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* gc.c (BACKPTR_VEC_SIZE): Preprocessor symbol renamed to
CHECKOBJ_VEC_SIZE.
(FULL_GC_INTERVAL): Increased to 40 since the modified
algorithm now leaves less work for the full gc to do.
(backptr, backptr_idx): Static variables renamed to
checkobj and checkobj_idx.
(mark): Follows rename of backptr and backptr_idx.
(gc): Commented out handy printf added.
(gc_set): Use in_malloc_range check to avoid adding to
the check array pointers which are being stored in non-heap locations,
since non-heap locations are already GC roots.
(gc_mutated): Follows variable renaming.
(gc_push): Just do the push using gc_set.
* lib.c (malloc_low_bound, malloc_high_bound): New variables.
(chk_malloc, chk_calloc, chk_realloc): Updated malloc_low_bound
and malloc_high_bound.
(in_malloc_range): New function.
* lib.h (in_malloc_range): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
which hold direct references to other objects and must be used
each time a mutation takes place.
* eval.c (op_dohash): invocations of mut macro removed.
Comment rewritten.
* lib.c (sort_list): Use set macro for mutating assignment.
Do not invoke mut on sorted list; it won't work anyway, because
it doesn't mean what the code wants it to mean: that the list will be
fully traversed during gc marking.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* gc.c (gc_mutated): Return the value.
* gc.h (gc_mutated): Declaration updated.
* hash.c (remhash): Fix unsafe assignment to use set macro.
* lib.c (sort): Fix wrong use of mut macro on the list
before it is sorted rather than after.
* lib.h (mut): Trivial version of macro updated to return argument.
* unwind.c (uw_init): The toplevel environment's match_context
should be gc_protected. Though this is probably not used,
which is why it has not been a problem.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (lazy_str_force, lazy_str_force_upto): Use set macro
when assigning lim. This won't cause a problem unless lim is
in the bignum range, however.
(acons_new, aconsq_new): When overwriting the cdr value of
the existing entry, use set. This is the smoking gun;
these functions are used for manipulating bindings.
(sort): After sorting a list, we must mark it as having
been mutated. If a list contains only mature conses or only
fresh conses, there is no problem. But if it contains a mixture,
then sorting could reverse their relationship, causing mature
conses to backpoint to the fresh ones.
(obj_init): Use set when installing the t symbol into the user package.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* gc.c (gc_push): New function.
* gc.h (gc_push): Declared.
* hash.c (pushhash): Use mpush.
* lib.c (push): Reverted to unsafe operation. TODO comment replaced
with warning.
(lazy_flatten_scan): push occurence commented as safe.
(lazy_stream_func): Unsafe push replaced with mpush.
* lib.h (mpush): New macro.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
causes CONFIG_GEN_GC to be defined as 1 in config.h.
* eval.c (op_defvar, dwim_loc, op_modplace, transform_op): Handle
mutating assignments via set macro.
(op_dohash): Inform gc about mutated variables. TODO here.
* filter.c (trie_add, trie_compress): Handle mutating assignments
via set macro.
* gc.c (BACKPTR_VEC_SIZE, FULL_GC_INTERVAL): New preprocessor symbols.
(backptr, backptr_idx, partial_gc_count, full): New static variables.
(make_obj): Initialize generation to zero.
(gc): Added logic for deciding between full and partial gc.
(gc_set, gc_mutated): New functions.
* gc.h (gc_set, gc_mutated): Declared.
* hash.c (hash_mark): Changed useless use of vecref_l to vecref.
(gethash_f): Use set when assigning through *found since it
is a possible mutation.
* lib.c (car_l, cdr_l, vecref_l): Got rid of loc macro uses. Using the
value properly is going to be the caller's responsibility.
(push): push may be a mutation, so use set.
(intern): Uset set to mutate a hash entry.
(acons_new_l, aconsq_new_l): Use set when replacing *list.
* lib.h (PTR_BIT): New preprocessor symbol.
(obj_common): New macro for defining common object fields.
type_t is split into two bitfields, half a pointer wide,
allowing for generation to be represented.
(struct any, struct cons, struct string, struct sym, struct package,
struct func, struct vec, struct lazy_cons, struct cobj, struct env,
struct bignum, struct flonum): Use obj_common macro to defined
common fields.
(loc): Macro removed.
(set, mut): Macros conditionally defined for real functionality.
(list_collect, list_collect_nconc, list_collect_append): Replace
mutating operations with set.
* match.c (dest_set, v_cat, v_output, v_filter): Replace
mutating operations with set.
* stream.c (string_in_get_line, string_in_get_char,
strlist_out_put_string, strlist_out_put_char): Replace mutating
operations with set.
* unwind.c (uw_register_subtype): Replace mutating operation with set.
|
|
|
|
|
|
|
|
| |
(vecref_l): Use loc to lift address of cell.
(replace_vec): Use macro mut to indicate the object is being
mutated.
* lib.h (mut): New macro.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
to places where we potentially assign a reference to a younger object
inside a field located in an older object (chronological
backreference) and also where we take the address of an object
field, making it possible that the user of the address will do so.
This patch does not take care of vectors.
No, this is not an April Fool's joke.
* eval.c (env_fbind, env_vbind, env_replace_vbind, lookup_var,
lookup_sym_lisp1): Use set macro instead of assignment.
* hash.c (hash_grow, set_hash_userdata, hash_next):
Use set macro instead of assignment.
* lib.c (rplaca, rplacd, string_extend, length_str, replace_str,
rehome_sym, lazy_stream_func, lazy_str, lazy_str_force,
lazy_str_force_upto, obj_init): Use set macro instead of assignment.
(car_l, cdr_l): Use loc instead of address-of operator.
* lib.h (set, loc): New macros.
|
|
|
|
|
|
|
|
|
| |
to treat the number as floating or integer. We can't just look
for the presence of E, e or . because these coudl be part of
trailing junk for instance "123XYZE." should convert
to the integer 123, where "XYZE." is trailing junk.
* txr.1: Documented int-str, flo-str and num-str.
|
|
|
|
|
|
| |
favor the left one.
* txr.1: Documented min and max.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(exptmod): Bugfix: was no normalizing the bignum, ouch.
Also was reporting "non-integral operands" for other
errors.
* eval.c (eval_init): Registered = intrinsic function.
* lib.c (numeqv): New function.
* lib.h (numeq, numeqv): Declared.
* txr.1: Documented expt, sqrt, isqrt, exptmod, fixnump, bignump,
integerp, floatp, numberp, zerop, evenp, oddp, >, <, >=, <= and =.
* txr.vim: Highlight =
|
|
|
|
| |
notation for lazy strings that have been forced.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* filter.c (tonumber_k, tointeger_k, tofloat_k, hextoint_k):
New keyword variables.
(filter_init): New variables initialized; new filters registered.
* filter.h (tonumber_k, tointeger_k, tofloat_k, hextoint_k):
Declared.
* lib.c (num_str): New function.
* lib.h (num_str): Declared.
* txr.1: New filters documented.
|
|
|
|
| |
* lib.c (funcall): Likewise.
|
|
|
|
|
|
|
|
|
|
| |
* lib.h (rebind_s): Declared.
* match.c (v_rebind): New static function.
(dir_tables_init): Registered rebind_s to v_rebind,
and also to hv_trampoline in the horizontal directive table.
* txr.1: Documented it.
|
|
|
|
|
|
|
|
|
|
| |
intrinsics.
* lib.c (match_str, match_str_tree): Default position to zero.
* txr.1: Doc stubs created.
* txr.vim: Highlighting for match-str and match-str-tree.
|
|
|
|
| |
This is needed for this to work right as an optional argument.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
result is in the fixnum range.
Implemented FLNUM cases, except for adding a FLNUM
to BGNUM.
(minus, mul): Use num_fast when the cnum value is in the fixnum range.
(int_flo): New function.
* eval.c (eval_init): Register int-flo intrinsic.
* lib.c (c_flo): New function.
* lib.h (TYPE_SHIFT, TYPE_PAIR): New macros, carried over
from the lazy strings branch.
(c_flo, int_flo): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
version of intptr_t is available and should be generated in config.h
as uintptr_t.
* eval.c (eval_init): New intrinsic functions floatp,
integerp, flo-str.
* gc.c (finalize): Handle FLNUM case. Rearranged
cases so that all trivially returning cases are
together.
(mark): Handle FLNUM case.
* hash.c (hash_double): New function.
(equal_hash): Handle FLNUM via hash_double.
(eql_hash): Likewise.
* lib.c: <math.h> is included.
(float_s): New symbol variable.
(code2type, equal): Handle FLNUM case in switch.
(integerp): New function; does the same thing
as integerp before.
(numberp): Returns t for floats.
(flo, floatp, flo_str): New functions.
(obj_init): Initialize new float_s variable.
(obj_print, obj_pprint): Handle FLNUM case in switch.
Printing does not work yet; needs work in stream.c.
* lib.h (enum type): New enumeration FLNUM.
(struct flonum): New struct type.
(union obj): New member, fl.
(float_s, flo, floatp, integerp, flo_str): Declared.
* parser.l (FLO): New token pattern definition.
Scans to a NUMBER token.
Corrected uses of yylval.num to yylval.val.
* parser.y (%union): Removed num member from yystype.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
simpler. A pseudo type code is introduced called NIL with value 0.
* lib.h (enum type): New enumeration value, NIL.
(type): Function accepts object nil and maps it to code NIL.
* eval.c (dwim_loc, op_dwim): test for nil obj and goto hack is gone,
just handle NIL in the switch.
* gc.c (make_obj, mark): Handle new NIL type code in switch.
* hash.c (equal_hash): Handle NIL in the switch instead of nil test.
* lib.c (code2type): Map new NIL type code to null.
(typeof, typecheck): Code simplified.
(class_check, car): Move nil test into switch.
(eql, equal, consp, bignump, stringp, lazy_stringp,
symbolp, functionp, vectorp, cobjp): Simplified.
(length, sub, ref, refset, replace, obj_print, obj_pprint): Handle NIL
in switch instead of nil test. goto hack removed from refset.
* match.c (do_match_line, do_output_line): switch condition simplified.
* regex.c (regexp): Simplified.
(regex_nfa): Assert condition simplified.
|
|
|
|
|
|
| |
function, if any, is treated as variadic. Subsequent
functions are monadic.
(chain, chainv): Turn do_chain into variadic.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
chain, andf, orf, iff.
* lib.c (chainv): New function.
(do_and, do_or): Generalized to handle functions of
any arguments via apply.
(andf, orf): Turn do_and and do_or into variadic function instead of a
monadic function.
(do_iff): New static function.
(andv, orv, iff): New functions.
* lib.h (chainv, andv, orv, iff): New functions declared.
* txr.1: Doc stubs created.
* txr.vim: Updated.
|
|
|
|
| |
leading to unbounded recursion.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
can't ever come out true.
* match.c (search_form, h_var, h_coll, h_parallel, h_fun): Handle
position t emanating from match_line, indicating match to end of line.
(h_skip): When skipping to the end of line (empty spec), just
return t as the position rather than the end of the line. This avoids
calculating the length of the line, which forces a lazy string.
(do_match_line): Near the beginning of the loop, if the position is t,
then substitute the length of the line.
(freeform_prepare): Return the freeform line limit value.
(v_freeform): Check for t coming out of match line and do the
conversion back to the trailing list in that case, but only if
the freeform was limited by number of lines.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
that occur in horizontal matching of basic text patterns.
* lib.c (match_str, match_str_tree): New functions.
* lib.h (match_str, match_str_tree): Declared.
* match.c (do_match_line): Use match_str_tree and match_str when matching
strings and string lists, respectively, rather than stupidly calling
search functions and then asserting that the match was found at the
starting position.
|
|
|
|
|
|
|
|
|
|
| |
object is nil.
* match.c (do_match_line): Bugfix for incorrect treatment of long
lines. Must return the absolute position from the start of the original
line (plus(c->pos, c->base)), rather than just c->pos, which only
measures from the start of a line that may have been chopped by
consume_prefix.
|
|
|
|
|
|
|
|
|
|
| |
Condense the output to 8 times the screen width, for more context.
Condense the output in vertical mode (when the entire input line
is shown) not only character mode.
* lib.c (remq, remql, remqual): New functions.
* lib.h (remq, remql, remqual): Declared.
|
|
|
|
|
| |
sub_vec, replace_vec): Regression: replace incorrect zerop(to)
test with to == zero, because to is not necessarily a number.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.h: Likewise.
* debug.c: Added copyright header.
* debug.h: Updated copyright year.
* eval.c: Likewise.
* eval.h: Likewise.
* filter.c: Likewise.
* filter.h: Likewise.
* gc.c: Likewise.
* gc.h: Likewise.
* hash.c: Likewise.
* hash.h: Likewise.
* lib.c: Likewise.
* lib.h: Likewise.
* match.c: Likewise.
* match.h: Likewise.
* parser.h: Likewise.
* regex.c: Likewise.
* regex.h: Likewise.
* stream.c: Likewise.
* stream.h: Likewise.
* txr.c: Likewise, and e-mail address.
* txr.h: Updated copyright year.
* unwind.c: Likewise.
* unwind.h: Likewise.
|
|
|
|
|
|
|
|
|
| |
replace_str, sub_vec, replace_vec): Implementing floating zero
behavior. This is necessary so that the important case index .. (+
index 1) for selecting one element as a subrange works even if index is
negative.
* txr.1: Floating zero behavior for ranges documented.
|
|
|
|
|
|
|
|
| |
deleted range of values. Missing del cases added for single
index cases.
* lib.c (quicksort): Fix pivot selection one more time.
(length): Fix bad argument in "not a sequence" error.
|
| |
|
|
|
|
|
| |
Previously this function did nothing, but now it interns
some important symbols.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
and replace.
* lib.c (do_sort): Static function renamed to sort_list.
(swap, quicksort, sort_vec): New static functions.
(sort): Made generic over lists, vectors and strings.
(refset): New function.
* lib.h (sort): Declaration updated (parameter name change).
(refset): Declared.
* txr.1: Mention refset.
* txr.vim: Updated with refset.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* debug.c (help, show_bindings): put_string arguments reversed.
* eval.c (bind_args): Support colon notation in interpreted
function lambda lists for optional arguments. Improved error checking.
(apply): Allow optional arguments to be left out.
(dwim_loc): Reversed arguments to replace_str, replace_vec,
replace_list.
(eval_init): Numerous intrinsics now have arguments that are optional.
New function rand introduced which reverses arguments relative to
random. New intrinsic function hash introduced for alternative
construction of hashes.
* gc.c (sweep): Reversed arguments to put_char.
* hash.c (weak_keys_k, weak_vals_k, equal_based_k): New keyword
symbol variables.
(hashv): New function.
(hash_init): Intern new symbols.
* hash.h (weak_keys_k, weak_vals_k, equal_based_k, hashv): Declared.
* lib.c (colon_k): New keyword symbol variable.
(replace_list, replace_str, replace_vec): Arguments rearranged.
(tree_find): testfun becomes optional argument.
(int_str): base becomes optional argument.
(func_f0, func_f1, func_f2, func_f3, func_f4, func_n0,
func_n1, func_n2, func_n3, func_n4, func_f0v, func_f1v,
func_f2v, func_f3v, func_f4v, func_n0v, func_n1v,
func_n2v, func_n3v, func_n4v, func_interp): Initialize optargs to zero.
(func_n0o, func_n1o, func_n2o, func_n3o, func_n4o): New functions.
(cobj_print_op): Reversed arguments to put_string.
(find): testfun and keyfun become optional arguments.
(replace): Parameters rearranged and arguments rearranged in calls to
replace_list, replace_str and replace_vec.
(obj_init): colon_k initialized.
(obj_print, obj_pprint): Arguments reversed, and stream defaults
to std_output. Arguments reversed in calls to put_char and put_string.
(dump): Arguments reversed in call to put_char.
* lib.h (struct func): sizes of minparam, fixparam bitfields
adjusted. New bitfield optargs. New unnamed bitfield added so
the previous ones add up to 16 bits.
(colon_k): Declared.
(func_n0o, func_n1o, func_n2o, func_n3o, func_n4o): Declared.
(replace_list, replace_str, replace_vec, replace): Declarations updated.
* match.c (debuglf, dump_shell_string, dump_byte_string, dump_var,
do_output_line, extract): Reversed arguments to put_char and
|
|
|
|
|
|
|
|
|
|
| |
* lib.h (sub, ref, replace): Declared.
* match.c (format_field): Generic indexing using new functions.
* txr.1: Documentation stub.
* txr.vim: Highlighting for new functions.
|
|
|
|
|
|
| |
the input is a list, and not handling the case
atom -> (atom) like its non-lazy counterpart.
This broke @(next :list expr).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
character literals as hex escapes, followed by semicolon if
necessary. Don't use iswprint function since it is locale-specific
and concludes that non-ASCII characters are unprintable.
Changed print syntax for lazy strings.
(obj_pprint): Changed print syntax for lazy strings.
* parser.l: Bugfix in hex/octal character constant.
num_esc(yytext) was called rather than num_esc(yytext+1).
* parser.y (chrlit): Bugfix: missing case for hex and octal
constants which are given by a LITCHAR token.
* stream.c (vformat): Bugfix: strings were being printed as if using ~a
even under ~s.
|
|
|
|
|
|
|
| |
(sub_str): Bugfix: handle t values of from from and to, and negative
indices, just like sub_vec. Special handling for lazy strings
introduced. If to is the value t, then the a lazy string can be
produced.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(do_eval_args): Allow calls specified by improper lists
like (x y . z) where the z expression must evaluate to a list
that turns into addition arguments to be applied.
(transform_op, expand_op): New static functions.
(expand): Call expand_op.
(eval_init): Initialize rest_s and op_s. Use rest_s
to register rest function.
* lib.c (gensym): New function based on gensymv.
(gensymv): Now calls gensym.
* lib.h (gensym): Declared.
* parser.l: Parse @ followed by digits as a new kind of token,
METANUM.
* parser.y (METANUM): New token.
(meta_expr, exprs): Missing rlcp's added.
(expr): METANUM variant introduced.
(yybadtoken): Handle METANUM.
* txr.1: Documented one-symbol argument list of lambda.
Documented op. Closed some unbalanced parentheses.
* txr.vim: Highlight op.
|
|
|
|
|
|
|
|
| |
passing in an object that is not a hash results in corruption
or crashing behavior.
* lib.c (class_check): Improved to a one-step check with a clear
message.
|
|
|
|
| |
* lib.c (replace_list): Fix code that is valid C++ but not C.
|