From: Dmitry Antipov Date: Thu, 7 Mar 2013 23:37:36 +0000 (+0400) Subject: * bidi.c (bidi_fetch_char): Swap first and second arguments X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~598 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=36075a19b2d37e38e8258dff2f774a2a3702dc55;p=emacs.git * bidi.c (bidi_fetch_char): Swap first and second arguments to match other functions accepting character and byte positions. Adjust comment. (bidi_resolve_explicit_1, bidi_level_of_next_char): Adjust users. (bidi_paragraph_init): Likewise. Use DEC_BOTH which is faster when you need just to move to the previous buffer position. * xdisp.c (Fcurrent_bidi_paragraph_direction): Use DEC_BOTH. --- diff --git a/src/ChangeLog b/src/ChangeLog index 54b1fd04503..02c928f8f82 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2013-03-08 Dmitry Antipov + + * bidi.c (bidi_fetch_char): Swap first and second arguments + to match other functions accepting character and byte positions. + Adjust comment. + (bidi_resolve_explicit_1, bidi_level_of_next_char): Adjust users. + (bidi_paragraph_init): Likewise. Use DEC_BOTH which is faster + when you need just to move to the previous buffer position. + * xdisp.c (Fcurrent_bidi_paragraph_direction): Use DEC_BOTH. + 2013-03-07 Eli Zaretskii * .gdbinit (prowlims): Display the enabled_p flag of the row. diff --git a/src/bidi.c b/src/bidi.c index cf5e580cd8f..7d070462a85 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -910,7 +910,7 @@ bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, bool unibyte) return STRING_CHAR (s); } -/* Fetch and return the character at BYTEPOS/CHARPOS. If that +/* Fetch and return the character at CHARPOS/BYTEPOS. If that character is covered by a display string, treat the entire run of covered characters as a single character, either u+2029 or u+FFFC, and return their combined length in CH_LEN and NCHARS. DISP_POS @@ -925,7 +925,7 @@ bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, bool unibyte) string to iterate, or NULL if iterating over a buffer or a Lisp string; in the latter case, STRING->lstring is the Lisp string. */ static int -bidi_fetch_char (ptrdiff_t bytepos, ptrdiff_t charpos, ptrdiff_t *disp_pos, +bidi_fetch_char (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t *disp_pos, int *disp_prop, struct bidi_string_data *string, bool frame_window_p, ptrdiff_t *ch_len, ptrdiff_t *nchars) { @@ -1220,7 +1220,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, bool no_default_p) bytepos = pstartbyte; if (!string_p) pos = BYTE_TO_CHAR (bytepos); - ch = bidi_fetch_char (bytepos, pos, &disp_pos, &disp_prop, + ch = bidi_fetch_char (pos, bytepos, &disp_pos, &disp_prop, &bidi_it->string, bidi_it->frame_window_p, &ch_len, &nchars); type = bidi_get_type (ch, NEUTRAL_DIR); @@ -1248,7 +1248,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, bool no_default_p) && bidi_at_paragraph_end (pos, bytepos) >= -1) break; /* Fetch next character and advance to get past it. */ - ch = bidi_fetch_char (bytepos, pos, &disp_pos, + ch = bidi_fetch_char (pos, bytepos, &disp_pos, &disp_prop, &bidi_it->string, bidi_it->frame_window_p, &ch_len, &nchars); pos += nchars; @@ -1279,8 +1279,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, bool no_default_p) /* FXIME: What if p is covered by a display string? See also a FIXME inside bidi_find_paragraph_start. */ - p--; - pbyte = CHAR_TO_BYTE (p); + DEC_BOTH (p, pbyte); prevpbyte = bidi_find_paragraph_start (p, pbyte); } pstartbyte = prevpbyte; @@ -1398,7 +1397,7 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it) /* Fetch the character at BYTEPOS. If it is covered by a display string, treat the entire run of covered characters as a single character u+FFFC. */ - curchar = bidi_fetch_char (bidi_it->bytepos, bidi_it->charpos, + curchar = bidi_fetch_char (bidi_it->charpos, bidi_it->bytepos, &bidi_it->disp_pos, &bidi_it->disp_prop, &bidi_it->string, bidi_it->frame_window_p, &bidi_it->ch_len, &bidi_it->nchars); @@ -2191,7 +2190,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) if (bidi_it->nchars <= 0) emacs_abort (); do { - ch = bidi_fetch_char (bpos += clen, cpos += nc, &disp_pos, &dpp, &bs, + ch = bidi_fetch_char (cpos += nc, bpos += clen, &disp_pos, &dpp, &bs, fwp, &clen, &nc); if (ch == '\n' || ch == BIDI_EOB) chtype = NEUTRAL_B; diff --git a/src/xdisp.c b/src/xdisp.c index 934c617bf8e..3838d237c91 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -19910,10 +19910,7 @@ See also `bidi-paragraph-direction'. */) to make sure we are within that paragraph. To that end, find the previous non-empty line. */ if (pos >= ZV && pos > BEGV) - { - pos--; - bytepos = CHAR_TO_BYTE (pos); - } + DEC_BOTH (pos, bytepos); if (fast_looking_at (build_string ("[\f\t ]*\n"), pos, bytepos, ZV, ZV_BYTE, Qnil) > 0) {