summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Merry C++mas!Kaz Kylheku2013-12-253-10/+21
| | | | | | | * configure: Avoid using "new" as identifier in signals test case. * signal.c (set_sig_handler): Fix warning about { 0 } initializer. (sig_mask): Avoid using "new" as identifier.
* Fixing a bug and performance issue.Kaz Kylheku2013-12-203-5/+84
| | | | | | | | | | | | | | | | | | | | | Problem: we are using sigsetjmp but with a jmp_buf structure; it requires sigjmp_buf! Performance issue: sigsetjmp is a dog which makes system calls. Solution: let's roll our own cached version of sigprocmask which only calls the real sigprocmask when the mask changes. Then our extended_setjmp will just use regular setjmp, plus our own custom signal saving and restoring based on the cached version. * signal.c (sig_blocked_cache): New variable. (set_sig_handler): Use our sig_mask instead of sigprocmask. (mem_set_bits, mem_clr_bits): New static functions. (sig_mask): New function. * signal.h (extended_jmp_buf): New member, blocked. (extended_setjmp): save blocked signals by peeking into sig_blocked_cache, and restore using sig_mask. (sig_blocked_cache, sig_mask): Declared.
* Version 72txr-72Kaz Kylheku2013-12-175-4/+47
|
* * stream.c (stdio_seek): Bugfix. Was returning current positionKaz Kylheku2013-12-172-1/+6
| | | | whenever offset is zero, regardless of whence argument.
* * parser.y (yybadtoken): Handle HASH_H.Kaz Kylheku2013-12-172-0/+5
|
* * txr.vim: Regenerated.Kaz Kylheku2013-12-171-64/+64
|
* * eval.c (op_defvar): Fix the semantics to be similar to Common Lisp:Kaz Kylheku2013-12-173-6/+55
| | | | | | no effect if the variable already exists. * txr.1: Documented defvar and lisp-parse.
* * lib.c (intern): fix the previous diagnostic bug once more with moreKaz Kylheku2013-12-164-19/+26
| | | | | | | | | | feeling. * parser.l (grammar): Recognize package prefixes in symbol tokens. Got rid of special rule for handling lone colon. * parser.y (sym_helper): Catch undefined package as a parsing error rather allowing intern function to throw exception.
* Changing the tokenizer to get rid of IDENT, KEYWORD and METAVARKaz Kylheku2013-12-154-56/+105
| | | | | | | | | | | | | | | | | | | | | token categories, replaced by a single one called SYMTOK. Package prefixes are now recognized and processed in tokens. * lib.c (delete_package): Fix problem in no-such-package error case: it would always report nil as the name. (intern): Fix nonsensical error message: in the no-such-package case it would report that the symbol exists already. * parser.l (grammar): Occurences of KEYWORD, METAVAR, and IDENT scrubbed. All rules reporting any of these now return SYMTOK. The main one of these is greatly simplified. * parser.y (sym_helper): New function. (char_from_name): const qualifier inside param's type declaration. (grammar): IDENT, KEYWORD and METAVAR tokens are gone. New token SYMTOK. Grammar refactored around SYMTOK and using the new sym_helper function. (char_from_name): Updated.
* Support for parsing Lisp expression out of strings and streams.Kaz Kylheku2013-12-147-2/+139
| | | | | | | | | | | | | | | | | | | | | | New catenated streams make the Yacc hack possible. * eval.c (eval_init): Register lisp_parse as intrinsic. * parser.h (lisp_parse): Declared. * parser.l: New lexical hack to produce SECRET_ESCAPE_E token. (regex_parse): Move declaration before statements. (lisp_parse): New function. * parser.y (SECRET_ESCAPE_E): New token type. (spec): New production rule for single expression. * stream.c (cat_stream_print, cat_get_line, cat_get_char, cat_get_byte, cat_get_prop): New static functions. (cat_stream_ops): New static function. (make_catenated_stream): New function. * stream.h (make_catenated_stream): Declared.
* New stream property: name. Some streams can reportKaz Kylheku2013-12-134-5/+45
| | | | | | | | | | | | | | | | | their name: some kind of string. * stream.c (name_k): New variable. (null_get_prop): New static function. (null_ops): Wire null_get_prop into ops structure. (stdio_get_prop): Report h->descr as name. (string_in_get_prop): New function. (string_in_ops): Wire string_in_get_prop into ops structure. (stream_init): Initialize name_k. * stream.h (name_k): Declared. * syslog.c (syslog_get_prop): Report "syslog" as stream name.
* * txr.vim: Regenerated.Kaz Kylheku2013-12-131-84/+95
|
* * signal.c (sig_handler): Pass two arguments to signalKaz Kylheku2013-12-133-2/+43
| | | | | | | | | | | | | handler rather than 1. The new argument is the value t, telling the handler that it's asynchronously invoked in a real signal context. If the signal handler returns true, then mark it deferred so that it can re-trigger in a synchronous context. (sig_check): Pass nil as a the second argument to signal handlers, indicating that they are synchronously called, not in a signal handler context. * txr.1: Added documentation.
* * signal.c (set_sig_handler): Disable signals around thisKaz Kylheku2013-12-132-0/+12
| | | | | function because it manipulates the mask of deferred signals which can also be manipulated by an async signal.
* * 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.