From de1339b0a8a5b6b8bf784c816b2b974f4610e3ac Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 27 Aug 2012 10:23:48 -0700 Subject: [PATCH] * composite.c, data.c, dbusbind.c, dired.c: Use bool for booleans. * composite.c (find_composition, composition_gstring_p) (composition_reseat_it, find_automatic_composition): * data.c (let_shadows_buffer_binding_p) (let_shadows_global_binding_p, set_internal, make_blv) (Fmake_variable_buffer_local, Fmake_local_variable) (Fmake_variable_frame_local, arithcompare, cons_to_unsigned) (cons_to_signed, arith_driver): * dbusbind.c (xd_in_read_queued_messages): * dired.c (directory_files_internal, file_name_completion): Use bool for booleans. * dired.c (file_name_completion): * process.h (fd_callback): Omit int (actually boolean) argument. It wasn't being used. All uses changed. * composite.h, lisp.h: Reflect above API changes. --- src/ChangeLog | 17 +++++++++++++++++ src/composite.c | 22 ++++++++++++---------- src/composite.h | 13 ++++++------- src/data.c | 49 ++++++++++++++++++++++++------------------------- src/dbusbind.c | 7 +++---- src/dired.c | 30 ++++++++++++++++-------------- src/lisp.h | 4 ++-- src/process.c | 16 +++++++--------- src/process.h | 2 +- src/xsmfns.c | 2 +- 10 files changed, 89 insertions(+), 73 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 7be88c568e..15d5211efd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,22 @@ 2012-08-27 Paul Eggert + * composite.c, data.c, dbusbind.c, dired.c: Use bool for booleans. + * composite.c (find_composition, composition_gstring_p) + (composition_reseat_it, find_automatic_composition): + * data.c (let_shadows_buffer_binding_p) + (let_shadows_global_binding_p, set_internal, make_blv) + (Fmake_variable_buffer_local, Fmake_local_variable) + (Fmake_variable_frame_local, arithcompare, cons_to_unsigned) + (cons_to_signed, arith_driver): + * dbusbind.c (xd_in_read_queued_messages): + * dired.c (directory_files_internal, file_name_completion): + Use bool for booleans. + * dired.c (file_name_completion): + * process.h (fd_callback): + Omit int (actually boolean) argument. It wasn't being used. + All uses changed. + * composite.h, lisp.h: Reflect above API changes. + * cmds.c, coding.c: Use bool for booleans. * cmds.c (move_point, Fself_insert_command): * coding.h (struct composition status, struct coding_system): diff --git a/src/composite.c b/src/composite.c index 4e90e9bb91..eddabb66d3 100644 --- a/src/composite.c +++ b/src/composite.c @@ -428,7 +428,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars, This doesn't check the validity of composition. */ -int +bool find_composition (ptrdiff_t pos, ptrdiff_t limit, ptrdiff_t *start, ptrdiff_t *end, Lisp_Object *prop, Lisp_Object object) @@ -709,7 +709,7 @@ static Lisp_Object fill_gstring_header (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); -int +bool composition_gstring_p (Lisp_Object gstring) { Lisp_Object header; @@ -1212,11 +1212,13 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos, string. In that case, FACE must not be NULL. If the character is composed, setup members of CMP_IT (id, nglyphs, - from, to, reversed_p), and return 1. Otherwise, update - CMP_IT->stop_pos, and return 0. */ + from, to, reversed_p), and return true. Otherwise, update + CMP_IT->stop_pos, and return false. */ -int -composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t endpos, struct window *w, struct face *face, Lisp_Object string) +bool +composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, + ptrdiff_t bytepos, ptrdiff_t endpos, struct window *w, + struct face *face, Lisp_Object string) { if (endpos < 0) endpos = NILP (string) ? BEGV : 0; @@ -1482,10 +1484,10 @@ struct position_record /* This is like find_composition, but find an automatic composition instead. It is assured that POS is not within a static composition. If found, set *GSTRING to the glyph-string - representing the composition, and return 1. Otherwise, *GSTRING to - Qnil, and return 0. */ + representing the composition, and return true. Otherwise, *GSTRING to + Qnil, and return false. */ -static int +static bool find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, ptrdiff_t *start, ptrdiff_t *end, Lisp_Object *gstring, Lisp_Object string) @@ -1498,7 +1500,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, int c; Lisp_Object window; struct window *w; - int need_adjustment = 0; + bool need_adjustment = 0; window = Fget_buffer_window (Fcurrent_buffer (), Qnil); if (NILP (window)) diff --git a/src/composite.h b/src/composite.h index 6a7e0a5e2c..68f5b27ee4 100644 --- a/src/composite.h +++ b/src/composite.h @@ -223,8 +223,8 @@ extern Lisp_Object Qcomposition; extern Lisp_Object composition_hash_table; extern ptrdiff_t get_composition_id (ptrdiff_t, ptrdiff_t, ptrdiff_t, Lisp_Object, Lisp_Object); -extern int find_composition (ptrdiff_t, ptrdiff_t, ptrdiff_t *, ptrdiff_t *, - Lisp_Object *, Lisp_Object); +extern bool find_composition (ptrdiff_t, ptrdiff_t, ptrdiff_t *, ptrdiff_t *, + Lisp_Object *, Lisp_Object); extern void update_compositions (ptrdiff_t, ptrdiff_t, int); extern void make_composition_value_copy (Lisp_Object); extern void compose_region (int, int, Lisp_Object, Lisp_Object, @@ -310,17 +310,16 @@ struct font_metrics; extern Lisp_Object composition_gstring_put_cache (Lisp_Object, ptrdiff_t); extern Lisp_Object composition_gstring_from_id (ptrdiff_t); -extern int composition_gstring_p (Lisp_Object); +extern bool composition_gstring_p (Lisp_Object); extern int composition_gstring_width (Lisp_Object, ptrdiff_t, ptrdiff_t, struct font_metrics *); extern void composition_compute_stop_pos (struct composition_it *, ptrdiff_t, ptrdiff_t, ptrdiff_t, Lisp_Object); -extern int composition_reseat_it (struct composition_it *, - ptrdiff_t, ptrdiff_t, ptrdiff_t, - struct window *, struct face *, - Lisp_Object); +extern bool composition_reseat_it (struct composition_it *, ptrdiff_t, + ptrdiff_t, ptrdiff_t, struct window *, + struct face *, Lisp_Object); extern int composition_update_it (struct composition_it *, ptrdiff_t, ptrdiff_t, Lisp_Object); diff --git a/src/data.c b/src/data.c index f121d8772c..d8b7f42ea3 100644 --- a/src/data.c +++ b/src/data.c @@ -1080,10 +1080,10 @@ DEFUN ("set", Fset, Sset, 2, 2, 0, return newval; } -/* Return 1 if SYMBOL currently has a let-binding +/* Return true if SYMBOL currently has a let-binding which was made in the buffer that is now current. */ -static int +static bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol) { struct specbinding *p; @@ -1102,7 +1102,7 @@ let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol) return 0; } -static int +static bool let_shadows_global_binding_p (Lisp_Object symbol) { struct specbinding *p; @@ -1118,14 +1118,15 @@ let_shadows_global_binding_p (Lisp_Object symbol) If buffer/frame-locality is an issue, WHERE specifies which context to use. (nil stands for the current buffer/frame). - If BINDFLAG is zero, then if this symbol is supposed to become + If BINDFLAG is false, then if this symbol is supposed to become local in every buffer where it is set, then we make it local. - If BINDFLAG is nonzero, we don't do that. */ + If BINDFLAG is true, we don't do that. */ void -set_internal (register Lisp_Object symbol, register Lisp_Object newval, register Lisp_Object where, int bindflag) +set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, + bool bindflag) { - int voide = EQ (newval, Qunbound); + bool voide = EQ (newval, Qunbound); struct Lisp_Symbol *sym; Lisp_Object tem1; @@ -1464,7 +1465,8 @@ union Lisp_Val_Fwd }; static struct Lisp_Buffer_Local_Value * -make_blv (struct Lisp_Symbol *sym, int forwarded, union Lisp_Val_Fwd valcontents) +make_blv (struct Lisp_Symbol *sym, bool forwarded, + union Lisp_Val_Fwd valcontents) { struct Lisp_Buffer_Local_Value *blv = xmalloc (sizeof *blv); Lisp_Object symbol; @@ -1508,7 +1510,7 @@ The function `default-value' gets the default value and `set-default' sets it. struct Lisp_Symbol *sym; struct Lisp_Buffer_Local_Value *blv = NULL; union Lisp_Val_Fwd valcontents IF_LINT (= {LISP_INITIALLY_ZERO}); - int forwarded IF_LINT (= 0); + bool forwarded IF_LINT (= 0); CHECK_SYMBOL (variable); sym = XSYMBOL (variable); @@ -1580,10 +1582,10 @@ See also `make-variable-buffer-local'. Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. */) - (register Lisp_Object variable) + (Lisp_Object variable) { - register Lisp_Object tem; - int forwarded IF_LINT (= 0); + Lisp_Object tem; + bool forwarded IF_LINT (= 0); union Lisp_Val_Fwd valcontents IF_LINT (= {LISP_INITIALLY_ZERO}); struct Lisp_Symbol *sym; struct Lisp_Buffer_Local_Value *blv = NULL; @@ -1767,9 +1769,9 @@ is to set the VARIABLE frame parameter of that frame. See Note that since Emacs 23.1, variables cannot be both buffer-local and frame-local any more (buffer-local bindings used to take precedence over frame-local bindings). */) - (register Lisp_Object variable) + (Lisp_Object variable) { - int forwarded; + bool forwarded; union Lisp_Val_Fwd valcontents; struct Lisp_Symbol *sym; struct Lisp_Buffer_Local_Value *blv = NULL; @@ -2225,7 +2227,7 @@ static Lisp_Object arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison) { double f1 = 0, f2 = 0; - int floatp = 0; + bool floatp = 0; CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1); CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2); @@ -2342,7 +2344,7 @@ DEFUN ("zerop", Fzerop, Szerop, 1, 1, 0, uintmax_t cons_to_unsigned (Lisp_Object c, uintmax_t max) { - int valid = 0; + bool valid = 0; uintmax_t val IF_LINT (= 0); if (INTEGERP (c)) { @@ -2395,7 +2397,7 @@ cons_to_unsigned (Lisp_Object c, uintmax_t max) intmax_t cons_to_signed (Lisp_Object c, intmax_t min, intmax_t max) { - int valid = 0; + bool valid = 0; intmax_t val IF_LINT (= 0); if (INTEGERP (c)) { @@ -2513,14 +2515,11 @@ static Lisp_Object float_arith_driver (double, ptrdiff_t, enum arithop, static Lisp_Object arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args) { - register Lisp_Object val; - ptrdiff_t argnum; - register EMACS_INT accum = 0; - register EMACS_INT next; - - int overflow = 0; - ptrdiff_t ok_args; - EMACS_INT ok_accum; + Lisp_Object val; + ptrdiff_t argnum, ok_args; + EMACS_INT accum = 0; + EMACS_INT next, ok_accum; + bool overflow = 0; switch (code) { diff --git a/src/dbusbind.c b/src/dbusbind.c index f63f294830..901820648c 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -70,7 +70,7 @@ static Lisp_Object QCdbus_registered_signal; static Lisp_Object xd_registered_buses; /* Whether we are reading a D-Bus event. */ -static int xd_in_read_queued_messages = 0; +static bool xd_in_read_queued_messages = 0; /* We use "xd_" and "XD_" as prefix for all internal symbols, because @@ -997,8 +997,7 @@ xd_find_watch_fd (DBusWatch *watch) } /* Prototype. */ -static void -xd_read_queued_messages (int fd, void *data, int for_read); +static void xd_read_queued_messages (int fd, void *data); /* Start monitoring WATCH for possible I/O. */ static dbus_bool_t @@ -1686,7 +1685,7 @@ xd_read_message (Lisp_Object bus) /* Callback called when something is ready to read or write. */ static void -xd_read_queued_messages (int fd, void *data, int for_read) +xd_read_queued_messages (int fd, void *data) { Lisp_Object busp = xd_registered_buses; Lisp_Object bus = Qnil; diff --git a/src/dired.c b/src/dired.c index 771230717e..206f370ed6 100644 --- a/src/dired.c +++ b/src/dired.c @@ -109,18 +109,20 @@ directory_files_internal_unwind (Lisp_Object dh) } /* Function shared by Fdirectory_files and Fdirectory_files_and_attributes. - When ATTRS is zero, return a list of directory filenames; when - non-zero, return a list of directory filenames and their attributes. + If not ATTRS, return a list of directory filenames; + if ATTRS, return a list of directory filenames and their attributes. In the latter case, ID_FORMAT is passed to Ffile_attributes. */ Lisp_Object -directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object match, Lisp_Object nosort, int attrs, Lisp_Object id_format) +directory_files_internal (Lisp_Object directory, Lisp_Object full, + Lisp_Object match, Lisp_Object nosort, bool attrs, + Lisp_Object id_format) { DIR *d; ptrdiff_t directory_nbytes; Lisp_Object list, dirfilename, encoded_directory; struct re_pattern_buffer *bufp = NULL; - int needsep = 0; + bool needsep = 0; ptrdiff_t count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; DIRENTRY *dp; @@ -227,7 +229,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object m if (DIRENTRY_NONEMPTY (dp)) { ptrdiff_t len; - int wanted = 0; + bool wanted = 0; Lisp_Object name, finalname; struct gcpro gcpro1, gcpro2; @@ -381,9 +383,8 @@ which see. */) } -static Lisp_Object file_name_completion - (Lisp_Object file, Lisp_Object dirname, int all_flag, int ver_flag, - Lisp_Object predicate); +static Lisp_Object file_name_completion (Lisp_Object, Lisp_Object, bool, + Lisp_Object); DEFUN ("file-name-completion", Ffile_name_completion, Sfile_name_completion, 2, 3, 0, @@ -415,7 +416,7 @@ determined by the variable `completion-ignored-extensions', which see. */) if (!NILP (handler)) return call4 (handler, Qfile_name_completion, file, directory, predicate); - return file_name_completion (file, directory, 0, 0, predicate); + return file_name_completion (file, directory, 0, predicate); } DEFUN ("file-name-all-completions", Ffile_name_all_completions, @@ -439,14 +440,15 @@ These are all file names in directory DIRECTORY which begin with FILE. */) if (!NILP (handler)) return call3 (handler, Qfile_name_all_completions, file, directory); - return file_name_completion (file, directory, 1, 0, Qnil); + return file_name_completion (file, directory, 1, Qnil); } static int file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, struct stat *st_addr); static Lisp_Object Qdefault_directory; static Lisp_Object -file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int ver_flag, Lisp_Object predicate) +file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag, + Lisp_Object predicate) { DIR *d; ptrdiff_t bestmatchsize = 0; @@ -459,10 +461,10 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v Lisp_Object encoded_dir; struct stat st; int directoryp; - /* If includeall is zero, exclude files in completion-ignored-extensions as + /* If not INCLUDEALL, exclude files in completion-ignored-extensions as well as "." and "..". Until shown otherwise, assume we can't exclude anything. */ - int includeall = 1; + bool includeall = 1; ptrdiff_t count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; @@ -500,7 +502,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v { DIRENTRY *dp; ptrdiff_t len; - int canexclude = 0; + bool canexclude = 0; errno = 0; dp = readdir (d); diff --git a/src/lisp.h b/src/lisp.h index 9ae24998aa..127177e44c 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2620,7 +2620,7 @@ extern _Noreturn void args_out_of_range_3 (Lisp_Object, Lisp_Object, Lisp_Object); extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object); extern Lisp_Object do_symval_forwarding (union Lisp_Fwd *); -extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, int); +extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, bool); extern void syms_of_data (void); extern void init_data (void); extern void swap_in_global_binding (struct Lisp_Symbol *); @@ -3434,7 +3434,7 @@ extern void syms_of_ccl (void); extern void syms_of_dired (void); extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, - int, Lisp_Object); + bool, Lisp_Object); /* Defined in term.c */ extern int *char_ins_del_vector; diff --git a/src/process.c b/src/process.c index 7f6f6bafbe..64c70c4959 100644 --- a/src/process.c +++ b/src/process.c @@ -4870,15 +4870,13 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, for (channel = 0; channel <= max_input_desc; ++channel) { struct fd_callback_data *d = &fd_callback_info[channel]; - if (FD_ISSET (channel, &Available) - && d->func != 0 - && (d->condition & FOR_READ) != 0) - d->func (channel, d->data, 1); - if (FD_ISSET (channel, &write_mask) - && d->func != 0 - && (d->condition & FOR_WRITE) != 0) - d->func (channel, d->data, 0); - } + if (d->func + && ((d->condition & FOR_READ + && FD_ISSET (channel, &Available)) + || (d->condition & FOR_WRITE + && FD_ISSET (channel, &write_mask)))) + d->func (channel, d->data); + } for (channel = 0; channel <= max_process_desc; channel++) { diff --git a/src/process.h b/src/process.h index b963f4ca05..ce3d2e702c 100644 --- a/src/process.h +++ b/src/process.h @@ -219,7 +219,7 @@ extern void hold_keyboard_input (void); extern void unhold_keyboard_input (void); extern int kbd_on_hold_p (void); -typedef void (*fd_callback)(int fd, void *data, int for_read); +typedef void (*fd_callback) (int fd, void *data); extern void add_read_fd (int fd, fd_callback func, void *data); extern void delete_read_fd (int fd); diff --git a/src/xsmfns.c b/src/xsmfns.c index 1f6eb84260..cddbb2aae8 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c @@ -97,7 +97,7 @@ ice_connection_closed (void) open to a session manager, just return. */ static void -x_session_check_input (int fd, void *data, int for_read) +x_session_check_input (int fd, void *data) { int ret; -- 2.20.1