Mercurial > hg > xemacs-beta
comparison src/lread.c @ 853:2b6fa2618f76
[xemacs-hg @ 2002-05-28 08:44:22 by ben]
merge my stderr-proc ws
make-docfile.c: Fix places where we forget to check for EOF.
code-init.el: Don't use CRLF conversion by default on process output. CMD.EXE and
friends work both ways but Cygwin programs don't like the CRs.
code-process.el, multicast.el, process.el: Removed.
Improvements to call-process-internal:
-- allows a buffer to be specified for input and stderr output
-- use it on all systems
-- implement C-g as documented
-- clean up and comment
call-process-region uses new call-process facilities; no temp file.
remove duplicate funs in process.el.
comment exactly how coding systems work and fix various problems.
open-multicast-group now does similar coding-system frobbing to
open-network-stream.
dumped-lisp.el, faces.el, msw-faces.el: Fix some hidden errors due to code not being defined at the right time.
xemacs.mak: Add -DSTRICT.
================================================================
ALLOW SEPARATION OF STDOUT AND STDERR IN PROCESSES
================================================================
Standard output and standard error can be processed separately in
a process. Each can have its own buffer, its own mark in that buffer,
and its filter function. You can specify a separate buffer for stderr
in `start-process' to get things started, or use the new primitives:
set-process-stderr-buffer
process-stderr-buffer
process-stderr-mark
set-process-stderr-filter
process-stderr-filter
Also, process-send-region takes a 4th optional arg, a buffer.
Currently always uses a pipe() under Unix to read the error output.
(#### Would a PTY be better?)
sysdep.h, sysproc.h, unexfreebsd.c, unexsunos4.c, nt.c, emacs.c, callproc.c, symsinit.h, sysdep.c, Makefile.in.in, process-unix.c: Delete callproc.c. Move child_setup() to process-unix.c.
wait_for_termination() now only needed on a few really old systems.
console-msw.h, event-Xt.c, event-msw.c, event-stream.c, event-tty.c, event-unixoid.c, events.h, process-nt.c, process-unix.c, process.c, process.h, procimpl.h: Rewrite the process methods to handle a separate channel for
error input. Create Lstreams for reading in the error channel.
Many process methods need change. In general the changes are
fairly clear as they involve duplicating what's used for reading
the normal stdout and changing for stderr -- although tedious,
as such changes are required throughout the entire process code.
Rewrote the code that reads process output to do two loops, one
for stdout and one for stderr.
gpmevent.c, tooltalk.c: set_process_filter takes an argument for stderr.
================================================================
NEW ERROR-TRAPPING MECHANISM
================================================================
Totally rewrite error trapping code to be unified and support more
features. Basic function is call_trapping_problems(), which lets
you specify, by means of flags, what sorts of problems you want
trapped. these can include
-- quit
-- errors
-- throws past the function
-- creation of "display objects" (e.g. buffers)
-- deletion of already-existing "display objects" (e.g. buffers)
-- modification of already-existing buffers
-- entering the debugger
-- gc
-- errors->warnings (ala suspended errors)
etc. All other error funs rewritten in terms of this one.
Various older mechanisms removed or rewritten.
window.c, insdel.c, console.c, buffer.c, device.c, frame.c: When creating a display object, added call to
note_object_created(), for use with trapping_problems mechanism.
When deleting, call check_allowed_operation() and note_object
deleted().
The trapping-problems code records the objects created since the
call-trapping-problems began. Those objects can be deleted, but
none others (i.e. previously existing ones).
bytecode.c, cmdloop.c: internal_catch takes another arg.
eval.c: Add long comments describing the "five lists" used to maintain
state (backtrace, gcpro, specbind, etc.) in the Lisp engine.
backtrace.h, eval.c: Implement trapping-problems mechanism, eliminate old mechanisms or
redo in terms of new one.
frame.c, gutter.c: Flush out the concept of "critical display section", defined by
the in_display() var. Use an internal_bind() to get it reset,
rather than just doing it at end, because there may be a non-local
exit.
event-msw.c, event-stream.c, console-msw.h, device.c, dialog-msw.c, frame.c, frame.h, intl.c, toolbar.c, menubar-msw.c, redisplay.c, alloc.c, menubar-x.c: Make use of new trapping-errors stuff and rewrite code based on
old mechanisms.
glyphs-widget.c, redisplay.h: Protect calling Lisp in redisplay.
insdel.c: Protect hooks against deleting existing buffers.
frame-msw.c: Use EQ, not EQUAL in hash tables whose keys are just numbers.
Otherwise we run into stickiness in redisplay because
internal_equal() can QUIT.
================================================================
SIGNAL, C-G CHANGES
================================================================
Here we change the way that C-g interacts with event reading. The
idea is that a C-g occurring while we're reading a user event
should be read as C-g, but elsewhere should be a QUIT. The former
code did all sorts of bizarreness -- requiring that no QUIT occurs
anywhere in event-reading code (impossible to enforce given the
stuff called or Lisp code invoked), and having some weird system
involving enqueue/dequeue of a C-g and interaction with Vquit_flag
-- and it didn't work.
Now, we simply enclose all code where we want C-g read as an event
with {begin/end}_dont_check_for_quit(). This completely turns off
the mechanism that checks (and may remove or alter) C-g in the
read-ahead queues, so we just get the C-g normal.
Signal.c documents this very carefully.
cmdloop.c: Correct use of dont_check_for_quit to new scheme, remove old
out-of-date comments.
event-stream.c: Fix C-g handling to actually work.
device-x.c: Disable quit checking when err out.
signal.c: Cleanup. Add large descriptive comment.
process-unix.c, process-nt.c, sysdep.c: Use QUIT instead of REALLY_QUIT.
It's not necessary to use REALLY_QUIT and just confuses the issue.
lisp.h: Comment quit handlers.
================================================================
CONS CHANGES
================================================================
free_cons() now takes a Lisp_Object not the result of XCONS().
car and cdr have been renamed so that they don't get used directly;
go through XCAR(), XCDR() instead.
alloc.c, dired.c, editfns.c, emodules.c, fns.c, glyphs-msw.c, glyphs-x.c, glyphs.c, keymap.c, minibuf.c, search.c, eval.c, lread.c, lisp.h: Correct free_cons calling convention: now takes Lisp_Object,
not Lisp_Cons
chartab.c: Eliminate direct use of ->car, ->cdr, should be black box.
callint.c: Rewrote using EXTERNAL_LIST_LOOP to avoid use of Lisp_Cons.
================================================================
USE INTERNAL-BIND-*
================================================================
eval.c: Cleanups of these funs.
alloc.c, fileio.c, undo.c, specifier.c, text.c, profile.c, lread.c, redisplay.c, menubar-x.c, macros.c: Rewrote to use internal_bind_int() and internal_bind_lisp_object()
in place of whatever varied and cumbersome mechanisms were
formerly there.
================================================================
SPECBIND SANITY
================================================================
backtrace.h: - Improved comments
backtrace.h, bytecode.c, eval.c: Add new mechanism check_specbind_stack_sanity() for sanity
checking code each time the catchlist or specbind stack change.
Removed older prototype of same mechanism.
================================================================
MISC
================================================================
lisp.h, insdel.c, window.c, device.c, console.c, buffer.c: Fleshed out authorship.
device-msw.c: Correct bad Unicode-ization.
print.c: Be more careful when not initialized or in fatal error handling.
search.c: Eliminate running_asynch_code, an FSF holdover.
alloc.c: Added comments about gc-cons-threshold.
dialog-x.c: Use begin_gc_forbidden() around code to build up a widget value
tree, like in menubar-x.c.
gui.c: Use Qunbound not Qnil as the default for
gethash.
lisp-disunion.h, lisp-union.h: Added warnings on use of VOID_TO_LISP().
lisp.h: Use ERROR_CHECK_STRUCTURES to turn on
ERROR_CHECK_TRAPPING_PROBLEMS and ERROR_CHECK_TYPECHECK
lisp.h: Add assert_with_message.
lisp.h: Add macros for gcproing entire arrays. (You could do this before
but it required manual twiddling the gcpro structure.)
lisp.h: Add prototypes for new functions defined elsewhere.
author | ben |
---|---|
date | Tue, 28 May 2002 08:45:36 +0000 |
parents | e7ee5f8bde58 |
children | 804517e16990 |
comparison
equal
deleted
inserted
replaced
852:d83885ef293b | 853:2b6fa2618f76 |
---|---|
324 | 324 |
325 static Lisp_Object | 325 static Lisp_Object |
326 load_unwind (Lisp_Object stream) /* used as unwind-protect function in load */ | 326 load_unwind (Lisp_Object stream) /* used as unwind-protect function in load */ |
327 { | 327 { |
328 Lstream_close (XLSTREAM (stream)); | 328 Lstream_close (XLSTREAM (stream)); |
329 if (--load_in_progress < 0) | |
330 load_in_progress = 0; | |
331 return Qnil; | |
332 } | |
333 | |
334 static Lisp_Object | |
335 load_descriptor_unwind (Lisp_Object oldlist) | |
336 { | |
337 Vload_descriptor_list = oldlist; | |
338 return Qnil; | |
339 } | |
340 | |
341 static Lisp_Object | |
342 load_file_name_internal_unwind (Lisp_Object oldval) | |
343 { | |
344 Vload_file_name_internal = oldval; | |
345 return Qnil; | |
346 } | |
347 | |
348 static Lisp_Object | |
349 load_file_name_internal_the_purecopy_unwind (Lisp_Object oldval) | |
350 { | |
351 Vload_file_name_internal_the_purecopy = oldval; | |
352 return Qnil; | |
353 } | |
354 | |
355 static Lisp_Object | |
356 load_byte_code_version_unwind (Lisp_Object oldval) | |
357 { | |
358 load_byte_code_version = XINT (oldval); | |
359 return Qnil; | 329 return Qnil; |
360 } | 330 } |
361 | 331 |
362 /* The plague is coming. | 332 /* The plague is coming. |
363 | 333 |
488 retry_close (XINT (XCAR (tail))); | 458 retry_close (XINT (XCAR (tail))); |
489 } | 459 } |
490 | 460 |
491 #ifdef I18N3 | 461 #ifdef I18N3 |
492 Lisp_Object Vfile_domain; | 462 Lisp_Object Vfile_domain; |
493 | |
494 Lisp_Object | |
495 restore_file_domain (Lisp_Object val) | |
496 { | |
497 Vfile_domain = val; | |
498 return Qnil; | |
499 } | |
500 #endif /* I18N3 */ | 463 #endif /* I18N3 */ |
501 | 464 |
502 DEFUN ("load-internal", Fload_internal, 1, 6, 0, /* | 465 DEFUN ("load-internal", Fload_internal, 1, 6, 0, /* |
503 Execute a file of Lisp code named FILE; no coding-system frobbing. | 466 Execute a file of Lisp code named FILE; no coding-system frobbing. |
504 This function is identical to `load' except for the handling of the | 467 This function is identical to `load' except for the handling of the |
673 (XLSTREAM (lispstream), get_coding_system_for_text_file (codesys, 1), | 636 (XLSTREAM (lispstream), get_coding_system_for_text_file (codesys, 1), |
674 CODING_DECODE, 0); | 637 CODING_DECODE, 0); |
675 Lstream_set_buffering (XLSTREAM (lispstream), LSTREAM_BLOCKN_BUFFERED, | 638 Lstream_set_buffering (XLSTREAM (lispstream), LSTREAM_BLOCKN_BUFFERED, |
676 block_size); | 639 block_size); |
677 /* NOTE: Order of these is very important. Don't rearrange them. */ | 640 /* NOTE: Order of these is very important. Don't rearrange them. */ |
641 internal_bind_int (&load_in_progress, 1 + load_in_progress); | |
678 record_unwind_protect (load_unwind, lispstream); | 642 record_unwind_protect (load_unwind, lispstream); |
679 record_unwind_protect (load_descriptor_unwind, Vload_descriptor_list); | 643 internal_bind_lisp_object (&Vload_descriptor_list, |
680 record_unwind_protect (load_file_name_internal_unwind, | 644 Fcons (make_int (fd), Vload_descriptor_list)); |
681 Vload_file_name_internal); | 645 internal_bind_lisp_object (&Vload_file_name_internal, found); |
682 record_unwind_protect (load_file_name_internal_the_purecopy_unwind, | 646 internal_bind_lisp_object (&Vload_file_name_internal_the_purecopy, Qnil); |
683 Vload_file_name_internal_the_purecopy); | 647 /* this is not a simple internal_bind. */ |
684 record_unwind_protect (load_force_doc_string_unwind, | 648 record_unwind_protect (load_force_doc_string_unwind, |
685 Vload_force_doc_string_list); | 649 Vload_force_doc_string_list); |
686 Vload_file_name_internal = found; | 650 Vload_force_doc_string_list = Qnil; |
687 Vload_file_name_internal_the_purecopy = Qnil; | |
688 specbind (Qload_file_name, found); | 651 specbind (Qload_file_name, found); |
689 Vload_descriptor_list = Fcons (make_int (fd), Vload_descriptor_list); | |
690 Vload_force_doc_string_list = Qnil; | |
691 #ifdef I18N3 | 652 #ifdef I18N3 |
692 record_unwind_protect (restore_file_domain, Vfile_domain); | 653 /* set it to nil; a call to #'domain will set it. */ |
693 Vfile_domain = Qnil; /* set it to nil; a call to #'domain will set it. */ | 654 internal_bind_lisp_object (&Vfile_domain, Qnil); |
694 #endif | 655 #endif |
695 load_in_progress++; | |
696 | 656 |
697 /* Now determine what sort of ELC file we're reading in. */ | 657 /* Now determine what sort of ELC file we're reading in. */ |
698 record_unwind_protect (load_byte_code_version_unwind, | 658 internal_bind_int (&load_byte_code_version, load_byte_code_version); |
699 make_int (load_byte_code_version)); | |
700 if (reading_elc) | 659 if (reading_elc) |
701 { | 660 { |
702 char elc_header[8]; | 661 char elc_header[8]; |
703 int num_read; | 662 int num_read; |
704 | 663 |
1593 UNGCPRO; | 1552 UNGCPRO; |
1594 return tem; | 1553 return tem; |
1595 } | 1554 } |
1596 | 1555 |
1597 | 1556 |
1598 #ifdef LISP_BACKQUOTES | |
1599 | |
1600 static Lisp_Object | |
1601 backquote_unwind (Lisp_Object ptr) | |
1602 { /* used as unwind-protect function in read0() */ | |
1603 int *counter = (int *) get_opaque_ptr (ptr); | |
1604 if (--*counter < 0) | |
1605 *counter = 0; | |
1606 free_opaque_ptr (ptr); | |
1607 return Qnil; | |
1608 } | |
1609 | |
1610 #endif | |
1611 | 1557 |
1612 /* Use this for recursive reads, in contexts where internal tokens | 1558 /* Use this for recursive reads, in contexts where internal tokens |
1613 are not allowed. See also read1(). */ | 1559 are not allowed. See also read1(). */ |
1614 static Lisp_Object | 1560 static Lisp_Object |
1615 read0 (Lisp_Object readcharfun) | 1561 read0 (Lisp_Object readcharfun) |
1617 Lisp_Object val = read1 (readcharfun); | 1563 Lisp_Object val = read1 (readcharfun); |
1618 | 1564 |
1619 if (CONSP (val) && UNBOUNDP (XCAR (val))) | 1565 if (CONSP (val) && UNBOUNDP (XCAR (val))) |
1620 { | 1566 { |
1621 Emchar c = XCHAR (XCDR (val)); | 1567 Emchar c = XCHAR (XCDR (val)); |
1622 free_cons (XCONS (val)); | 1568 free_cons (val); |
1623 return Fsignal (Qinvalid_read_syntax, | 1569 return Fsignal (Qinvalid_read_syntax, |
1624 list1 (Fchar_to_string (make_char (c)))); | 1570 list1 (Fchar_to_string (make_char (c)))); |
1625 } | 1571 } |
1626 | 1572 |
1627 return val; | 1573 return val; |
2200 switch (ch) | 2146 switch (ch) |
2201 { | 2147 { |
2202 case '`': | 2148 case '`': |
2203 { | 2149 { |
2204 Lisp_Object tem; | 2150 Lisp_Object tem; |
2205 int speccount = specpdl_depth (); | 2151 int speccount = internal_bind_int (&old_backquote_flag, |
2206 ++old_backquote_flag; | 2152 1 + old_backquote_flag); |
2207 record_unwind_protect (backquote_unwind, | |
2208 make_opaque_ptr (&old_backquote_flag)); | |
2209 tem = read0 (readcharfun); | 2153 tem = read0 (readcharfun); |
2210 unbind_to (speccount); | 2154 unbind_to (speccount); |
2211 ch = reader_nextchar (readcharfun); | 2155 ch = reader_nextchar (readcharfun); |
2212 if (ch != ')') | 2156 if (ch != ')') |
2213 { | 2157 { |
2335 /* Read the string itself. */ | 2279 /* Read the string itself. */ |
2336 tmp = read1 (readcharfun); | 2280 tmp = read1 (readcharfun); |
2337 if (!STRINGP (tmp)) | 2281 if (!STRINGP (tmp)) |
2338 { | 2282 { |
2339 if (CONSP (tmp) && UNBOUNDP (XCAR (tmp))) | 2283 if (CONSP (tmp) && UNBOUNDP (XCAR (tmp))) |
2340 free_cons (XCONS (tmp)); | 2284 free_cons (tmp); |
2341 return Fsignal (Qinvalid_read_syntax, | 2285 return Fsignal (Qinvalid_read_syntax, |
2342 list1 (build_string ("#"))); | 2286 list1 (build_string ("#"))); |
2343 } | 2287 } |
2344 GCPRO1 (tmp); | 2288 GCPRO1 (tmp); |
2345 /* Read the intervals and their properties. */ | 2289 /* Read the intervals and their properties. */ |
2351 | 2295 |
2352 beg = read1 (readcharfun); | 2296 beg = read1 (readcharfun); |
2353 if (CONSP (beg) && UNBOUNDP (XCAR (beg))) | 2297 if (CONSP (beg) && UNBOUNDP (XCAR (beg))) |
2354 { | 2298 { |
2355 ch = XCHAR (XCDR (beg)); | 2299 ch = XCHAR (XCDR (beg)); |
2356 free_cons (XCONS (beg)); | 2300 free_cons (beg); |
2357 if (ch == ')') | 2301 if (ch == ')') |
2358 break; | 2302 break; |
2359 else | 2303 else |
2360 invalid = 1; | 2304 invalid = 1; |
2361 } | 2305 } |
2362 if (!invalid) | 2306 if (!invalid) |
2363 { | 2307 { |
2364 end = read1 (readcharfun); | 2308 end = read1 (readcharfun); |
2365 if (CONSP (end) && UNBOUNDP (XCAR (end))) | 2309 if (CONSP (end) && UNBOUNDP (XCAR (end))) |
2366 { | 2310 { |
2367 free_cons (XCONS (end)); | 2311 free_cons (end); |
2368 invalid = 1; | 2312 invalid = 1; |
2369 } | 2313 } |
2370 } | 2314 } |
2371 if (!invalid) | 2315 if (!invalid) |
2372 { | 2316 { |
2373 plist = read1 (readcharfun); | 2317 plist = read1 (readcharfun); |
2374 if (CONSP (plist) && UNBOUNDP (XCAR (plist))) | 2318 if (CONSP (plist) && UNBOUNDP (XCAR (plist))) |
2375 { | 2319 { |
2376 free_cons (XCONS (plist)); | 2320 free_cons (plist); |
2377 invalid = 1; | 2321 invalid = 1; |
2378 } | 2322 } |
2379 } | 2323 } |
2380 if (invalid) | 2324 if (invalid) |
2381 RETURN_UNGCPRO | 2325 RETURN_UNGCPRO |
2511 | 2455 |
2512 #ifdef LISP_BACKQUOTES | 2456 #ifdef LISP_BACKQUOTES |
2513 case '`': | 2457 case '`': |
2514 { | 2458 { |
2515 Lisp_Object tem; | 2459 Lisp_Object tem; |
2516 int speccount = specpdl_depth (); | 2460 int speccount = internal_bind_int (&new_backquote_flag, |
2517 ++new_backquote_flag; | 2461 1 + new_backquote_flag); |
2518 record_unwind_protect (backquote_unwind, | |
2519 make_opaque_ptr (&new_backquote_flag)); | |
2520 tem = read0 (readcharfun); | 2462 tem = read0 (readcharfun); |
2521 unbind_to (speccount); | 2463 unbind_to (speccount); |
2522 return list2 (Qbackquote, tem); | 2464 return list2 (Qbackquote, tem); |
2523 } | 2465 } |
2524 | 2466 |
2734 { | 2676 { |
2735 Lisp_Object tem = elt; | 2677 Lisp_Object tem = elt; |
2736 Emchar ch; | 2678 Emchar ch; |
2737 | 2679 |
2738 elt = XCDR (elt); | 2680 elt = XCDR (elt); |
2739 free_cons (XCONS (tem)); | 2681 free_cons (tem); |
2740 tem = Qnil; | 2682 tem = Qnil; |
2741 ch = XCHAR (elt); | 2683 ch = XCHAR (elt); |
2742 #ifdef FEATUREP_SYNTAX | 2684 #ifdef FEATUREP_SYNTAX |
2743 if (ch == s->terminator) /* deal with #+, #- reader macros */ | 2685 if (ch == s->terminator) /* deal with #+, #- reader macros */ |
2744 { | 2686 { |
2763 s->head = read0 (readcharfun); | 2705 s->head = read0 (readcharfun); |
2764 elt = read1 (readcharfun); | 2706 elt = read1 (readcharfun); |
2765 if (CONSP (elt) && UNBOUNDP (XCAR (elt))) | 2707 if (CONSP (elt) && UNBOUNDP (XCAR (elt))) |
2766 { | 2708 { |
2767 ch = XCHAR (XCDR (elt)); | 2709 ch = XCHAR (XCDR (elt)); |
2768 free_cons (XCONS (elt)); | 2710 free_cons (elt); |
2769 if (ch == s->terminator) | 2711 if (ch == s->terminator) |
2770 { | 2712 { |
2771 unreadchar (readcharfun, s->terminator); | 2713 unreadchar (readcharfun, s->terminator); |
2772 goto done; | 2714 goto done; |
2773 } | 2715 } |
2934 | 2876 |
2935 for (i = 0, p = &(XVECTOR_DATA (s.head)[0]); | 2877 for (i = 0, p = &(XVECTOR_DATA (s.head)[0]); |
2936 i < len; | 2878 i < len; |
2937 i++, p++) | 2879 i++, p++) |
2938 { | 2880 { |
2939 Lisp_Cons *otem = XCONS (tem); | 2881 Lisp_Object otem = tem; |
2940 tem = Fcar (tem); | 2882 tem = Fcar (tem); |
2941 *p = tem; | 2883 *p = tem; |
2942 tem = otem->cdr; | 2884 tem = XCDR (otem); |
2943 free_cons (otem); | 2885 free_cons (otem); |
2944 } | 2886 } |
2945 return s.head; | 2887 return s.head; |
2946 } | 2888 } |
2947 | 2889 |
2966 return | 2908 return |
2967 continuable_read_syntax_error ("#[...] used with wrong number of elements"); | 2909 continuable_read_syntax_error ("#[...] used with wrong number of elements"); |
2968 | 2910 |
2969 for (iii = 0; CONSP (stuff); iii++) | 2911 for (iii = 0; CONSP (stuff); iii++) |
2970 { | 2912 { |
2971 Lisp_Cons *victim = XCONS (stuff); | 2913 Lisp_Object victim = stuff; |
2972 make_byte_code_args[iii] = Fcar (stuff); | 2914 make_byte_code_args[iii] = Fcar (stuff); |
2973 if ((purify_flag || load_force_doc_strings) | 2915 if ((purify_flag || load_force_doc_strings) |
2974 && CONSP (make_byte_code_args[iii]) | 2916 && CONSP (make_byte_code_args[iii]) |
2975 && EQ (XCAR (make_byte_code_args[iii]), Vload_file_name_internal)) | 2917 && EQ (XCAR (make_byte_code_args[iii]), Vload_file_name_internal)) |
2976 { | 2918 { |