summaryrefslogtreecommitdiffstats
path: root/txr.c
Commit message (Collapse)AuthorAgeFilesLines
* Connect -n option to linenoise noninteractive mode.Kaz Kylheku2017-04-041-0/+2
| | | | | | | | | | * parser.c (repl): Set noninteractive mode from noninteractive option. * txr.c (help): Mention effect of -n upon listener. * txr.1: Documented effect of -n/--noninteractive on the listener.
* Bugfix: missing warnings when main file is .txr.Kaz Kylheku2017-03-221-2/+2
| | | | | | | | | | | | | | | | | | | If the main file of an application is a .txr file, unbound function and variable warnings are not being generated. * match.c (v_load): For consistency with the load function in eval.c, release deferred warnings in the normal return case, if we are not a recursive load. However, this doesn't fix anything because a load or include is always recursive being invoked from a .txr file that is being loaded. The problem is in fact that the recursive flag is nil when it shouldn't be, and then the uw_unwind block obliterates the warnings. * txr.c (txr_main): We must bind *load-recursive* to t around not just the loading of Lisp, but also of TXR. Otherwise the individual loads will release warnings, raising false positives for forward references.
* Better way for releasing deferred warnings.Kaz Kylheku2017-02-101-2/+2
| | | | | | | | | | | | | | | | | | | | We should be re-throwing deferred warnings as ordinary warnings, not dumping them to a stream. * eval.c (eval_exception): Use uw_release_deferred_warnings instead of uw_dupm_deferred_warnings. (load): Likewise. * parser.c (read_eval_ret_last): Likewise. * txr.c (txr_main): Likewise. * unwind.c (uw_release_deferred_warnings): New function. * unwind.h (uw_release_deferred_warnings): Declared. * txr.1: Documented release-deferred-warnings and updated documentation for dump-deferred-warnings.
* Suppress undef warnings in command line file.Kaz Kylheku2017-01-291-0/+3
| | | | | | * txr.c (txr_main): Bind sys:*load-recursive* to t before reading and evaluating forms, then bind to nil before entering repl.
* Bump copyright year to 2017.Kaz Kylheku2017-01-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/except.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/package.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl: Add 2017 to all copyright headers and strings.
* Enable unbound warnings when expanding TXR code.Kaz Kylheku2017-01-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this change, Lisp expansion-time warnings are no longer suppressed during the parsing of the TXR pattern language. Embedded Lisp expressions can refer to TXR pattern variables, which generates spurious warnings that must be suppressed. Since TXR pattern variables are dynamically introduced in a very flexible way, it's hard to do an exact job of this. We take the crude approach that warnings are suppressed for all pattern variables that appear anywhere in the TXR code. To do that, we identify, at parse time, all directives which can bind new variables, and register those variables as if they were tentative global defs, purging all pending warnings for them. * match.c (binding_directive_table): New static hash table. (match_reg_var, match_reg_params, match_reg_elem): New functions. (match_reg_var_rec): New static function. (dir_tables_init): gc-protect binding_directive_table, and populate its entries. * match.h (into_k, named_k): Declared. (match_reg_var, match_reg_params, match_reg_elem): Declared. * parser.y (process_catch_exprs): New static function. (elem): Call match_reg_elem for each basic directive, to process the variables in that directive according to its operator symbol. Do this for each compound form elem and variable elem. Te horizontal @(define) eleme has its own grammar production here, and we handle its parameter list in that rule. (define_clause): Handle the parameters of a vertical @(define). It binds pattern variables, and so we must suppress unbound warnings for those. (catch_clauses_opt): Process the parameters bound by @(catch) clauses. (output_clause): Suppress warnings for the variables nominated by any :into or :named argument. (expand_repeat_rep_args): Suppress warnings for :counter variable, and for :vars variables. (parse_once): Remove the warning-muffling handler frame set up around the yyparse call. * txr.c (txr_main): Suppress warnings for TXR variables defined using -D syntax on the command line. Dump deferred warnings after parsing a .txr file.
* Streamline repeated intern call in txr_main.Kaz Kylheku2017-01-221-3/+4
| | | | | * txr.c (txr_main): Reduce three repetitions of the same call to intern to one call.
* Deferred warnings.Kaz Kylheku2017-01-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Warnings about undefined functions and variables are now deferred during loading, so forward references do not generate nuisance diagnostics. * eval.c (load_recursive_s): New symbol variable. (eval_defr_warn): New static function. (op_defvarl, op_defun): Purge any deferred warning about the given function or variable not being defined. (load): Rebind the sys:*load-recursive* special var to true around the load. After the load, dump deferred warnings if the prior binding of sys:*load-recursive* is false. Discard deferred warnings in the case of termination by a nonlocal control transfer. (do_expand): Treat unbound vars and functions as deferrable warnings, specially tagged for individual purging frkm the deferred list. (eval_init): Intern sys:*load-recursive* and initialize load_recursive_s variable. * eval.h (load_recursive_s): Declared. * parse.c (repl_warning): Accept variable arguments. Check whether we are loading and if so, defer deferrable (repl): Adjustment for altered signature of repl_warning. warnings. * txr.c (txr_main): dump deferred warnings after evaluating Lisp stream. * unwind.c (deferred_warnings): New static variable. (uw_throw): When a deferrable warning is caught, suppress the usual message and add it to the deferred_warnings list. (uw_defer_warning, uw_dump_deferred_warnings, uw_dump_deferred_warnings, uw_purge_deferred_warnings): New functions. (uw_late_init): gc-protect deferred_warnings. * unwind.h (uw_defer_warning, uw_dump_deferred_warnings, uw_dump_deferred_warnings, uw_purge_deferred_warnings): New functions declared.
* Fix some C style casts to use casting macros.Kaz Kylheku2016-12-071-1/+1
| | | | | | | | | | | | | | | | | | | | This is uncovered by compiling with g++ using -Wold-style-cast. * mpi/mpi.c (mp_get_intptr): Use convert macro. Also in one of the rules producing REGCHAR. * parser.l (num_esc): Likewise. * struct.c (static_slot_set, static_slot_ens_rec, get_equal_method): Use coerce macro for int to pointer conversion. * sysif.c (setgroups_wrap): Use convert macro. * termios.c (termios_unpack, termios_pack): Likewise. * txr.c (sysroot_init): Likewise.
* Expose compat option value as sys:compat variable.Kaz Kylheku2016-11-291-0/+2
| | | | | | | * txr.c (compat): Update sys:compat variable with actual value. (txr_main): Register sys:compat variable with default zero value.
* Revive -b option for binding Lisp variables.Kaz Kylheku2016-11-201-3/+21
| | | | | | | | * txr.c (txr_main): Implement -b option that takes an argument. Ensure that -b produces an error if clumped with other options. * txr.1: Documented -b var=val.
* Switch to user package before entering repl.Kaz Kylheku2016-11-141-0/+1
| | | | | | * txr.c (txr_main): The file loaded by the -i command line argument could manipulate *package*. Let's reset *package* to the user package before running the REPL.
* Synchronize license comments with LICENSE.Kaz Kylheku2016-10-011-16/+17
| | | | | | | | | | | | | | | | | | | | * Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, socket.c, socket.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Revert to verbatim 2-Clause BSD.
* Overhaul of self-load-path mechanism.Kaz Kylheku2016-09-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The self-load-path symbol macro is as of now deprecated. It simply expands to *load-path*. *load-path* is a new special variable which is dynamically bound to the path of a file being loaded. * eval.c (self_load_path_s): Global variable renamed to load_path_s. (sys_load): Bind *load-path* around processing of loaded file. (me_load): Expand (load x) simply to (sys:load x *load-path*). (set_get_symacro): Function removed. (reg_symacro): New static function. (eval_init): Initialize renamed load_path_s with interned symbol having the name *load-path*. Register the *load-path* special variable. Set up the sel-load-path symbol macro aliasing for *load-path*. * eval.h (self_load_path_s): Declaration renamed. * match.c (v_load): Bind *load-path* around loading or inclusion. * parser.c (load_rcfile): Bind *load-path* around loading of .txr_profile file. * txr.c (txr_main): Bind *load-path* instead of self-load-path symbol macro. * txr.1: Updated documentation for @(load) directive and load macro. Replaced documentation of self-load-path with *load-path*.
* Change misleading missing license diagnostic.Kaz Kylheku2016-09-261-3/+3
| | | | | | | * txr.c (license): Do not say that the TXR installation might be unlicensed; there is no such licensing condition that the license must be present at run-time. Just state the fact of being unable to display it.
* Bugfix: -Dvar=val not seen in some Lisp code.Kaz Kylheku2016-09-231-0/+5
| | | | | | | | | | | | | | | | | | | TXR Lisp files run from the command line do not see -Dvar=val bindings, whereas -p expressions do. The REPL sees the bindings, but not code loaded from it using (load "file.tl") because they are lexical. Let's keep these bindings as local lexicals for -p and -e forms, but install them as global lexicals for the other situations. * parser.c (repl): Get rid of the local repl_env made from the bindings that are passed in. Instead, before starting the REPL, loop through the bindings and install them as global lexicals with reg_varl. * txr.c (txr_main): Before processing a Lisp file, install the bindings as global lexicals with reg_varl.
* Address -c not working with --lisp.Kaz Kylheku2016-09-011-0/+6
| | | | | | | | | | | * txr.c (txr_main): the --lisp option causes the parse stream to be processed as Lisp, which is fine if it is a file stream. If it is a byte string input stream created by the -c option, it won't work due to missing character operations on the stream, resulting in a strange error message and termination. That issue isn't being fixed here; just providing a more meaningful error message when --lisp is combined with -c.
* Preparations for bundling Cygwin library.Kaz Kylheku2016-06-271-11/+25
| | | | | | | | | | * LICENSE-CYG: New file. * METALICENSE: Include a note about the use of Cygwin in accordance with LGPL. * txr.c (license): Use glob to iterate over all files in the txr share directory which match the LICENSE* pattern.
* New --free-all option for freeing memory on exit.Kaz Kylheku2016-06-071-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although we are garbage-collected, being able to clean up on shutdown is nevertheless useful for uncovering leaks. Leaks can occur, for instance, due to neglect to free out-of-heap satellite data from objects that are reclaimed by gc. This feature is long overdue. * arith.c, arith.h (arith_free_all): New function. * gc.c, gc.h (gc_free_all): New function. * lib.c (init): Remove program name parameter and redundant initialization of progname globl variable. * lib.h (progname): Superfluous declaration removed. This is already declared in txr.h. (init): Declaration updated. * regex.c (char_set_destroy): Do not check the static allocation flag here; just destroy the object. Do check for a null pointer, though. (char_set_cobj_destroy): This cobj destructor now checks the static flag of the char set object and avoids freeing it. Thus our char set singletons are left alone by gc, but our global freeing function takes care of them. (wide_cs): New static variable moved out of wide_display_char_p to static scope. (regex_free_all): New function. * regex.h (regex_free_all): Declared. * txr.c (progname): const qualifier and initializer removed. (main): Ensure progname is always dynamically allocated, even in the argv[0] == 0 case. Do not pass progname to init; it doesn't take that argument any more. (free_all): New static function. (txr_main): Implement --free-all option. * txr.h (progname): Declaration updated.
* The stdlib variable gets a trailing slash.Kaz Kylheku2016-06-051-1/+9
| | | | | | | | | | | | | | | | | | | * txr.c (sysroot_init): Add slash to stdlib_path. (sysroot_compat_fixup): Replace user-visible stdlib variable with a path that doesn't have a slash, if compatibility is 143 or lower. (compat): Call sysroot_compat_fixup. * lisplib.c (place_set_entries, ver_set_entries, ifa_set_entries, txr_case_set_entries, with_resources_set_entries, path_test_set_entries, struct_set_entries, with_stream_set_entries, hash_set_entries, except_set_entries, type_set_entries, yield_set_entries, sock_set_entries, termios_set_entries): Remove slash from format string since the directory includes it. * txr.1: Added note under stdlib about the slash, and also an entry COMPATIBILITY.
* Stand-alone application support.Kaz Kylheku2016-05-251-18/+43
| | | | | | | | | | | | | | | | | | | * txr.c (sysroot_init): Don't print "unable to calculate sysroot" error message in the fallback case, and use the absolute path of the executable directory as the sysroot in this case. (txr_main): Define static area prefixed by @(txr): header. If a string is present in this data area then process it as an argument. Treat the *args* variable carefully. If we use the stored string as the argument, save the args in orig_args variable, then later bind *args* to that. In the -e, -p and related options processing, we bind *args* to the original list so args are available to the expression being evaluated. If the expression mutates *args* then we keep the mutated args whether or not we are processing the stored string. * txr.1: Documented in new sction, STAND-ALONE APPLICATION SUPPORT.
* New variable: txr-path.Kaz Kylheku2016-05-251-0/+7
| | | | | | | * txr.c (dirname): New static function. (sysroot_init): Register txr-path variable. * txr.1: documented txr-path.
* Bugfix: strange diagostic for -B-c.Kaz Kylheku2016-05-231-2/+7
| | | | | | * txr.c (txr_main): Diagnose unrecognized long option in if/else statement that handles long options, rather than clumsily in switch for non-clumping options.
* Few more drop_privilege calls in txr_main.Kaz Kylheku2016-05-231-0/+2
| | | | | | * txr.c (txr_main): Drop setuid privilege as soon as we know we are just going to exit, before producing any diagnostic output, like in existing cases.
* Help text upkeep.Kaz Kylheku2016-05-181-0/+7
| | | | | * txr.c (help): Note the existence of --args and --eargs, without giving a full description.
* New feature: self-load-path symbol macro.Kaz Kylheku2016-05-181-0/+2
| | | | | | | | | | | | | | | | | | | | | * eval.c (self_load_path_s): New symbol variable. (sys_load): Save, set-up and restore self-load-path around load. (set_get_symacro): New function. (eval_init): Register load function using sys_load_s instead of redundant intern. * eval.h (set_get_symacro): Declared. * match.c (v_load): Save, set-up and restore self-load-path macro. * parser.c (load_rcfile): Likewise. * txr.c (txr_main: Set up self-load-path when opening file. * txr.1: Documented self-load-path.
* *args*, *args-full* and self-path in listener.Kaz Kylheku2016-05-071-8/+10
| | | | | | | * txr.c (txr_main): Register *args-full* variable before first branch to repl. In repl section, register or re-register *args* to any remaining args, and self-path to the string "listener".
* Copyright in --help text.Kaz Kylheku2016-05-051-1/+1
| | | | | txr.c (help): 2015 was so last year. Let's make it a range from 2009 to current.
* Condense --help text.Reini Urban2016-05-051-1/+0
| | | | | txr.c (help): Remove blank line between name and copyright line.
* Typo in --help.Reini Urban2016-05-051-1/+1
| | | | txr.c (help): "sare" -> "are".
* New --reexec option.Kaz Kylheku2016-05-051-0/+8
| | | | | | | | | | | | | | | | | This helps with setuid hash bang scripting on Mac OS, and other plaforms where the interpreter executed out of a hash bang script runs with orinary privilege, even if marked setuid. * sysif.c (exec_wrap): Static function turns extern. * sysif.h (exec-wrap): Declared. * txr.1: Documented --reexec. Added notes about setuid under Hash Bang Support. * txr.c (help): List --reexec option. (txr_main): Implement --reexec option.
* Fix treatment of "false" in out-of-memory handler.Kaz Kylheku2016-05-041-1/+2
| | | | | | * txr.c (oom_realloc_handler): When terminating, only print the word false if the print-bindings option -B is in effect. Also, print it to standard output, not standard error.
* Calculate sysroot even if executable is renamed.Kaz Kylheku2016-05-041-1/+17
| | | | | | | | | | | If txr is renamed to something else in the same installation directory, we can still calculate the sysroot. * txr.c (substitute_basename): New function. (sysroot_init): Make one more attempt to calculate the sysroot by substituting the actual base name of the program into the compile-time relative path, and using that path agains the full path name.
* Consolidate sysroot calculation.Kaz Kylheku2016-05-041-16/+19
| | | | | | | | | | | | * txr.c (sysroot_path): New static variable. (progpath): Variable renamed to prog_path. (sysroot_helper): Function removed. (maybe_sysroot): New function. (sysroot): Function now just catenates previously calculated sysroot path onto target without. (sysroot_init): Follow rename of progpath to prog_path. GC-protect sysroot_path. Calculate sysroot path; if not able, emit warning message and use empty string.
* Implement setgid script support.Kaz Kylheku2016-05-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TXR now notices that it's running setgid, and implements setgid logic for scripts. * sysif.c (orig_egid, real_gid, is_setgid): New static variables. (repress_privilege): Treat real and effective group ID similarly to user ID. Save them in global variables, and set the is_setgid flag. (drop_privilege): Drop setgid privilege similarly to setuid. Operate selectively: if neither setuid nor setgid is in effect, do nothing, but if just one is in effect, don't do anything for the other. (simulate_setuid): Function renamed to simulate_setuid_setgid. A small change is made here: if the fstat fails, just drop privilege, don't abort. Implement setgid operation independently of setuid. The is_setgid and is_setuid flags are manipulated here now to get the drop_privileges function to selectively drop setuid if we are running a script which is only segid, or drop setgid if we are running a setuid only script. * sysif.h (simulate_setuid): Declaration name change to simulate_setuid_setgid. * txr.c (txr_main): Follow rename of simulate_setuid. * txr.1: SETUID OPERATION section changed to SETUID/SETGID operation, and setgid description worked into the text.
* Close source files after parsing.Kaz Kylheku2016-04-151-0/+4
| | | | | | | | | | | | | * eval.c (sys_load): close stream in all cases. * match.c (v_load): Likewise. * parser.c (load_rcfile): Close stream in unwind block, if open. * txr.c (txr_main): Close stream after parsing in all cases. If stream is std_input, or a string stream, close_stream does nothing.
* Adding --eargs mechanism.Kaz Kylheku2016-02-021-1/+22
| | | | | | * txr.c (txr_main): Implement --eargs. * txr.1: Documented.
* Support setuid operation.Kaz Kylheku2016-01-231-1/+28
| | | | | | | | | | | | | | | | | | | | | * sysif.c (orig_euid, real_uid, repress_called, is_setuid): New static variables. (repress_privilege, drop_privilage, simulate_setuid): New functions. (RC_MAGIC): New preprocessor symbol. * sysif.c (repress_privilege, drop_privilage, simulate_setuid): Declared. * txr.c (txr_main): Call repress_privilege to check and remember whether we are in setuid mode, and temporarily drop the effective uid to the real one. (txr_main): Permanently drop privileges in all cases except script execution. In script execution cases, go through simulate_setuid to either set or preserve the effective user ID, or else drop privs. * txr.1: Documented setuid operation in new section.
* Header file cleanup.Kaz Kylheku2016-01-221-2/+0
| | | | | | | * arith.c, cadr.c, debug.c, eval.c, filter.c, gencadr.txr, glob.c, hash.c, linenoise/linenoise.c, lisplib.c, match.c, parser.c, rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c, syslog.c, txr.c, unwind.c, utf8.c: Remove unncessary header files.
* Copyright year bump.Kaz Kylheku2015-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | * LICENSE, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/cadr.tl, share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Add 2016 copyright. * linenoise/LICENSE, linenoise/linenoise.c, linenoise/linenoise.h: Bump one principal author's copyright from 2014 to 2015. The code is based on a snapshot of 2015 upstream work.
* New --debug-expansion option.Kaz Kylheku2015-12-181-0/+11
| | | | | | | | | | | | | * txr.c (opt_dbg_expansion): New global variable. (help): Print summary for --debug-expansion. (txr_main): Recognize new option and set flag. * parser.y (parse_once): Suppress debug stepping around parser if opt_dbg_expansion is false. * txr.1 (opt_dbg_expansion): Declared. * txr.1: Documented new option.
* TXR_COMPAT option.Kaz Kylheku2015-11-201-0/+23
| | | | | | | | | * txr.c (txr_main): Implement handling of TXR_COMPAT environment variable. Also, before entering interactive mode, if compatibility has been set via TXR_COMPAT, emit an informative message about this. * txr.1: Documented TXR_COMPAT.
* Stop using C library setjmp/longjmp.Kaz Kylheku2015-10-251-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TXR is moving to custom assembly-language routines. This is mainly motivated by a very dubious thing done in the GNU C Library setjmp and longjmp in the name of security. Evidently, glibc's setjmp "mangles" certain pointer values which are stored into the jmp_buf buffer. It's been that way since 2005, evidently. This means that, firstly, all along, the use of setjmp in gc.c to get registers into a buffer so they can be scanned has not actually worked properly. More importantly, this pointer mangling in setjmp and longjmp is very hostile to a stack copying implementation of delimited continuations. The reason is that continuations contain jmp_buf buffers, which get relocated in the process of capturing and reviving a continuation. Any pointers in a jmp_buf which point into the captured stack segment have to be fixed up to point into the relocated location. Mangled pointers make this difficult, requiring hacks which are specific to glibc and the machine architecture. We might as well implement a clean, well-behaved setjmp and longjmp. * Makefile (jmp.o): New object file. (dbg/%.o, opt/%.o): New rules for .S prerequisites. * args.c, arith.c, cadr.c, combi.c, cadr.c, combi.c, debug.c, eval.c, filter.c, glob.c, hash.c, lib.c, match.c, parser.c, rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c, syslog.c, txr.c, unwind.c, utf8.c: Removed <setjmp.h> include. * gc.c: Switch to struct jmp and jmp_save, instead of jmp_buf and setjmp. * jmp.S: New source file. * signal.h (struct jmp): New struct type. (jmp_save, jmp_restore): New function declarations denoting assembly language routines in jmp.S. (extended_jmp_buf): Uses struct jmp instead of setjmp. (extended_setjmp): Use jmp_save instead of setjmp. (extended_longjmp): Use jmp_restore instead of longjmp.
* Most uses of auto_str should be static_str.Kaz Kylheku2015-10-161-3/+3
| | | | | | | | | These functions do exactly same thing, but communicate something different to the reader of the code. An auto_str is on the stack, and so must not be passed somewhere where it will be retained. * txr.c (help, compat, txr_main): Use static_str on version.
* Go into listener if no arguments are given.Kaz Kylheku2015-10-131-0/+24
| | | | | | | | * txr.c (help): Document the behavior. (banner): New static function. (txr_main): If listener support compiled in, show the banner and go to REPL instead of showing the usage hint and bailing.
* Capitalization in help text.Kaz Kylheku2015-10-131-3/+3
| | | | * txr.c (help): Capitalize TXR, Copyright and Usage.
* Bugfix: *args* not bound for command line expressions.Kaz Kylheku2015-09-101-2/+7
| | | | | | | | | | | | | | | | The documentation says that *args* is bound to nil, but actually it is not bound at all. Let us fix this by actualy binding *args* to the remaining arguments, and by also allowing modification of *args* to dynamically take effect. * txr.c: Set up value of *args* prior to processing any option which evaluates TXR Lisp. Afterwards, reload the argument list from that variable. * txr.1: Documented semantics of *args* during command line processing.
* Bugfix: make self-path visible to Lisp.Kaz Kylheku2015-09-101-2/+5
| | | | | | | | | | | | | | | The self-path variable is not bound in TXR Lisp scripts or the command line. * txr.c (txr_main): Set self-path to "cmdline-expr" before command line Lisp evaluations. (For TXR pattern language syntax invoked in a -c, it continues to be "cmdline"). Set self-path to the file name when reading a Lisp file. Also, the legacy, undocumented *self-path* is only set for TXR scripts, and is reverted to being a special variable, not a global lexical. * txr.1: Documented self-path in more detail.
* C++: fix goto repl which skips initializations.Kaz Kylheku2015-09-091-3/+3
| | | | | | | * txr.c (txr_main): Move the labeled code to the end of the function, so it's not sitting in the scope of of names whose initialization is skipped. This is a better organization: thank you, C++.
* Wrap call to repl with #if HAVE_TERMIOS.Kaz Kylheku2015-09-091-0/+2
| | | | | * txr.c (txr_main): The repl funtion is not declared unless HAVE_TERMIOS is present and nonzero.