[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r109861: * emacs.c, eval.c: Use bool
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r109861: * emacs.c, eval.c: Use bool for boolean. |
Date: |
Sun, 02 Sep 2012 10:10:35 -0700 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 109861
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Sun 2012-09-02 10:10:35 -0700
message:
* 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.
modified:
src/ChangeLog
src/dispextern.h
src/emacs.c
src/eval.c
src/firstfile.c
src/lisp.h
src/msdos.c
src/process.c
src/w32.c
src/xdisp.c
src/xterm.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-09-02 16:56:31 +0000
+++ b/src/ChangeLog 2012-09-02 17:10:35 +0000
@@ -1,5 +1,32 @@
2012-09-02 Paul Eggert <address@hidden>
+ * 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.
=== modified file 'src/dispextern.h'
--- a/src/dispextern.h 2012-09-02 16:56:31 +0000
+++ b/src/dispextern.h 2012-09-02 17:10:35 +0000
@@ -3055,7 +3055,7 @@
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;
=== modified file 'src/emacs.c'
--- a/src/emacs.c 2012-09-01 08:01:36 +0000
+++ b/src/emacs.c 2012-09-02 17:10:35 +0000
@@ -95,10 +95,10 @@
/* 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 @@
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 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 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 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
(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");
=== modified file 'src/eval.c'
--- a/src/eval.c 2012-09-02 16:56:31 +0000
+++ b/src/eval.c 2012-09-02 17:10:35 +0000
@@ -131,7 +131,7 @@
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 @@
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 @@
use `called-interactively-p'. */)
(void)
{
- return interactive_p (1) ? Qt : Qnil;
+ return interactive_p () ? Qt : Qnil;
}
@@ -550,19 +550,17 @@
\(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.
-
- 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)
+/* Return true if function in which this appears was called using
+ call-interactively and is not a built-in. */
+
+static bool
+interactive_p (void)
{
struct backtrace *btp;
Lisp_Object fun;
@@ -591,9 +589,9 @@
/* `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 @@
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 @@
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 @@
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 @@
}
-/* 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 @@
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 @@
= 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 @@
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 @@
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
=== modified file 'src/firstfile.c'
--- a/src/firstfile.c 2012-01-19 07:21:25 +0000
+++ b/src/firstfile.c 2012-09-02 17:10:35 +0000
@@ -27,7 +27,6 @@
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
-
=== modified file 'src/lisp.h'
--- a/src/lisp.h 2012-09-02 16:56:31 +0000
+++ b/src/lisp.h 2012-09-02 17:10:35 +0000
@@ -3258,7 +3258,7 @@
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 @@
#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;
-
-/* Nonzero means remove site-lisp directories from load-path. */
-extern int no_site_lisp;
+extern void shut_down_emacs (int, Lisp_Object);
+
+/* 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 @@
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 */
=== modified file 'src/msdos.c'
--- a/src/msdos.c 2012-08-21 10:21:04 +0000
+++ b/src/msdos.c 2012-09-02 17:10:35 +0000
@@ -1029,7 +1029,6 @@
{
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)
=== modified file 'src/process.c'
--- a/src/process.c 2012-09-02 16:56:31 +0000
+++ b/src/process.c 2012-09-02 17:10:35 +0000
@@ -5194,7 +5194,7 @@
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 @@
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)
=== modified file 'src/w32.c'
--- a/src/w32.c 2012-08-26 10:29:37 +0000
+++ b/src/w32.c 2012-09-02 17:10:35 +0000
@@ -6773,7 +6773,7 @@
|| 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. */
=== modified file 'src/xdisp.c'
--- a/src/xdisp.c 2012-08-28 05:49:02 +0000
+++ b/src/xdisp.c 2012-09-02 17:10:35 +0000
@@ -768,9 +768,9 @@
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 @@
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 @@
}
-/* 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);
=== modified file 'src/xterm.c'
--- a/src/xterm.c 2012-09-02 16:56:31 +0000
+++ b/src/xterm.c 2012-09-02 17:10:35 +0000
@@ -7843,7 +7843,7 @@
(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\
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r109861: * emacs.c, eval.c: Use bool for boolean.,
Paul Eggert <=