Commit b3ffc17c authored by Dan Nicolaescu's avatar Dan Nicolaescu

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.
parent 0521f580
2010-07-13 Dan Nicolaescu <dann@ics.uci.edu>
Convert maybe_fatal to standard C.
* lisp.h (verror): Declare.
* eval.c (verror): New function containing the code from ...
(error): ... this. Call verror.
* 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.
2010-07-12 Dan Nicolaescu <dann@ics.uci.edu> 2010-07-12 Dan Nicolaescu <dann@ics.uci.edu>
* xterm.c (x_scroll_bar_set_handle, x_scroll_bar_expose) * xterm.c (x_scroll_bar_set_handle, x_scroll_bar_expose)
......
...@@ -1991,11 +1991,10 @@ find_handler_clause (Lisp_Object handlers, Lisp_Object conditions, ...@@ -1991,11 +1991,10 @@ find_handler_clause (Lisp_Object handlers, Lisp_Object conditions,
return Qnil; return Qnil;
} }
/* dump an error message; called like printf */
/* VARARGS 1 */ /* dump an error message; called like vprintf */
void void
error (const char *m, ...) verror (const char *m, va_list ap)
{ {
char buf[200]; char buf[200];
int size = 200; int size = 200;
...@@ -2009,14 +2008,8 @@ error (const char *m, ...) ...@@ -2009,14 +2008,8 @@ error (const char *m, ...)
while (1) while (1)
{ {
va_list ap;
int used; int used;
/* A va_list can't be reused if we have to go around the loop
again; we need to "reinitialize" it each time. */
va_start(ap, m);
used = doprnt (buffer, size, m, m + mlen, ap); used = doprnt (buffer, size, m, m + mlen, ap);
va_end(ap);
if (used < size) if (used < size)
break; break;
size *= 2; size *= 2;
...@@ -2035,6 +2028,19 @@ error (const char *m, ...) ...@@ -2035,6 +2028,19 @@ error (const char *m, ...)
xsignal1 (Qerror, string); xsignal1 (Qerror, string);
} }
/* dump an error message; called like printf */
/* VARARGS 1 */
void
error (const char *m, ...)
{
va_list ap;
va_start (ap, m);
verror (m, ap);
va_end (ap);
}
DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0, DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0,
doc: /* Non-nil if FUNCTION makes provisions for interactive calling. doc: /* Non-nil if FUNCTION makes provisions for interactive calling.
......
...@@ -2908,6 +2908,7 @@ extern void specbind (Lisp_Object, Lisp_Object); ...@@ -2908,6 +2908,7 @@ extern void specbind (Lisp_Object, Lisp_Object);
extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object);
extern Lisp_Object unbind_to (int, Lisp_Object); extern Lisp_Object unbind_to (int, Lisp_Object);
extern void error (const char *, ...) NO_RETURN; extern void error (const char *, ...) NO_RETURN;
extern void verror (const char *, va_list) NO_RETURN;
extern void do_autoload (Lisp_Object, Lisp_Object); extern void do_autoload (Lisp_Object, Lisp_Object);
extern Lisp_Object un_autoload (Lisp_Object); extern Lisp_Object un_autoload (Lisp_Object);
EXFUN (Ffetch_bytecode, 1); EXFUN (Ffetch_bytecode, 1);
......
...@@ -101,6 +101,10 @@ static void clear_tty_hooks (struct terminal *terminal); ...@@ -101,6 +101,10 @@ static void clear_tty_hooks (struct terminal *terminal);
static void set_tty_hooks (struct terminal *terminal); static void set_tty_hooks (struct terminal *terminal);
static void dissociate_if_controlling_tty (int fd); static void dissociate_if_controlling_tty (int fd);
static void delete_tty (struct terminal *); static void delete_tty (struct terminal *);
static void maybe_fatal (int must_succeed, struct terminal *terminal,
const char *str1, const char *str2, ...) NO_RETURN;
static void vfatal (const char *str, va_list ap) NO_RETURN;
#define OUTPUT(tty, a) \ #define OUTPUT(tty, a) \
emacs_tputs ((tty), a, \ emacs_tputs ((tty), a, \
...@@ -3375,8 +3379,6 @@ dissociate_if_controlling_tty (int fd) ...@@ -3375,8 +3379,6 @@ dissociate_if_controlling_tty (int fd)
#endif /* !DOS_NT */ #endif /* !DOS_NT */
} }
static void maybe_fatal();
/* Create a termcap display on the tty device with the given name and /* Create a termcap display on the tty device with the given name and
type. type.
...@@ -3748,7 +3750,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ ...@@ -3748,7 +3750,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
if (FrameRows (tty) < 3 || FrameCols (tty) < 3) if (FrameRows (tty) < 3 || FrameCols (tty) < 3)
maybe_fatal (must_succeed, terminal, maybe_fatal (must_succeed, terminal,
"Screen size %dx%d is too small" "Screen size %dx%d is too small",
"Screen size %dx%d is too small", "Screen size %dx%d is too small",
FrameCols (tty), FrameRows (tty)); FrameCols (tty), FrameRows (tty));
...@@ -3924,24 +3926,39 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ ...@@ -3924,24 +3926,39 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
return terminal; return terminal;
} }
static void
vfatal (const char *str, va_list ap)
{
fprintf (stderr, "emacs: ");
vfprintf (stderr, str, ap);
if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n'))
fprintf (stderr, "\n");
va_end (ap);
fflush (stderr);
exit (1);
}
/* Auxiliary error-handling function for init_tty. /* Auxiliary error-handling function for init_tty.
Delete TERMINAL, then call error or fatal with str1 or str2, Delete TERMINAL, then call error or fatal with str1 or str2,
respectively, according to MUST_SUCCEED. */ respectively, according to MUST_SUCCEED. */
static void static void
maybe_fatal (must_succeed, terminal, str1, str2, arg1, arg2) maybe_fatal (int must_succeed, struct terminal *terminal,
int must_succeed; const char *str1, const char *str2, ...)
struct terminal *terminal;
char *str1, *str2, *arg1, *arg2;
{ {
va_list ap;
va_start (ap, str2);
if (terminal) if (terminal)
delete_tty (terminal); delete_tty (terminal);
if (must_succeed) if (must_succeed)
fatal (str2, arg1, arg2); vfatal (str2, ap);
else else
error (str1, arg1, arg2); verror (str1, ap);
va_end (ap);
abort (); abort ();
} }
...@@ -3950,13 +3967,8 @@ fatal (const char *str, ...) ...@@ -3950,13 +3967,8 @@ fatal (const char *str, ...)
{ {
va_list ap; va_list ap;
va_start (ap, str); va_start (ap, str);
fprintf (stderr, "emacs: "); vfatal (str, ap);
vfprintf (stderr, str, ap);
if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n'))
fprintf (stderr, "\n");
va_end (ap); va_end (ap);
fflush (stderr);
exit (1);
} }
......
...@@ -10183,11 +10183,9 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) ...@@ -10183,11 +10183,9 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
xsettings_initialize (dpyinfo); xsettings_initialize (dpyinfo);
#ifdef subprocesses
/* This is only needed for distinguishing keyboard and process input. */ /* This is only needed for distinguishing keyboard and process input. */
if (connection != 0) if (connection != 0)
add_keyboard_wait_descriptor (connection); add_keyboard_wait_descriptor (connection);
#endif
#ifdef F_SETOWN #ifdef F_SETOWN
fcntl (connection, F_SETOWN, getpid ()); fcntl (connection, F_SETOWN, getpid ());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment