summaryrefslogtreecommitdiffstats
path: root/eval.c
Commit message (Collapse)AuthorAgeFilesLines
* * eval.c (eval_init): log_authpriv_v registered as log-authpriv.Kaz Kylheku2013-12-111-0/+3
| | | | | | | | | | * syslog.c (log_authpriv_v): New variable. (syslog_init): New variable initialized. * syslog.h (log_authpriv_v): Declared. * txr.1: Documented log-authpriv, and put in notes about testing for variables that may not be present, including log-perror.
* * eval.c (symbol_value, boundp, fboundp): New functions.Kaz Kylheku2013-12-111-0/+19
| | | | | | (eval_init): New functions registred as intrinsics. * txr.1: Documented.
* Bumping copyrights to 2014 and expressing them as year ranges.Kaz Kylheku2013-12-101-1/+1
| | | | Fixing some errors in copyright comments.
* * eval.c (eval_init): closelog_wrap interned.Kaz Kylheku2013-12-101-0/+1
| | | | | | | | * syslog.c (closelog_wrap): New function. * syslog.h (closelog_wrap): Declared. * txr.1: Documented.
* * eval.c (eval_init): Register streamp, real_time_stream_p,Kaz Kylheku2013-12-101-1/+4
| | | | | | | | | | | | stream_get_prop and stream_set_prop as intrinsics. * stream.c (stream_get_prop): New function. * stream.h (stream_get_prop): Declared. * syslog.c (syslog_get_prop): Bugfix: check for prio_k not real_time_k. * txr.1: Updated.
* syslog support; bitwise logior and logand functions become variadic.Kaz Kylheku2013-12-101-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | * 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-2/+28
| | | | | | | | | | | | | | | | | | | | * 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): Update registration of regex-compileKaz Kylheku2013-12-061-1/+1
| | | | | | | | | | | | | | | | | | | to reflect that it has two arguments now. * parser.y (grammar): Update calls to regex_compile to pass two arguments. Since we don't expect regex_compile to parse, we specify the error stream as nil. (spec): The "secret syntax" for a regex is simplified not to include the slashes. This provides better diagnostics for unterminated syntax and requires less string processing to generate. Also, the form returned doesn't have the regex symbol consed onto it, which parse_regex just throws away. * regex.c (regex_compile): Now takes a stream argument. * regex.h (regex_compile): Declaration updated. * txr.1: Updated
* * eval.c (eval_init): Registered regex_parse as newKaz Kylheku2013-12-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | intrinsic function and std_null as new variable. * parser.h (yylex_destroy): Existing function declared. * parser.l (regex_parse): New function. New lexical syntax added which returns SECRET_ESCAPE_R. * parser.y (SECRET_ESCAPE_R): New token. (spec): Added syntactic variant which lets us smuggle a regex into the parser easily. * stream.c:x (std_null): New global variable. (null_stream_print): New static function. (null_ops): New static structure. (make_null_stream): New function. (stream_init): Protect and initialize std_null. * stream.h (std_null, make_null_stream): Declared. * txr.1: New features documented: regex-parse, *stdnull*. * txr.c (txr_main): Call yylex_destroy after parsing the program now that I know about this function; this can free up some memory.
* * 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/+1
| | | | | | | | | | | | | | | | | | | 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.
* * configure: Detect the daemon function.Kaz Kylheku2013-11-281-0/+20
| | | | | | | | | | * eval.c: Include <unistd.h> conditionally. (errno_wrap, daemon_wrap): New functions. (eval_init): Registered errno_wrap and daemon_wrap as intrinsics under the names daemon and errno. * txr.1: Documented errno and daemon in new UNIX PROGRAMMING section.
* Whitespace.Kaz Kylheku2013-11-281-0/+1
|
* Extending intrinsic functions to go up to 7 arguments.Kaz Kylheku2013-11-281-1/+13
| | | | | | | | | | | | | | | | | | | 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.
* * configure: Added check to detect POSIX sleep function.Kaz Kylheku2013-11-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register new open_tail function as intrinsic. * match.c (complex_snarf, complex_stream): Update calls to make_stdio_stream and make_pipe_stream to take fewer arguments. (match_files): Support a stream object as a data source specification in place of a string. * parser.l (parse_reset): Update call to make_stdio_stream to take fewer arguments. * stream.c: Inclusion of <unistd.h> made properly conditional. (struct stdio_handle): pid member defined as pid_t only if we have fork functionality, otherwise defined as int. (tail_get_line, tail_get_char, tail_get_byte): New static functions. (tail_ops): New static structure. (make_stdio_stream_common): New static structure. (make_stdio_stream, make_pipe_stream): These functions lose the input and output parameters, which ended up never used. Reimplemented in terms of new common function. (make_tail_stream): New function. (make_pipevp_stream): Reimplemented in terms of new common function. (open_file, open_command): Simplified by removal of useless local variables and their computation, which used to be extra arguments to make_stdio_stream and make_pipe_stream. (open_tail): New function. (stream_init): Calls to make_stdio_stream updated. * stream.h (make_stdio_stream, make_pipe_stream): Declarations updated. (make_tail_stream, open_tail): Declared. * txr.c (txr_main): Calls to make_stdio_stream updated.
* Stream-seeking functionality.Kaz Kylheku2013-11-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bugfix in stdio_flush: check FILE * handle for null. Minor cleanups. * eval.c (eval_init): Register seek_stream as intrinsic. * stream.c (from_start_k, from_current_k, from_end_k): New symbol variables. (strm_whence): New enum. (strm_ops): New member, seek. (stdio_maybe_write_error): Renamed to stdio_maybe_error; takes new string argument to describe action. (stdio_put_string, stdio_put_char, stdio_put_byte): Updated call to stdio_maybe_error. (stdio_flush): Updated call to stdio_maybe_error. Check handle for null. (stdio_seek): New static function. (stdio_ops): Added stdio_seek. (pipe_ops, string_in_ops, byte_in_ops, string_out_ops, strlist_out_ops, dir_ops): Added explicit zero entries and comments for unimplemented functions. (seek_stream): New function. (stream_init): New keyword symbols interned. * stream.h (from_start_k, from_current_k, from_end_k): New variables declared. (dev_k, ino_k, mode_k, nlink_k, uid_k, gid_k, rdev_k, size_k, blksize_k, blocks_k, atime_k, mtime_k, ctime_k, 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): Existing extern variables declared. (seek_stream): New function declared. * txr.1: Documented seek-stream.
* Fix 2013-10-06 regression in op syntax. This happens when a @varKaz Kylheku2013-10-271-1/+3
| | | | | | | | | | syntax appears in an op form, crashing the expander with infinite recursion at program load time, before the code is run. * eval.c (transform_op): The fi == var check to handle a trailing op variable in the dot position of a form needs to ensure that it really is @<num> type var, and not the @<sym> type for instance.
* Improving behavior of op and fixing a bug.Kaz Kylheku2013-10-061-5/+37
| | | | | | | | | | | | | | | | | | | | | Explicitly specifying @rest using (op ... . @rest) did not work at all. The then-func agument of iff and iffi may now be nil. * eval.c (format_op_arg): New static function. (transform_op): Handle dotted lists ending in @rest or @<num>. (supplement_op_syms): New static function. (expand_op): Add missing numeric arguments, so that all 1 through n are in the list. Trailing rest is now added under different conditions. * lib.c (do_iff): Give thenfun the same behavior on nil that elsefun enjoys. * txr.1: Updated.
* Version 67Kaz Kylheku2013-07-121-0/+1
| | | | | | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version, set date and documented string-cmp. * configure (txr_ver): Bumped. * eval.c (eval_init): Forgotten string-cmp registered as intrinsic. * txr.vim: Highlighting for string-cmp. * RELNOTES: Updated.
* * 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-str's third argument is optional.Kaz Kylheku2013-06-111-5/+6
| | | | | | | | | | | | | | | | | | | Added lazy-stringp. Changing names of length-str-{gt,ge,lt,le} to be consistent with the >, >=, < and <= functions. * lib.c (lazy_stream_func): Greatly simplified implementation. The lazy list now continues by means of recursing via an optimized version of lazy_stream_cons called lazy_stream_cont. The environment structure is simplified to just hold the next item, rather than a pointless list. The pointless setting of lcons->lc.func to nil is also removed; this is always done by the caller. (lazy_stream_cont): New static function, similar to lazy_stream_cons, but optimized by not consing up a new function and new environment cell. (lazy_stream_cons): The environment for the update function is simplified to just a single cons. * txr.1: Documented lazy string functions and lazy-stream-cons.
* * eval.c (eval_init): lazy string related functions become intrinsics.Kaz Kylheku2013-05-221-0/+10
| | | | | | | * 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.
* * eval.c (eval_init): State argument in random-fixnum should beKaz Kylheku2013-05-141-1/+1
| | | | | | optional. * txr.1: Documented random functions as well as range and range*
* * 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.
* * eval.c: Allow the test form of a for loop to be omitted,Kaz Kylheku2012-09-251-1/+2
| | | | | | | defaulting to a true test, allowing an infinite loop to be expressed as (for () () () ...). * txr.1: Documented.
* * eval.c (apply): Fix in error message: hard coded "apply" insteadKaz Kylheku2012-09-241-1/+1
| | | | of using ctx_form.
* * arith.c (logtest): New function.Kaz Kylheku2012-09-181-0/+25
| | | | | | | | | | | | | | | | | | | | | | | * 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.
* * eval.c (eval_init): New intrinsics: make-similar-hash, copy-hash,Kaz Kylheku2012-09-121-1/+5
| | | | | | | | | | | | | | hash-uni, hash-diff, hash-isec. * hash.c (make_similar_hash, copy_hash, hash_uni, hash_diff, hash_isec): New functions. * hash.h (make_similar_hash, copy_hash, hash_uni, hash_diff, hash_isec): Declared. * txr.1: Updated. * txr.vim: Highlighting for these new functions.
* * configure: Added test for <sys/stat.h>Kaz Kylheku2012-09-111-0/+2
| | | | | | | | | | | | | | | * eval.c: New intrinsic functions "stat" and "prop". * stream.c: Include <sys/stat.h> if we have it. (w_stat, statf): New functions. (val dev_k, ino_k, mode_k, nlink_k, uid_k, val gid_k, rdev_k, size_k, blksize_k, blocks_k; val atime_k, mtime_k, ctime_k): New sybol variables. (stream_init): Intern new keywords symbols. * stream.h (statf): Declared. * txr.1: prop documented. Stub for stat created.
* * eval.c (eval_init): new instrinsic function /= registered.Kaz Kylheku2012-09-111-0/+1
| | | | | | | | * lib.c (numneqv): New function. * lib.h (numneqv): Declared. * txr.1: New function documented.
* * eval.c (eval_init): Follow function renames.Kaz Kylheku2012-09-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * hash.c (make_hash): Likewise. * lib.c (assq): Renamed to assql for consistency. (aconsq_new): Renamed to aconsql_new. (aconsq_new_l): Renamed to aconsql_new_l. (alist_remove_test): Use equal rather than eq. Association lists use equal equality by default. (alist_nremove): Use memqual rather than memq. (alist_nremove1): Use equal rather than eq. (merge): Bugfix: unnecessary consing caused by using append instead of nconc on list pieces that are already destructively chopped up. This has implications for the efficiency of sort over lists! (multi_sort_less): Implement key functions. (multi_sort): Interface change: arguments rearranged, and new argument to specify key functions. * lib.h (assoc, assq, assql, aconsq_new, aconsq_new_l): Declarations renamed. (multi_sort): Declaration updated. * txr.1: Documented alist library, list sorting and completed documenting lazy library. * txr.vim: multi-sort highlighted.
* * eval.c (symbol_function): Bugfix: return the function rather thanKaz Kylheku2012-09-011-1/+1
| | | | the whole binding.
* * eval.c (expand): Bugfix: failure to handle regularKaz Kylheku2012-08-311-0/+2
| | | | | expression syntax, resulting in (set ...) syntax being regarded as assignment (due to another recent change).
* * eval.c (eval_intrinsic): Bugfix: take the expanded form insteadKaz Kylheku2012-08-301-2/+2
| | | | | | | of throwing it away. (expand): Recurse into expand_place for (set ...) forms. * txr.1: Documented eval.
* * eval.c (mapcarv): Changed to external linkage.Kaz Kylheku2012-08-291-1/+2
| | | | | | | | | | | | * eval.h (mapcarv): Declaration added. (eval_init): New intrinsic multi-sort registered. * lib.c (multi_sort_less): New static function. (multi_sort): New function. * lib.h (multi_sort): Declared. * txr.1: stub section added.
* * eval.c (eval_init): Registered open-command and open-processKaz Kylheku2012-05-181-2/+3
| | | | | | | | | | | | intrinsics. open-pipe is now deprecated but stays for backward compatibility as a synonym for open-command. * stream.c (open_pipe): Renamed to open_command. (open_pipevp): Renamed to open_process. * stream.h (open_pipe, open_pipevp): Declarations updated. * txr.1: Documentation headings updated.
* Implementing new pipe function to get around the limitationKaz Kylheku2012-05-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | that popen accepts a complete command. We need something which accepts a program name, and a list of arguments, so that we don't have to assemble together a correctly quoted string. popen needs an alternative interface resembling execvp. * eval.c (eval_init): New intrinsic registered, open-pipe-args. * stream.c (struct stdio_handle): New member, pid. (stdio_stream_print): Print the pid, if it is nonzero. (pipevp_close): New close function. (pipe_close): If h->pid is nonzero, it's a new-style pipe, which must be closed with pipev_close. (make_stdio_stream, make_pipe_stream): Initialize new stdio_handle member to zero. (make_pipevp_stream): New static function. (open_pipevp): New function. * stream.h (open_pipevp): Declared. * txr.1: open-pipe-args added to stub section heading.
* * eval.c (range_v_func, range_v_star_func): Restore the order ofKaz Kylheku2012-04-241-2/+2
| | | | | | | | | | arguments to plus, so that the from object is on the left. This change was introduced in a commit on 2012-02-14, causing character ranges to break due to bug that addition did not commute for char + fixnum. Although the previous commit fixed the regression, it's still good to have the object on the left in case there are some future data types in case there is ever some form of addition which does not commute.
* * eval.c (eval_init): New intrinsic functions remq*, remql*,Kaz Kylheku2012-04-151-0/+5
| | | | | | | | | | | | | remqual*, remove-if*, keep-if*. * lib.c (rem_lazy_func, rem_lazy_rec): New static functions. (remq_lazy, remql_lazy, remqual_lazy, remove_if_lazy, keep_if_lazy): New functions. * lib.h (remq_lazy, remql_lazy, remqual_lazy, remove_if_lazy, keep_if_lazy): Declared. * txr.1: New functions documented.
* * eval.c (eval_init): find-if intrinsic registered.Kaz Kylheku2012-04-141-0/+1
| | | | | | | | | | | * lib.c (find): First and second arguments reversed. The item should be first. (find_if): New function. * lib.h (find): Declaration updated. (find_if): Declaration added. * txr.1: Stub section.
* * eval.c (eval_init): New functions remove-if and keep-if.Kaz Kylheku2012-04-141-0/+2
| | | | | | | | * lib.c (remove_if, keep_if): New functions. * lib.h (remove_if, keep_if): Declared. * txr.1: Documented.
* Provide access to line number info and source path.Kaz Kylheku2012-04-111-0/+6
| | | | | | | | | | | | | | * eval.c (eval_init): New intrinsic functions source-loc and source-loc-str. New variable *self-path*. * txr.1: Stub doc sections. * txr.c (self_path): New variable. * txr.h (self_path): Declared. * txr.vim: Syntax highlighting for source-loc, source-loc-str and *self-path*.