diff options
| author | Paul Eggert | 2013-03-08 13:37:41 -0800 |
|---|---|---|
| committer | Paul Eggert | 2013-03-08 13:37:41 -0800 |
| commit | 457882c20c301f076ff6a4ef7ffd78ed3d35e699 (patch) | |
| tree | f5295ec9fd8cdf57a90b99a52be684cf71b4361b /src | |
| parent | b5426561089d39f18b42bed9dbfcb531f43ed562 (diff) | |
| download | emacs-457882c20c301f076ff6a4ef7ffd78ed3d35e699.tar.gz emacs-457882c20c301f076ff6a4ef7ffd78ed3d35e699.zip | |
region-cache.c, scroll.c, search.c: Use bool for booleans.
* lisp.h (compile_pattern):
* scroll.c (do_scrolling, do_direct_scrolling):
* search.c (struct regexp_cache, compile_pattern_1)
(compile_pattern, string_match_1, search_command)
(trivial_regexp_p, search_buffer, Freplace_match, match_limit)
(search_regs_saved, Fregexp_quote):
Use bool for boolean.
* region-cache.c (region_cache_forward, region_cache_backward):
Fix comments to match code: these functions return int, not boolean.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 13 | ||||
| -rw-r--r-- | src/lisp.h | 2 | ||||
| -rw-r--r-- | src/region-cache.c | 10 | ||||
| -rw-r--r-- | src/scroll.c | 17 | ||||
| -rw-r--r-- | src/search.c | 64 |
5 files changed, 60 insertions, 46 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index fe084b160c4..69e8303111a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2013-03-08 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | region-cache.c, scroll.c, search.c: Use bool for booleans. | ||
| 4 | * lisp.h (compile_pattern): | ||
| 5 | * scroll.c (do_scrolling, do_direct_scrolling): | ||
| 6 | * search.c (struct regexp_cache, compile_pattern_1) | ||
| 7 | (compile_pattern, string_match_1, search_command) | ||
| 8 | (trivial_regexp_p, search_buffer, Freplace_match, match_limit) | ||
| 9 | (search_regs_saved, Fregexp_quote): | ||
| 10 | Use bool for boolean. | ||
| 11 | * region-cache.c (region_cache_forward, region_cache_backward): | ||
| 12 | Fix comments to match code: these functions return int, not boolean. | ||
| 13 | |||
| 1 | 2013-03-08 Dmitry Antipov <dmantipov@yandex.ru> | 14 | 2013-03-08 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 15 | ||
| 3 | * search.c (find_newline): Accept start and end byte positions | 16 | * search.c (find_newline): Accept start and end byte positions |
diff --git a/src/lisp.h b/src/lisp.h index 12906bfa33e..e4993866b1f 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3357,7 +3357,7 @@ extern void record_unwind_save_match_data (void); | |||
| 3357 | struct re_registers; | 3357 | struct re_registers; |
| 3358 | extern struct re_pattern_buffer *compile_pattern (Lisp_Object, | 3358 | extern struct re_pattern_buffer *compile_pattern (Lisp_Object, |
| 3359 | struct re_registers *, | 3359 | struct re_registers *, |
| 3360 | Lisp_Object, int, bool); | 3360 | Lisp_Object, bool, bool); |
| 3361 | extern ptrdiff_t fast_string_match (Lisp_Object, Lisp_Object); | 3361 | extern ptrdiff_t fast_string_match (Lisp_Object, Lisp_Object); |
| 3362 | extern ptrdiff_t fast_c_string_match_ignore_case (Lisp_Object, const char *, | 3362 | extern ptrdiff_t fast_c_string_match_ignore_case (Lisp_Object, const char *, |
| 3363 | ptrdiff_t); | 3363 | ptrdiff_t); |
diff --git a/src/region-cache.c b/src/region-cache.c index 14e6982cd9a..452a5b3a065 100644 --- a/src/region-cache.c +++ b/src/region-cache.c | |||
| @@ -695,8 +695,9 @@ know_region_cache (struct buffer *buf, struct region_cache *c, | |||
| 695 | 695 | ||
| 696 | /* Interface: using the cache. */ | 696 | /* Interface: using the cache. */ |
| 697 | 697 | ||
| 698 | /* Return true if the text immediately after POS in BUF is known, for | 698 | /* Return the value for the text immediately after POS in BUF if the value |
| 699 | the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest | 699 | is known, for the purposes of CACHE, and return zero otherwise. |
| 700 | If NEXT is non-zero, set *NEXT to the nearest | ||
| 700 | position after POS where the knowledge changes. */ | 701 | position after POS where the knowledge changes. */ |
| 701 | int | 702 | int |
| 702 | region_cache_forward (struct buffer *buf, struct region_cache *c, | 703 | region_cache_forward (struct buffer *buf, struct region_cache *c, |
| @@ -732,8 +733,9 @@ region_cache_forward (struct buffer *buf, struct region_cache *c, | |||
| 732 | } | 733 | } |
| 733 | } | 734 | } |
| 734 | 735 | ||
| 735 | /* Return true if the text immediately before POS in BUF is known, for | 736 | /* Return the value for the text immediately before POS in BUF if the |
| 736 | the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest | 737 | value is known, for the purposes of CACHE, and return zero |
| 738 | otherwise. If NEXT is non-zero, set *NEXT to the nearest | ||
| 737 | position before POS where the knowledge changes. */ | 739 | position before POS where the knowledge changes. */ |
| 738 | int region_cache_backward (struct buffer *buf, struct region_cache *c, | 740 | int region_cache_backward (struct buffer *buf, struct region_cache *c, |
| 739 | ptrdiff_t pos, ptrdiff_t *next) | 741 | ptrdiff_t pos, ptrdiff_t *next) |
diff --git a/src/scroll.c b/src/scroll.c index 9e11feb64d4..037e338c696 100644 --- a/src/scroll.c +++ b/src/scroll.c | |||
| @@ -246,9 +246,8 @@ do_scrolling (struct frame *frame, struct glyph_matrix *current_matrix, | |||
| 246 | struct matrix_elt *p; | 246 | struct matrix_elt *p; |
| 247 | int i, j, k; | 247 | int i, j, k; |
| 248 | 248 | ||
| 249 | /* Set to 1 if we have set a terminal window with | 249 | /* True if we have set a terminal window with set_terminal_window. */ |
| 250 | set_terminal_window. It's unsigned to work around GCC bug 48228. */ | 250 | bool terminal_window_p = 0; |
| 251 | unsigned int terminal_window_p = 0; | ||
| 252 | 251 | ||
| 253 | /* A queue for line insertions to be done. */ | 252 | /* A queue for line insertions to be done. */ |
| 254 | struct queue { int count, pos; }; | 253 | struct queue { int count, pos; }; |
| @@ -657,18 +656,16 @@ do_direct_scrolling (struct frame *frame, struct glyph_matrix *current_matrix, | |||
| 657 | alloca (window_size * sizeof *queue_start); | 656 | alloca (window_size * sizeof *queue_start); |
| 658 | struct alt_queue *queue = queue_start; | 657 | struct alt_queue *queue = queue_start; |
| 659 | 658 | ||
| 660 | /* Set to 1 if a terminal window has been set with | 659 | /* True if a terminal window has been set with set_terminal_window. */ |
| 661 | set_terminal_window: */ | 660 | bool terminal_window_p = 0; |
| 662 | int terminal_window_p = 0; | ||
| 663 | 661 | ||
| 664 | /* A nonzero value of write_follows indicates that a write has been | 662 | /* If true, a write has been selected, allowing either an insert or a |
| 665 | selected, allowing either an insert or a delete to be selected | 663 | delete to be selected next. If false, a delete cannot be selected |
| 666 | next. When write_follows is zero, a delete cannot be selected | ||
| 667 | unless j < i, and an insert cannot be selected unless i < j. | 664 | unless j < i, and an insert cannot be selected unless i < j. |
| 668 | This corresponds to a similar restriction (with the ordering | 665 | This corresponds to a similar restriction (with the ordering |
| 669 | reversed) in calculate_direct_scrolling, which is intended to | 666 | reversed) in calculate_direct_scrolling, which is intended to |
| 670 | ensure that lines marked as inserted will be blank. */ | 667 | ensure that lines marked as inserted will be blank. */ |
| 671 | int write_follows_p = 1; | 668 | bool write_follows_p = 1; |
| 672 | 669 | ||
| 673 | /* For each row in the new matrix what row of the old matrix it is. */ | 670 | /* For each row in the new matrix what row of the old matrix it is. */ |
| 674 | int *copy_from = alloca (window_size * sizeof *copy_from); | 671 | int *copy_from = alloca (window_size * sizeof *copy_from); |
diff --git a/src/search.c b/src/search.c index 8bcf556eeeb..c5ac7d494dc 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -49,8 +49,8 @@ struct regexp_cache | |||
| 49 | Lisp_Object syntax_table; | 49 | Lisp_Object syntax_table; |
| 50 | struct re_pattern_buffer buf; | 50 | struct re_pattern_buffer buf; |
| 51 | char fastmap[0400]; | 51 | char fastmap[0400]; |
| 52 | /* Nonzero means regexp was compiled to do full POSIX backtracking. */ | 52 | /* True means regexp was compiled to do full POSIX backtracking. */ |
| 53 | char posix; | 53 | bool posix; |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | /* The instances of that struct. */ | 56 | /* The instances of that struct. */ |
| @@ -100,7 +100,7 @@ static EMACS_INT boyer_moore (EMACS_INT, unsigned char *, ptrdiff_t, | |||
| 100 | ptrdiff_t, int); | 100 | ptrdiff_t, int); |
| 101 | static EMACS_INT search_buffer (Lisp_Object, ptrdiff_t, ptrdiff_t, | 101 | static EMACS_INT search_buffer (Lisp_Object, ptrdiff_t, ptrdiff_t, |
| 102 | ptrdiff_t, ptrdiff_t, EMACS_INT, int, | 102 | ptrdiff_t, ptrdiff_t, EMACS_INT, int, |
| 103 | Lisp_Object, Lisp_Object, int); | 103 | Lisp_Object, Lisp_Object, bool); |
| 104 | 104 | ||
| 105 | static _Noreturn void | 105 | static _Noreturn void |
| 106 | matcher_overflow (void) | 106 | matcher_overflow (void) |
| @@ -112,13 +112,14 @@ matcher_overflow (void) | |||
| 112 | PATTERN is the pattern to compile. | 112 | PATTERN is the pattern to compile. |
| 113 | CP is the place to put the result. | 113 | CP is the place to put the result. |
| 114 | TRANSLATE is a translation table for ignoring case, or nil for none. | 114 | TRANSLATE is a translation table for ignoring case, or nil for none. |
| 115 | POSIX is nonzero if we want full backtracking (POSIX style) | 115 | POSIX is true if we want full backtracking (POSIX style) for this pattern. |
| 116 | for this pattern. 0 means backtrack only enough to get a valid match. | 116 | False means backtrack only enough to get a valid match. |
| 117 | 117 | ||
| 118 | The behavior also depends on Vsearch_spaces_regexp. */ | 118 | The behavior also depends on Vsearch_spaces_regexp. */ |
| 119 | 119 | ||
| 120 | static void | 120 | static void |
| 121 | compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Lisp_Object translate, int posix) | 121 | compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, |
| 122 | Lisp_Object translate, bool posix) | ||
| 122 | { | 123 | { |
| 123 | char *val; | 124 | char *val; |
| 124 | reg_syntax_t old; | 125 | reg_syntax_t old; |
| @@ -205,12 +206,12 @@ clear_regexp_cache (void) | |||
| 205 | values that will result from matching this pattern. | 206 | values that will result from matching this pattern. |
| 206 | If it is 0, we should compile the pattern not to record any | 207 | If it is 0, we should compile the pattern not to record any |
| 207 | subexpression bounds. | 208 | subexpression bounds. |
| 208 | POSIX is nonzero if we want full backtracking (POSIX style) | 209 | POSIX is true if we want full backtracking (POSIX style) for this pattern. |
| 209 | for this pattern. 0 means backtrack only enough to get a valid match. */ | 210 | False means backtrack only enough to get a valid match. */ |
| 210 | 211 | ||
| 211 | struct re_pattern_buffer * | 212 | struct re_pattern_buffer * |
| 212 | compile_pattern (Lisp_Object pattern, struct re_registers *regp, | 213 | compile_pattern (Lisp_Object pattern, struct re_registers *regp, |
| 213 | Lisp_Object translate, int posix, bool multibyte) | 214 | Lisp_Object translate, bool posix, bool multibyte) |
| 214 | { | 215 | { |
| 215 | struct regexp_cache *cp, **cpp; | 216 | struct regexp_cache *cp, **cpp; |
| 216 | 217 | ||
| @@ -267,7 +268,7 @@ compile_pattern (Lisp_Object pattern, struct re_registers *regp, | |||
| 267 | 268 | ||
| 268 | 269 | ||
| 269 | static Lisp_Object | 270 | static Lisp_Object |
| 270 | looking_at_1 (Lisp_Object string, int posix) | 271 | looking_at_1 (Lisp_Object string, bool posix) |
| 271 | { | 272 | { |
| 272 | Lisp_Object val; | 273 | Lisp_Object val; |
| 273 | unsigned char *p1, *p2; | 274 | unsigned char *p1, *p2; |
| @@ -365,7 +366,8 @@ data if you want to preserve them. */) | |||
| 365 | } | 366 | } |
| 366 | 367 | ||
| 367 | static Lisp_Object | 368 | static Lisp_Object |
| 368 | string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int posix) | 369 | string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, |
| 370 | bool posix) | ||
| 369 | { | 371 | { |
| 370 | ptrdiff_t val; | 372 | ptrdiff_t val; |
| 371 | struct re_pattern_buffer *bufp; | 373 | struct re_pattern_buffer *bufp; |
| @@ -975,9 +977,9 @@ find_before_next_newline (ptrdiff_t from, ptrdiff_t to, | |||
| 975 | 977 | ||
| 976 | static Lisp_Object | 978 | static Lisp_Object |
| 977 | search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, | 979 | search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, |
| 978 | Lisp_Object count, int direction, int RE, int posix) | 980 | Lisp_Object count, int direction, int RE, bool posix) |
| 979 | { | 981 | { |
| 980 | register EMACS_INT np; | 982 | EMACS_INT np; |
| 981 | EMACS_INT lim; | 983 | EMACS_INT lim; |
| 982 | ptrdiff_t lim_byte; | 984 | ptrdiff_t lim_byte; |
| 983 | EMACS_INT n = direction; | 985 | EMACS_INT n = direction; |
| @@ -1047,9 +1049,9 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, | |||
| 1047 | return make_number (np); | 1049 | return make_number (np); |
| 1048 | } | 1050 | } |
| 1049 | 1051 | ||
| 1050 | /* Return 1 if REGEXP it matches just one constant string. */ | 1052 | /* Return true if REGEXP it matches just one constant string. */ |
| 1051 | 1053 | ||
| 1052 | static int | 1054 | static bool |
| 1053 | trivial_regexp_p (Lisp_Object regexp) | 1055 | trivial_regexp_p (Lisp_Object regexp) |
| 1054 | { | 1056 | { |
| 1055 | ptrdiff_t len = SBYTES (regexp); | 1057 | ptrdiff_t len = SBYTES (regexp); |
| @@ -1118,7 +1120,7 @@ static struct re_registers search_regs_1; | |||
| 1118 | static EMACS_INT | 1120 | static EMACS_INT |
| 1119 | search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | 1121 | search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, |
| 1120 | ptrdiff_t lim, ptrdiff_t lim_byte, EMACS_INT n, | 1122 | ptrdiff_t lim, ptrdiff_t lim_byte, EMACS_INT n, |
| 1121 | int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix) | 1123 | int RE, Lisp_Object trt, Lisp_Object inverse_trt, bool posix) |
| 1122 | { | 1124 | { |
| 1123 | ptrdiff_t len = SCHARS (string); | 1125 | ptrdiff_t len = SCHARS (string); |
| 1124 | ptrdiff_t len_byte = SBYTES (string); | 1126 | ptrdiff_t len_byte = SBYTES (string); |
| @@ -1273,7 +1275,7 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 1273 | /* Set to positive if we find a non-ASCII char that need | 1275 | /* Set to positive if we find a non-ASCII char that need |
| 1274 | translation. Otherwise set to zero later. */ | 1276 | translation. Otherwise set to zero later. */ |
| 1275 | int char_base = -1; | 1277 | int char_base = -1; |
| 1276 | int boyer_moore_ok = 1; | 1278 | bool boyer_moore_ok = 1; |
| 1277 | 1279 | ||
| 1278 | /* MULTIBYTE says whether the text to be searched is multibyte. | 1280 | /* MULTIBYTE says whether the text to be searched is multibyte. |
| 1279 | We must convert PATTERN to match that, or we will not really | 1281 | We must convert PATTERN to match that, or we will not really |
| @@ -2282,12 +2284,12 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2282 | (Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp) | 2284 | (Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp) |
| 2283 | { | 2285 | { |
| 2284 | enum { nochange, all_caps, cap_initial } case_action; | 2286 | enum { nochange, all_caps, cap_initial } case_action; |
| 2285 | register ptrdiff_t pos, pos_byte; | 2287 | ptrdiff_t pos, pos_byte; |
| 2286 | int some_multiletter_word; | 2288 | bool some_multiletter_word; |
| 2287 | int some_lowercase; | 2289 | bool some_lowercase; |
| 2288 | int some_uppercase; | 2290 | bool some_uppercase; |
| 2289 | int some_nonuppercase_initial; | 2291 | bool some_nonuppercase_initial; |
| 2290 | register int c, prevc; | 2292 | int c, prevc; |
| 2291 | ptrdiff_t sub; | 2293 | ptrdiff_t sub; |
| 2292 | ptrdiff_t opoint, newpoint; | 2294 | ptrdiff_t opoint, newpoint; |
| 2293 | 2295 | ||
| @@ -2432,7 +2434,7 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2432 | { | 2434 | { |
| 2433 | ptrdiff_t substart = -1; | 2435 | ptrdiff_t substart = -1; |
| 2434 | ptrdiff_t subend = 0; | 2436 | ptrdiff_t subend = 0; |
| 2435 | int delbackslash = 0; | 2437 | bool delbackslash = 0; |
| 2436 | 2438 | ||
| 2437 | FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte); | 2439 | FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte); |
| 2438 | 2440 | ||
| @@ -2529,7 +2531,7 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2529 | ptrdiff_t substed_alloc_size, substed_len; | 2531 | ptrdiff_t substed_alloc_size, substed_len; |
| 2530 | bool buf_multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); | 2532 | bool buf_multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); |
| 2531 | bool str_multibyte = STRING_MULTIBYTE (newtext); | 2533 | bool str_multibyte = STRING_MULTIBYTE (newtext); |
| 2532 | int really_changed = 0; | 2534 | bool really_changed = 0; |
| 2533 | 2535 | ||
| 2534 | substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length | 2536 | substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length |
| 2535 | ? STRING_BYTES_BOUND | 2537 | ? STRING_BYTES_BOUND |
| @@ -2695,7 +2697,7 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2695 | } | 2697 | } |
| 2696 | 2698 | ||
| 2697 | static Lisp_Object | 2699 | static Lisp_Object |
| 2698 | match_limit (Lisp_Object num, int beginningp) | 2700 | match_limit (Lisp_Object num, bool beginningp) |
| 2699 | { | 2701 | { |
| 2700 | EMACS_INT n; | 2702 | EMACS_INT n; |
| 2701 | 2703 | ||
| @@ -2968,9 +2970,9 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */) | |||
| 2968 | return Qnil; | 2970 | return Qnil; |
| 2969 | } | 2971 | } |
| 2970 | 2972 | ||
| 2971 | /* If non-zero the match data have been saved in saved_search_regs | 2973 | /* If true the match data have been saved in saved_search_regs |
| 2972 | during the execution of a sentinel or filter. */ | 2974 | during the execution of a sentinel or filter. */ |
| 2973 | static int search_regs_saved; | 2975 | static bool search_regs_saved; |
| 2974 | static struct re_registers saved_search_regs; | 2976 | static struct re_registers saved_search_regs; |
| 2975 | static Lisp_Object saved_last_thing_searched; | 2977 | static Lisp_Object saved_last_thing_searched; |
| 2976 | 2978 | ||
| @@ -3035,9 +3037,9 @@ DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0, | |||
| 3035 | doc: /* Return a regexp string which matches exactly STRING and nothing else. */) | 3037 | doc: /* Return a regexp string which matches exactly STRING and nothing else. */) |
| 3036 | (Lisp_Object string) | 3038 | (Lisp_Object string) |
| 3037 | { | 3039 | { |
| 3038 | register char *in, *out, *end; | 3040 | char *in, *out, *end; |
| 3039 | register char *temp; | 3041 | char *temp; |
| 3040 | int backslashes_added = 0; | 3042 | ptrdiff_t backslashes_added = 0; |
| 3041 | 3043 | ||
| 3042 | CHECK_STRING (string); | 3044 | CHECK_STRING (string); |
| 3043 | 3045 | ||