From a08d4ba773a70961d153bf213db68dfcc5a50b01 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 2 Sep 2012 00:10:10 -0700 Subject: [PATCH] * doc.c, editfns.c, insdel.c, intervals.c: Use bool for boolean. * doc.c (read_bytecode_char, get_doc_string, reread_doc_file) (Fdocumentation, Fdocumentation_property, Fsnarf_documentation) (Fsubstitute_command_keys): * editfns.c (region_limit, find_field, Fconstrain_to_field) (save_excursion_save, save_excursion_restore) (disassemble_lisp_time, decode_time_components, emacs_nmemftime) (format_time_string, general_insert_function) (make_buffer_string, make_buffer_string_both) (Fsubst_char_in_region, Ftranslate_region_internal, Fformat): * insdel.c (check_markers, gap_left, adjust_markers_for_insert) (copy_text, insert_1, insert_1_both, insert_from_string) (insert_from_string_before_markers, insert_from_string_1) (insert_from_buffer, insert_from_buffer_1, replace_range) (replace_range_2, del_range_1, del_range_byte, del_range_both) (del_range_2, modify_region): * intervals.c (intervals_equal, balance_possible_root_interval) (adjust_intervals_for_insertion, merge_properties_sticky) (graft_intervals_into_buffer, lookup_char_property) (adjust_for_invis_intang, set_point_both) (get_property_and_range, compare_string_intervals) (set_intervals_multibyte_1, set_intervals_multibyte): * keyboard.c (decode_timer): Use bool for boolean. * intervals.h, lisp.h, systime.h: Reflect above API changes. * editfns.c (struct info): Use 1-bit unsigned bitfields for booleans. --- src/ChangeLog | 29 ++++++++++++++++ src/doc.c | 39 ++++++++++----------- src/editfns.c | 91 +++++++++++++++++++++++++------------------------ src/insdel.c | 72 ++++++++++++++++++-------------------- src/intervals.c | 58 +++++++++++++++---------------- src/intervals.h | 14 ++++---- src/keyboard.c | 7 ++-- src/lisp.h | 34 +++++++++--------- src/systime.h | 4 +-- 9 files changed, 184 insertions(+), 164 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index cb1ef00a542..0bcfa6c85f6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,32 @@ +2012-09-02 Paul Eggert + + * doc.c, editfns.c, insdel.c, intervals.c: Use bool for boolean. + * doc.c (read_bytecode_char, get_doc_string, reread_doc_file) + (Fdocumentation, Fdocumentation_property, Fsnarf_documentation) + (Fsubstitute_command_keys): + * editfns.c (region_limit, find_field, Fconstrain_to_field) + (save_excursion_save, save_excursion_restore) + (disassemble_lisp_time, decode_time_components, emacs_nmemftime) + (format_time_string, general_insert_function) + (make_buffer_string, make_buffer_string_both) + (Fsubst_char_in_region, Ftranslate_region_internal, Fformat): + * insdel.c (check_markers, gap_left, adjust_markers_for_insert) + (copy_text, insert_1, insert_1_both, insert_from_string) + (insert_from_string_before_markers, insert_from_string_1) + (insert_from_buffer, insert_from_buffer_1, replace_range) + (replace_range_2, del_range_1, del_range_byte, del_range_both) + (del_range_2, modify_region): + * intervals.c (intervals_equal, balance_possible_root_interval) + (adjust_intervals_for_insertion, merge_properties_sticky) + (graft_intervals_into_buffer, lookup_char_property) + (adjust_for_invis_intang, set_point_both) + (get_property_and_range, compare_string_intervals) + (set_intervals_multibyte_1, set_intervals_multibyte): + * keyboard.c (decode_timer): + Use bool for boolean. + * intervals.h, lisp.h, systime.h: Reflect above API changes. + * editfns.c (struct info): Use 1-bit unsigned bitfields for booleans. + 2012-09-02 Chong Yidong * keymap.c (push_key_description): Print M-TAB as C-M-i diff --git a/src/doc.c b/src/doc.c index ed311d918d7..b4eadfff875 100644 --- a/src/doc.c +++ b/src/doc.c @@ -48,7 +48,7 @@ static unsigned char *read_bytecode_pointer; If UNREADFLAG is 1, we unread a byte. */ int -read_bytecode_char (int unreadflag) +read_bytecode_char (bool unreadflag) { if (unreadflag) { @@ -70,20 +70,18 @@ read_bytecode_char (int unreadflag) (e.g. because the file has been modified and the location is stale), return nil. - If UNIBYTE is nonzero, always make a unibyte string. + If UNIBYTE, always make a unibyte string. - If DEFINITION is nonzero, assume this is for reading + If DEFINITION, assume this is for reading a dynamic function definition; convert the bytestring and the constants vector with appropriate byte handling, and return a cons cell. */ Lisp_Object -get_doc_string (Lisp_Object filepos, int unibyte, int definition) +get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) { - char *from, *to; - register int fd; - register char *name; - register char *p, *p1; + char *from, *to, *name, *p, *p1; + int fd; ptrdiff_t minsize; int offset; EMACS_INT position; @@ -302,7 +300,7 @@ read_doc_string (Lisp_Object filepos) return get_doc_string (filepos, 0, 1); } -static int +static bool reread_doc_file (Lisp_Object file) { #if 0 @@ -335,7 +333,7 @@ string is passed through `substitute-command-keys'. */) Lisp_Object fun; Lisp_Object funcar; Lisp_Object doc; - int try_reload = 1; + bool try_reload = 1; documentation: @@ -467,7 +465,7 @@ This differs from `get' in that it can refer to strings stored in the aren't strings. */) (Lisp_Object symbol, Lisp_Object prop, Lisp_Object raw) { - int try_reload = 1; + bool try_reload = 1; Lisp_Object tem; documentation_property: @@ -562,12 +560,11 @@ the same file name is found in the `doc-directory'. */) { int fd; char buf[1024 + 1]; - register int filled; - register EMACS_INT pos; - register char *p; + int filled; + EMACS_INT pos; Lisp_Object sym; - char *name; - int skip_file = 0; + char *p, *name; + bool skip_file = 0; CHECK_STRING (filename); @@ -722,9 +719,9 @@ Otherwise, return a new string, without any text properties. */) (Lisp_Object string) { char *buf; - int changed = 0; - register unsigned char *strp; - register char *bufp; + bool changed = 0; + unsigned char *strp; + char *bufp; ptrdiff_t idx; ptrdiff_t bsize; Lisp_Object tem; @@ -733,7 +730,7 @@ Otherwise, return a new string, without any text properties. */) ptrdiff_t length, length_byte; Lisp_Object name; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; - int multibyte; + bool multibyte; ptrdiff_t nchars; if (NILP (string)) @@ -787,7 +784,7 @@ Otherwise, return a new string, without any text properties. */) else if (strp[0] == '\\' && strp[1] == '[') { ptrdiff_t start_idx; - int follow_remap = 1; + bool follow_remap = 1; changed = 1; strp += 2; /* skip \[ */ diff --git a/src/editfns.c b/src/editfns.c index 7b451e4e443..a14e043c1bf 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -65,7 +65,7 @@ extern Lisp_Object w32_get_internal_run_time (void); #endif static Lisp_Object format_time_string (char const *, ptrdiff_t, EMACS_TIME, - int, struct tm *); + bool, struct tm *); static int tm_diff (struct tm *, struct tm *); static void update_buffer_properties (ptrdiff_t, ptrdiff_t); @@ -246,11 +246,11 @@ The return value is POSITION. */) /* Return the start or end position of the region. - BEGINNINGP non-zero means return the start. + BEGINNINGP means return the start. If there is no region active, signal an error. */ static Lisp_Object -region_limit (int beginningp) +region_limit (bool beginningp) { Lisp_Object m; @@ -264,7 +264,7 @@ region_limit (int beginningp) error ("The mark is not set now, so there is no region"); /* Clip to the current narrowing (bug#11770). */ - return make_number ((PT < XFASTINT (m)) == (beginningp != 0) + return make_number ((PT < XFASTINT (m)) == beginningp ? PT : clip_to_bounds (BEGV, XFASTINT (m), ZV)); } @@ -435,12 +435,12 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o BEG_LIMIT and END_LIMIT serve to limit the ranged of the returned results; they do not effect boundary behavior. - If MERGE_AT_BOUNDARY is nonzero, then if POS is at the very first + If MERGE_AT_BOUNDARY is non-nil, then if POS is at the very first position of a field, then the beginning of the previous field is returned instead of the beginning of POS's field (since the end of a field is actually also the beginning of the next input field, this behavior is sometimes useful). Additionally in the MERGE_AT_BOUNDARY - true case, if two fields are separated by a field with the special + non-nil case, if two fields are separated by a field with the special value `boundary', and POS lies within it, then the two separated fields are considered to be adjacent, and POS between them, when finding the beginning and ending of the "merged" field. @@ -455,10 +455,10 @@ find_field (Lisp_Object pos, Lisp_Object merge_at_boundary, { /* Fields right before and after the point. */ Lisp_Object before_field, after_field; - /* 1 if POS counts as the start of a field. */ - int at_field_start = 0; - /* 1 if POS counts as the end of a field. */ - int at_field_end = 0; + /* True if POS counts as the start of a field. */ + bool at_field_start = 0; + /* True if POS counts as the end of a field. */ + bool at_field_end = 0; if (NILP (pos)) XSETFASTINT (pos, PT); @@ -502,19 +502,19 @@ find_field (Lisp_Object pos, Lisp_Object merge_at_boundary, xxxx.yyyy - In this situation, if merge_at_boundary is true, we consider the + In this situation, if merge_at_boundary is non-nil, consider the `x' and `y' fields as forming one big merged field, and so the end of the field is the end of `y'. However, if `x' and `y' are separated by a special `boundary' field - (a field with a `field' char-property of 'boundary), then we ignore + (a field with a `field' char-property of 'boundary), then ignore this special field when merging adjacent fields. Here's the same situation, but with a `boundary' field between the `x' and `y' fields: xxx.BBBByyyy Here, if point is at the end of `x', the beginning of `y', or - anywhere in-between (within the `boundary' field), we merge all + anywhere in-between (within the `boundary' field), merge all three fields and consider the beginning as being the beginning of the `x' field, and the end as being the end of the `y' field. */ @@ -658,7 +658,7 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */) { /* If non-zero, then the original point, before re-positioning. */ ptrdiff_t orig_point = 0; - int fwd; + bool fwd; Lisp_Object prev_old, prev_new; if (NILP (new_pos)) @@ -816,8 +816,8 @@ This function does not move point. */) Lisp_Object save_excursion_save (void) { - int visible = (XBUFFER (XWINDOW (selected_window)->buffer) - == current_buffer); + bool visible = (XBUFFER (XWINDOW (selected_window)->buffer) + == current_buffer); return Fcons (Fpoint_marker (), Fcons (Fcopy_marker (BVAR (current_buffer, mark), Qnil), @@ -831,7 +831,7 @@ save_excursion_restore (Lisp_Object info) { Lisp_Object tem, tem1, omark, nmark; struct gcpro gcpro1, gcpro2, gcpro3; - int visible_p; + bool visible_p; tem = Fmarker_buffer (XCAR (info)); /* If buffer being returned to is now deleted, avoid error */ @@ -1467,8 +1467,8 @@ make_lisp_time (EMACS_TIME t) /* Decode a Lisp list SPECIFIED_TIME that represents a time. Set *PHIGH, *PLOW, *PUSEC, *PPSEC to its parts; do not check their values. - Return nonzero if successful. */ -static int + Return true if successful. */ +static bool disassemble_lisp_time (Lisp_Object specified_time, Lisp_Object *phigh, Lisp_Object *plow, Lisp_Object *pusec, Lisp_Object *ppsec) @@ -1511,8 +1511,8 @@ disassemble_lisp_time (Lisp_Object specified_time, Lisp_Object *phigh, If *DRESULT is not null, store into *DRESULT the number of seconds since the start of the POSIX Epoch. - Return nonzero if successful. */ -int + Return true if successful. */ +bool decode_time_components (Lisp_Object high, Lisp_Object low, Lisp_Object usec, Lisp_Object psec, EMACS_TIME *result, double *dresult) @@ -1632,7 +1632,7 @@ or (if you need time as a string) `format-time-string'. */) /* Write information into buffer S of size MAXSIZE, according to the FORMAT of length FORMAT_LEN, using time information taken from *TP. - Default to Universal Time if UT is nonzero, local time otherwise. + Default to Universal Time if UT, local time otherwise. Use NS as the number of nanoseconds in the %N directive. Return the number of bytes written, not including the terminating '\0'. If S is NULL, nothing will be written anywhere; so to @@ -1643,7 +1643,7 @@ or (if you need time as a string) `format-time-string'. */) bytes in FORMAT and it does not support nanoseconds. */ static size_t emacs_nmemftime (char *s, size_t maxsize, const char *format, - size_t format_len, const struct tm *tp, int ut, int ns) + size_t format_len, const struct tm *tp, bool ut, int ns) { size_t total = 0; @@ -1748,7 +1748,7 @@ usage: (format-time-string FORMAT-STRING &optional TIME UNIVERSAL) */) static Lisp_Object format_time_string (char const *format, ptrdiff_t formatlen, - EMACS_TIME t, int ut, struct tm *tmp) + EMACS_TIME t, bool ut, struct tm *tmp) { char buffer[4000]; char *buf = buffer; @@ -2228,11 +2228,11 @@ general_insert_function (void (*insert_func) (const char *, ptrdiff_t), void (*insert_from_string_func) (Lisp_Object, ptrdiff_t, ptrdiff_t, - ptrdiff_t, ptrdiff_t, int), - int inherit, ptrdiff_t nargs, Lisp_Object *args) + ptrdiff_t, ptrdiff_t, bool), + bool inherit, ptrdiff_t nargs, Lisp_Object *args) { ptrdiff_t argnum; - register Lisp_Object val; + Lisp_Object val; for (argnum = 0; argnum < nargs; argnum++) { @@ -2455,7 +2455,7 @@ from adjoining text, if those properties are sticky. */) /* Return a Lisp_String containing the text of the current buffer from START to END. If text properties are in use and the current buffer has properties in the range specified, the resulting string will also - have them, if PROPS is nonzero. + have them, if PROPS is true. We don't want to use plain old make_string here, because it calls make_uninit_string, which can cause the buffer arena to be @@ -2466,7 +2466,7 @@ from adjoining text, if those properties are sticky. */) buffer substrings. */ Lisp_Object -make_buffer_string (ptrdiff_t start, ptrdiff_t end, int props) +make_buffer_string (ptrdiff_t start, ptrdiff_t end, bool props) { ptrdiff_t start_byte = CHAR_TO_BYTE (start); ptrdiff_t end_byte = CHAR_TO_BYTE (end); @@ -2479,7 +2479,7 @@ make_buffer_string (ptrdiff_t start, ptrdiff_t end, int props) If text properties are in use and the current buffer has properties in the range specified, the resulting string will also - have them, if PROPS is nonzero. + have them, if PROPS is true. We don't want to use plain old make_string here, because it calls make_uninit_string, which can cause the buffer arena to be @@ -2491,7 +2491,7 @@ make_buffer_string (ptrdiff_t start, ptrdiff_t end, int props) Lisp_Object make_buffer_string_both (ptrdiff_t start, ptrdiff_t start_byte, - ptrdiff_t end, ptrdiff_t end_byte, int props) + ptrdiff_t end, ptrdiff_t end_byte, bool props) { Lisp_Object result, tem, tem1; @@ -2842,7 +2842,8 @@ Both characters must have the same length of multi-byte form. */) #define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER) int maybe_byte_combining = COMBINING_NO; ptrdiff_t last_changed = 0; - int multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); + bool multibyte_p + = !NILP (BVAR (current_buffer, enable_multibyte_characters)); int fromc, toc; restart: @@ -3078,8 +3079,8 @@ It returns the number of characters changed. */) int cnt; /* Number of changes made. */ ptrdiff_t size; /* Size of translate table. */ ptrdiff_t pos, pos_byte, end_pos; - int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); - int string_multibyte IF_LINT (= 0); + bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); + bool string_multibyte IF_LINT (= 0); validate_region (&start, &end); if (CHAR_TABLE_P (table)) @@ -3650,9 +3651,9 @@ usage: (format STRING &rest OBJECTS) */) byte combining problem, i.e., a byte may be combined with a multibyte character of the previous string. This flag tells if we must consider such a situation or not. */ - int maybe_combine_byte; + bool maybe_combine_byte; Lisp_Object val; - int arg_intervals = 0; + bool arg_intervals = 0; USE_SAFE_ALLOCA; /* discarded[I] is 1 if byte I of the format @@ -3668,8 +3669,8 @@ usage: (format STRING &rest OBJECTS) */) struct info { ptrdiff_t start, end; - int converted_to_string; - int intervals; + unsigned converted_to_string : 1; + unsigned intervals : 1; } *info = 0; /* It should not be necessary to GCPRO ARGS, because @@ -3746,13 +3747,13 @@ usage: (format STRING &rest OBJECTS) */) digits to print after the '.' for floats, or the max. number of chars to print from a string. */ - int minus_flag = 0; - int plus_flag = 0; - int space_flag = 0; - int sharp_flag = 0; - int zero_flag = 0; + bool minus_flag = 0; + bool plus_flag = 0; + bool space_flag = 0; + bool sharp_flag = 0; + bool zero_flag = 0; ptrdiff_t field_width; - int precision_given; + bool precision_given; uintmax_t precision = UINTMAX_MAX; char *num_end; char conversion; @@ -4132,7 +4133,7 @@ usage: (format STRING &rest OBJECTS) */) char *src = sprintf_buf; char src0 = src[0]; int exponent_bytes = 0; - int signedp = src0 == '-' || src0 == '+' || src0 == ' '; + bool signedp = src0 == '-' || src0 == '+' || src0 == ' '; int significand_bytes; if (zero_flag && ((src[signedp] >= '0' && src[signedp] <= '9') diff --git a/src/insdel.c b/src/insdel.c index 8cb98566085..da258c19a1e 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -31,19 +31,15 @@ along with GNU Emacs. If not, see . */ #include "blockinput.h" #include "region-cache.h" -static void insert_from_string_1 (Lisp_Object string, - ptrdiff_t pos, ptrdiff_t pos_byte, - ptrdiff_t nchars, ptrdiff_t nbytes, - int inherit, int before_markers); -static void insert_from_buffer_1 (struct buffer *buf, - ptrdiff_t from, ptrdiff_t nchars, - int inherit); -static void gap_left (ptrdiff_t charpos, ptrdiff_t bytepos, int newgap); -static void gap_right (ptrdiff_t charpos, ptrdiff_t bytepos); +static void insert_from_string_1 (Lisp_Object, ptrdiff_t, ptrdiff_t, ptrdiff_t, + ptrdiff_t, bool, bool); +static void insert_from_buffer_1 (struct buffer *, ptrdiff_t, ptrdiff_t, bool); +static void gap_left (ptrdiff_t, ptrdiff_t, bool); +static void gap_right (ptrdiff_t, ptrdiff_t); /* List of elements of the form (BEG-UNCHANGED END-UNCHANGED CHANGE-AMOUNT) describing changes which happened while combine_after_change_calls - was nonzero. We use this to decide how to call them + was non-nil. We use this to decide how to call them once the deferral ends. In each element. @@ -67,8 +63,8 @@ static void signal_before_change (ptrdiff_t, ptrdiff_t, ptrdiff_t *); static void check_markers (void) { - register struct Lisp_Marker *tail; - int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); + struct Lisp_Marker *tail; + bool multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) { @@ -113,13 +109,13 @@ move_gap_both (ptrdiff_t charpos, ptrdiff_t bytepos) /* Move the gap to a position less than the current GPT. BYTEPOS describes the new position as a byte position, and CHARPOS is the corresponding char position. - If NEWGAP is nonzero, then don't update beg_unchanged and end_unchanged. */ + If NEWGAP, then don't update beg_unchanged and end_unchanged. */ static void -gap_left (ptrdiff_t charpos, ptrdiff_t bytepos, int newgap) +gap_left (ptrdiff_t charpos, ptrdiff_t bytepos, bool newgap) { - register unsigned char *to, *from; - register ptrdiff_t i; + unsigned char *to, *from; + ptrdiff_t i; ptrdiff_t new_s1; if (!newgap) @@ -287,10 +283,10 @@ adjust_markers_for_delete (ptrdiff_t from, ptrdiff_t from_byte, static void adjust_markers_for_insert (ptrdiff_t from, ptrdiff_t from_byte, - ptrdiff_t to, ptrdiff_t to_byte, int before_markers) + ptrdiff_t to, ptrdiff_t to_byte, bool before_markers) { struct Lisp_Marker *m; - int adjusted = 0; + bool adjusted = 0; ptrdiff_t nchars = to - from; ptrdiff_t nbytes = to_byte - from_byte; @@ -515,7 +511,7 @@ make_gap (ptrdiff_t nbytes_added) ptrdiff_t copy_text (const unsigned char *from_addr, unsigned char *to_addr, - ptrdiff_t nbytes, int from_multibyte, int to_multibyte) + ptrdiff_t nbytes, bool from_multibyte, bool to_multibyte) { if (from_multibyte == to_multibyte) { @@ -664,7 +660,7 @@ insert_before_markers_and_inherit (const char *string, void insert_1 (const char *string, ptrdiff_t nbytes, - int inherit, int prepare, int before_markers) + bool inherit, bool prepare, bool before_markers) { insert_1_both (string, chars_in_text ((unsigned char *) string, nbytes), nbytes, inherit, prepare, before_markers); @@ -790,7 +786,7 @@ count_combining_after (const unsigned char *string, void insert_1_both (const char *string, ptrdiff_t nchars, ptrdiff_t nbytes, - int inherit, int prepare, int before_markers) + bool inherit, bool prepare, bool before_markers) { if (nchars == 0) return; @@ -867,7 +863,7 @@ insert_1_both (const char *string, void insert_from_string (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, - ptrdiff_t length, ptrdiff_t length_byte, int inherit) + ptrdiff_t length, ptrdiff_t length_byte, bool inherit) { ptrdiff_t opoint = PT; @@ -887,7 +883,7 @@ void insert_from_string_before_markers (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t length, ptrdiff_t length_byte, - int inherit) + bool inherit) { ptrdiff_t opoint = PT; @@ -905,7 +901,7 @@ insert_from_string_before_markers (Lisp_Object string, static void insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t nchars, ptrdiff_t nbytes, - int inherit, int before_markers) + bool inherit, bool before_markers) { struct gcpro gcpro1; ptrdiff_t outgoing_nbytes = nbytes; @@ -1039,7 +1035,7 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes) void insert_from_buffer (struct buffer *buf, - ptrdiff_t charpos, ptrdiff_t nchars, int inherit) + ptrdiff_t charpos, ptrdiff_t nchars, bool inherit) { ptrdiff_t opoint = PT; @@ -1050,7 +1046,7 @@ insert_from_buffer (struct buffer *buf, static void insert_from_buffer_1 (struct buffer *buf, - ptrdiff_t from, ptrdiff_t nchars, int inherit) + ptrdiff_t from, ptrdiff_t nchars, bool inherit) { ptrdiff_t chunk, chunk_expanded; ptrdiff_t from_byte = buf_charpos_to_bytepos (buf, from); @@ -1265,7 +1261,7 @@ adjust_after_insert (ptrdiff_t from, ptrdiff_t from_byte, } /* Replace the text from character positions FROM to TO with NEW, - If PREPARE is nonzero, call prepare_to_modify_buffer. + If PREPARE, call prepare_to_modify_buffer. If INHERIT, the newly inserted text should inherit text properties from the surrounding non-deleted text. */ @@ -1278,7 +1274,7 @@ adjust_after_insert (ptrdiff_t from, ptrdiff_t from_byte, void replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new, - int prepare, int inherit, int markers) + bool prepare, bool inherit, bool markers) { ptrdiff_t inschars = SCHARS (new); ptrdiff_t insbytes = SBYTES (new); @@ -1443,7 +1439,7 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new, Note that this does not yet handle markers quite right. - If MARKERS is nonzero, relocate markers. + If MARKERS, relocate markers. Unlike most functions at this level, never call prepare_to_modify_buffer and never call signal_after_change. */ @@ -1452,7 +1448,7 @@ void replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t to, ptrdiff_t to_byte, const char *ins, ptrdiff_t inschars, ptrdiff_t insbytes, - int markers) + bool markers) { ptrdiff_t nbytes_del, nchars_del; @@ -1563,7 +1559,7 @@ del_range (ptrdiff_t from, ptrdiff_t to) RET_STRING says to return the deleted text. */ Lisp_Object -del_range_1 (ptrdiff_t from, ptrdiff_t to, int prepare, int ret_string) +del_range_1 (ptrdiff_t from, ptrdiff_t to, bool prepare, bool ret_string) { ptrdiff_t from_byte, to_byte; Lisp_Object deletion; @@ -1599,7 +1595,7 @@ del_range_1 (ptrdiff_t from, ptrdiff_t to, int prepare, int ret_string) /* Like del_range_1 but args are byte positions, not char positions. */ void -del_range_byte (ptrdiff_t from_byte, ptrdiff_t to_byte, int prepare) +del_range_byte (ptrdiff_t from_byte, ptrdiff_t to_byte, bool prepare) { ptrdiff_t from, to; @@ -1643,7 +1639,7 @@ del_range_byte (ptrdiff_t from_byte, ptrdiff_t to_byte, int prepare) void del_range_both (ptrdiff_t from, ptrdiff_t from_byte, - ptrdiff_t to, ptrdiff_t to_byte, int prepare) + ptrdiff_t to, ptrdiff_t to_byte, bool prepare) { /* Make args be valid */ if (from_byte < BEGV_BYTE) @@ -1685,13 +1681,13 @@ del_range_both (ptrdiff_t from, ptrdiff_t from_byte, /* Delete a range of text, specified both as character positions and byte positions. FROM and TO are character positions, while FROM_BYTE and TO_BYTE are byte positions. - If RET_STRING is true, the deleted area is returned as a string. */ + If RET_STRING, the deleted area is returned as a string. */ Lisp_Object del_range_2 (ptrdiff_t from, ptrdiff_t from_byte, - ptrdiff_t to, ptrdiff_t to_byte, int ret_string) + ptrdiff_t to, ptrdiff_t to_byte, bool ret_string) { - register ptrdiff_t nbytes_del, nchars_del; + ptrdiff_t nbytes_del, nchars_del; Lisp_Object deletion; check_markers (); @@ -1770,12 +1766,12 @@ del_range_2 (ptrdiff_t from, ptrdiff_t from_byte, and warns the next redisplay that it should pay attention to that area. - If PRESERVE_CHARS_MODIFF is non-zero, do not update CHARS_MODIFF. + If PRESERVE_CHARS_MODIFF, do not update CHARS_MODIFF. Otherwise set CHARS_MODIFF to the new value of MODIFF. */ void modify_region (struct buffer *buffer, ptrdiff_t start, ptrdiff_t end, - int preserve_chars_modiff) + bool preserve_chars_modiff) { struct buffer *old_buffer = current_buffer; diff --git a/src/intervals.c b/src/intervals.c index 0a85e20e5d9..49d61b2f9b0 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -178,14 +178,13 @@ merge_properties (register INTERVAL source, register INTERVAL target) } } -/* Return 1 if the two intervals have the same properties, - 0 otherwise. */ +/* Return true if the two intervals have the same properties. */ -int +bool intervals_equal (INTERVAL i0, INTERVAL i1) { - register Lisp_Object i0_cdr, i0_sym; - register Lisp_Object i1_cdr, i1_val; + Lisp_Object i0_cdr, i0_sym; + Lisp_Object i1_cdr, i1_val; if (DEFAULT_INTERVAL_P (i0) && DEFAULT_INTERVAL_P (i1)) return 1; @@ -469,10 +468,10 @@ balance_an_interval (INTERVAL i) Lisp Object. */ static inline INTERVAL -balance_possible_root_interval (register INTERVAL interval) +balance_possible_root_interval (INTERVAL interval) { Lisp_Object parent; - int have_parent = 0; + bool have_parent = 0; if (!INTERVAL_HAS_OBJECT (interval) && !INTERVAL_HAS_PARENT (interval)) return interval; @@ -845,9 +844,9 @@ static INTERVAL adjust_intervals_for_insertion (INTERVAL tree, ptrdiff_t position, ptrdiff_t length) { - register INTERVAL i; - register INTERVAL temp; - int eobp = 0; + INTERVAL i; + INTERVAL temp; + bool eobp = 0; Lisp_Object parent; ptrdiff_t offset; @@ -1068,11 +1067,10 @@ FR 8 9 A B static Lisp_Object merge_properties_sticky (Lisp_Object pleft, Lisp_Object pright) { - register Lisp_Object props, front, rear; + Lisp_Object props, front, rear; Lisp_Object lfront, lrear, rfront, rrear; - register Lisp_Object tail1, tail2, sym, lval, rval, cat; - int use_left, use_right; - int lpresent; + Lisp_Object tail1, tail2, sym, lval, rval, cat; + bool use_left, use_right, lpresent; props = Qnil; front = Qnil; @@ -1610,7 +1608,7 @@ reproduce_tree_obj (INTERVAL source, Lisp_Object parent) void graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position, ptrdiff_t length, struct buffer *buffer, - int inherit) + bool inherit) { INTERVAL tree = buffer_intervals (buffer); INTERVAL under, over, this; @@ -1753,9 +1751,9 @@ textget (Lisp_Object plist, register Lisp_Object prop) } Lisp_Object -lookup_char_property (Lisp_Object plist, register Lisp_Object prop, int textprop) +lookup_char_property (Lisp_Object plist, Lisp_Object prop, bool textprop) { - register Lisp_Object tail, fallback = Qnil; + Lisp_Object tail, fallback = Qnil; for (tail = plist; CONSP (tail); tail = Fcdr (XCDR (tail))) { @@ -1826,8 +1824,8 @@ set_point (ptrdiff_t charpos) /* If there's an invisible character at position POS + TEST_OFFS in the current buffer, and the invisible property has a `stickiness' such that inserting a character at position POS would inherit the property it, - return POS + ADJ, otherwise return POS. If TEST_INTANG is non-zero, - then intangibility is required as well as invisibility. + return POS + ADJ, otherwise return POS. If TEST_INTANG, intangibility + is required as well as invisibility. TEST_OFFS should be either 0 or -1, and ADJ should be either 1 or -1. @@ -1836,7 +1834,7 @@ set_point (ptrdiff_t charpos) static ptrdiff_t adjust_for_invis_intang (ptrdiff_t pos, ptrdiff_t test_offs, ptrdiff_t adj, - int test_intang) + bool test_intang) { Lisp_Object invis_propval, invis_overlay; Lisp_Object test_pos; @@ -1883,8 +1881,8 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos) initial position is the same as the destination, in the rare instances where this is important, e.g. in line-move-finish (simple.el). */ - int backwards = (charpos < old_position ? 1 : 0); - int have_overlays; + bool backwards = charpos < old_position; + bool have_overlays; ptrdiff_t original_position; bset_point_before_scroll (current_buffer, Qnil); @@ -2154,12 +2152,12 @@ move_if_not_intangible (ptrdiff_t position) /* If text at position POS has property PROP, set *VAL to the property value, *START and *END to the beginning and end of a region that - has the same property, and return 1. Otherwise return 0. + has the same property, and return true. Otherwise return false. OBJECT is the string or buffer to look for the property in; nil means the current buffer. */ -int +bool get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *val, ptrdiff_t *start, ptrdiff_t *end, Lisp_Object object) { @@ -2306,10 +2304,10 @@ copy_intervals_to_string (Lisp_Object string, struct buffer *buffer, set_string_intervals (string, interval_copy); } -/* Return 1 if strings S1 and S2 have identical properties; 0 otherwise. +/* Return true if strings S1 and S2 have identical properties. Assume they have identical characters. */ -int +bool compare_string_intervals (Lisp_Object s1, Lisp_Object s2) { INTERVAL i1, i2; @@ -2348,7 +2346,7 @@ compare_string_intervals (Lisp_Object s1, Lisp_Object s2) START_BYTE ... END_BYTE in bytes. */ static void -set_intervals_multibyte_1 (INTERVAL i, int multi_flag, +set_intervals_multibyte_1 (INTERVAL i, bool multi_flag, ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, ptrdiff_t end_byte) { @@ -2456,11 +2454,11 @@ set_intervals_multibyte_1 (INTERVAL i, int multi_flag, } /* Update the intervals of the current buffer - to fit the contents as multibyte (if MULTI_FLAG is 1) - or to fit them as non-multibyte (if MULTI_FLAG is 0). */ + to fit the contents as multibyte (if MULTI_FLAG) + or to fit them as non-multibyte (if not MULTI_FLAG). */ void -set_intervals_multibyte (int multi_flag) +set_intervals_multibyte (bool multi_flag) { INTERVAL i = buffer_intervals (current_buffer); diff --git a/src/intervals.h b/src/intervals.h index 01e72d7c9db..2b30101d0fa 100644 --- a/src/intervals.h +++ b/src/intervals.h @@ -227,7 +227,7 @@ extern INTERVAL make_interval (void); extern INTERVAL create_root_interval (Lisp_Object); extern void copy_properties (INTERVAL, INTERVAL); -extern int intervals_equal (INTERVAL, INTERVAL); +extern bool intervals_equal (INTERVAL, INTERVAL); extern void traverse_intervals (INTERVAL, ptrdiff_t, void (*) (INTERVAL, Lisp_Object), Lisp_Object); @@ -242,22 +242,22 @@ extern INTERVAL previous_interval (INTERVAL); extern INTERVAL merge_interval_left (INTERVAL); extern void offset_intervals (struct buffer *, ptrdiff_t, ptrdiff_t); extern void graft_intervals_into_buffer (INTERVAL, ptrdiff_t, ptrdiff_t, - struct buffer *, int); + struct buffer *, bool); extern void verify_interval_modification (struct buffer *, ptrdiff_t, ptrdiff_t); extern INTERVAL balance_intervals (INTERVAL); extern void copy_intervals_to_string (Lisp_Object, struct buffer *, ptrdiff_t, ptrdiff_t); extern INTERVAL copy_intervals (INTERVAL, ptrdiff_t, ptrdiff_t); -extern int compare_string_intervals (Lisp_Object, Lisp_Object); +extern bool compare_string_intervals (Lisp_Object, Lisp_Object); extern Lisp_Object textget (Lisp_Object, Lisp_Object); -extern Lisp_Object lookup_char_property (Lisp_Object, Lisp_Object, int); +extern Lisp_Object lookup_char_property (Lisp_Object, Lisp_Object, bool); extern void move_if_not_intangible (ptrdiff_t); -extern int get_property_and_range (ptrdiff_t, Lisp_Object, Lisp_Object *, - ptrdiff_t *, ptrdiff_t *, Lisp_Object); +extern bool get_property_and_range (ptrdiff_t, Lisp_Object, Lisp_Object *, + ptrdiff_t *, ptrdiff_t *, Lisp_Object); extern Lisp_Object get_local_map (ptrdiff_t, struct buffer *, Lisp_Object); extern INTERVAL update_interval (INTERVAL, ptrdiff_t); -extern void set_intervals_multibyte (int); +extern void set_intervals_multibyte (bool); extern INTERVAL validate_interval_range (Lisp_Object, Lisp_Object *, Lisp_Object *, int); extern INTERVAL interval_of (ptrdiff_t, Lisp_Object); diff --git a/src/keyboard.c b/src/keyboard.c index 7b1ea341e7f..ff2b75e351c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -4339,9 +4339,8 @@ struct input_event last_timer_event EXTERNALLY_VISIBLE; ...). Each element has the form (FUN . ARGS). */ Lisp_Object pending_funcalls; -/* If TIMER is a valid timer, return nonzero and place its value into - *RESULT. Otherwise return zero. */ -static int +/* Return true if TIMER is a valid timer, placing its value into *RESULT. */ +static bool decode_timer (Lisp_Object timer, EMACS_TIME *result) { Lisp_Object *vector; @@ -8445,7 +8444,7 @@ append_tool_bar_item (void) /* Append entries from tool_bar_item_properties to the end of tool_bar_items_vector. */ - vcopy (tool_bar_items_vector, ntool_bar_items, + vcopy (tool_bar_items_vector, ntool_bar_items, XVECTOR (tool_bar_item_properties)->contents, TOOL_BAR_ITEM_NSLOTS); ntool_bar_items += TOOL_BAR_ITEM_NSLOTS; } diff --git a/src/lisp.h b/src/lisp.h index 2815a2ae325..b906e4a1dfd 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2720,43 +2720,43 @@ extern void move_gap_both (ptrdiff_t, ptrdiff_t); extern _Noreturn void buffer_overflow (void); extern void make_gap (ptrdiff_t); extern ptrdiff_t copy_text (const unsigned char *, unsigned char *, - ptrdiff_t, int, int); + ptrdiff_t, bool, bool); extern int count_combining_before (const unsigned char *, ptrdiff_t, ptrdiff_t, ptrdiff_t); extern int count_combining_after (const unsigned char *, ptrdiff_t, ptrdiff_t, ptrdiff_t); extern void insert (const char *, ptrdiff_t); extern void insert_and_inherit (const char *, ptrdiff_t); -extern void insert_1 (const char *, ptrdiff_t, int, int, int); +extern void insert_1 (const char *, ptrdiff_t, bool, bool, bool); extern void insert_1_both (const char *, ptrdiff_t, ptrdiff_t, - int, int, int); + bool, bool, bool); extern void insert_from_gap (ptrdiff_t, ptrdiff_t); extern void insert_from_string (Lisp_Object, ptrdiff_t, ptrdiff_t, - ptrdiff_t, ptrdiff_t, int); -extern void insert_from_buffer (struct buffer *, ptrdiff_t, ptrdiff_t, int); + ptrdiff_t, ptrdiff_t, bool); +extern void insert_from_buffer (struct buffer *, ptrdiff_t, ptrdiff_t, bool); extern void insert_char (int); extern void insert_string (const char *); extern void insert_before_markers (const char *, ptrdiff_t); extern void insert_before_markers_and_inherit (const char *, ptrdiff_t); extern void insert_from_string_before_markers (Lisp_Object, ptrdiff_t, ptrdiff_t, ptrdiff_t, - ptrdiff_t, int); + ptrdiff_t, bool); extern void del_range (ptrdiff_t, ptrdiff_t); -extern Lisp_Object del_range_1 (ptrdiff_t, ptrdiff_t, int, int); -extern void del_range_byte (ptrdiff_t, ptrdiff_t, int); -extern void del_range_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, int); +extern Lisp_Object del_range_1 (ptrdiff_t, ptrdiff_t, bool, bool); +extern void del_range_byte (ptrdiff_t, ptrdiff_t, bool); +extern void del_range_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, bool); extern Lisp_Object del_range_2 (ptrdiff_t, ptrdiff_t, - ptrdiff_t, ptrdiff_t, int); -extern void modify_region (struct buffer *, ptrdiff_t, ptrdiff_t, int); + ptrdiff_t, ptrdiff_t, bool); +extern void modify_region (struct buffer *, ptrdiff_t, ptrdiff_t, bool); extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *); extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t); extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t); extern void adjust_markers_for_delete (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t); -extern void replace_range (ptrdiff_t, ptrdiff_t, Lisp_Object, int, int, int); +extern void replace_range (ptrdiff_t, ptrdiff_t, Lisp_Object, bool, bool, bool); extern void replace_range_2 (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, - const char *, ptrdiff_t, ptrdiff_t, int); + const char *, ptrdiff_t, ptrdiff_t, bool); extern void syms_of_insdel (void); /* Defined in dispnew.c */ @@ -3094,9 +3094,9 @@ extern Lisp_Object save_restriction_save (void); extern Lisp_Object save_excursion_restore (Lisp_Object); extern Lisp_Object save_restriction_restore (Lisp_Object); extern _Noreturn void time_overflow (void); -extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, int); +extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool); extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, - ptrdiff_t, int); + ptrdiff_t, bool); extern void init_editfns (void); const char *get_system_name (void); extern void syms_of_editfns (void); @@ -3332,9 +3332,9 @@ extern void syms_of_callproc (void); /* Defined in doc.c */ extern Lisp_Object Qfunction_documentation; extern Lisp_Object read_doc_string (Lisp_Object); -extern Lisp_Object get_doc_string (Lisp_Object, int, int); +extern Lisp_Object get_doc_string (Lisp_Object, bool, bool); extern void syms_of_doc (void); -extern int read_bytecode_char (int); +extern int read_bytecode_char (bool); /* Defined in bytecode.c */ extern Lisp_Object Qbytecode; diff --git a/src/systime.h b/src/systime.h index d3bdeb83019..9ce7ce646fb 100644 --- a/src/systime.h +++ b/src/systime.h @@ -154,8 +154,8 @@ extern void set_waiting_for_input (EMACS_TIME *); #ifdef GCPRO1 /* defined in editfns.c */ extern Lisp_Object make_lisp_time (EMACS_TIME); -extern int decode_time_components (Lisp_Object, Lisp_Object, Lisp_Object, - Lisp_Object, EMACS_TIME *, double *); +extern bool decode_time_components (Lisp_Object, Lisp_Object, Lisp_Object, + Lisp_Object, EMACS_TIME *, double *); extern EMACS_TIME lisp_time_argument (Lisp_Object); #endif -- 2.39.2