summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* linenoise: fix use of int for wide char.Kaz Kylheku2018-11-011-1/+1
| | | | | | | * linenoise/linenoise.c (history_search): The c variable for capturing the input character should be of type wint_t, not int. This was caught by GNU C++, due to a signed/unsigned warning when c was compared to WEOF.
* linenoise: avoid refresh in paren matching.Kaz Kylheku2018-11-011-4/+51
| | | | | | | | | | * linenoise/linenoise.c (move_cursor_multiline, move_cursor): New functions. (paren_jump): Use move_cursor rather than refresh_line. In multi-line mode, this calculates the required cursor movement and emits the escape sequences to make it happen, without issuing a refresh, sending way less data to the terminal.
* linenoise: avoid refresh for new text in multi-line mode.Kaz Kylheku2018-11-011-3/+9
| | | | | | | | * linenoise/linenoise.c (edit_insert): This function is missing an important optimization for multi-line mode. Let's add it. Since multi-line mode doesn't scroll horizontally, it is very simple: if a character is added at the end, there is no need for refresh.
* linenoise: clear need_refresh in refresh_line.Kaz Kylheku2018-11-011-3/+3
| | | | | | | | | | * linenoise/linenoise.c (refresh_line): Clear the need_refresh flag here. (edit): No need to clear it here any more. This will prevent some useless calls to refresh_line. Some edit operations set refresh_line, but then execute something that performs refresh_line unconditionally. If the flag is then reset, the top of the loop doesn't have to do another wasteful refresh.
* linenoise: move modulo operation into function.Kaz Kylheku2018-11-011-3/+3
| | | | | | | | | * linenoise/linenoise.c (col_offset_in_str): Take a cols parameter and wrap the return value into the number of columns. (refresh_multiline): No need to do the % cols operation on the return value of col_offset_in_str any more; just pass cols down into it.
* linenoise: guard against setting cols to zero.Kaz Kylheku2018-11-011-1/+1
| | | | | | | | * linenoise/linenoise.c (get_columns): Avoid the situation that cols is zero or negative. The cols value is involved in a modulo calculation (position % cols), which requires cols not to be zero. The situation hasn't been observed; this is just defensive coding.
* linenoise: improve efficiency of warning flash.Kaz Kylheku2018-11-011-12/+20
| | | | | | | | | | | * linenoise/linenoise.c (usec_delay): return a Boolean indicator whether the delay was prematurely canceled by input. (flash): Use the return value of usec_delay to bail out of the loop early, canceling the flashing. Instead of doing full line refreshes to display and hide the exclamation mark, perform the flash by simply printing the exclamation mark at the current location and then erasing it with backspace-space-backspace.
* repl: bugfix: slow paste into terminal window.Kaz Kylheku2018-11-011-1/+3
| | | | | | | | | | * stream.c (stream_init): When stdin is a TTY, we make it unbuffered. This affects the parenthesis matching and incomplete line warning flash in the listener, in the following way. The listener uses the poll function to execute delays which is canceled by the presence of TTY input. This logic breaks when data is pasted into the terminal, because the stdin stream buffers the input.
* repl: bugfix: abort on window size change.Kaz Kylheku2018-10-311-3/+21
| | | | | | * parser.c (lino_getch): Catch the exception that is thrown by get_char when the read fails with EINTR due to the SIGWINCH interrupt. Convert exception to WEOF return.
* repl: allocate the "catch all" exception list once.Kaz Kylheku2018-10-311-5/+3
| | | | | | * parser.c (catch_all): New static variable. (provide_atom, repl): Use static catch_all. (parse_init): Protect catch_all from GC reclamation.
* linenoise: bugfix: incorrect tests for WEOF.Kaz Kylheku2018-10-311-7/+7
| | | | | | | * linenoise/linenoise.c (complete_line, history_search, edit): The test c < 0 is not correct. Unlike EOF, WEOF isn't required to be negative, and in fact in the glibc environment, it isn't.
* Hide deprecated, undocumented variables.Kaz Kylheku2018-10-303-7/+19
| | | | | | | | | | * arith.c (arith_init): Do not define *flo-dig*, *flo-max*, *flo-min*, *flo-epsilon*, *pi* and *e* unless compatibility with TXR 199 or earlier is requested. * txr.c (txr_main): Likewise for *self-path*. * txr.1: Compat note added.
* initialization: use self_path_s instead of re-interning.Kaz Kylheku2018-10-301-1/+1
| | | | | | * txr.c (txr_main): When establishing self-path with a new value, use self_path_s instead of calling intern on the symbol name again.
* doc: correction under Object TypeKaz Kylheku2018-10-301-1/+1
| | | | | | * txr.1: Square brackets in the graph indicate a categorization node that is invisible to programs, not visible.
* html doc: "collapse all" shouldn't hide whole TOC.Kaz Kylheku2018-10-291-7/+9
| | | | | | | | | | | | * genman.txr: show the toggle as "expand all" initially. Assign the sections of the TOC to the "tocsec" class, and then select the elements by class rather than by the dl element type. This avoids selecting the dl that wraps the entire TOC. (xpanded): New boolean variable. (toggleall): Base toggle on boolean variable rather than the state of the first section dl element. Toggle the xpanded variable.
* Version 199.txr-199Kaz Kylheku2018-10-287-490/+536
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Regenerated.
* hash: gnu C++ signed/unsigned warning.Kaz Kylheku2018-10-281-1/+1
| | | | | * hash.c (hash_double): Fix comparison warning between signed loop variable and unsigned limit expression.
* genvim: include .tlo files in vimrc example.Kaz Kylheku2018-10-281-2/+2
| | | | | * genvim.txr: In the Vim syntax file comment's example .vimrc lines, include .tlo files, which are just TXR Lisp syntax.
* doc: *rec-source-loc* bad heading formattingKaz Kylheku2018-10-281-1/+1
| | | | * txr.1: Fix missing @ for code font.
* doc: new section: Compiled File Compatibility.Kaz Kylheku2018-10-271-0/+54
| | | | | | | * txr.1: TXR doesn't guarantee backwards compatibility for handling compiled files, as it does for most aspects of its operation. This has to documented in its own section. Also adding a paragraph to COMPATIBILITY to discuss this.
* doc: document compile-file and load-time interaction.Kaz Kylheku2018-10-271-0/+18
| | | | | * txr.1: Document that compile-file evaluates load-time forms during compilation unless compile-only is used.
* doc: add Compilation Library section header.Kaz Kylheku2018-10-271-0/+2
| | | | | | | | * txr.1: We need a SS section for the compilation functions, otherwise they appear to be children of the preceding "Treatment of the Hash Bang Line" section. An alternative would have been to promote them to a higher section level with .coSS instead of .coNP.
* op: bugfix: sys:*op-ctx* defined too late.Kaz Kylheku2018-10-261-2/+2
| | | | | | | | * share/txr/stdlib/op.tl (sys:*op-ctx*) Move definition before the make-struct-type call which instantiates the sys:op-ctx structure type, because the variable is referenced in that expression and treated as lexical. This situation now generates a warning.
* defvar: warn about prior lexical uses.Kaz Kylheku2018-10-263-1/+11
| | | | | | | | | | | | | | | | | | | Now that the compiler has a more efficient treatment of global lexical variables, code which accesses global variables that have not yet been defined will misbehave if the intent is to for those variables to be dynamically scoped. There is such a bug in the op expander, in fact. * eval.c (me_def_variable): When defvar/defparm are expanding, they now check whether there is an outstanding unbound warning against the variable. If so, then a warning is issued that the variable was previously used lexically and is now being marked special. * unwind.c (uw_warning_exists): New function. * unwind.h (uw_warning_exists): Declared.
* compiler: use symtab caching for global lexicals.Kaz Kylheku2018-10-262-10/+17
| | | | | | | | | | | | | | | | * parser.c (read_file_common): Allow version three object files. * share/txr/stdlib/compiler.tl (compiler comp-var): If a global variable isn't special, then treat it via the getlx instruction. The symbol gets added to the symtab, and referenced by index number. (compiler comp-setq): Similarly, treat a non-special global variable using the setlx instruction. (%tlo-ver%): We bump the major version of .tlo files from 2 to 3, since old txr executables won't recognize these new instructions. However, we are backward compatible; hence read_file_common still allows version 2.
* vm/asm: new instructions getlx and setlx.Kaz Kylheku2018-10-263-4/+57
| | | | | | | | | | | | | | | | | | | | These instructions can be used for accessing cached global variable bindings through the symtab of the vm descriptor. The compiler will use these for optimizing access to global lexical variables. * share/txr/stdlib/asm.tl (op-getlx, op-setlx): New opcode classes. * vm.c (vm_stab): Take the lookup function as an argument, so this can be used for variable bindings. (vm_gcall, vm_gapply): Pass lookup_fun function to vm_stab, as well as the appropriate string for the unbound error. (vm_gettab, vm_settab): New static functions. (vm_execute): Implement GETLX and SETLX using vm_gettab and vm_settab. * vmop.h: Regenerated.
* vm: bugfix: corruption of global desc list.Kaz Kylheku2018-10-261-5/+5
| | | | | | | | | * vm.c (vm_make_desc): We must register the newly malloced descriptor structure into the free list before calling cobj, because calling cobj may trigger gc, which can blow away the object pointed to by our vtail local variable. Alternatively, we calculate vtail after doign the cobj. Obtaining vtail and using it cannot be separated by gc.
* vm: rename remaining vestiges of ftab terminology.Kaz Kylheku2018-10-261-10/+10
| | | | | | | | | * vm.c (struct vm_stent): Rename fb and fbloc members to bind and bind_loc. (vm_desc_mark, vm_stab, vm_invalidate_binding): Follow rename. A local variable in vm_stab is also renamed. The error message in this function still says "function ... not defined"; that word will be replaced by a parameter in a later commit.
* doc: return value of list-builder methods.Kaz Kylheku2018-10-251-0/+14
| | | | | | * txr.1: Document that the list-builder methods which add to the list have unspecified return values, and that the local functions set up by the build macro are the same way.
* doc: no such thing as define-parameter-macro.Kaz Kylheku2018-10-161-1/+1
| | | | | | * txr.1: Replace reference to the nonexistent define-parameter-macro with the correct define-param-expander.
* doc: shorten some POSIX awk examples.Kaz Kylheku2018-10-141-2/+2
| | | | | | * txr.1: Remove unnecessary test for the existence of a field, since the find function accepts nil. Use len instead of length.
* doc: use nequal.Kaz Kylheku2018-10-141-2/+2
| | | | | * txr.1: shorten some examples by replacing (not (equal ...)) with (nequal ...).
* awk: unwanted package prefix in error message.Kaz Kylheku2018-10-121-1/+1
| | | | | | | * share/txr/stdlib/awk.tl (sys:awk-code-move-check): A symbol in the sys: package is being used just for the English word that its name supplies, so print it using ~a so the sys: prefix doesn't appear.
* compiler: typo in error message.Kaz Kylheku2018-08-071-1/+1
| | | | | | | * share/txr/stdlib/compiler.tl (expand-quasi-mods): Fix misspelled "missing". Small repro test case to trigger the diagnostic: (compile-toplevel '`@{"" []}`) where, note, there is nothing between the square brackets.
* New function: signum.Kaz Kylheku2018-08-072-0/+47
| | | | | | | arith.c (signum): New function. (arith_init): signum intrinsic registered. * txr.1: Documented.
* doc: option processing fixes.Kaz Kylheku2018-08-021-2/+3
| | | | | * txr.1: Wording change in introductory paragraph. Error in description of Boolean options.
* feature: support for floating-point rounding control.Kaz Kylheku2018-07-263-0/+135
| | | | | | | | | | | | | | | * arith.c (flo_get_round_mode, flo_set_round_mode): New functions. (arith_init): Register global lexical variables flo-near, flo-down, flo-up and flo-zero. Register flo-get-round-mode and flo-set-round-mode intrinsic functions. * configure: Test for fesetround and fegetround variables, and the associated constants, prpoducing a HAVE_ROUNDING_CTL_H variable in config.h. * txr.1: Documented new variables and functions.
* doc: updates regarding top-level form expansion order.Kaz Kylheku2018-07-231-2/+99
| | | | | | * txr.1: The descriptions of eval, the File Compilation Model and compile-toplevel give details about the processing of top-level forms.
* tests: remove macro-time hack from man-or-boy test.Kaz Kylheku2018-07-171-1/+1
| | | | | | * tests/012/man-or-boy.tl (defun-cbn): We no longer need the macro-time expression here to force the evaluation of the defmacro form.
* compile-file: incremental expansion of top-level forms.Kaz Kylheku2018-07-171-17/+18
| | | | | | | | | | | | | | Harmonizing with the previous change to eval, the compiler should also handle those situations. * share/txr/stdlib/compiler.tl (compile-file): do not perform a full expansion on each object that it reads from the file before passing it into the top-level walk. Rather, the raw form is passed into the top-level walk. It is partially expanded with macro-expand, and this is repated at each descent of the recursion. Only forms which are not top-level forms are then fully expanded before compilation, by not passing the t argument to compile-toplevel.
* eval: handle top-level incrementally.Kaz Kylheku2018-07-171-3/+30
| | | | | | | | | | | | | | | | | | | | | | | | Like in some other Lisp dialects, evaluation of top-level forms should deal with forms like: (progn (defmacro a () 42) (a)) where the (a) will correctly reference the macro earlier in the progn. * eval.c (eval_only_s, compile_only_s): New symbol variables. (expand_eval): New static function, based on previous code of eval_intrinsic. (eval_intrinsic): Rewritten to perform incremental macroexpand, similarly to compile-file, and recurse. If a form, after macro-expansion, is a progn, eval-only or compile-only, then its constituents are individually evaluated through expand_eval as separate forms: each one is fully expanded and evaluated before the next one is processed. If the form isn't a progn, eval-only or compile-only, then it is treated as a single expansion and evaluation. (eval_init): Initialize new symbol variables and use their values in registering their respective operators.
* hash: replace hashing function for doubles.Kaz Kylheku2018-07-171-5/+8
| | | | | * hash.c (hash_double): Rewrite silly byte rotation with union aliased against ucnum array.
* random-float: new function.Kaz Kylheku2018-07-162-0/+42
| | | | | | | * rand.c (random_float): New function. (rand_init): Register random-float. * txr.1: Documented.
* opip, oand: rewrite in Lisp.Kaz Kylheku2018-07-164-215/+194
| | | | | | | | | | | | | | | | | * eval.c (opip_s, oand_s, chain_s, chand_s): Variables removed. (me_opip): Function removed. (eval_init): Initializations of removed variables removed. chain and chand symbols interned at point of function registration. * lisplib.c (op_set_entries): Add autoload entries for opip and oand. * share/txr/stdlib/op.tl (sys:opip-expand): New function. (opip, oand): New macros. * protsym.c: Regenerated.
* op: convert to Lisp trivial macros related to op.Kaz Kylheku2018-07-164-188/+165
| | | | | | | | | | | | | | | | | | | | | | | The op macro is no longer written in C, but the trivial macros ap, ip, ado, ido, ret and aret are still C. It's silly to have macros written in C, baked into the TXR executable, which just produce syntax for a complicated macro written in Lisp that must be autoloaded when that code is used. * eval.c (ap_s, apf_s, ipf_s, ret_s, aret_s): Variables removed. (me_ap, me_ip, me_ado, me_ido, me_ret_aret): Functions removed. (eval_init): Do not initialize removed variables. Remove registration for macros ap, ip, ado, ido, ret and aret. Intern the apf and ipf symbols in the same expression which registers these functions. * lisplib.c (op_set_entries): Add autoload entries for ap, ip, ado, ido, ret and aret. * share/txr/stdlib/op.tl (ap, ip, ado, ido, ret, aret): New macros. * protsym.c: Regenerated.
* compile-file: support hash bang.Kaz Kylheku2018-07-112-0/+15
| | | | | | | | | * share/txr/stdlib/compiler.tl (usr:compile-file): Check for a hash bang line in the source file. If so, propagate it to the compiled file. * txr.1: Documented existing support for hash bang in .tlo files, and the translation of hash bang from .tl to .tlo.
* doc: indentation issueKaz Kylheku2018-07-111-2/+5
| | | | | | * txr.1: Fix wrong deindentation after .RS/.RE delimited bulleted lists. A vertical space is needed in one case after a bulleted list.
* list-build: rewrite methods for semantics & efficiency.Kaz Kylheku2018-07-111-10/+28
| | | | | | | | | | | | | | | | | | The list builder needlessly copies list structure. At any given moment, the last piece of structure added to the list can remain shared. We can leave the tail pointing to that piece and copy it later in a nondestructive operation. Also, we would like (build (add 1) (pend 2)) to produce (1 . 2) rather than an errror. The implementation gives this to us in the same stroke. * share/txr/stdlib/build.tl (list-builder :postinit): Just initialize tail to be head, rather than eagerly chasing to the last cons. (list-builder add, list-builder pend, list-builder pend*, list-builder ncon, list-builder ncon*): Rewrite.
* struct: uslot and umethod: improve diagnostics.Kaz Kylheku2018-07-111-3/+3
| | | | | | | | * struct.c (uslot_fun, umethod_fun, umethod_args_fun): Use the struct_handle_for_slot function rather than struct_handle. That function includes the slot name in the diagnostic message when the object isn't a struct; the programmer knows which slot was being asked for in the non-struct object.
* compiler: bugfix: mishandled empty testKaz Kylheku2018-07-101-6/+9
| | | | | | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-for): Fix exception thrown when compiling (for init test step ...) when test is nil. Firstly, we must distinguish a (nil) test from (), because the latter means (t). Hence the need for the test-p Boolean. The list of frags must not contain a nil, which isn't a frag. The instruction template must not only omit generating the conditional jump when the test is absent, but also omit generating the test code (insertion of tfrag.code) in that case, because tfrag is nil.