summaryrefslogtreecommitdiffstats
path: root/lib.h
Commit message (Collapse)AuthorAgeFilesLines
* * eval.c (eval_init): Register last function as intrinsic.Kaz Kylheku2014-03-231-0/+1
| | | | | | | | * lib.c (last): New function. * lib.h (last): Declared. * txr.1: Documented last.
* * eval.c (eval_init): Register empty as intrinsic.Kaz Kylheku2014-03-231-0/+1
| | | | | | | | | | | | * lib.c (copy): Bugfix: handle lazy strings. Also, handle hash tables via copy_hash. (length): Bugifx: handle lazy strings. Also, handle hash tables via hash_count. (empty): New function. * lib.h (empty): Declared. * txr.1: Documented.
* * eval.c (plus_s, prof_s): New symbol global variables.Kaz Kylheku2014-03-121-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (op_prof, me_pprof): New static functions. (eval_init): Intern prof symbol, store in prof_s. Captured interned + symbol in plus_s. Register prof operator and pprof macro. * gc.c (gc_bytes): New global variable. (more): Use nse function chk_malloc_gc_more instead of chk_malloc. (make_obj): Increment gc_bytes. * lib.c (malloc_bytes): New global variable. (chk_malloc, chk_realloc): Increment malloc_bytes. (chk_calloc): Bugfix: incorrect size in recursion into oom_realloc. Incorrect calculation of malloc_high_bound. Increment malloc_bytes. (chk_malloc_gc_more): New function. * lib.h (alloc_bytes_t): New typedef. (malloc_bytes, gc_bytes): Declared. (chk_malloc_gc_more): Declared. * stream.c (format_s): New symbol global. (stream_init): format_s inited. format_s used to register formatv function. * stream.h (format_s): Declared. * txr.1: Documented prof and pprof. * genvim.txr: Recognize reg_fun calls with intern followed by a preceding assignment or other syntax. * txr.vim: Updated.
* * lib.c (upop): New function.Kaz Kylheku2014-03-071-0/+1
| | | | | | | | | | | | | | * lib.h (upop): Declared. * txr.c (txr_main): Two bugfixes. One is that the argument - was being pushed back twice resulting in *args* being ("-" "-"). This is because the option processing loop checked for "-" and pushed it back into args, and then some logic after the loop pushed arg back into args again. But, these pushes were wrong because they push back a different cons cell; we would like to be able to do (ldiff *full-args* *args*). This is solved by upop, which provides one element of undo. After upop, we can restore the prior list from the undo save location.
* * lib.c (assert_s): New global variable.Kaz Kylheku2014-03-061-1/+1
| | | | | | | | | | | | | | | (obj_init): Intern assert symbol, store in assert_s. * lib.h (assert_s): Declared. * match.c (typed_error, v_assert, h_assert): New static functions. (dir_tables_init): Register v_assert and h_assert. Register assert_s as non-data-matching directive. * unwind.c (uw_init): Register assert as a subtype of error. * txr.1: Describe assert.
* * arith.c (logten): New function.Kaz Kylheku2014-03-041-0/+1
| | | | | | | | * eval.c (eval_init): logten registered as intrinsic. * lib.h (logten): Declared. * txr.1: Documented.
* New quasiquote idea: let's have two quasiquote macros sharing oneKaz Kylheku2014-03-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | expander. One macro based on sys:qquote, sys:unquote and sys:splice, and the other based on qquote, unquote and splice in the user package. The read syntax puts out the sys: one. * eval.c (expand_qquote): Takes three additional arguments: the qquote, unquote and splice symbols to recognize. The invalid splice diagnostic is adjusted based on which backquote we are expanding. (me_qquote): Look at the symbol in the first position of the form and then expand either the internal quasiquote macro or the public one, passing the right symbols into expand_qquote. (eval_init): Register error-throwing stub functions for the sys_qquote_s, sys_unquote_s and sys_splice_s symbols. Register a macro for sys_qquote_s. * lib.c (sys_qquote_s, sys_unquote_s, sys_splice_s): New symbol variables. (obj_init): Initialize new variables. Change qquote_s, unquote_s and splice_s to user package. (obj_print, obj_pprint): Convert only sys_qquote_s, sys_unquote_s and sys_splice_s to the read syntax. The quote_s, unquote_s and splice_s symbols are not treated specially. * lib.h (sys_qquote_s, sys_unquote_s, sys_splice_s): Declared. * parser.y (n_expr): Use sys_qquote_s, sys_unquote_s and sys_splice_s rather than qquote_s, unquote_s and splice_s. (unquotes_occur): Likewise. * txr.1: Documented.
* Turn *gensym-counter* into proper special variable.Kaz Kylheku2014-02-281-1/+3
| | | | | | | | | | | | | | | | | * eval.c (eval_init): Save *gensym-counter* symbol in gensym_counter_s symbol variable right after interning, and use zero as the inital value rather than the gensym_counter variable which is removed now. * lib.c (gensym_counter_s): New symbol variable. (gensym_counter): Variable removed. (gensym): Slight refactoring to avoid a double variable lookup. Also, for generational GC correctness, use the set macro to update it, since the variable could live inside heap object and the counter could overflow to bignums which are heap objects. (obj_init): Remove initialization of gensym_counter. * lib.h (gensym_counter_s): Declared. (gensym_counter): Declaration removed, replaced by macro.
* Change in the design of how special variables work, to fix the brokenKaz Kylheku2014-02-281-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | re-binding. C code now has to go through the dynamic environment lookup to access things like *random-state*, or *stdout*. As part of this, I'm moving some intrinsic variable and function initializations out of eval.c and into their respective modules. Macros are are used to make global variables look like ordinary C variables. This is very similar to the errno trick in POSIX threads implementations. * eval.c (looup_var, lookup_var_l): Restructured to eliminate silly goto, the cobjp handling is gone. (reg_fun, reg_var): Internal function becomes external. reg_var registers a simple cons cell binding now, without any C pointer tricks to real C global variables. (c_var_mark): Static function removed. (c_var_ops): Static struct removed. (eval_init): Numerous initializations for streams, syslog, rand, signals and others moved to their respective modules. The new symbol variables user_package_s, keyword_package_s and system_package_s are interned here, and the variables are created in a special way. * eval.h (reg_var, reg_fun): Declared. * gc.c (prot1): Added assert that the loc pointer isn't null. This happened, and blew up during garbage collection. * lib.c (system_package, keyword_package, user_package): Variables removed these become macros. (system_package_var, keyword_package_var, user_package_var): New global variables. (system_package_s, keyword_package_s, user_package_s): New symbol globals. (get_user_package, get_system_package, get_keyword_package): New functions. (obj_init): Protect new variables. Initialization order of modules tweaked: the modules sig_init, stream_init, and rand_init are moved after eval_init because they register variables. * lib.h (keyword_package, system_pckage, user_package): Variables turned into macros. (system_package_var, keyword_package_var, user_package_var): Declared. (system_package_s, keyword_package_s, user_package_s): Declared. (get_user_package, get_system_package, get_keyword_package): Declared. * rand.c (struct random_state): Renamed to struct rand_state to avoid clash with new random_state macro. (random_state): Global variable removed. (random_state_s): New symbol global. (make_state, rand32, make_random_state, random_fixnum, random): Follow rename of struct random_state.
* * lib.c (copy): New function.Kaz Kylheku2014-02-271-0/+1
| | | | | | | | * lib.h (copy): Declared. * eval.c (eval_init): Registered copy function as intrinsic. * txr.1: Added missing documentation for length. Documented copy.
* Replacing uses of the eq function which are used only as C booleans,Kaz Kylheku2014-02-221-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with just using the == operator. Removing cobj_equal_op since it's indistinguishable from eq. Streamlining missingp and null_or_missing_p. * eval.c (transform_op): eq to ==. (c_var_ops): cobj_equal_op to eq. * filter.c (trie_compress, trie_lookup_feed_char, filter_string_tree, html_hex_continue, html_dec_continue): eq to ==. * hash.c (hash_iter_ops): cobj_equal to eq. * lib.c (countq, getplist, getplist_f, search_str_tree, posq): eq to ==. (cobj_equal_op): Function removed. * lib.h (cobj_equal_op): Declaration removed. (missingp): Becomes a simple macro that yields a C boolean instead of t/nil val, because it's only used that way. (null_or_missing_p): Becomes inline function returning int. * match.c (v_output): eq to ==. * rand.c (random_state_ops): cobj_equal_op to eq. * regex.c (char_set_obj_ops, regex_obj_ops): cobj_equal_op to eq. (reg_derivative): Silly if3 expression replaced by null. (regexp): Redundant if2 expression wrapped around eq removed. * stream.c (null_ops, stdio_ops, tail_ops, pipe_ops, string_in_ops, byte_in_ops, string_out_ops, strlist_out_ops, dir_ops, cat_stream_ops): cobj_equal_op to eq. * syslog.c (syslog_strm_ops): cobj_equal_op to eq.
* The C function nullp is being renamed to null, and the rarelyKaz Kylheku2014-02-221-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | used global variable null which holds a symbol becomes null_s. A new macro called nilp is added that more efficiently checks whether an object is nil, producing a C boolean value rather than t or nil. Most of the uses of nullp in the codebase just become the more streamlined nilp. * debug.c (show_bindings): nullp to nilp * eval.c (lookup_var, lookup_var_l, lookup_fun, lookup_sym_lisp1, do_eval, expand_qquote, expand_quasi, expand_op): nullp to nilp. (op_modplace): nullp to null. (eval_init): Update registration of null and not from C function nullp to null. * filter.c (trie_compress, html_hex_continue): nullp to nil. (filter_string_tree): null to null_s. * hash.c (hash_next): nullp to nilp. * lib.c (null): Variable renamed to null_s. (code2type): null to null_s. (lazy_flatten_scan, chainv, lazy_str, lazy_str_force_upto, obj_print, obj_pprint): nullp to nilp. (obj_init): null to null_s; nullp to null. * lib.h (null): declaration changed to null_s. (nullp): Inline function renamed to null. (nilp): New macro. * match.c (do_match_line): nullp to nilp. * rand.c (make_random_state): Likewise. * regex.c (compile_regex): Likewise.
* * eval.c (eval_init): Register gensym function as the gensymKaz Kylheku2014-02-171-1/+0
| | | | | | | | | | | | | | intrinsic, rather than gensymv. Register gensym_counter as *gensym-counter*. * lib.c (gensym): Handle missing prefix argument by defaulting the prefix to "g". (gensymv): Function removed. * lib.h (gensymv): Declaration removed. * txr.1: Fixed omission: missing documentation for gensym. Documented *gensym-counter*.
* Replacing acons_new_l and aconsq_new_l interfaces with onesKaz Kylheku2014-02-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | that return the new or old cons cell rather than a pointer to its cdr field. * eval.c (transform_op): use of acons_new_l replaced with acons_new_c. * hash.c (struct hash): acons_new_l_fun member replaced with acons_new_c_fun. (make_hash, make_similar_hash): initialize acons_new_l_fun member using either acons_new_c or aconsql_new_c. (gethash_l): function becomes an inline in hash.h. (gethash_c): new function, based on gethash_l. (inhash, gethash_n): updated w.r.t struct hash change. * hash.h (gethash_c): declared. (gethash_l): becomes an inline wrapper for gethash_c. * lib.c (acons_new_l, aconsql_new_l): functions removed. (acons_new_c, aconsql_new_c): new functions. (obj_init): use gethash_c and rplacd instead of gethash_l and set. * lib.h (acons_new_l, aconsql_new_l): declarations removed. (acons_new_c, aconsql_new_c): declared.
* * eval.c (eval_init): Register new functions posqual, posql,Kaz Kylheku2014-02-111-0/+5
| | | | | | | | | | posq, pos, and pos_if as intrinsics. * lib.c (posqual, posql, posq, pos, pos_if): New functions. * lib.h (posqual, posql, posq, pos, pos_if): Declared. * txr.1: Documented
* * eval.c (rperm_list, rperm_vec, rperm_str): n variable renamedKaz Kylheku2014-02-091-0/+2
| | | | | | | | | | | | | | | | | | to k, for consistency with rperm. (rperm): Likewise, and the behavior in the k == zero case is changed to return a single empty permutation. (perm_while_fun, perm_index, perm_gen_fun_common, perm_init_common, perm_vec_gen_fill, perm_vec_gen_fun, perm_vec, perm_list_gen_fill, perm_list_gen_fun, perm_list, perm_str_gen_fill, perm_str_gen_fun, perm_str, perm): New static functions. (eval_init): perm registered as intrinsic. * lib.c (vecref_l): Bugfix: allow negative indices, just like vecref. * lib.h (three, four): New macros. * txr.1: Updated documentation for rperm. Documented perm.
* * hash.c (hash_grow, make_hash, make_similar_hash, copy_hash):Kaz Kylheku2014-02-061-1/+1
| | | | | | | | | | | | | | | Pass second argument to vector. * lib.c (vector): Takes additional argument specifying the value for the slots of the vector. (vector_list, sub_vec): Pass second argument to vector. * lib.h (vector): Declaration updated. * eval.c (eval_init): Register vector as two-argument function with one required arg. * txr.1: Updated.
* Allow sequences and hashes to be called as functions.Kaz Kylheku2014-02-051-0/+1
| | | | | | | | | | | | | | | | This is already supported in the DWIM operator. * eval.c (apply): If object isn't a function, gather the arguments into an array and delegate to generic_funcall. * lib.c (generic_funcall): Changed from static to external linkage. Supports sequences and hashes as functions. Error messages fixed not to refer to "funcall". (funcall, funcall1, funcall2, funcall3, funcall4): Do not throw exception if fun is not of FUN type; instead, delegate to generic_funcall. Error messages fixed not to refer to "funcall". * lib.h (generic_function): Declared.
* * arith.c (lognot): Conform to new scheme for defaulting optional args.Kaz Kylheku2014-02-051-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (apply): Unconditionally use colon_k for missing optional args, for intrinsic functions. (eval_intrinsic, rangev, rangev_star, errno_wrap): Conform to new scheme for defaulting optional args. (reg_fun_mark): Function removed. (eval_init): Switch reduce_left and reduce_right back to reg_fun registration. * hash.c (gethash_n): Conform to new scheme for defaulting optional arguments. * lib.c (sub_list, replace_list, remove_if, keep_if, remove_if_lazy, keep_if_lazy, tree_find, count_if, some_satisfy, all_satisfy, none_satisfy, search_str, match_str, match_str_tree, sub_str, replace_str, cat_str, tok_str, intern, rehome_sym, sub_vec, replace_vec, lazy_str, sort, multi_sort, find, find_if, set_diff, obj_print, obj_pprint): Conform to new scheme for defaulting optional arguments. (func_f0, func_f1, func_f2, func_f3, func_f4, func_n0, func_n1, func_n2, func_n3, func_n4, func_n5, func_n6, func_n7, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n5v, func_n6v, func_n7v): Remove references to removed mark_missing_args member of struct func. (func_set_mark_missing): Function removed. (generic_funcall): Unconditionally use colon_k for missing optional args, for intrinsic functions. * lib.h (struct func): mark_missing_args member removed. (func_set_mark_missing): Declaration removed. (default_arg, default_bool_arg): New inline functions. * rand.c (random): Left argument is not optional. (rnd): Conform to new scheme for defaulting optional arguments. * regex.c (search_regex, match_regex): Conform to new scheme for defaulting optional arguments. * stream.c (unget_char, unget_byte, put_string, put_char, put_byte, put_line): Conform to new scheme for defaulting optional arguments. * syslog.c (openlog_wrap): Conform to new scheme for defaulting optional arguments. * txr.1: Remove the specification that nil is a sentinel value in default arguments, where necessary. Use consistent syntax for specifying variable parts in argument lists. A few errors and omissions addressed.
* * eval.c (apply): Pass missing optional arguments as colon_k.Kaz Kylheku2014-02-051-1/+6
| | | | | | | | | | | | | | | | | | | | | | | to functions for which this is requested. (reg_fun_mark): New static function. (eval_init): Register reduce_left and reduce_right as requiring marking for missing optionals. * lib.c (func_set_mark_missing): New function. (generic_funcall): Pass missing optional arguments as colon_k to functions for which this is requested. (reduce_left, reduce_right): Handle missing values of init and key. (func_f0, func_f1, func_f2, func_f3, func_f4, func_n0, func_n1, func_n2, func_n3, func_n4, func_n5, func_n6, func_n7, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n5v, func_n6v, func_n7v): Initialize new mark_missing_args member of struct func. * lib.h (struct func): New bitfield member, mark_missing_args. (func_set_mark_missing): Declared. (missingp, null_or_missing_p): New inline functions. * txr.1: Updated descriptions of reduce-left and reduce-right.
* * lib.c (nullp): Function removed.Kaz Kylheku2014-02-031-2/+3
| | | | | * lib.h (nullp): New inline function. (eq): Removed useless parentheses: it's not a macro.
* append can now take additional leading arguments before the list.Kaz Kylheku2014-02-021-0/+1
| | | | | | | | | | | | | * eval.c (apply_frob_args): New static function. (apply_intrinsic): Process arguments with apply_frob_args. (eval_init): apply_intrinsic registered differently, as a variadic function with one mandatory arg. * lib.c (lastcons): New function. * lib.h (lastcons): Declared. * txr.1: Updated append documentation.
* * eval.c (apply): Support string and vector arglist.Kaz Kylheku2014-02-021-0/+1
| | | | | | | | | | | (do_eval_args): Support string or vector in dot position. * lib.c (tolist): New function. * lib.h (tolist): Declared. * txr.1: Document how apply and dot position in compound forms supports strings as well as vectors.
* * eval.c (expand_op): When the variant is do, and the symbolKaz Kylheku2014-01-301-0/+4
| | | | | | | | | is an operator, then suppress the addition of the rest parameter in the dotted cons position at the end of the form, since this mechanism for applying additional arguments is only supported by function calls, not by special forms. * lib.h (and2, and3): New macros.
* * hash.c (hash_update): New function.Kaz Kylheku2014-01-241-0/+1
| | | | | | | | | | | | * hash.h (hash_update): Declared. * lib.c (update): New function. * lib.h (update): Declared. * eval.c (eval_init): Register hash_update and update as intrinsics. * txr.1: Documented.
* * lib.c (conses, lazy_conses, func_set_env): New functions.Kaz Kylheku2014-01-231-0/+3
| | | | | | | | | | | (lazy_conses_func): New static function. * lib.h (conses, lazy_conses, func_set_env): Declared. * eval.c (eval_init): conses, lazy_conses and func_set_env registered as intrinsics. * txr.1: Documented.
* Changes to the list collection mechanism to improveKaz Kylheku2014-01-221-27/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the extension of list operations over vectors and strings. * eval.c (do_eval_args, bindings_helper, op_each, subst_vars, supplement_op_syms, mapcarv, mappendv): Switch from list_collect_* macros to functions. * lib.c (copy_list): Switch from list_collect* macros to functions. Use list_collect_nconc for the final terminator. Doing a copy there with list_collect_append was actually wasteful, and now that list_collect_append calls copy_list in places, it triggered runaway recursion. (make_like): Bugfix: list_vector was used instead of vector_list. (to_seq, list_collect, list_collect_nconc, list_collect_append): New functions. (append2, appendv, nappend2, sub_list, replace_list, ldiff, remq, remql, remqual, remove_if, keep_if, proper_plist_to_alist, improper_plist_to_alist, split_str, split_str_set, tok_str, list_str, chain, andf, orf, lis_vector, mapcar, mapcon, mappend, merge, set_diff, env): Switch from list_collect* macros to functions. (replace_str, replace_vec): Allow single item replacement sequence. * lib.h (to_seq): Declared. (list_collect, list_collect_nconc, list_collect_append): Macros removed, replaced by function declarations of the same name. These functions return the new ptail since they cannot assign to it, requiring all uses to be updated to do the assignment of the returned value. (list_collect_decl): Use val rather than obj_t *. * match.c (vars_to_bindings, h_coll, subst_vars, extract_vars, extract_bindings, do_output_line, do_output, v_gather, v_collect): Switch from list_collect* macros to functions. * parser.y (o_elems_transform): Likewise. * regex.c (dv_compile_regex, regsub): Likewise. * txr.c (txr_main): Likewise.
* * eval.c (mapcarv, mappendv): Convert output to type of leftmostKaz Kylheku2014-01-211-0/+1
| | | | | | | | | | | | | input sequence. * lib.c (make_like): New function. (reverse, remq, remql, remqual, remove_if, keep_if, mapcar, mapcon, mappend, set_diff): Convert output list to type of leftmost input sequence. * lib.h (make_like): Declared. * txr.1: Documented.
* * lib.c (broken_down_time_list): New static function.Kaz Kylheku2014-01-201-0/+2
| | | | | | | | | | | (time_fields_local, time_fields_utc): New functions. * lib.h (time_fields_local, time_fields_utc): Declared. * eval.c (eval_init): Intern time_fields_local and time_fields_utc as intrinsic functions. * txr.1: Documented.
* * arith.c (atang2): New function.Kaz Kylheku2014-01-151-0/+1
| | | | | | | | * eval.c (eval_init): Register as atang2 as a atan2 intrinsic. * lib.h (atang2): Declared. * txr.1: Documented atan2.
* * configure: Generate HAVE_VALGRIND as #define-d to 1, rathernKaz Kylheku2014-01-101-1/+1
| | | | | | | | | | | | | | | than just fdefined. * gc.c: Use #if HAVE_VALGRIND instaed of #ifdef HAVE_VALGRIND, consistently with other HAVE_* config variables. * lib.c: Likewise. * lib.h: Likewise. * txr.c: Likewise. * txr.h: Likewise.
* Bumping copyrights to 2014 and expressing them as year ranges.Kaz Kylheku2013-12-101-1/+1
| | | | Fixing some errors in copyright comments.
* syslog support; bitwise logior and logand functions become variadic.Kaz Kylheku2013-12-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * Makefile: Use -iquote to restrict our #include search paths from being processed for #include <...>. Add syslog.o to OBJS-y if have_syslog is y. * configure (have_syslog): New variable, set by detecting syslog API. * eval.c (eval_init): logand and logior registrations changed to go to variadic versions. New syslog variables and functions registered. * lib.c (logandv, logiorv): New functions. * lib.h (logandv, logiorv): Declared. * txr.c (main): Call syslog_init. * syslog.c: New file. * syslog.h: New file. * txr.1: Updated. * txr.vim: Regenerated.
* syslog support; bitwise logior and logand functions become variadic.Kaz Kylheku2013-12-101-0/+2
| | | | | | | | | | | | | | | | | | | | * Makefile: Use -iquote to restrict our #include search paths from being processed for #include <...>. Add syslog.o to OBJS-y if have_syslog is y. * configure (have_syslog): New variable, set by detecting syslog API. * eval.c (eval_init): logand and logior registrations changed to go to variadic versions. New syslog variables and functions registered. * lib.c (logandv, logiorv): New functions. * lib.h (logandv, logiorv): Declared. * txr.c (main): Call syslog_init. * syslog.c: New file. * syslog.h: New file.
* * eval.c (eval_init): New functions countqual, countql, countqKaz Kylheku2013-11-291-0/+4
| | | | | | | | | | and count_if registered as intrinsics. * lib.c (countqual, countql, countq, count_if): New functions. * lib.h (countqual, countql, countq, count_if): Declared. * txr.1: New functions documented.
* * configure (config_flags): New variable, allowing us toKaz Kylheku2013-11-291-0/+3
| | | | | | | | | | | | | | | | | | | have stricter diagnosis for configure tests. (have_timegm, need_svid_source, need_bsd_source): New variables. sys/stat.h test only declares static data and compiles an object file. Adding tests for timegm, tzset, setenv and unsetenv. * eval.c (eval_init): Register new intrinsic, make_time_utc. * lib.c (make_time_impl): New static function. (make_time): Reimplemented as call to make_time_impl. (timegm_hack): New conditionally-defined static function. (make_time_utc): New function. * lib.h (make_time_utc): Declared. * txr.1: make-time-utc documented.
* Extending intrinsic functions to go up to 7 arguments.Kaz Kylheku2013-11-281-2/+17
| | | | | | | | | | | | | | | | | | | Adding wrapper for mktime. * eval.c (apply): Handle function codes N5 through N7. (eval_init): Register make_time as intrinsic. * lib.c (auto_k): New keyword symbol variable. (equal, generic_funcall): Handle N5-N7. (func_n5, func_n6, func_n7, func_n5v, func_n6v, func_n7v): New functions. (obj_init): Initialize auto_k. (make_time): New function. * lib.h (functype_t): New enum members: N5, N6, N7. (struct func): New members: n5, n6, n7, n5v, n6v, n7v. (auto_k, func_n5, func_n6, func_n7, func_n5v, func_n6v, func_n7v, make_time): Declared.
* Ouch! Turns out the code base has numerous unintendedKaz Kylheku2013-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | deviations from C90, like mixed declations and statements. GCC doesn't diagnose these without the --pedantic flag. * configure: GCC's --ansi flag should be spelled -ansi. * lib.c (split_str, obj_print): Reorder declaration before statements. (make_sym): Fix similar problem by eliminating a statement. (funcall1, funcall2, funcall3, funcall4): Use assignment to initialize local array with non-constant elements. This is actually good for performance because we only initialize those parts of the array that we use. * lib.h (struct func): Change functype member to unsigned, since enum-typed bitfields are a GCC extension. * match.c (ml_all, mf_all): Use assignments to initialize local struct with non-constants. (do_txeval, v_collect): Slightly revise unwinding macrology with help of new macros to avoid mixing declarations and statements. (spec_bind): Removed spurious semicolon from macro expansion. (v_gather): Reorder two lines to avoid mixed decls and statements. (match_filter): Move declaration of ret a few lines up, ahead of statements. * unwind.c (uw_pop_until): New function. * unwind.h (uw_pop_until): Declared. (uw_mark_frame, uw_fast_return): New macros.
* * eval.c (eval_init): tok-str acquires new parameterKaz Kylheku2013-06-111-1/+1
| | | | | | | | * lib.c (tok_str): New parameter, keep_sep. * lib.h (tok_str): Declaration updated. * txr.1: Documentation for tok-str updated.
* * eval.c (eval_init): lazy string related functions become intrinsics.Kaz Kylheku2013-05-221-1/+2
| | | | | | | * lib.c (string_cmp): New function. * lib.h (TYPE_SHIFT, TYPE_PAIR): New macros. (string_cmp): Declared.
* * eval.c (eval_init): Register tok_str as intrinsic.Kaz Kylheku2013-05-201-0/+1
| | | | | | | | * lib.c (tok_str): New function. * lib.h (tok_str): Declared. * txr.1: Documented.
* * eval.c (eval_init): New intrinsics, time-string-local andKaz Kylheku2013-05-151-0/+2
| | | | | | | | | | | | | time-string-utc. * lib.c (string_time): New static function. (time_string_local, time_string_utc): New functions. * lib.h (time_string_local, time_string_utc): Declared. * txr.1: Documented. * RELNOTES: Updated.
* * RELNOTES: Updated in preparation for release.Kaz Kylheku2013-05-141-0/+3
| | | | | | | | | | | | | * eval.c (eval_init): Expose delete-package, rehome-sym and packagep. * lib.c (make_package, intern): use ~s formatting for package name in error message. (packagep, delete_package, rehome_sym): New functions. * lib.h (packagep, delete_package, rehome_sym): Declared. * txr.1: Documented process functions and packages.
* * eval.c (eval_init): New instrinsic function iffi registered.Kaz Kylheku2013-01-111-0/+1
| | | | | | | | | | * lib.c (iff): Reversed argument names corrected. No functional change. (iffi): New function. * lib.h (iffi): Declared. * txr.1: Documented iffi.
* * arith.c (logtest): New function.Kaz Kylheku2012-09-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): Registered logtest. Registered s-ifmt, s-iflnk, s-ifreg, s-ifblk, s-ifdir, s-ifchr, s-ififo, s-isuid, s-isgid, s-isvtx, s-irwxu, s-irusr, s-iwusr, s-ixusr, s-irwxg, s-irgrp, s-iwgrp, s-ixgrp, s-irwxo, s-iroth, s-iwoth, s-ixoth variables. * lib.h (logtest): Declared. * stream.c (s_ifmt, s_ifsock, s_iflnk, s_ifreg, s_ifblk, s_ifdir, s_ifchr, s_ififo, s_isuid, s_isgid, s_isvtx, s_irwxu, s_irusr, s_iwusr, s_ixusr, s_irwxg, s_irgrp, s_iwgrp, s_ixgrp, s_irwxo, s_iroth, s_iwoth, s_ixoth): New global variables. * stream.h (s_ifmt, s_ifsock, s_iflnk, s_ifreg, s_ifblk, s_ifdir, s_ifchr, s_ififo, s_isuid, s_isgid, s_isvtx, s_irwxu, s_irusr, s_iwusr, s_ixusr, s_irwxg, s_irgrp, s_iwgrp, s_ixgrp, s_irwxo, s_iroth, s_iwoth, s_ixoth): Declared. * txr.1: Documented logtest and s-* variables for stat, as well as open-file and open-directory.
* * arith.c (comp_trunc, logcomp): logcomp renamed to lognot,Kaz Kylheku2012-09-171-1/+1
| | | | | | | | consistent with Common Lisp. * eval.c (eval_init): logcomp to lognot. * lib.h (logcomp): Declaration updated.
* * arith.c (highest_significant_bit): New static function.Kaz Kylheku2012-09-171-0/+2
| | | | | | | | | | | | | | | | (comp_clamp): Bugfix: avoid shifting left into sign bit. Function renamed to comp_trunc. (logtrunc, ash): New functions. * eval.c (eval_init): Registered logtrunc and ash intrinsics. * lib.h (logtrunc, ash): Declared. * mpi-patches/add-bitops (s_highest_bit_mp): Forward declaration for added. (mp_clamp_comp): Bugfix in handling remainder bits. Function renamed to mp_trunc_comp. (mp_trunc, mp_shift): New functions.
* * arith.c (logand, logior, logxor): Bugfix: result needs to beKaz Kylheku2012-09-161-1/+1
| | | | | | | | | | | | | | normalized, otherwise we end up with fixnum-range bignums. (comp_clamp): New function. (logcomp): Changed to two argument form. If second argument is present (not nil) then call comp_clamp. * eval.c (eval_init): Change registration of logcomp to allow optional argument. * lib.h (logcomp): Declaration updated. * mpi-patches/add-bitops: New mp_clamp_comp function implemented.
* Adding complementing function.Kaz Kylheku2012-09-161-0/+1
| | | | | | | | | | * arith.c (logcomp): New function. * eval.c (eval_init): logcomp registered as intrinsic. * lib.h (logcomp) declared. * mpi-patches/add-bitops: Fixed bugs in mp_xor. Implemented mp_comp.
* Starting work on adding bit operations. The semantics is thatKaz Kylheku2012-09-161-0/+3
| | | | | | | | | | | | | | negative integers behave as an "infinite bit two's complement". * arith.c (logand, logor, logxor): New functions. * eval.c (eval_init): New intrinsic functions logand, logior, logxor. * lib.h (logand, logor, logxor): Declared. * mpi-patches/series: New patch, add-bitops. * mpi-patches/add-bitops: New file.