From 05e193f1706f5d9846530e734d0271b15b9a818c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 5 Mar 2013 20:12:25 +0200 Subject: [PATCH] Don't sync charpos and bytepos in bidi_resolve_explicit_1. src/bidi.c (bidi_resolve_explicit_1): Don't call CHAR_TO_BYTE or bidi_count_bytes, as the callers now arrange for bidi_it->charpos to be in sync with bidi_it->bytepos. Suggested by Dmitry Antipov . --- src/ChangeLog | 7 +++++++ src/bidi.c | 14 +++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 23071b03bee..c4b4703e59d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2013-03-05 Eli Zaretskii + + * bidi.c (bidi_resolve_explicit_1): Don't call CHAR_TO_BYTE or + bidi_count_bytes, as the callers now arrange for bidi_it->charpos + to be in sync with bidi_it->bytepos. Suggested by Dmitry Antipov + . + 2013-03-05 Paul Eggert Fix a build failure on OpenBSD 4.x and MirBSD. diff --git a/src/bidi.c b/src/bidi.c index 364d7e500ba..57d154bc544 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -1353,15 +1353,19 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it) : bidi_it->string.s); if (bidi_it->charpos < 0) - bidi_it->charpos = 0; - bidi_it->bytepos = bidi_count_bytes (p, 0, 0, bidi_it->charpos, - bidi_it->string.unibyte); + bidi_it->charpos = bidi_it->bytepos = 0; + eassert (bidi_it->bytepos == bidi_count_bytes (p, 0, 0, + bidi_it->charpos, + bidi_it->string.unibyte)); } else { if (bidi_it->charpos < BEGV) - bidi_it->charpos = BEGV; - bidi_it->bytepos = CHAR_TO_BYTE (bidi_it->charpos); + { + bidi_it->charpos = BEGV; + bidi_it->bytepos = BEGV_BYTE; + } + eassert (bidi_it->bytepos == CHAR_TO_BYTE (bidi_it->charpos)); } } /* Don't move at end of buffer/string. */ -- 2.39.2