Commit 1882aa38 authored by Paul Eggert's avatar Paul Eggert

* emacs.c, eval.c: Use bool for boolean.

* emacs.c (initialized, inhibit_window_system, running_asynch_code):
(malloc_using_checking) [DOUG_LEA_MALLOC]:
(display_arg) [HAVE_X_WINDOWS || HAVE_NS]:
(noninteractive, no_site_lisp, fatal_error_in_progress, argmatch)
(main, decode_env_path, Fdaemon_initialized):
* eval.c (call_debugger, Finteractive_p, interactive_p):
(unwind_to_catch, Fsignal, wants_debugger, skip_debugger)
(maybe_call_debugger, Fbacktrace):
* process.c (read_process_output, exec_sentinel):
Use bool for booleans.
* emacs.c (shut_down_emacs): Omit unused boolean argument NO_X.
All callers changed.
* eval.c (interactive_p): Omit always-true boolean argument
EXCLUDE_SUBRS_P.  All callers changed.
* dispextern.h, lisp.h: Reflect above API changes.
* firstfile.c (dummy): Use the address of 'main', whose signature
won't change, instead of the address of 'initialize', whose
signature just changed from int to bool.
* lisp.h (fatal_error_in_progress): New decl of boolean, moved here ...
* msdos.c (fatal_error_in_progress): ... from here.
* xdisp.c (redisplaying_p): Now a boolean.  Set it to 1 instead
of incrementing it.
(redisplay_internal, unwind_redisplay): Simply clear
REDISPLAYING_P when unwinding, instead of saving its previous,
always-false value and then restoring it.
parent a411ac43
2012-09-02 Paul Eggert <eggert@cs.ucla.edu>
* emacs.c, eval.c: Use bool for boolean.
* emacs.c (initialized, inhibit_window_system, running_asynch_code):
(malloc_using_checking) [DOUG_LEA_MALLOC]:
(display_arg) [HAVE_X_WINDOWS || HAVE_NS]:
(noninteractive, no_site_lisp, fatal_error_in_progress, argmatch)
(main, decode_env_path, Fdaemon_initialized):
* eval.c (call_debugger, Finteractive_p, interactive_p):
(unwind_to_catch, Fsignal, wants_debugger, skip_debugger)
(maybe_call_debugger, Fbacktrace):
* process.c (read_process_output, exec_sentinel):
Use bool for booleans.
* emacs.c (shut_down_emacs): Omit unused boolean argument NO_X.
All callers changed.
* eval.c (interactive_p): Omit always-true boolean argument
EXCLUDE_SUBRS_P. All callers changed.
* dispextern.h, lisp.h: Reflect above API changes.
* firstfile.c (dummy): Use the address of 'main', whose signature
won't change, instead of the address of 'initialize', whose
signature just changed from int to bool.
* lisp.h (fatal_error_in_progress): New decl of boolean, moved here ...
* msdos.c (fatal_error_in_progress): ... from here.
* xdisp.c (redisplaying_p): Now a boolean. Set it to 1 instead
of incrementing it.
(redisplay_internal, unwind_redisplay): Simply clear
REDISPLAYING_P when unwinding, instead of saving its previous,
always-false value and then restoring it.
Clean up some extern decls.
Mostly, this hoists extern decls out of .c files and into .h files.
That way, we're more likely to catch errors if the interfaces change.
......
......@@ -3055,7 +3055,7 @@ void move_it_in_display_line (struct it *it,
int in_display_vector_p (struct it *);
int frame_mode_line_height (struct frame *);
extern Lisp_Object Qtool_bar;
extern int redisplaying_p;
extern bool redisplaying_p;
extern int help_echo_showing_p;
extern int current_mode_line_height, current_header_line_height;
extern Lisp_Object help_echo_string, help_echo_window;
......
......@@ -95,10 +95,10 @@ static const char emacs_copyright[] = "Copyright (C) 2012 Free Software Foundati
/* Empty lisp strings. To avoid having to build any others. */
Lisp_Object empty_unibyte_string, empty_multibyte_string;
/* Set nonzero after Emacs has started up the first time.
Prevents reinitialization of the Lisp world and keymaps
on subsequent starts. */
int initialized;
/* Set after Emacs has started up the first time.
Prevents reinitialization of the Lisp world and keymaps
on subsequent starts. */
bool initialized;
#ifdef DARWIN_OS
extern void unexec_init_emacs_zone (void);
......@@ -112,9 +112,9 @@ static void *malloc_state_ptr;
extern void *malloc_get_state (void);
/* From glibc, a routine that overwrites the malloc internal state. */
extern int malloc_set_state (void*);
/* Non-zero if the MALLOC_CHECK_ environment variable was set while
/* True if the MALLOC_CHECK_ environment variable was set while
dumping. Used to work around a bug in glibc's malloc. */
static int malloc_using_checking;
static bool malloc_using_checking;
#endif
Lisp_Object Qfile_name_handler_alist;
......@@ -123,17 +123,17 @@ Lisp_Object Qrisky_local_variable;
Lisp_Object Qkill_emacs;
/* If non-zero, Emacs should not attempt to use a window-specific code,
/* If true, Emacs should not attempt to use a window-specific code,
but instead should use the virtual terminal under which it was started. */
int inhibit_window_system;
bool inhibit_window_system;
/* If non-zero, a filter or a sentinel is running. Tested to save the match
/* If true, a filter or a sentinel is running. Tested to save the match
data on the first attempt to change it inside asynchronous code. */
int running_asynch_code;
bool running_asynch_code;
#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS)
/* If non-zero, -d was specified, meaning we're using some window system. */
int display_arg;
/* If true, -d was specified, meaning we're using some window system. */
bool display_arg;
#endif
/* An address near the bottom of the stack.
......@@ -150,11 +150,11 @@ static void *my_heap_start;
static uprintmax_t heap_bss_diff;
#endif
/* Nonzero means running Emacs without interactive terminal. */
int noninteractive;
/* True means running Emacs without interactive terminal. */
bool noninteractive;
/* Nonzero means remove site-lisp directories from load-path. */
int no_site_lisp;
/* True means remove site-lisp directories from load-path. */
bool no_site_lisp;
/* Name for the server started by the daemon.*/
static char *daemon_name;
......@@ -272,8 +272,8 @@ section of the Emacs manual or the file BUGS.\n"
/* Signal code for the fatal signal that was received. */
static int fatal_error_code;
/* Nonzero if handling a fatal error already. */
int fatal_error_in_progress;
/* True if handling a fatal error already. */
bool fatal_error_in_progress;
#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
/* When compiled with GTK and running under Gnome,
......@@ -311,7 +311,7 @@ fatal_error_signal (int sig)
if (sig == SIGTERM || sig == SIGHUP || sig == SIGINT)
Fkill_emacs (make_number (sig));
shut_down_emacs (sig, 0, Qnil);
shut_down_emacs (sig, Qnil);
}
/* Signal the same code; this time it will really be fatal.
......@@ -568,7 +568,7 @@ DEFINE_DUMMY_FUNCTION (__main)
Too bad we can't just use getopt for all of this, but we don't have
enough information to do it right. */
static int
static bool
argmatch (char **argv, int argc, const char *sstr, const char *lstr,
int minlen, char **valptr, int *skipptr)
{
......@@ -675,12 +675,12 @@ main (int argc, char **argv)
Lisp_Object dummy;
#endif
char stack_bottom_variable;
int do_initial_setlocale;
bool do_initial_setlocale;
int skip_args = 0;
#ifdef HAVE_SETRLIMIT
struct rlimit rlim;
#endif
int no_loadup = 0;
bool no_loadup = 0;
char *junk = 0;
char *dname_arg = 0;
#ifdef NS_IMPL_COCOA
......@@ -1955,7 +1955,7 @@ all of which are called before Emacs is actually killed. */)
x_clipboard_manager_save_all ();
#endif
shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil);
shut_down_emacs (0, STRINGP (arg) ? arg : Qnil);
#ifdef HAVE_NS
ns_release_autorelease_pool (ns_pool);
......@@ -1991,7 +1991,7 @@ all of which are called before Emacs is actually killed. */)
and Fkill_emacs. */
void
shut_down_emacs (int sig, int no_x, Lisp_Object stuff)
shut_down_emacs (int sig, Lisp_Object stuff)
{
/* Prevent running of hooks from now on. */
Vrun_hooks = Qnil;
......@@ -2026,17 +2026,6 @@ shut_down_emacs (int sig, int no_x, Lisp_Object stuff)
unlock_all_files ();
#endif
#if 0 /* This triggers a bug in XCloseDisplay and is not needed. */
#ifdef HAVE_X_WINDOWS
/* It's not safe to call intern here. Maybe we are crashing. */
if (!noninteractive && SYMBOLP (Vinitial_window_system)
&& SCHARS (SYMBOL_NAME (Vinitial_window_system)) == 1
&& SREF (SYMBOL_NAME (Vinitial_window_system), 0) == 'x'
&& ! no_x)
Fx_close_current_connection ();
#endif /* HAVE_X_WINDOWS */
#endif
#ifdef SIGIO
/* There is a tendency for a SIGIO signal to arrive within exit,
and cause a SIGHUP because the input descriptor is already closed. */
......@@ -2228,7 +2217,7 @@ decode_env_path (const char *evarname, const char *defalt)
const char *path, *p;
Lisp_Object lpath, element, tem;
#ifdef WINDOWSNT
int defaulted = 0;
bool defaulted = 0;
const char *emacs_dir = egetenv ("emacs_dir");
static const char *emacs_dir_env = "%emacs_dir%/";
const size_t emacs_dir_len = strlen (emacs_dir_env);
......@@ -2324,7 +2313,7 @@ from the parent process and its tty file descriptors. */)
(void)
{
int nfd;
int err = 0;
bool err = 0;
if (!IS_DAEMON)
error ("This function can only be called if emacs is run as a daemon");
......
......@@ -131,7 +131,7 @@ int handling_signal;
Lisp_Object inhibit_lisp_code;
static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *);
static int interactive_p (int);
static bool interactive_p (void);
static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args);
/* Functions to set Lisp_Object slots of struct specbinding. */
......@@ -194,7 +194,7 @@ restore_stack_limits (Lisp_Object data)
static Lisp_Object
call_debugger (Lisp_Object arg)
{
int debug_while_redisplaying;
bool debug_while_redisplaying;
ptrdiff_t count = SPECPDL_INDEX ();
Lisp_Object val;
EMACS_INT old_max = max_specpdl_size;
......@@ -525,7 +525,7 @@ spec that specifies non-nil unconditionally (such as \"p\"); or (ii)
use `called-interactively-p'. */)
(void)
{
return interactive_p (1) ? Qt : Qnil;
return interactive_p () ? Qt : Qnil;
}
......@@ -550,19 +550,17 @@ non-nil unconditionally (\"p\" is a good way to do this), or via
\(not (or executing-kbd-macro noninteractive)). */)
(Lisp_Object kind)
{
return ((INTERACTIVE || !EQ (kind, intern ("interactive")))
&& interactive_p (1)) ? Qt : Qnil;
return (((INTERACTIVE || !EQ (kind, intern ("interactive")))
&& interactive_p ())
? Qt : Qnil);
}
/* Return 1 if function in which this appears was called using
call-interactively.
/* Return true if function in which this appears was called using
call-interactively and is not a built-in. */
EXCLUDE_SUBRS_P non-zero means always return 0 if the function
called is a built-in. */
static int
interactive_p (int exclude_subrs_p)
static bool
interactive_p (void)
{
struct backtrace *btp;
Lisp_Object fun;
......@@ -591,9 +589,9 @@ interactive_p (int exclude_subrs_p)
/* `btp' now points at the frame of the innermost function that isn't
a special form, ignoring frames for Finteractive_p and/or
Fbytecode at the top. If this frame is for a built-in function
(such as load or eval-region) return nil. */
(such as load or eval-region) return false. */
fun = Findirect_function (*btp->function, Qnil);
if (exclude_subrs_p && SUBRP (fun))
if (SUBRP (fun))
return 0;
/* `btp' points to the frame of a Lisp function that called interactive-p.
......@@ -1101,7 +1099,7 @@ internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object
static _Noreturn void
unwind_to_catch (struct catchtag *catch, Lisp_Object value)
{
int last_time;
bool last_time;
/* Save the value in the tag. */
catch->val = value;
......@@ -1450,8 +1448,8 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *),
static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object);
static int maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig,
Lisp_Object data);
static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig,
Lisp_Object data);
void
process_quit_flag (void)
......@@ -1556,7 +1554,7 @@ See also the function `condition-case'. */)
if requested". */
|| EQ (h->handler, Qerror)))
{
int debugger_called
bool debugger_called
= maybe_call_debugger (conditions, error_symbol, data);
/* We can't return values to code which signaled an error, but we
can continue code which has signaled a quit. */
......@@ -1650,10 +1648,10 @@ signal_error (const char *s, Lisp_Object arg)
}
/* Return nonzero if LIST is a non-nil atom or
/* Return true if LIST is a non-nil atom or
a list containing one of CONDITIONS. */
static int
static bool
wants_debugger (Lisp_Object list, Lisp_Object conditions)
{
if (NILP (list))
......@@ -1673,15 +1671,15 @@ wants_debugger (Lisp_Object list, Lisp_Object conditions)
return 0;
}
/* Return 1 if an error with condition-symbols CONDITIONS,
/* Return true if an error with condition-symbols CONDITIONS,
and described by SIGNAL-DATA, should skip the debugger
according to debugger-ignored-errors. */
static int
static bool
skip_debugger (Lisp_Object conditions, Lisp_Object data)
{
Lisp_Object tail;
int first_string = 1;
bool first_string = 1;
Lisp_Object error_message;
error_message = Qnil;
......@@ -1716,7 +1714,7 @@ skip_debugger (Lisp_Object conditions, Lisp_Object data)
= SIG is the error symbol, and DATA is the rest of the data.
= SIG is nil, and DATA is (SYMBOL . REST-OF-DATA).
This is for memory-full errors only. */
static int
static bool
maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data)
{
Lisp_Object combined_data;
......@@ -2939,7 +2937,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
Lisp_Object val, syms_left, next, lexenv;
ptrdiff_t count = SPECPDL_INDEX ();
ptrdiff_t i;
int optional, rest;
bool optional, rest;
if (CONSP (fun))
{
......@@ -3342,13 +3340,13 @@ Output stream used is value of `standard-output'. */)
write_string ("(", -1);
if (backlist->nargs == MANY)
{ /* FIXME: Can this happen? */
int i;
for (tail = *backlist->args, i = 0;
!NILP (tail);
tail = Fcdr (tail), i = 1)
bool later_arg = 0;
for (tail = *backlist->args; !NILP (tail); tail = Fcdr (tail))
{
if (i) write_string (" ", -1);
if (later_arg)
write_string (" ", -1);
Fprin1 (Fcar (tail), Qnil);
later_arg = 1;
}
}
else
......
......@@ -27,7 +27,6 @@ static char _my_begbss[1];
char * my_begbss_static = _my_begbss;
/* Add a dummy reference to ensure emacs.obj is linked in. */
extern int initialized;
static int * dummy = &initialized;
extern int main (int, char **);
static int (*dummy) (int, char **) = main;
#endif
......@@ -3258,7 +3258,7 @@ extern void syms_of_frame (void);
extern char **initial_argv;
extern int initial_argc;
#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS)
extern int display_arg;
extern bool display_arg;
#endif
extern Lisp_Object decode_env_path (const char *, const char *);
extern Lisp_Object empty_unibyte_string, empty_multibyte_string;
......@@ -3277,22 +3277,26 @@ void synchronize_system_time_locale (void);
#define synchronize_system_messages_locale()
#define synchronize_system_time_locale()
#endif
void shut_down_emacs (int, int, Lisp_Object);
/* Nonzero means don't do interactive redisplay and don't change tty modes. */
extern int noninteractive;
extern void shut_down_emacs (int, Lisp_Object);
/* Nonzero means remove site-lisp directories from load-path. */
extern int no_site_lisp;
/* True means don't do interactive redisplay and don't change tty modes. */
extern bool noninteractive;
/* True means remove site-lisp directories from load-path. */
extern bool no_site_lisp;
/* Pipe used to send exit notification to the daemon parent at
startup. */
extern int daemon_pipe[2];
#define IS_DAEMON (daemon_pipe[1] != 0)
/* Nonzero means don't do use window-system-specific display code. */
extern int inhibit_window_system;
/* Nonzero means that a filter or a sentinel is running. */
extern int running_asynch_code;
/* True if handling a fatal error already. */
extern bool fatal_error_in_progress;
/* True means don't do use window-system-specific display code. */
extern bool inhibit_window_system;
/* True means that a filter or a sentinel is running. */
extern bool running_asynch_code;
/* Defined in process.c. */
extern Lisp_Object QCtype, Qlocal;
......@@ -3514,9 +3518,9 @@ void syms_of_dbusbind (void);
extern char *emacs_root_dir (void);
#endif /* DOS_NT */
/* Nonzero means Emacs has already been initialized.
/* True means Emacs has already been initialized.
Used during startup to detect startup of dumped Emacs. */
extern int initialized;
extern bool initialized;
extern int immediate_quit; /* Nonzero means ^G can quit instantly */
......
......@@ -1029,7 +1029,6 @@ IT_clear_end_of_line (struct frame *f, int first_unused)
{
char *spaces, *sp;
int i, j, offset = 2 * (new_pos_X + screen_size_X * new_pos_Y);
extern int fatal_error_in_progress;
struct tty_display_info *tty = FRAME_TTY (f);
if (new_pos_X >= first_unused || fatal_error_in_progress)
......
......@@ -5194,7 +5194,7 @@ read_process_output (Lisp_Object proc, register int channel)
if (!NILP (outstream))
{
Lisp_Object text;
int outer_running_asynch_code = running_asynch_code;
bool outer_running_asynch_code = running_asynch_code;
int waiting = waiting_for_user_input_p;
/* No need to gcpro these, because all we do with them later
......@@ -6558,9 +6558,9 @@ static void
exec_sentinel (Lisp_Object proc, Lisp_Object reason)
{
Lisp_Object sentinel, odeactivate;
register struct Lisp_Process *p = XPROCESS (proc);
struct Lisp_Process *p = XPROCESS (proc);
ptrdiff_t count = SPECPDL_INDEX ();
int outer_running_asynch_code = running_asynch_code;
bool outer_running_asynch_code = running_asynch_code;
int waiting = waiting_for_user_input_p;
if (inhibit_sentinels)
......
......@@ -6773,7 +6773,7 @@ shutdown_handler (DWORD type)
|| type == CTRL_SHUTDOWN_EVENT) /* User shutsdown. */
{
/* Shut down cleanly, making sure autosave files are up to date. */
shut_down_emacs (0, 0, Qnil);
shut_down_emacs (0, Qnil);
}
/* Allow other handlers to handle this signal. */
......
......@@ -768,9 +768,9 @@ static int clear_image_cache_count;
static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 };
#endif
/* Non-zero while redisplay_internal is in progress. */
/* True while redisplay_internal is in progress. */
int redisplaying_p;
bool redisplaying_p;
static Lisp_Object Qinhibit_free_realized_faces;
static Lisp_Object Qmode_line_default_help_echo;
......@@ -12966,12 +12966,11 @@ redisplay_internal (void)
if (redisplaying_p)
return;
/* Record a function that resets redisplaying_p to its old value
/* Record a function that clears redisplaying_p
when we leave this function. */
count = SPECPDL_INDEX ();
record_unwind_protect (unwind_redisplay,
Fcons (make_number (redisplaying_p), selected_frame));
++redisplaying_p;
record_unwind_protect (unwind_redisplay, selected_frame);
redisplaying_p = 1;
specbind (Qinhibit_free_realized_faces, Qnil);
{
......@@ -13709,21 +13708,15 @@ redisplay_preserve_echo_area (int from_where)
}
/* Function registered with record_unwind_protect in
redisplay_internal. Reset redisplaying_p to the value it had
before redisplay_internal was called, and clear
prevent_freeing_realized_faces_p. It also selects the previously
/* Function registered with record_unwind_protect in redisplay_internal.
Clear redisplaying_p. Also, select the previously
selected frame, unless it has been deleted (by an X connection
failure during redisplay, for example). */
static Lisp_Object
unwind_redisplay (Lisp_Object val)
unwind_redisplay (Lisp_Object old_frame)
{
Lisp_Object old_redisplaying_p, old_frame;
old_redisplaying_p = XCAR (val);
redisplaying_p = XFASTINT (old_redisplaying_p);
old_frame = XCDR (val);
redisplaying_p = 0;
if (! EQ (old_frame, selected_frame)
&& FRAME_LIVE_P (XFRAME (old_frame)))
select_frame_for_redisplay (old_frame);
......
......@@ -7843,7 +7843,7 @@ x_connection_closed (Display *dpy, const char *error_message)
(https://bugzilla.gnome.org/show_bug.cgi?id=85715). Once,
the resulting Glib error message loop filled a user's disk.
To avoid this, kill Emacs unconditionally on disconnect. */
shut_down_emacs (0, 0, Qnil);
shut_down_emacs (0, Qnil);
fprintf (stderr, "%s\n\
When compiled with GTK, Emacs cannot recover from X disconnects.\n\
This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\
......
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