summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* * signal.c (set_sig_handler): Clear the deferred flagKaz Kylheku2013-12-133-1/+122
| | | | | | for a signal that is being set to ignored or default. * txr.1: Documented signals.
* * eval.c (eval_init): Registered vars for signal numbers.Kaz Kylheku2013-12-124-0/+121
| | | | | | | | | | | | * signal.c (sig_hup, sig_int, sig_quit, sig_ill, sig_trap, sig_abrt, sig_bus, val sig_fpe, sig_kill, sig_usr1, sig_segv, sig_usr2, sig_pipe, sig_alrm, val sig_term, sig_chld, sig_cont, sig_stop, sig_tstp, sig_ttin, val sig_ttou, sig_urg, sig_xcpu, sig_xfsz, sigtalrm, sig_prof, val sig_poll, sig_sys, sig_winch, sig_iot, sig_stkflt, sig_io, sig_lost, sig_pwr): New variables. (sig_init): New variables initialized. * signal.h: New variables declared.
* First cut at signal handling support.Kaz Kylheku2013-12-1225-64/+473
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile (OBJS-y): Include signal.o if have_posix_sigs is "y". * configure (have_posix_sigs): New variable, set by detecting POSIX signal stuff. * dep.mk: Regenerated. * arith.c, debug.c, eval.c, filter.c, hash.c, match.c, parser.y, parser.l, rand.c, regex.c, syslog.c, txr.c, utf8.c: Include new signal.h header, now required by unwind, and the <signal.h> system header. * eval.c (exit_wrap): New function. (eval_init): New functions registered as intrinsics: exit_wrap, set_sig_handler, get_sig_handler, sig_check. * gc.c (release): Unused functions removed. * gc.h (release): Declaration removed. * lib.c (init): Call sig_init. * stream.c (set_putc, se_getc, se_fflush): New static functions. (stdio_put_char_callback, stdio_get_char_callback, stdio_put_byte, stdio_flush, stdio_get_byte): Use new functions to enable signals when blocked on I/O. (tail_strategy): Allow signals across sleep. (pipev_close): Allow signals across waitpid. (se_pclose): New static function. (pipe_close): Use new function to enable signals across pclose. * unwind.c (uw_unwind_to_exit_point): use extended_longjmp instead of longjmp. * unwind.h (struct uw_block, struct uw_catch): jb member changes from jmp_buf to extended_jmp_buf. (uw_block_begin, uw_simple_catch_begin, uw_catch_begin): Use extended_setjmp instead of setjmp. * signal.c: New file. * signal.h: New file.
* * configure (config_flags): Variable removed. This was more trouble than itKaz Kylheku2013-12-122-5/+15
| | | | | was worth, and only solved problems caused by not checking that the test program was made all the way to an executable.
* * configure: Fix warnings in test cases for HAVE_FORK_STUFFKaz Kylheku2013-12-123-3/+14
| | | | | | and HAVE_DAEMON. * eval.c: daemon support must be wrapped in #if HAVE_DAEMON
* * txr.c (txr_main): Change stderr to line buffered mode.Kaz Kylheku2013-12-112-0/+6
|
* Copyright year range: 2009 to 2014.Kaz Kylheku2013-12-111-1/+1
|
* * eval.c (eval_init): log_authpriv_v registered as log-authpriv.Kaz Kylheku2013-12-115-5/+32
| | | | | | | | | | * 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-113-6/+55
| | | | | | (eval_init): New functions registred as intrinsics. * txr.1: Documented.
* * arith.c, hash.c, lib.c, rand.c, stream.c, syslog.c: RemovingKaz Kylheku2013-12-117-6/+6
| | | | | include <assert.h> since none of these modules uses the standard C assert macro.
* Bumping copyrights to 2014 and expressing them as year ranges.Kaz Kylheku2013-12-1037-41/+37
| | | | Fixing some errors in copyright comments.
* * eval.c (eval_init): closelog_wrap interned.Kaz Kylheku2013-12-105-0/+30
| | | | | | | | * syslog.c (closelog_wrap): New function. * syslog.h (closelog_wrap): Declared. * txr.1: Documented.
* * txr.vim: Regenerated.Kaz Kylheku2013-12-101-19/+20
|
* Fixed occurrences of "garbage allocator". :)Kaz Kylheku2013-12-101-4/+5
|
* * eval.c (eval_init): Register streamp, real_time_stream_p,Kaz Kylheku2013-12-106-4/+122
| | | | | | | | | | | | 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-1010-109/+406
| | | | | | | | | | | | | | | | | | | | | | | | | * 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-109-5/+245
| | | | | | | | | | | | | | | | | | | | * 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.
* Version 71txr-71Kaz Kylheku2013-12-075-4/+56
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES: Updated.
* * parser.l (end_of_regex): Fix start condition stack underflowKaz Kylheku2013-12-062-3/+10
| | | | during regex_parse.
* * parser.l (regex_parse): Match the simplified grammar nowKaz Kylheku2013-12-062-3/+11
| | | | | expected in the parser, with no slashes around the regex. Change prefix for diagnostic message.
* * eval.c (eval_init): Update registration of regex-compileKaz Kylheku2013-12-066-15/+38
| | | | | | | | | | | | | | | | | | | 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
* Fixing some old-style coding that became obsoleteKaz Kylheku2013-12-064-8/+20
| | | | | | | | | | | | around November 2009. * lib.c (lazy_str): Use the efficient lit("...") that doesn't allocate memory instead of string(L"..."). (lazy_str_get_trailing_list): Likewise. * stream.c (open_process): Likewise. * txr.c (remove_hash_bang_line): Likewise.
* * regex.c (regex_compile): Handle string input.Kaz Kylheku2013-12-054-6/+26
| | | | | | | * regex.h (regex_compile): Don't call argument regex_sexp, since it can be a string. * txr.1: Updated.
* * eval.c (eval_init): Registered regex_parse as newKaz Kylheku2013-12-059-4/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Spellcheck.Kaz Kylheku2013-12-051-17/+17
|
* * stream.c (stdio_set_prop): Fix reversed boolean.Kaz Kylheku2013-12-022-1/+5
|
* * stream.c (tail_strategy): Execute the strategy code alsoKaz Kylheku2013-12-023-17/+24
| | | | | | | | | | | | | | in the case that the stream's FILE * handle is null. This handles opening the file for the first time. (make_stdio_stream_common): Do not use the FILE * handle if it is null. (open_tail): Do not open the file immediately and error out. This is undesirable because log files might not exist at the time open_tail is called on them. Instead, produce a stream which contains a null file handle, and use tail_strategy to poll for the file to come into existence. * utf8.c (w_freopen): Just in case freopen doesn't like a null pointer for the existing stream, use fopen instead if that is the case.
* * genvim.txr: Missing catch and finally keywords added.Kaz Kylheku2013-12-023-12/+18
| | | | * txr.vim: Regenerated.
* debug_check calls are the culprit triggering lookaheadKaz Kylheku2013-12-023-4/+18
| | | | | | | | | | | | | in lazy lists. Changing the semantics of the data argument so that it can just be the list. * debug.c (debug): If data is a cons, then replace it with the first item. * match.c (match_files): Pass c.data to debug_check, rather than the value of if2(consp(c.data), car(c.data)) which accesses car(c.data) whether or not we are debugging. (match_fun): Likewise.
* Steps toward fixing an issue: lazy list readahead.Kaz Kylheku2013-12-016-14/+169
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is that accurate lazy lists are not suitable for real time use, where we want the TXR program to respond immediately to matching some datum. I'm implementing a simple, naive variant of lazy stream lists which simply populates the lazy cons by reading from the stream when the car or cdr fields are accessed. This type of stream can never be nil (empty list) even if the file is empty; in that case it will be (nil) and in general, it will have a spurious nil item at the end instead of ending in a string. (An adjustment was made in match.c to detect this; more will be needed.) I'm adding attributes to streams so streams can now have a "real-time" attribute. When a lazy string list is constructed over a real-time stream, the simple implementation is used. File streams are automatically real-time if (on Unix) they are tied to tty streams. Tail streams are also real-time. More work is needed to achieve the goal of this change, but this is a big step in the right direction. * configure: Detect isatty function. * lib.c (simple_lazy_stream_func): New static function. (lazy_stream_cons): Use simple implementation for real-time streams. * match.c (match_files): Do not call match_line_completely with a data line that is nil (as a result of simple lazy list over a real-time stream). A nil item in a lazy list of strings is treated as eof. * stream.c (real_time_k): New symbol variable. (struct strm_ops): New members: get_prop, set_prop. (struct stdio_handle): New member: is_real_time. (stdio_get_prop, stdio_set_prop): New static function. (stdio_ops, tail_ops, pipe_ops): stdio_get_prop and stdio_set_prop funtions wired in. (make_stdio_stream_common): Attribute streams as real-time if they are tty devices. (make_tail_stream): Tail streams are real-time attributed. (stream_set_prop, real_time_stream_p): New functions. (stream_init): Initialize real_time_k. * stream.h (real_time_k): Declared. (real_time_stream_p, stream_set_prop): Likewise.
* Refresh.Kaz Kylheku2013-11-291-65/+67
|
* * eval.c (eval_init): New functions countqual, countql, countqKaz Kylheku2013-11-295-0/+103
| | | | | | | | | | 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-296-14/+160
| | | | | | | | | | | | | | | | | | | 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.
* * lib.c (make_time): We must subtract from the 1-12Kaz Kylheku2013-11-282-1/+7
| | | | | month for the tm_mon member of struct tm; we were adding 1 instead.
* * stream.c (tail_calc): New functionKaz Kylheku2013-11-282-11/+27
| | | | | | (tail_strategy): Handle the situation when the file disappears. We cannot throw an error, but must poll the filesystem for the file to reappear.
* * configure: Detect the daemon function.Kaz Kylheku2013-11-284-0/+86
| | | | | | | | | | * 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.
* * txr.1: Documented open-tail and make-time.Kaz Kylheku2013-11-282-0/+61
|
* Whitespace.Kaz Kylheku2013-11-281-0/+1
|
* Extending intrinsic functions to go up to 7 arguments.Kaz Kylheku2013-11-284-4/+171
| | | | | | | | | | | | | | | | | | | 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.
* * stream.c (make_stdio_stream_common): Initialize newKaz Kylheku2013-11-282-0/+6
| | | | mode member of struct stdio_ops to nil.
* * stream.c (struct stdio_handle): New member, mode.Kaz Kylheku2013-11-284-5/+85
| | | | | | | | | | | | | (stdio_stream_mark): Mark the new member during gc. (stdio_seek): When we seek, we should reset the utf8 machine. (tail_strategy): New function. (tail_get_line, tail_get_char, tail_get_byte): Use tail_strategy for polling the file at EOF. (open_tail): Store the mode in the file handle. * utf8.c (w_freopen): New function. * utf8.h (w_freopen): Declared.
* * Changelog: missing entries reconstructed.Kaz Kylheku2013-11-275-6/+105
| | | | | | | | | | | | | * Makefile (conftest.clean): Use @ to suppress output. * configure (have_unistd): New variable. Set true by every successful test that compiles something that contains #include <unistd.h>. HAVE_UNISTD_H is conditionally generated in config.h based on this variable. Minor cleanup. * parser.l: Inclusion of <unistd.h> wrapped in #if/#endif. * stream.c: Conditional inclusion of <unistd.h> based on new HAVE_UNISTD_H symbol.
* * configure: Added check to detect POSIX sleep function.Kaz Kylheku2013-11-277-72/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-264-39/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * match.c (v_load): Bugfix: bindings were propagated in only one of twoKaz Kylheku2013-11-242-1/+9
| | | | | | subcases of a successful load. This bug means that a loaded TXR sub-query was not reliably able to bind variables that are then visible to subsquent directives in the parent.
* * genvim.txr: Missing highlighting for hex integers.Kaz Kylheku2013-11-242-0/+2
| | | | * txr.vim: Updated.
* Fix for uninitialized struct member curfiles in the match context.Kaz Kylheku2013-11-242-7/+20
| | | | | | | | | This is used for reporting the current match location in debug traces. * match.c (mf_all): Takes new argument curfiles and initializes the match_files_ctx member of the same name. (do_match_line, mf_from_ml, match_filter, match_fun, extract): Pass curfile to ml_all.
* * genvim.txr: Change how the hard-coded symbols (end, and, or) areKaz Kylheku2013-11-223-10/+17
| | | | | | * added, and also add the missing rep to these. * txr.vim: Regenerated.
* Version 70txr-70Kaz Kylheku2013-11-215-4/+42
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES: Updated.
* Nasty bug fixed: @(accept) from inside a @(collect) was found not toKaz Kylheku2013-11-212-6/+20
| | | | | | | | | | | | | propagate bindings. The culprit? The bindings_coll variable in the v_collect function being indeterminate by the well-documented and understood action of setjmp. Marking the bindings_coll variable volatile instantly fixed it. I reviewed this code to find any other instance of this oversight. * match.c (v_skip, v_collect): Mark some local variable volatile: precisely those which are used after possibly returning via an unwind, and which might have been modified since setting up the unwind block.