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.
This commit is contained in:
Paul Eggert 2013-03-08 13:37:41 -08:00
parent b542656108
commit 457882c20c
5 changed files with 60 additions and 46 deletions

View file

@ -1,3 +1,16 @@
2013-03-08 Paul Eggert <eggert@cs.ucla.edu>
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.
2013-03-08 Dmitry Antipov <dmantipov@yandex.ru>
* search.c (find_newline): Accept start and end byte positions

View file

@ -3357,7 +3357,7 @@ extern void record_unwind_save_match_data (void);
struct re_registers;
extern struct re_pattern_buffer *compile_pattern (Lisp_Object,
struct re_registers *,
Lisp_Object, int, bool);
Lisp_Object, bool, bool);
extern ptrdiff_t fast_string_match (Lisp_Object, Lisp_Object);
extern ptrdiff_t fast_c_string_match_ignore_case (Lisp_Object, const char *,
ptrdiff_t);

View file

@ -695,8 +695,9 @@ know_region_cache (struct buffer *buf, struct region_cache *c,
/* Interface: using the cache. */
/* Return true if the text immediately after POS in BUF is known, for
the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest
/* Return the value for the text immediately after POS in BUF if the value
is known, for the purposes of CACHE, and return zero otherwise.
If NEXT is non-zero, set *NEXT to the nearest
position after POS where the knowledge changes. */
int
region_cache_forward (struct buffer *buf, struct region_cache *c,
@ -732,8 +733,9 @@ region_cache_forward (struct buffer *buf, struct region_cache *c,
}
}
/* Return true if the text immediately before POS in BUF is known, for
the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest
/* Return the value for the text immediately before POS in BUF if the
value is known, for the purposes of CACHE, and return zero
otherwise. If NEXT is non-zero, set *NEXT to the nearest
position before POS where the knowledge changes. */
int region_cache_backward (struct buffer *buf, struct region_cache *c,
ptrdiff_t pos, ptrdiff_t *next)

View file

@ -246,9 +246,8 @@ do_scrolling (struct frame *frame, struct glyph_matrix *current_matrix,
struct matrix_elt *p;
int i, j, k;
/* Set to 1 if we have set a terminal window with
set_terminal_window. It's unsigned to work around GCC bug 48228. */
unsigned int terminal_window_p = 0;
/* True if we have set a terminal window with set_terminal_window. */
bool terminal_window_p = 0;
/* A queue for line insertions to be done. */
struct queue { int count, pos; };
@ -657,18 +656,16 @@ do_direct_scrolling (struct frame *frame, struct glyph_matrix *current_matrix,
alloca (window_size * sizeof *queue_start);
struct alt_queue *queue = queue_start;
/* Set to 1 if a terminal window has been set with
set_terminal_window: */
int terminal_window_p = 0;
/* True if a terminal window has been set with set_terminal_window. */
bool terminal_window_p = 0;
/* A nonzero value of write_follows indicates that a write has been
selected, allowing either an insert or a delete to be selected
next. When write_follows is zero, a delete cannot be selected
/* If true, a write has been selected, allowing either an insert or a
delete to be selected next. If false, a delete cannot be selected
unless j < i, and an insert cannot be selected unless i < j.
This corresponds to a similar restriction (with the ordering
reversed) in calculate_direct_scrolling, which is intended to
ensure that lines marked as inserted will be blank. */
int write_follows_p = 1;
bool write_follows_p = 1;
/* For each row in the new matrix what row of the old matrix it is. */
int *copy_from = alloca (window_size * sizeof *copy_from);

View file

@ -49,8 +49,8 @@ struct regexp_cache
Lisp_Object syntax_table;
struct re_pattern_buffer buf;
char fastmap[0400];
/* Nonzero means regexp was compiled to do full POSIX backtracking. */
char posix;
/* True means regexp was compiled to do full POSIX backtracking. */
bool posix;
};
/* The instances of that struct. */
@ -100,7 +100,7 @@ static EMACS_INT boyer_moore (EMACS_INT, unsigned char *, ptrdiff_t,
ptrdiff_t, int);
static EMACS_INT search_buffer (Lisp_Object, ptrdiff_t, ptrdiff_t,
ptrdiff_t, ptrdiff_t, EMACS_INT, int,
Lisp_Object, Lisp_Object, int);
Lisp_Object, Lisp_Object, bool);
static _Noreturn void
matcher_overflow (void)
@ -112,13 +112,14 @@ matcher_overflow (void)
PATTERN is the pattern to compile.
CP is the place to put the result.
TRANSLATE is a translation table for ignoring case, or nil for none.
POSIX is nonzero if we want full backtracking (POSIX style)
for this pattern. 0 means backtrack only enough to get a valid match.
POSIX is true if we want full backtracking (POSIX style) for this pattern.
False means backtrack only enough to get a valid match.
The behavior also depends on Vsearch_spaces_regexp. */
static void
compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Lisp_Object translate, int posix)
compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern,
Lisp_Object translate, bool posix)
{
char *val;
reg_syntax_t old;
@ -205,12 +206,12 @@ clear_regexp_cache (void)
values that will result from matching this pattern.
If it is 0, we should compile the pattern not to record any
subexpression bounds.
POSIX is nonzero if we want full backtracking (POSIX style)
for this pattern. 0 means backtrack only enough to get a valid match. */
POSIX is true if we want full backtracking (POSIX style) for this pattern.
False means backtrack only enough to get a valid match. */
struct re_pattern_buffer *
compile_pattern (Lisp_Object pattern, struct re_registers *regp,
Lisp_Object translate, int posix, bool multibyte)
Lisp_Object translate, bool posix, bool multibyte)
{
struct regexp_cache *cp, **cpp;
@ -267,7 +268,7 @@ compile_pattern (Lisp_Object pattern, struct re_registers *regp,
static Lisp_Object
looking_at_1 (Lisp_Object string, int posix)
looking_at_1 (Lisp_Object string, bool posix)
{
Lisp_Object val;
unsigned char *p1, *p2;
@ -365,7 +366,8 @@ data if you want to preserve them. */)
}
static Lisp_Object
string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int posix)
string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start,
bool posix)
{
ptrdiff_t val;
struct re_pattern_buffer *bufp;
@ -975,9 +977,9 @@ find_before_next_newline (ptrdiff_t from, ptrdiff_t to,
static Lisp_Object
search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
Lisp_Object count, int direction, int RE, int posix)
Lisp_Object count, int direction, int RE, bool posix)
{
register EMACS_INT np;
EMACS_INT np;
EMACS_INT lim;
ptrdiff_t lim_byte;
EMACS_INT n = direction;
@ -1047,9 +1049,9 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
return make_number (np);
}
/* Return 1 if REGEXP it matches just one constant string. */
/* Return true if REGEXP it matches just one constant string. */
static int
static bool
trivial_regexp_p (Lisp_Object regexp)
{
ptrdiff_t len = SBYTES (regexp);
@ -1118,7 +1120,7 @@ static struct re_registers search_regs_1;
static EMACS_INT
search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
ptrdiff_t lim, ptrdiff_t lim_byte, EMACS_INT n,
int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix)
int RE, Lisp_Object trt, Lisp_Object inverse_trt, bool posix)
{
ptrdiff_t len = SCHARS (string);
ptrdiff_t len_byte = SBYTES (string);
@ -1273,7 +1275,7 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
/* Set to positive if we find a non-ASCII char that need
translation. Otherwise set to zero later. */
int char_base = -1;
int boyer_moore_ok = 1;
bool boyer_moore_ok = 1;
/* MULTIBYTE says whether the text to be searched is multibyte.
We must convert PATTERN to match that, or we will not really
@ -2282,12 +2284,12 @@ since only regular expressions have distinguished subexpressions. */)
(Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp)
{
enum { nochange, all_caps, cap_initial } case_action;
register ptrdiff_t pos, pos_byte;
int some_multiletter_word;
int some_lowercase;
int some_uppercase;
int some_nonuppercase_initial;
register int c, prevc;
ptrdiff_t pos, pos_byte;
bool some_multiletter_word;
bool some_lowercase;
bool some_uppercase;
bool some_nonuppercase_initial;
int c, prevc;
ptrdiff_t sub;
ptrdiff_t opoint, newpoint;
@ -2432,7 +2434,7 @@ since only regular expressions have distinguished subexpressions. */)
{
ptrdiff_t substart = -1;
ptrdiff_t subend = 0;
int delbackslash = 0;
bool delbackslash = 0;
FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte);
@ -2529,7 +2531,7 @@ since only regular expressions have distinguished subexpressions. */)
ptrdiff_t substed_alloc_size, substed_len;
bool buf_multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
bool str_multibyte = STRING_MULTIBYTE (newtext);
int really_changed = 0;
bool really_changed = 0;
substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length
? STRING_BYTES_BOUND
@ -2695,7 +2697,7 @@ since only regular expressions have distinguished subexpressions. */)
}
static Lisp_Object
match_limit (Lisp_Object num, int beginningp)
match_limit (Lisp_Object num, bool beginningp)
{
EMACS_INT n;
@ -2968,9 +2970,9 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */)
return Qnil;
}
/* If non-zero the match data have been saved in saved_search_regs
/* If true the match data have been saved in saved_search_regs
during the execution of a sentinel or filter. */
static int search_regs_saved;
static bool search_regs_saved;
static struct re_registers saved_search_regs;
static Lisp_Object saved_last_thing_searched;
@ -3035,9 +3037,9 @@ DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0,
doc: /* Return a regexp string which matches exactly STRING and nothing else. */)
(Lisp_Object string)
{
register char *in, *out, *end;
register char *temp;
int backslashes_added = 0;
char *in, *out, *end;
char *temp;
ptrdiff_t backslashes_added = 0;
CHECK_STRING (string);