From 2f221583cf4a4b412c16260d148b59931b12455a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 24 Aug 2012 20:11:12 -0700 Subject: [PATCH] * bytecode.c, callint.c, callproc.c: Use bool for boolean. * bytecode.c (exec_byte_code): * callint.c (check_mark, Fcall_interactively): * callproc.c (Fcall_process, add_env, child_setup, getenv_internal_1) (getenv_internal, sync_process_alive, call_process_exited): * lisp.h (USE_SAFE_ALLOCA): Use bool for booleans, instead of int. * lisp.h, process.h: Adjust prototypes to match above changes. * callint.c (Fcall_interactively): Don't assume the mark's offset fits in 'int'. --- src/ChangeLog | 13 +++++++++++++ src/bytecode.c | 2 +- src/callint.c | 16 ++++++++-------- src/callproc.c | 36 ++++++++++++++++++------------------ src/lisp.h | 4 ++-- src/process.h | 2 +- 6 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index feed9f8233e..95b9a57f24b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2012-08-25 Paul Eggert + + * bytecode.c, callint.c, callproc.c: Use bool for boolean. + * bytecode.c (exec_byte_code): + * callint.c (check_mark, Fcall_interactively): + * callproc.c (Fcall_process, add_env, child_setup, getenv_internal_1) + (getenv_internal, sync_process_alive, call_process_exited): + * lisp.h (USE_SAFE_ALLOCA): + Use bool for booleans, instead of int. + * lisp.h, process.h: Adjust prototypes to match above changes. + * callint.c (Fcall_interactively): Don't assume the mark's + offset fits in 'int'. + 2012-08-24 Paul Eggert * buffer.c, buffer.h: Use bool for boolean. diff --git a/src/bytecode.c b/src/bytecode.c index 5ac8b4fa2bd..753f149ae01 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -553,7 +553,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, if (INTEGERP (args_template)) { ptrdiff_t at = XINT (args_template); - int rest = at & 128; + bool rest = (at & 128) != 0; int mandatory = at & 127; ptrdiff_t nonrest = at >> 8; eassert (mandatory <= nonrest); diff --git a/src/callint.c b/src/callint.c index 36a59e812f2..b11545ddea2 100644 --- a/src/callint.c +++ b/src/callint.c @@ -150,7 +150,7 @@ static const char *callint_argfuns[] = {"", "point", "mark", "region-beginning", "region-end"}; static void -check_mark (int for_region) +check_mark (bool for_region) { Lisp_Object tem; tem = Fmarker_buffer (BVAR (current_buffer, mark)); @@ -273,11 +273,11 @@ invoke it. If KEYS is omitted or nil, the return value of signed char *varies; ptrdiff_t i, nargs; - int foo; - int arg_from_tty = 0; + ptrdiff_t mark; + bool arg_from_tty = 0; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; ptrdiff_t key_count; - int record_then_fail = 0; + bool record_then_fail = 0; Lisp_Object save_this_command, save_last_command; Lisp_Object save_this_original_command, save_real_this_command; @@ -685,7 +685,7 @@ invoke it. If KEYS is omitted or nil, the return value of goto have_prefix_arg; case 'n': /* Read number from minibuffer. */ { - int first = 1; + bool first = 1; do { Lisp_Object str; @@ -726,11 +726,11 @@ invoke it. If KEYS is omitted or nil, the return value of check_mark (1); set_marker_both (point_marker, Qnil, PT, PT_BYTE); /* visargs[i+1] = Qnil; */ - foo = marker_position (BVAR (current_buffer, mark)); + mark = marker_position (BVAR (current_buffer, mark)); /* visargs[i] = Qnil; */ - args[i] = PT < foo ? point_marker : BVAR (current_buffer, mark); + args[i] = PT < mark ? point_marker : BVAR (current_buffer, mark); varies[i] = 3; - args[++i] = PT > foo ? point_marker : BVAR (current_buffer, mark); + args[++i] = PT > mark ? point_marker : BVAR (current_buffer, mark); varies[i] = 4; break; diff --git a/src/callproc.c b/src/callproc.c index 4bf1da04e1a..2e9a8950700 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -77,7 +77,7 @@ static Lisp_Object Vtemp_file_name_pattern; /* True if we are about to fork off a synchronous process or if we are waiting for it. */ -int synch_process_alive; +bool synch_process_alive; /* Nonzero => this is a string explaining death of synchronous subprocess. */ const char *synch_process_death; @@ -94,8 +94,8 @@ int synch_process_retcode; On MSDOS, delete the temporary file on any kind of termination. On Unix, kill the process and any children on termination by signal. */ -/* Nonzero if this is termination due to exit. */ -static int call_process_exited; +/* True if this is termination due to exit. */ +static bool call_process_exited; static Lisp_Object call_process_kill (Lisp_Object fdpid) @@ -190,7 +190,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object infile, buffer, current_dir, path, cleanup_info_tail; - int display_p; + bool display_p; int fd[2]; int filefd; #define CALLPROC_BUFFER_SIZE_MIN (16 * 1024) @@ -217,7 +217,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) struct coding_system argument_coding; /* coding-system of arguments */ /* Set to the return value of Ffind_operation_coding_system. */ Lisp_Object coding_systems; - int output_to_buffer = 1; + bool output_to_buffer = 1; /* Qt denotes that Ffind_operation_coding_system is not yet called. */ coding_systems = Qt; @@ -241,7 +241,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) /* If arguments are supplied, we may have to encode them. */ if (nargs >= 5) { - int must_encode = 0; + bool must_encode = 0; Lisp_Object coding_attrs; for (i = 4; i < nargs; i++) @@ -610,12 +610,12 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) Lisp_Object volatile buffer_volatile = buffer; Lisp_Object volatile coding_systems_volatile = coding_systems; Lisp_Object volatile current_dir_volatile = current_dir; - int volatile display_p_volatile = display_p; + bool volatile display_p_volatile = display_p; + bool volatile output_to_buffer_volatile = output_to_buffer; + bool volatile sa_must_free_volatile = sa_must_free; int volatile fd1_volatile = fd1; int volatile fd_error_volatile = fd_error; int volatile fd_output_volatile = fd_output; - int volatile output_to_buffer_volatile = output_to_buffer; - int volatile sa_must_free_volatile = sa_must_free; ptrdiff_t volatile sa_count_volatile = sa_count; unsigned char const **volatile new_argv_volatile = new_argv; @@ -766,11 +766,11 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) if (output_to_buffer) { - register int nread; - int first = 1; + int nread; + bool first = 1; EMACS_INT total_read = 0; int carryover = 0; - int display_on_the_fly = display_p; + bool display_on_the_fly = display_p; struct coding_system saved_coding; saved_coding = process_coding; @@ -1086,7 +1086,7 @@ static char ** add_env (char **env, char **new_env, char *string) { char **ep; - int ok = 1; + bool ok = 1; if (string == NULL) return new_env; @@ -1126,8 +1126,7 @@ add_env (char **env, char **new_env, char *string) Therefore, the superior process must save and restore the value of environ around the vfork and the call to this function. - SET_PGRP is nonzero if we should put the subprocess into a separate - process group. + If SET_PGRP, put the subprocess into a separate process group. CURRENT_DIR is an elisp string giving the path of the current directory the subprocess should have. Since we can't really signal @@ -1135,7 +1134,8 @@ add_env (char **env, char **new_env, char *string) executable directory by the parent. */ int -child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, Lisp_Object current_dir) +child_setup (int in, int out, int err, char **new_argv, bool set_pgrp, + Lisp_Object current_dir) { char **env; char *pwd_var; @@ -1394,7 +1394,7 @@ relocate_fd (int fd, int minfd) } #endif /* not WINDOWSNT */ -static int +static bool getenv_internal_1 (const char *var, ptrdiff_t varlen, char **value, ptrdiff_t *valuelen, Lisp_Object env) { @@ -1429,7 +1429,7 @@ getenv_internal_1 (const char *var, ptrdiff_t varlen, char **value, return 0; } -static int +static bool getenv_internal (const char *var, ptrdiff_t varlen, char **value, ptrdiff_t *valuelen, Lisp_Object frame) { diff --git a/src/lisp.h b/src/lisp.h index 7847d454bc1..ef167ba56c0 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3330,7 +3330,7 @@ extern void setup_process_coding_systems (Lisp_Object); #ifndef DOS_NT _Noreturn #endif -extern int child_setup (int, int, int, char **, int, Lisp_Object); +extern int child_setup (int, int, int, char **, bool, Lisp_Object); extern void init_callproc_1 (void); extern void init_callproc (void); extern void set_initial_environment (void); @@ -3586,7 +3586,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); extern void *record_xmalloc (size_t); #define USE_SAFE_ALLOCA \ - ptrdiff_t sa_count = SPECPDL_INDEX (); int sa_must_free = 0 + ptrdiff_t sa_count = SPECPDL_INDEX (); bool sa_must_free = 0 /* SAFE_ALLOCA allocates a simple buffer. */ diff --git a/src/process.h b/src/process.h index 55a572117c6..b963f4ca05c 100644 --- a/src/process.h +++ b/src/process.h @@ -184,7 +184,7 @@ pset_gnutls_cred_type (struct Lisp_Process *p, Lisp_Object val) /* True if we are about to fork off a synchronous process or if we are waiting for it. */ -extern int synch_process_alive; +extern bool synch_process_alive; /* Communicate exit status of sync process to from sigchld_handler to Fcall_process. */ -- 2.39.2