Mercurial > hg > xemacs-beta
diff src/eval.c @ 802:19dfb459d51a
[xemacs-hg @ 2002-04-03 10:47:37 by ben]
fix tty problem et al
internals/internals.texi: Add section on correctly merging a branch back into the trunk.
console-tty.c, eval.c, event-unixoid.c, file-coding.c, file-coding.h, lisp.h, print.c, sysdep.c: Fix data corruption error in print.c from print_depth becoming
negative. Borrow primitives internal_bind_int,
internal_bind_lisp_object from my stderr-proc ws, soon to be
integrated; use them to properly bind print_depth et al.
First fix for TTY problem. The basic problem is I switched things
so that the TTY I/O is filtered through a coding system, for the
support of kterm and such, that speak JIS or similar
encodings. (#### I ***swear*** I had this working way back in
19.12.) Anyway, this introduced buffering issues, in which instead
of one char being read, it tried to read 1024 chars. I tried
setting the stdin descriptor non-blocking, but it doesn't appear
to work on Cygwin. (#### Andy, do you know anything about this?)
So I fixed it elsewhere. If you get weirdness on the TTY, look in
console-tty.c and see how it gets the coding system; maybe there's
a way to change it (and if not, there should be!).
Also fix warning in sysdep.c.
author | ben |
---|---|
date | Wed, 03 Apr 2002 10:47:52 +0000 |
parents | 2b676dc88c66 |
children | a634e3b7acc8 |
line wrap: on
line diff
--- a/src/eval.c Mon Apr 01 03:59:04 2002 +0000 +++ b/src/eval.c Wed Apr 03 10:47:52 2002 +0000 @@ -4906,6 +4906,95 @@ } static Lisp_Object +restore_lisp_object (Lisp_Object cons) +{ + Lisp_Object opaque = XCAR (cons); + Lisp_Object *addr = (Lisp_Object *) get_opaque_ptr (opaque); + *addr = XCDR (cons); + free_opaque_ptr (opaque); + free_cons (XCONS (cons)); + return Qnil; +} + +/* Establish an unwind-protect which will restore the Lisp_Object pointed to + by ADDR with the value VAL. */ +int +record_unwind_protect_restoring_lisp_object (Lisp_Object *addr, + Lisp_Object val) +{ + Lisp_Object opaque = make_opaque_ptr (addr); + return record_unwind_protect (restore_lisp_object, + noseeum_cons (opaque, val)); +} + +/* Similar to specbind() but for any C variable whose value is a + Lisp_Object. Sets up an unwind-protect to restore the variable + pointed to by ADDR to its existing value, and then changes its + value to NEWVAL. Returns the previous value of specpdl_depth(); + pass this to unbind_to() after you are done. */ +int +internal_bind_lisp_object (Lisp_Object *addr, Lisp_Object newval) +{ + int count = specpdl_depth (); + record_unwind_protect_restoring_lisp_object (addr, *addr); + *addr = newval; + return count; +} + +static Lisp_Object +restore_int (Lisp_Object cons) +{ + Lisp_Object opaque = XCAR (cons); + Lisp_Object lval = XCDR (cons); + int *addr = (int *) get_opaque_ptr (opaque); + int val; + + if (INTP (lval)) + val = XINT (lval); + else + { + val = (int) get_opaque_ptr (lval); + free_opaque_ptr (lval); + } + + *addr = val; + free_opaque_ptr (opaque); + free_cons (XCONS (cons)); + return Qnil; +} + +/* Establish an unwind-protect which will restore the int pointed to + by ADDR with the value VAL. This function works correctly with + all ints, even those that don't fit into a Lisp integer. */ +int +record_unwind_protect_restoring_int (int *addr, int val) +{ + Lisp_Object opaque = make_opaque_ptr (addr); + Lisp_Object lval; + + if (NUMBER_FITS_IN_AN_EMACS_INT (val)) + lval = make_int (val); + else + lval = make_opaque_ptr ((void *) val); + return record_unwind_protect (restore_int, noseeum_cons (opaque, lval)); +} + +/* Similar to specbind() but for any C variable whose value is an int. + Sets up an unwind-protect to restore the variable pointed to by + ADDR to its existing value, and then changes its value to NEWVAL. + Returns the previous value of specpdl_depth(); pass this to + unbind_to() after you are done. This function works correctly with + all ints, even those that don't fit into a Lisp integer. */ +int +internal_bind_int (int *addr, int newval) +{ + int count = specpdl_depth (); + record_unwind_protect_restoring_int (addr, *addr); + *addr = newval; + return count; +} + +static Lisp_Object free_pointer (Lisp_Object opaque) { xfree (get_opaque_ptr (opaque));