summaryrefslogtreecommitdiffstats
path: root/txr.c
Commit message (Collapse)AuthorAgeFilesLines
* * Makefile: Removing trailing spaces.Kaz Kylheku2014-10-241-1/+1
| | | | | | | | | | (GREP_CHECK): New macro. (enforce): Rewritten using GREP_CHECK, with new checks. * arith.c, combi.c, debug.c, eval.c, filter.c, gc.c, hash.c, lib.c, * lib.h, match.c, parser.l, parser.y, rand.c, regex.c, signal.c, * signal.h, stream.c, syslog.c, txr.c, unwind.c, utf8.c: Remove trailing spaces.
* Converting cast expressions to macros that are retargettedKaz Kylheku2014-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to C++ style casts when compiling as C++. * lib.h (strip_qual, convert, coerce): New casting macros. (TAG_MASK, tag, type, wli_noex, auto_str, static_str, litptr, num_fast, chr, lit_noex, nil, nao): Use cast macros. * arith.c (mul, isqrt_fixnum, bit): Use cast macros. * configure (INT_PTR_MAX): Define using cast macro. * debug.c (debug_init): Use cast macro. * eval.c (do_eval, expand_macro, reg_op, reg_mac, eval_init): Use cast macros. * filter.c (filter_init): Use cast macro. * gc.c (more, mark_obj, in_heap, mark, sweep_one, unmark): Use cast macros. * hash.c (hash_double, equal_hash, eql_hash, hash_equal_op, hash_hash_op, hash_print_op, hash_mark, make_hash, make_similar_hash, copy_hash, gethash_c, gethash, gethash_f, gethash_n, remhash, hash_count, get_hash_userdata, set_hash_userdata, hash_iter_destroy, hash_iter_mark, hash_begin, hash_uni, hash_diff, hash_isec): Use cast macros. * lib.c (code2type, chk_malloc, chk_malloc_gc_more, chk_calloc, chk_realloc, chk_strdup, num, c_num, string, mkstring, mkustring, upcase_str, downcase_str, string_extend, sub_str, cat_str, trim_str, c_chr, vector, vec_set_length, copy_vec, sub_vec, cat_vec, cobj_print_op, obj_init): Likewise. * match.c (do_match_line, hv_trampoline, match_files, dir_tables_init): Likewise. * parser.l (grammar): Likewise. * parser.y (parse): Likewise. * rand.c (make_state, make_random_state, random_fixnum, random): Likewise. * regex.c (CHAR_SET_L2_LO, CHAR_SET_L2_HI, CHAR_SET_L1_LO, CHAR_SET_L1_HI, CHAR_SET_L0_LO, CHAR_SET_L0_HI, L0_full, L0_fill_range, L1_full, L1_fill_range, L1_contains, L1_free, L2_full, L2_fill_range, L2_contains, L2_free, L3_fill_range, L3_contains, L3_free, char_set_create, char_set_cobj_destroy, nfa_state_accept, nfa_state_empty, nfa_state_single, nfa_state_wild, nfa_state_set,
* C++ upkeep.Kaz Kylheku2014-10-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TXR's support for compiling as C++ pays off: C++ compiler finds serious bugs introduced in August 2 ("Big switch to reentrant lexing and parsing"). The yyerror function was being misused; some of the calls reversed the scanner and parser arguments. Since one of the two parameters is void *, this reversal wasn't caught. * parser.l (yyerror): Fix first two arguments being reversed. (num_esc): Change previously correct call to yyerror to follow reversed arguments, so that it stays correct. * parser.y (%parse-param): Change order of these directives so that the scnr parameter is before the parser parameter. This causes the yacc-generated calls to yyerror to have the arguments in the correct order. It also has the effect of changing the signature of yyparse, reversing its parameters. (parse): Update call to yyparse to new argument order. * parser.h (yyparse): Declaration removed. (yyerror): Declaration updated. * regex.c (regex_kind_t): New enum typedef. (struct regex): Use regex_kind_t rather than an enum inside the struct, which has different scoping rules under C++. * txr.c (get_self_path): Fix signed/unsigned warning.
* * lib.c (compat_fixup): void return changed to int.Kaz Kylheku2014-09-101-4/+8
| | | | | | | | | Returns minimum supported emulation. * lib.h (compat_fixup): Declaration fixed. * txr.c (compat): Replace hard-coded min version by return value of compat_fixup.
* * txr.c (help): List new --compat option.Kaz Kylheku2014-09-091-44/+71
| | | | | | | | | (requires_arg, do_fixnum_opt, compat, array_dim, gc_delta): New static functions. (txr_main): Use do_fixnum_opt for handling options with integer argument. Add --compat alias for -C. * txr.1: Documented --compat. Added missing description of --debugger.
* * txr.c (txr_main): Cleaning up option handling code.Kaz Kylheku2014-09-091-51/+81
| | | | Better checking for misused long options.
* * txr.c (help): Revised help text.Kaz Kylheku2014-09-091-4/+5
|
* * gc.c (MALLOC_DELTA_THRESH): Macro remaned to DFL_MALLOC_DELTA_THRESH.Kaz Kylheku2014-09-081-0/+9
| | | | | | | | | | | | | | | | | | | | | (opt_gc_delta): New global variable. (make_obj): Use opt_gc_delta rather than MALLOC_DELTA_THRESH. (gc_set_delta, gc_wrap): New static functions. (gc_late_init): New function. * gc.h (gc_late_init): Declared. * genvim.txr: scan gc.c also. * lib.c (init): call gc_late_init. * txr.1: Document new --gc-delta option and the functions gc and gc-set-delta. * txr.c (help): Help text for --gc-delta. (txr_main): Parse --gc-delta option. * txr.h (opt_gc_delta): Declared.
* * lib.c (symbol_setname): New static function.Kaz Kylheku2014-09-031-0/+1
| | | | | | | | | | | | | | (obj_init): Change exception symbol names with underscores to use friendly dashes instead. (compat_fixup): New function. * lib.h (compat_fixup): Declared. * txr.1: Change occurrences of exception symbols from underscores to dashes. * txr.c (txr_main): Call compat_fixup when -C option is processed.
* * txr.1: Document -C option.Kaz Kylheku2014-09-021-3/+17
| | | | | | | | | * txr.c (opt_compat): New global variable. (help): Describe -C option. (txr_main): Process -C, and set opt_compat. Ensure -C does not clump. * txr.h (opt_compat): Declared.
* * eval.c (eval_init): Update registration of lisp-parse and readKaz Kylheku2014-09-021-2/+3
| | | | | | | | | | | | | | | | | | | | to account for new parameter. * lib.c (syntax_error_s): New symbol_variable. (obj_init): New symbol variable initialized. * lib.h (syntax_error_s): Declared. * parser.h (lisp_parse): Declaration updated. * parser.l (lisp_parse): Takes third parameter. * txr.1: Third parameter of read described. * txr.c (txr_main): Pass colon_k to third parameter of lisp_parse to obtain exception throwing behavior. * unwind.c (uw_init): Register syntax-error as subtype of error.
* Big switch to reentrant lexing and parsing.Kaz Kylheku2014-08-021-13/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * parser.l (YY_INPUT): Stop relying on removed yyin_stream; refer to stream via yyextra. (yyin_stream, lineno, errors, spec_file_str, prepared_error_message): Global variables removed. (yyget_column, yyset_column): Missing prototypes not generated by flex in bison bridge mode have to be added by us to avoid warning. (yyerror): Takes parser and scanner as parameters. Prepared error message is now in the parser context. Calls to other error handling functions receive scanner context. (yyerr): New function. (yyerrorf, yyerrprepf): Takes scanner argument, chases extra data to get to parser, and refers to parser variables instead of globals. (num_esc): Scanner argument added. (%option reentrant, %option bison-bridge, %option extra-type): New flex options. (grammar): yyscanner added everywhere. (end_of_char): Takes scanner argument. (parse_init): Removed references to yyin_stream and prepared_error_message. (parse_reset): Function renamed to open_txr_file. Returns results via pointers instead of setting global variables. (regex_parse, lisp_parse): Use reentrant parser interface. * parser.y (yyerror): Prototype removed. (yylex): Prototype moved after grammar, with new arguments. (sym_helper, define_transform): Take scanner argument. (make_expr): Takes parser argument. (rlrec): New static function. (rl): Function turned into macro. (mkexp, symhlpr): New macros. (%purse-parser, %parse-param, %lex-param): New Yacc options. (grammar): Actions re-worked for reentrance. Parser and scanner contexts are passed down to helper functions, in some cases via the three new macros. The result of the parse is stored in the syntax_tree member of the parser_t structure instead of a global. The yylex function receives the scanner instance. (get_spec): Function removed. (parse): New function. * parser.h (lineno, errors, yyin_stream, spec_file_str): Declarations removed. (parser_t): New struct. (yyerr): New function declared. (yyparse, yyerror, yyerrorf, end_of_regex, end_of_char, yylex, yylex_destroy): Declarations updated.
* * Makefile, arith.c, arith.h, combi.c, combi.h, configure, debug.c,Kaz Kylheku2014-07-231-16/+16
| | | | | | | | debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Synchronize license header with LICENSE.
* * txr.c (txr_main): Allow Lisp code executed via -e and -p options toKaz Kylheku2014-07-141-2/+2
| | | | see the bindings set up by prior -D options.
* * Makefile: install the LICENSE and METALICENSE files into the dataKaz Kylheku2014-07-071-0/+39
| | | | | | | | | | | | directory. * txr.c (help): Help text updated to document --license option. (license): New function. (txr_main): Implement --license option. * unwind.h (uw_catch): Add cast to suppress warning about unused symbol. * txr.1: Document --license option.
* * Makefile: Install share/txr/stdlib/*.txr material.Kaz Kylheku2014-06-121-0/+3
| | | | | | | | | | | * match.c (do_txeval): If a variable is not in the bindings, fall back on treating it as a TXR Lisp dynamic variable. This allows us to refer to the stdlib variable from a quasistring in a @(load ...) directive. * txr.c (sysroot_init): Register new variable, *txr-version*. * share/txr/stdlib/ver.txr: New file.
* * Makefile (txr.o): Pass TXR_VER preprocessor symbol on gcc commandKaz Kylheku2014-06-111-1/+1
| | | | | | | | | | | | | | | | | | | | line. (PREINSTALL): New variable holding a step for the install recipe. (pax tar zip): New targets. * configure (txr_ver): Version now added to config.make, passed through to txr.c. (gen_config_make): bindir, datadir and mandir are established using gmake's regular macro assignment (=) rather than expanding assignment (:=). This allows us to override the prefix variable after configure time. * lib.h (wli_noex): New macro. (wli): Retarget to wli_noex, so that argument is subject to macro replacement. * txr.c (version): Use TXR_VER defined on compiler command line, rather than hard-coded string literal.
* 2014-06-10 Kaz Kylheku <kaz@kylheku.com>Kaz Kylheku2014-06-101-4/+4
| | | | | | | | | | | | | | | * Makefile (PROG): Removing ./ prefix from variable name; adding it to invocations of $(PROG) in some rules. (txr.o): Pass several strings as macros on the command line: TXR_REL_PATH, EXE_SUFF and PROG_NAME. * configure (bindir, datadir, mandir): These variables become just relative paths from the prefix. * txr.c (sysroot): Use the TXR_REL_PATH, EXE_SUFF and PROG_NAME preprocessor symbols defined on the command line to avoid hard-coding strings like "bin/txr" and "bin/txr.exe" which actually should reflect the value of the bindir variable.
* * txr.c (get_self_path): Fix spelling of GetModuleFileName.Kaz Kylheku2014-06-101-3/+10
| | | | | | Add missing parentheses in expression. (sysroot_init): On Windows, filter progpath to change backslashes to forward slashes.
* New variable stdlib, with a sysroot mechanism to computeKaz Kylheku2014-06-091-0/+79
| | | | | | | | | the path based on the "sysroot" where it is actually installed. * txr.c (progname_8u, progpath): New static variables. (get_self_path, sysroot_helper, sysroot, sysroot_init): New static functions. Sysroot creates a stdlib variable. (main): Initialize progname_u8 value, and call sysroot_init.
* * txr.c (txr_main): New option --args.Kaz Kylheku2014-06-091-0/+8
| | | | | | Also, put in missing check for -f being erroneously clumped. * txr.1: Documented.
* The dumping of bindings and printing of false must nowKaz Kylheku2014-06-091-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | be explicitly requested by the -B option. * match.c (opt_nobindings): Variable removed. (opt_print_bindings): New variable. (extract): Print bindings or "false" if opt_print_bindings is true. * stream.c (output_produced): Variable removed. (stdio_put_string, stdio_put_char, stdio_put_byte): Remove update of output_produced. * stream.h (output_produced): Declaration removed. * txr.1: Documentation updated. * txr.c (txr_main): Option 'b' does nothing. 'B', 'l', 'a', and '--lisp-bindings' set opt_print_bindings to 1. * txr.h (opt_nobindings): Declaration removed. (opt_print_bindings): Declared. * unwind.c (uw_throw): When exiting due to a query error or file error, print false when opt_print_bindings is true.
* Version 89txr-89Kaz Kylheku2014-05-101-1/+1
|
* Update year in --help message.Kaz Kylheku2014-04-071-1/+1
|
* Version 88txr-88Kaz Kylheku2014-04-041-1/+1
|
* Version 87.txr-87Kaz Kylheku2014-03-221-1/+1
|
* Version 86.txr-86Kaz Kylheku2014-03-161-1/+1
|
* Version 85.txr-85Kaz Kylheku2014-03-081-1/+1
|
* Version 84.txr-84Kaz Kylheku2014-03-071-1/+1
|
* * lib.c (upop): New function.Kaz Kylheku2014-03-071-8/+8
| | | | | | | | | | | | | | * 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.
* * txr.c (txr_main): Don't push back arg into arg_list if arg is nil.Kaz Kylheku2014-03-051-2/+4
|
* Version 83txr-83Kaz Kylheku2014-03-021-1/+1
| | | | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version, set date. * configure (txr_ver): Bumped. * RELNOTES: Updated * dep.mk: Updated.
* Change in the design of how special variables work, to fix the brokenKaz Kylheku2014-02-281-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Version 82.txr-82Kaz Kylheku2014-02-271-1/+1
|
* Version 81txr-81Kaz Kylheku2014-02-261-1/+1
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES, txr.vim: Updated.
* * eval.c (env_hash): new function.Kaz Kylheku2014-02-181-107/+78
| | | | | | | | | | | | | | | | (eval_init): Register env and env_hash functions. Register prog_args and prog_args_full as *args* and *full-args*. * lib.c (timegm_hack): Invalidate env_list, after mucking with the environment via setenv and unsetenv. * txr.c (prog_args_full, prog_args): New global variables. (txr_main): Command-line processing converted to use TXR's library. Populates prog_args_full and prog_args. * txr.h (prog_args_full, prog_args): Declared. * txr.1: Documented *args*, *full-args*, env and env-hash.
* Version 80txr-80Kaz Kylheku2014-02-171-1/+1
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES, txr.vim, dep.mk: Updated.
* Version 79txr-79Kaz Kylheku2014-02-111-1/+1
|
* Version 78.txr-78Kaz Kylheku2014-02-061-1/+1
|
* Version 77txr-77Kaz Kylheku2014-01-291-1/+1
|
* Version 76txr-76Kaz Kylheku2014-01-231-1/+1
|
* Changes to the list collection mechanism to improveKaz Kylheku2014-01-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 (eval_instrinsic): Changed to external linkage.Kaz Kylheku2014-01-221-15/+32
| | | | | | | | | * eval.h (eval_intrinsic): Declared. * txr.c (spec_file): Global variable removed. (txr_main): Support for -e and -p options. Minor code cleanup. * txr.1: Documented new options.
* Version 75.txr-75Kaz Kylheku2014-01-161-1/+1
|
* Version 74txr-74Kaz Kylheku2014-01-131-1/+1
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES, txr.vim, dep.mk: Updated.
* * 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.
* Version 73txr-73Kaz Kylheku2014-01-081-1/+1
|
* Version 72txr-72Kaz Kylheku2013-12-171-1/+1
|
* First cut at signal handling support.Kaz Kylheku2013-12-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* * txr.c (txr_main): Change stderr to line buffered mode.Kaz Kylheku2013-12-111-0/+2
|