aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-08-23 13:31:52 -0700
committerPaul Eggert2012-08-23 13:31:52 -0700
commit2cc2116757629868401bdb2073ff44ce32c3d008 (patch)
treeee49e80d6573f97ddeaa36e05b81fcfbbdc10cc5 /src
parent7db4ddf40001758a58611c819605075d34edd924 (diff)
downloademacs-2cc2116757629868401bdb2073ff44ce32c3d008.tar.gz
emacs-2cc2116757629868401bdb2073ff44ce32c3d008.zip
* bidi.c: Use bool for boolean.
This is a bit more readable, and makes the text segment of bidi.o 0.4% smaller on my platform (GCC 4.7.1 x86-64, Fedora 15). Presumably it's faster too. (bidi_initialized, bidi_ignore_explicit_marks_for_paragraph_level): Now bool. (bidi_cache_find_level_change, bidi_cache_iterator_state) (bidi_unshelve_cache, bidi_init_it, bidi_count_bytes) (bidi_char_at_pos, bidi_fetch_char, bidi_paragraph_init) (bidi_explicit_dir_char, bidi_level_of_next_char) (bidi_find_other_level_edge, bidi_move_to_visually_next): Use bool for booleans, instead of int. * dispextern.h (bidi_init_it, bidi_paragraph_init) (bidi_unshelve_cache): Adjust decls to match code.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog17
-rw-r--r--src/bidi.c63
-rw-r--r--src/dispextern.h6
3 files changed, 51 insertions, 35 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 158be6d68a9..66df6a2df8f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,20 @@
12012-08-23 Paul Eggert <eggert@cs.ucla.edu>
2
3 * bidi.c: Use bool for boolean.
4 This is a bit more readable, and makes the text segment of bidi.o
5 0.4% smaller on my platform (GCC 4.7.1 x86-64, Fedora 15).
6 Presumably it's faster too.
7 (bidi_initialized, bidi_ignore_explicit_marks_for_paragraph_level):
8 Now bool.
9 (bidi_cache_find_level_change, bidi_cache_iterator_state)
10 (bidi_unshelve_cache, bidi_init_it, bidi_count_bytes)
11 (bidi_char_at_pos, bidi_fetch_char, bidi_paragraph_init)
12 (bidi_explicit_dir_char, bidi_level_of_next_char)
13 (bidi_find_other_level_edge, bidi_move_to_visually_next):
14 Use bool for booleans, instead of int.
15 * dispextern.h (bidi_init_it, bidi_paragraph_init)
16 (bidi_unshelve_cache): Adjust decls to match code.
17
12012-08-23 Martin Rudalics <rudalics@gmx.at> 182012-08-23 Martin Rudalics <rudalics@gmx.at>
2 19
3 * keyboard.c (Fposn_at_x_y): Do not allow internal window as 20 * keyboard.c (Fposn_at_x_y): Do not allow internal window as
diff --git a/src/bidi.c b/src/bidi.c
index 4df585d4f48..6b3ac53d318 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -63,7 +63,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
63#include "buffer.h" 63#include "buffer.h"
64#include "dispextern.h" 64#include "dispextern.h"
65 65
66static int bidi_initialized = 0; 66static bool bidi_initialized = 0;
67 67
68static Lisp_Object bidi_type_table, bidi_mirror_table; 68static Lisp_Object bidi_type_table, bidi_mirror_table;
69 69
@@ -82,10 +82,10 @@ typedef enum {
82/* UAX#9 says to search only for L, AL, or R types of characters, and 82/* UAX#9 says to search only for L, AL, or R types of characters, and
83 ignore RLE, RLO, LRE, and LRO, when determining the base paragraph 83 ignore RLE, RLO, LRE, and LRO, when determining the base paragraph
84 level. Yudit indeed ignores them. This variable is therefore set 84 level. Yudit indeed ignores them. This variable is therefore set
85 by default to ignore them, but setting it to zero will take them 85 by default to ignore them, but clearing it will take them into
86 into account. */ 86 account. */
87extern int bidi_ignore_explicit_marks_for_paragraph_level EXTERNALLY_VISIBLE; 87extern bool bidi_ignore_explicit_marks_for_paragraph_level EXTERNALLY_VISIBLE;
88int bidi_ignore_explicit_marks_for_paragraph_level = 1; 88bool bidi_ignore_explicit_marks_for_paragraph_level = 1;
89 89
90static Lisp_Object paragraph_start_re, paragraph_separate_re; 90static Lisp_Object paragraph_start_re, paragraph_separate_re;
91static Lisp_Object Qparagraph_start, Qparagraph_separate; 91static Lisp_Object Qparagraph_start, Qparagraph_separate;
@@ -438,7 +438,7 @@ bidi_cache_search (ptrdiff_t charpos, int level, int dir)
438 that is lower than LEVEL, and return its cache slot index. DIR is 438 that is lower than LEVEL, and return its cache slot index. DIR is
439 the direction to search, starting with the last used cache slot. 439 the direction to search, starting with the last used cache slot.
440 If DIR is zero, we search backwards from the last occupied cache 440 If DIR is zero, we search backwards from the last occupied cache
441 slot. BEFORE, if non-zero, means return the index of the slot that 441 slot. BEFORE means return the index of the slot that
442 is ``before'' the level change in the search direction. That is, 442 is ``before'' the level change in the search direction. That is,
443 given the cached levels like this: 443 given the cached levels like this:
444 444
@@ -448,9 +448,9 @@ bidi_cache_search (ptrdiff_t charpos, int level, int dir)
448 and assuming we are at the position cached at the slot marked with 448 and assuming we are at the position cached at the slot marked with
449 C, searching backwards (DIR = -1) for LEVEL = 2 will return the 449 C, searching backwards (DIR = -1) for LEVEL = 2 will return the
450 index of slot B or A, depending whether BEFORE is, respectively, 450 index of slot B or A, depending whether BEFORE is, respectively,
451 non-zero or zero. */ 451 true or false. */
452static ptrdiff_t 452static ptrdiff_t
453bidi_cache_find_level_change (int level, int dir, int before) 453bidi_cache_find_level_change (int level, int dir, bool before)
454{ 454{
455 if (bidi_cache_idx) 455 if (bidi_cache_idx)
456 { 456 {
@@ -512,7 +512,7 @@ bidi_cache_ensure_space (ptrdiff_t idx)
512} 512}
513 513
514static inline void 514static inline void
515bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved) 515bidi_cache_iterator_state (struct bidi_it *bidi_it, bool resolved)
516{ 516{
517 ptrdiff_t idx; 517 ptrdiff_t idx;
518 518
@@ -690,11 +690,11 @@ bidi_shelve_cache (void)
690 690
691/* Restore the cache state from a copy stashed away by 691/* Restore the cache state from a copy stashed away by
692 bidi_shelve_cache, and free the buffer used to stash that copy. 692 bidi_shelve_cache, and free the buffer used to stash that copy.
693 JUST_FREE non-zero means free the buffer, but don't restore the 693 JUST_FREE means free the buffer, but don't restore the
694 cache; used when the corresponding iterator is discarded instead of 694 cache; used when the corresponding iterator is discarded instead of
695 being restored. */ 695 being restored. */
696void 696void
697bidi_unshelve_cache (void *databuf, int just_free) 697bidi_unshelve_cache (void *databuf, bool just_free)
698{ 698{
699 unsigned char *p = databuf; 699 unsigned char *p = databuf;
700 700
@@ -802,7 +802,7 @@ bidi_set_paragraph_end (struct bidi_it *bidi_it)
802 802
803/* Initialize the bidi iterator from buffer/string position CHARPOS. */ 803/* Initialize the bidi iterator from buffer/string position CHARPOS. */
804void 804void
805bidi_init_it (ptrdiff_t charpos, ptrdiff_t bytepos, int frame_window_p, 805bidi_init_it (ptrdiff_t charpos, ptrdiff_t bytepos, bool frame_window_p,
806 struct bidi_it *bidi_it) 806 struct bidi_it *bidi_it)
807{ 807{
808 if (! bidi_initialized) 808 if (! bidi_initialized)
@@ -872,11 +872,10 @@ bidi_line_init (struct bidi_it *bidi_it)
872 872
873/* Count bytes in string S between BEG/BEGBYTE and END. BEG and END 873/* Count bytes in string S between BEG/BEGBYTE and END. BEG and END
874 are zero-based character positions in S, BEGBYTE is byte position 874 are zero-based character positions in S, BEGBYTE is byte position
875 corresponding to BEG. UNIBYTE, if non-zero, means S is a unibyte 875 corresponding to BEG. UNIBYTE means S is a unibyte string. */
876 string. */
877static inline ptrdiff_t 876static inline ptrdiff_t
878bidi_count_bytes (const unsigned char *s, const ptrdiff_t beg, 877bidi_count_bytes (const unsigned char *s, const ptrdiff_t beg,
879 const ptrdiff_t begbyte, const ptrdiff_t end, int unibyte) 878 const ptrdiff_t begbyte, const ptrdiff_t end, bool unibyte)
880{ 879{
881 ptrdiff_t pos = beg; 880 ptrdiff_t pos = beg;
882 const unsigned char *p = s + begbyte, *start = p; 881 const unsigned char *p = s + begbyte, *start = p;
@@ -900,10 +899,10 @@ bidi_count_bytes (const unsigned char *s, const ptrdiff_t beg,
900 899
901/* Fetch and returns the character at byte position BYTEPOS. If S is 900/* Fetch and returns the character at byte position BYTEPOS. If S is
902 non-NULL, fetch the character from string S; otherwise fetch the 901 non-NULL, fetch the character from string S; otherwise fetch the
903 character from the current buffer. UNIBYTE non-zero means S is a 902 character from the current buffer. UNIBYTE means S is a
904 unibyte string. */ 903 unibyte string. */
905static inline int 904static inline int
906bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, int unibyte) 905bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, bool unibyte)
907{ 906{
908 if (s) 907 if (s)
909 { 908 {
@@ -923,9 +922,9 @@ bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, int unibyte)
923 specifies the character position of the next display string, or -1 922 specifies the character position of the next display string, or -1
924 if not yet computed. When the next character is at or beyond that 923 if not yet computed. When the next character is at or beyond that
925 position, the function updates DISP_POS with the position of the 924 position, the function updates DISP_POS with the position of the
926 next display string. DISP_PROP non-zero means that there's really 925 next display string. *DISP_PROP non-zero means that there's really
927 a display string at DISP_POS, as opposed to when we searched till 926 a display string at DISP_POS, as opposed to when we searched till
928 DISP_POS without finding one. If DISP_PROP is 2, it means the 927 DISP_POS without finding one. If *DISP_PROP is 2, it means the
929 display spec is of the form `(space ...)', which is replaced with 928 display spec is of the form `(space ...)', which is replaced with
930 u+2029 to handle it as a paragraph separator. STRING->s is the C 929 u+2029 to handle it as a paragraph separator. STRING->s is the C
931 string to iterate, or NULL if iterating over a buffer or a Lisp 930 string to iterate, or NULL if iterating over a buffer or a Lisp
@@ -933,7 +932,7 @@ bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, int unibyte)
933static inline int 932static inline int
934bidi_fetch_char (ptrdiff_t bytepos, ptrdiff_t charpos, ptrdiff_t *disp_pos, 933bidi_fetch_char (ptrdiff_t bytepos, ptrdiff_t charpos, ptrdiff_t *disp_pos,
935 int *disp_prop, struct bidi_string_data *string, 934 int *disp_prop, struct bidi_string_data *string,
936 int frame_window_p, ptrdiff_t *ch_len, ptrdiff_t *nchars) 935 bool frame_window_p, ptrdiff_t *ch_len, ptrdiff_t *nchars)
937{ 936{
938 int ch; 937 int ch;
939 ptrdiff_t endpos 938 ptrdiff_t endpos
@@ -1134,7 +1133,7 @@ bidi_find_paragraph_start (ptrdiff_t pos, ptrdiff_t pos_byte)
1134 R2L, just use that. Otherwise, determine the paragraph direction 1133 R2L, just use that. Otherwise, determine the paragraph direction
1135 from the first strong directional character of the paragraph. 1134 from the first strong directional character of the paragraph.
1136 1135
1137 NO_DEFAULT_P non-zero means don't default to L2R if the paragraph 1136 NO_DEFAULT_P means don't default to L2R if the paragraph
1138 has no strong directional characters and both DIR and 1137 has no strong directional characters and both DIR and
1139 bidi_it->paragraph_dir are NEUTRAL_DIR. In that case, search back 1138 bidi_it->paragraph_dir are NEUTRAL_DIR. In that case, search back
1140 in the buffer until a paragraph is found with a strong character, 1139 in the buffer until a paragraph is found with a strong character,
@@ -1145,10 +1144,10 @@ bidi_find_paragraph_start (ptrdiff_t pos, ptrdiff_t pos_byte)
1145 direction as the preceding paragraph, even though Emacs generally 1144 direction as the preceding paragraph, even though Emacs generally
1146 views the separator as not belonging to any paragraph. */ 1145 views the separator as not belonging to any paragraph. */
1147void 1146void
1148bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p) 1147bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, bool no_default_p)
1149{ 1148{
1150 ptrdiff_t bytepos = bidi_it->bytepos; 1149 ptrdiff_t bytepos = bidi_it->bytepos;
1151 int string_p = bidi_it->string.s != NULL || STRINGP (bidi_it->string.lstring); 1150 bool string_p = bidi_it->string.s || STRINGP (bidi_it->string.lstring);
1152 ptrdiff_t pstartbyte; 1151 ptrdiff_t pstartbyte;
1153 /* Note that begbyte is a byte position, while end is a character 1152 /* Note that begbyte is a byte position, while end is a character
1154 position. Yes, this is ugly, but we are trying to avoid costly 1153 position. Yes, this is ugly, but we are trying to avoid costly
@@ -1221,8 +1220,8 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p)
1221 bidi_it->separator_limit = -1; 1220 bidi_it->separator_limit = -1;
1222 bidi_it->new_paragraph = 0; 1221 bidi_it->new_paragraph = 0;
1223 1222
1224 /* The following loop is run more than once only if NO_DEFAULT_P 1223 /* The following loop is run more than once only if NO_DEFAULT_P,
1225 is non-zero, and only if we are iterating on a buffer. */ 1224 and only if we are iterating on a buffer. */
1226 do { 1225 do {
1227 ptrdiff_t pos1; 1226 ptrdiff_t pos1;
1228 1227
@@ -1320,7 +1319,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p)
1320 The rest of this file constitutes the core of the UBA implementation. 1319 The rest of this file constitutes the core of the UBA implementation.
1321 ***********************************************************************/ 1320 ***********************************************************************/
1322 1321
1323static inline int 1322static inline bool
1324bidi_explicit_dir_char (int ch) 1323bidi_explicit_dir_char (int ch)
1325{ 1324{
1326 bidi_type_t ch_type; 1325 bidi_type_t ch_type;
@@ -1345,7 +1344,7 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1345 int current_level; 1344 int current_level;
1346 int new_level; 1345 int new_level;
1347 bidi_dir_t override; 1346 bidi_dir_t override;
1348 int string_p = bidi_it->string.s != NULL || STRINGP (bidi_it->string.lstring); 1347 bool string_p = bidi_it->string.s || STRINGP (bidi_it->string.lstring);
1349 1348
1350 /* If reseat()'ed, don't advance, so as to start iteration from the 1349 /* If reseat()'ed, don't advance, so as to start iteration from the
1351 position where we were reseated. bidi_it->bytepos can be less 1350 position where we were reseated. bidi_it->bytepos can be less
@@ -2189,7 +2188,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2189 ptrdiff_t nc = bidi_it->nchars; 2188 ptrdiff_t nc = bidi_it->nchars;
2190 struct bidi_string_data bs = bidi_it->string; 2189 struct bidi_string_data bs = bidi_it->string;
2191 bidi_type_t chtype; 2190 bidi_type_t chtype;
2192 int fwp = bidi_it->frame_window_p; 2191 bool fwp = bidi_it->frame_window_p;
2193 int dpp = bidi_it->disp_prop; 2192 int dpp = bidi_it->disp_prop;
2194 2193
2195 if (bidi_it->nchars <= 0) 2194 if (bidi_it->nchars <= 0)
@@ -2268,8 +2267,8 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2268 return level; 2267 return level;
2269} 2268}
2270 2269
2271/* Move to the other edge of a level given by LEVEL. If END_FLAG is 2270/* Move to the other edge of a level given by LEVEL. If END_FLAG,
2272 non-zero, we are at the end of a level, and we need to prepare to 2271 we are at the end of a level, and we need to prepare to
2273 resume the scan of the lower level. 2272 resume the scan of the lower level.
2274 2273
2275 If this level's other edge is cached, we simply jump to it, filling 2274 If this level's other edge is cached, we simply jump to it, filling
@@ -2289,7 +2288,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2289 function moves to point C, whereas the UAX#9 ``level 2 run'' ends 2288 function moves to point C, whereas the UAX#9 ``level 2 run'' ends
2290 at point B. */ 2289 at point B. */
2291static void 2290static void
2292bidi_find_other_level_edge (struct bidi_it *bidi_it, int level, int end_flag) 2291bidi_find_other_level_edge (struct bidi_it *bidi_it, int level, bool end_flag)
2293{ 2292{
2294 int dir = end_flag ? -bidi_it->scan_dir : bidi_it->scan_dir; 2293 int dir = end_flag ? -bidi_it->scan_dir : bidi_it->scan_dir;
2295 ptrdiff_t idx; 2294 ptrdiff_t idx;
@@ -2363,7 +2362,7 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it)
2363 scanning the text whenever we find a level change. */ 2362 scanning the text whenever we find a level change. */
2364 if (new_level != old_level) 2363 if (new_level != old_level)
2365 { 2364 {
2366 int ascending = new_level > old_level; 2365 bool ascending = new_level > old_level;
2367 int level_to_search = ascending ? old_level + 1 : old_level; 2366 int level_to_search = ascending ? old_level + 1 : old_level;
2368 int incr = ascending ? 1 : -1; 2367 int incr = ascending ? 1 : -1;
2369 int expected_next_level = old_level + incr; 2368 int expected_next_level = old_level + incr;
diff --git a/src/dispextern.h b/src/dispextern.h
index a25aac96df9..6fe5e249836 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3002,14 +3002,14 @@ enum tool_bar_item_image
3002 3002
3003/* Defined in bidi.c */ 3003/* Defined in bidi.c */
3004 3004
3005extern void bidi_init_it (ptrdiff_t, ptrdiff_t, int, struct bidi_it *); 3005extern void bidi_init_it (ptrdiff_t, ptrdiff_t, bool, struct bidi_it *);
3006extern void bidi_move_to_visually_next (struct bidi_it *); 3006extern void bidi_move_to_visually_next (struct bidi_it *);
3007extern void bidi_paragraph_init (bidi_dir_t, struct bidi_it *, int); 3007extern void bidi_paragraph_init (bidi_dir_t, struct bidi_it *, bool);
3008extern int bidi_mirror_char (int); 3008extern int bidi_mirror_char (int);
3009extern void bidi_push_it (struct bidi_it *); 3009extern void bidi_push_it (struct bidi_it *);
3010extern void bidi_pop_it (struct bidi_it *); 3010extern void bidi_pop_it (struct bidi_it *);
3011extern void *bidi_shelve_cache (void); 3011extern void *bidi_shelve_cache (void);
3012extern void bidi_unshelve_cache (void *, int); 3012extern void bidi_unshelve_cache (void *, bool);
3013 3013
3014/* Defined in xdisp.c */ 3014/* Defined in xdisp.c */
3015 3015