summaryrefslogtreecommitdiffstats
path: root/lib.c
Commit message (Collapse)AuthorAgeFilesLines
* * eval.c (eval_init): New functions remove-if and keep-if.Kaz Kylheku2012-04-141-0/+42
| | | | | | | | * lib.c (remove_if, keep_if): New functions. * lib.h (remove_if, keep_if): Declared. * txr.1: Documented.
* * arith.c (INT_PTR_MAX_MP): New static variable.Kaz Kylheku2012-04-101-3/+10
| | | | | | | | | | | | | | | (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.
* * eval.c (eval_init): Expose regex-compile and regexp as intrinsics.Kaz Kylheku2012-04-101-1/+1
| | | | | | | | | | | | | * 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.c (bignum): Previously static function now exposed as external.Kaz Kylheku2012-04-081-2/+20
| | | | | | | | | | | | | | | | | | | | * 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.
* * lib.c: Revert earlier change: config.h must be included before theKaz Kylheku2012-04-071-1/+1
| | | | | <windows.h> section because that header is conditionally included based on one of the config constants.
* * configure: Added new check for some clashing external names,Kaz Kylheku2012-04-071-1/+1
| | | | | | which we can redefine out of the way in config.h. * lib.c: config.h was being included before <windows.h>.
* Rounding out hash table functionality with lazy lists thatKaz Kylheku2012-04-071-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Code cleanup and tweaking.Kaz Kylheku2012-04-051-0/+19
| | | | | | | | | | | | | | | | | | | | | | | * 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.
* The mut macro should only be used for vectors or vector-like objectsKaz Kylheku2012-04-051-2/+6
| | | | | | | | | | | | | 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.
* Bunch of fixes.Kaz Kylheku2012-04-051-2/+1
| | | | | | | | | | | | | | | | | * 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.
* Fix failing test case tests/006/freeform-1.txr.Kaz Kylheku2012-04-031-6/+12
| | | | | | | | | | | | | | | * 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.
* * eval.c (op_modplace): push replaced with mpush (mutating push).Kaz Kylheku2012-04-031-5/+4
| | | | | | | | | | | | | | | * 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.
* * configure: Support a gen-gc configuration variable whichKaz Kylheku2012-04-031-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * lib.c (vec_set_length): Use set instead of assignment.Kaz Kylheku2012-04-021-3/+5
| | | | | | | | (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.
* Start of ground-work for ephemeral GC. We must add some abstractionKaz Kylheku2012-04-011-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * lib.c (num_str): Much more accurate test for deciding whetherKaz Kylheku2012-03-301-3/+6
| | | | | | | | | 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.
* * lib.c (min2, max2): Semantics tweak. If the numbers are equal,Kaz Kylheku2012-03-291-2/+2
| | | | | | favor the left one. * txr.1: Documented min and max.
* * arith.c (numeq): New function.Kaz Kylheku2012-03-291-0/+14
| | | | | | | | | | | | | | | | | (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 =
* * lib.c (obj_print, obj_pprint): Do not use the #<lazy-string ..>Kaz Kylheku2012-03-281-2/+10
| | | | notation for lazy strings that have been forced.
* * eval.c (eval_init): New intrinsic num-str registered.Kaz Kylheku2012-03-261-0/+8
| | | | | | | | | | | | | | | * 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.
* * arith.c (to_float): Fix unterminated argument list in throwf.Kaz Kylheku2012-03-261-1/+1
| | | | * lib.c (funcall): Likewise.
* * lib.c (rebind_s): New symbol variable.Kaz Kylheku2012-03-241-1/+2
| | | | | | | | | | * 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.
* * eval.c (eval_init): Register match-str and match-str-treeKaz Kylheku2012-03-241-0/+6
| | | | | | | | | | 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.
* * lib.c (search_str): If start_num is nil, default it to zero.Kaz Kylheku2012-03-241-0/+4
| | | | This is needed for this to work right as an optional argument.
* * arith.c (plus): Optimization: use num_fast whenKaz Kylheku2012-03-201-0/+6
| | | | | | | | | | | | | | | | 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.
* * configure (uintptr): New variable. Indicates whether unsignedKaz Kylheku2012-03-191-2/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Changing type function to not blow up on nil, which makes a lot of codeKaz Kylheku2012-03-171-80/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * lib.c (do_chain): More useful behavior. The firstKaz Kylheku2012-03-161-3/+10
| | | | | | function, if any, is treated as variadic. Subsequent functions are monadic. (chain, chainv): Turn do_chain into variadic.
* * eval.c (eval_init): New intrinsic functionsKaz Kylheku2012-03-161-6/+36
| | | | | | | | | | | | | | | | | | 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.
* * lib.c (quicksort): Bugfix: incorrect loop from 0 rather than fromKaz Kylheku2012-03-161-1/+1
| | | | leading to unbounded recursion.
* * lib.c (split_str): Separator can be a regex now.Kaz Kylheku2012-03-041-23/+46
|
* * lib.c (sub_str): Removed second check for lazy string thatKaz Kylheku2012-03-031-2/+1
| | | | | | | | | | | | | | | | 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.
* Fixing two instances of unintentional O(n*n) behavior and poor memory useKaz Kylheku2012-03-011-0/+35
| | | | | | | | | | | | | 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.
* * lib.c (numberp): Fix bad type check: null pointer dereference whenKaz Kylheku2012-02-281-0/+2
| | | | | | | | | | 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.
* * debug.c: Missing d command implemented.Kaz Kylheku2012-02-281-0/+45
| | | | | | | | | | 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.
* * lib.c (sub_list, replace_list, lazy_sub_str, sub_str, replace_str,Kaz Kylheku2012-02-281-7/+7
| | | | | sub_vec, replace_vec): Regression: replace incorrect zerop(to) test with to == zero, because to is not necessarily a number.
* * arith.c: Updated copyright year.Kaz Kylheku2012-02-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* * lib.c (sub_list, replace_list, lazy_sub_str, sub_str,Kaz Kylheku2012-02-221-6/+27
| | | | | | | | | 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.
* * eval.c (dwim_loc): del operator's return value is theKaz Kylheku2012-02-221-2/+2
| | | | | | | | 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.
* * lib.c (quicksort): Incorrect pivot selection.Kaz Kylheku2012-02-221-1/+1
|
* * lib.c (init): Hash bugfix: added missing call to hash_init.Kaz Kylheku2012-02-221-0/+1
| | | | | Previously this function did nothing, but now it interns some important symbols.
* * eval.c (eval_init): Intrinsic bindings for sub, ref, refsetKaz Kylheku2012-02-221-5/+69
| | | | | | | | | | | | | | | | 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.
* Introducing optional arguments.Kaz Kylheku2012-02-211-94/+161
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.c (sub, ref, replace): New functions.Kaz Kylheku2012-02-191-1/+56
| | | | | | | | | | * 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.
* * lib.c (lazy_flatten): Bugfix: function was assuming thatKaz Kylheku2012-02-121-7/+11
| | | | | | the input is a list, and not handling the case atom -> (atom) like its non-lazy counterpart. This broke @(next :list expr).
* * lib.c (obj_print): Print control characters in string andKaz Kylheku2012-02-121-9/+14
| | | | | | | | | | | | | | | | | 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.
* * lib.c (lazy_sub_str): New static function.Kaz Kylheku2012-02-091-8/+70
| | | | | | | (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.
* * eval.c (rest_s, op_s): New variables.Kaz Kylheku2012-02-031-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* * hash.c (hash_begin): Missing type check added, otherwiseKaz Kylheku2012-01-271-3/+2
| | | | | | | | 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.
* * eval.c (op_modplace): Fix warning caught by gcc, but not g++.txr-55Kaz Kylheku2012-01-261-2/+2
| | | | * lib.c (replace_list): Fix code that is valid C++ but not C.