diff options
| author | Dan Nicolaescu | 2010-07-12 21:47:45 -0700 |
|---|---|---|
| committer | Dan Nicolaescu | 2010-07-12 21:47:45 -0700 |
| commit | b3ffc17c5dafe807981af3e0b72b3508d3b4fff4 (patch) | |
| tree | 9ead3d845ae4b514f7330a27e335fbe443442dfd /src | |
| parent | 0521f5806bfc9ad55488c26c9808f513b9384ff4 (diff) | |
| download | emacs-b3ffc17c5dafe807981af3e0b72b3508d3b4fff4.tar.gz emacs-b3ffc17c5dafe807981af3e0b72b3508d3b4fff4.zip | |
Convert maybe_fatal to standard C.
* src/lisp.h (verror): Declare.
* src/eval.c (verror): New function containing the code from ...
(error): ... this. Call verror.
* src/term.c (vfatal): New function containing the code from ...
(fatal): ... this. Call vfatal.
(maybe_fatal): Convert to standard C, use variable number of
arguments. Declare as non-return.
(init_tty): Fix maybe_fatal call.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 12 | ||||
| -rw-r--r-- | src/eval.c | 24 | ||||
| -rw-r--r-- | src/lisp.h | 1 | ||||
| -rw-r--r-- | src/term.c | 42 | ||||
| -rw-r--r-- | src/xterm.c | 2 |
5 files changed, 55 insertions, 26 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 667a82c14ec..d7d2f935492 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2010-07-13 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | Convert maybe_fatal to standard C. | ||
| 4 | * lisp.h (verror): Declare. | ||
| 5 | * eval.c (verror): New function containing the code from ... | ||
| 6 | (error): ... this. Call verror. | ||
| 7 | * term.c (vfatal): New function containing the code from ... | ||
| 8 | (fatal): ... this. Call vfatal. | ||
| 9 | (maybe_fatal): Convert to standard C, use variable number of | ||
| 10 | arguments. Declare as non-return. | ||
| 11 | (init_tty): Fix maybe_fatal call. | ||
| 12 | |||
| 1 | 2010-07-12 Dan Nicolaescu <dann@ics.uci.edu> | 13 | 2010-07-12 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 14 | ||
| 3 | * xterm.c (x_scroll_bar_set_handle, x_scroll_bar_expose) | 15 | * xterm.c (x_scroll_bar_set_handle, x_scroll_bar_expose) |
diff --git a/src/eval.c b/src/eval.c index 1a7eb4a123e..953a41e4b1e 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -1991,11 +1991,10 @@ find_handler_clause (Lisp_Object handlers, Lisp_Object conditions, | |||
| 1991 | return Qnil; | 1991 | return Qnil; |
| 1992 | } | 1992 | } |
| 1993 | 1993 | ||
| 1994 | /* dump an error message; called like printf */ | ||
| 1995 | 1994 | ||
| 1996 | /* VARARGS 1 */ | 1995 | /* dump an error message; called like vprintf */ |
| 1997 | void | 1996 | void |
| 1998 | error (const char *m, ...) | 1997 | verror (const char *m, va_list ap) |
| 1999 | { | 1998 | { |
| 2000 | char buf[200]; | 1999 | char buf[200]; |
| 2001 | int size = 200; | 2000 | int size = 200; |
| @@ -2009,14 +2008,8 @@ error (const char *m, ...) | |||
| 2009 | 2008 | ||
| 2010 | while (1) | 2009 | while (1) |
| 2011 | { | 2010 | { |
| 2012 | va_list ap; | ||
| 2013 | int used; | 2011 | int used; |
| 2014 | |||
| 2015 | /* A va_list can't be reused if we have to go around the loop | ||
| 2016 | again; we need to "reinitialize" it each time. */ | ||
| 2017 | va_start(ap, m); | ||
| 2018 | used = doprnt (buffer, size, m, m + mlen, ap); | 2012 | used = doprnt (buffer, size, m, m + mlen, ap); |
| 2019 | va_end(ap); | ||
| 2020 | if (used < size) | 2013 | if (used < size) |
| 2021 | break; | 2014 | break; |
| 2022 | size *= 2; | 2015 | size *= 2; |
| @@ -2035,6 +2028,19 @@ error (const char *m, ...) | |||
| 2035 | 2028 | ||
| 2036 | xsignal1 (Qerror, string); | 2029 | xsignal1 (Qerror, string); |
| 2037 | } | 2030 | } |
| 2031 | |||
| 2032 | |||
| 2033 | /* dump an error message; called like printf */ | ||
| 2034 | |||
| 2035 | /* VARARGS 1 */ | ||
| 2036 | void | ||
| 2037 | error (const char *m, ...) | ||
| 2038 | { | ||
| 2039 | va_list ap; | ||
| 2040 | va_start (ap, m); | ||
| 2041 | verror (m, ap); | ||
| 2042 | va_end (ap); | ||
| 2043 | } | ||
| 2038 | 2044 | ||
| 2039 | DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0, | 2045 | DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0, |
| 2040 | doc: /* Non-nil if FUNCTION makes provisions for interactive calling. | 2046 | doc: /* Non-nil if FUNCTION makes provisions for interactive calling. |
diff --git a/src/lisp.h b/src/lisp.h index 656e8fbb624..3ec2ed07ed9 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2908,6 +2908,7 @@ extern void specbind (Lisp_Object, Lisp_Object); | |||
| 2908 | extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); | 2908 | extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); |
| 2909 | extern Lisp_Object unbind_to (int, Lisp_Object); | 2909 | extern Lisp_Object unbind_to (int, Lisp_Object); |
| 2910 | extern void error (const char *, ...) NO_RETURN; | 2910 | extern void error (const char *, ...) NO_RETURN; |
| 2911 | extern void verror (const char *, va_list) NO_RETURN; | ||
| 2911 | extern void do_autoload (Lisp_Object, Lisp_Object); | 2912 | extern void do_autoload (Lisp_Object, Lisp_Object); |
| 2912 | extern Lisp_Object un_autoload (Lisp_Object); | 2913 | extern Lisp_Object un_autoload (Lisp_Object); |
| 2913 | EXFUN (Ffetch_bytecode, 1); | 2914 | EXFUN (Ffetch_bytecode, 1); |
diff --git a/src/term.c b/src/term.c index 53879e57e5b..5ffd7416bbd 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -101,6 +101,10 @@ static void clear_tty_hooks (struct terminal *terminal); | |||
| 101 | static void set_tty_hooks (struct terminal *terminal); | 101 | static void set_tty_hooks (struct terminal *terminal); |
| 102 | static void dissociate_if_controlling_tty (int fd); | 102 | static void dissociate_if_controlling_tty (int fd); |
| 103 | static void delete_tty (struct terminal *); | 103 | static void delete_tty (struct terminal *); |
| 104 | static void maybe_fatal (int must_succeed, struct terminal *terminal, | ||
| 105 | const char *str1, const char *str2, ...) NO_RETURN; | ||
| 106 | static void vfatal (const char *str, va_list ap) NO_RETURN; | ||
| 107 | |||
| 104 | 108 | ||
| 105 | #define OUTPUT(tty, a) \ | 109 | #define OUTPUT(tty, a) \ |
| 106 | emacs_tputs ((tty), a, \ | 110 | emacs_tputs ((tty), a, \ |
| @@ -3375,8 +3379,6 @@ dissociate_if_controlling_tty (int fd) | |||
| 3375 | #endif /* !DOS_NT */ | 3379 | #endif /* !DOS_NT */ |
| 3376 | } | 3380 | } |
| 3377 | 3381 | ||
| 3378 | static void maybe_fatal(); | ||
| 3379 | |||
| 3380 | /* Create a termcap display on the tty device with the given name and | 3382 | /* Create a termcap display on the tty device with the given name and |
| 3381 | type. | 3383 | type. |
| 3382 | 3384 | ||
| @@ -3748,7 +3750,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | |||
| 3748 | 3750 | ||
| 3749 | if (FrameRows (tty) < 3 || FrameCols (tty) < 3) | 3751 | if (FrameRows (tty) < 3 || FrameCols (tty) < 3) |
| 3750 | maybe_fatal (must_succeed, terminal, | 3752 | maybe_fatal (must_succeed, terminal, |
| 3751 | "Screen size %dx%d is too small" | 3753 | "Screen size %dx%d is too small", |
| 3752 | "Screen size %dx%d is too small", | 3754 | "Screen size %dx%d is too small", |
| 3753 | FrameCols (tty), FrameRows (tty)); | 3755 | FrameCols (tty), FrameRows (tty)); |
| 3754 | 3756 | ||
| @@ -3924,24 +3926,39 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | |||
| 3924 | return terminal; | 3926 | return terminal; |
| 3925 | } | 3927 | } |
| 3926 | 3928 | ||
| 3929 | |||
| 3930 | static void | ||
| 3931 | vfatal (const char *str, va_list ap) | ||
| 3932 | { | ||
| 3933 | fprintf (stderr, "emacs: "); | ||
| 3934 | vfprintf (stderr, str, ap); | ||
| 3935 | if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n')) | ||
| 3936 | fprintf (stderr, "\n"); | ||
| 3937 | va_end (ap); | ||
| 3938 | fflush (stderr); | ||
| 3939 | exit (1); | ||
| 3940 | } | ||
| 3941 | |||
| 3942 | |||
| 3927 | /* Auxiliary error-handling function for init_tty. | 3943 | /* Auxiliary error-handling function for init_tty. |
| 3928 | Delete TERMINAL, then call error or fatal with str1 or str2, | 3944 | Delete TERMINAL, then call error or fatal with str1 or str2, |
| 3929 | respectively, according to MUST_SUCCEED. */ | 3945 | respectively, according to MUST_SUCCEED. */ |
| 3930 | 3946 | ||
| 3931 | static void | 3947 | static void |
| 3932 | maybe_fatal (must_succeed, terminal, str1, str2, arg1, arg2) | 3948 | maybe_fatal (int must_succeed, struct terminal *terminal, |
| 3933 | int must_succeed; | 3949 | const char *str1, const char *str2, ...) |
| 3934 | struct terminal *terminal; | ||
| 3935 | char *str1, *str2, *arg1, *arg2; | ||
| 3936 | { | 3950 | { |
| 3951 | va_list ap; | ||
| 3952 | va_start (ap, str2); | ||
| 3937 | if (terminal) | 3953 | if (terminal) |
| 3938 | delete_tty (terminal); | 3954 | delete_tty (terminal); |
| 3939 | 3955 | ||
| 3940 | if (must_succeed) | 3956 | if (must_succeed) |
| 3941 | fatal (str2, arg1, arg2); | 3957 | vfatal (str2, ap); |
| 3942 | else | 3958 | else |
| 3943 | error (str1, arg1, arg2); | 3959 | verror (str1, ap); |
| 3944 | 3960 | ||
| 3961 | va_end (ap); | ||
| 3945 | abort (); | 3962 | abort (); |
| 3946 | } | 3963 | } |
| 3947 | 3964 | ||
| @@ -3950,13 +3967,8 @@ fatal (const char *str, ...) | |||
| 3950 | { | 3967 | { |
| 3951 | va_list ap; | 3968 | va_list ap; |
| 3952 | va_start (ap, str); | 3969 | va_start (ap, str); |
| 3953 | fprintf (stderr, "emacs: "); | 3970 | vfatal (str, ap); |
| 3954 | vfprintf (stderr, str, ap); | ||
| 3955 | if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n')) | ||
| 3956 | fprintf (stderr, "\n"); | ||
| 3957 | va_end (ap); | 3971 | va_end (ap); |
| 3958 | fflush (stderr); | ||
| 3959 | exit (1); | ||
| 3960 | } | 3972 | } |
| 3961 | 3973 | ||
| 3962 | 3974 | ||
diff --git a/src/xterm.c b/src/xterm.c index 649e5c2d674..2f581d9f590 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -10183,11 +10183,9 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10183 | 10183 | ||
| 10184 | xsettings_initialize (dpyinfo); | 10184 | xsettings_initialize (dpyinfo); |
| 10185 | 10185 | ||
| 10186 | #ifdef subprocesses | ||
| 10187 | /* This is only needed for distinguishing keyboard and process input. */ | 10186 | /* This is only needed for distinguishing keyboard and process input. */ |
| 10188 | if (connection != 0) | 10187 | if (connection != 0) |
| 10189 | add_keyboard_wait_descriptor (connection); | 10188 | add_keyboard_wait_descriptor (connection); |
| 10190 | #endif | ||
| 10191 | 10189 | ||
| 10192 | #ifdef F_SETOWN | 10190 | #ifdef F_SETOWN |
| 10193 | fcntl (connection, F_SETOWN, getpid ()); | 10191 | fcntl (connection, F_SETOWN, getpid ()); |