aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2011-07-01 13:53:29 +0300
committerEli Zaretskii2011-07-01 13:53:29 +0300
commitf3014ef5b24ac42ec714b48148b7b604b47f7468 (patch)
tree98ca5852c241272f7e2d4b5d011e1d1785e650a3 /src
parent7e2ad32c19096fb9a86fbb88f7e7b1ed90a332e9 (diff)
downloademacs-f3014ef5b24ac42ec714b48148b7b604b47f7468.tar.gz
emacs-f3014ef5b24ac42ec714b48148b7b604b47f7468.zip
Support bidi reordering of unibyte strings. Fix crash displaying "All" in mode line of an empty buffer.
src/dispextern.h (struct bidi_string_data): New member `unibyte'. src/xdisp.c (handle_single_display_spec, next_overlay_string) (get_overlay_strings_1, reseat_1, reseat_to_string) (push_display_prop): Set up the `unibyte' member of bidi_it.string correctly. Don't assume unibyte strings are not bidi-reordered. (compute_display_string_pos) (compute_display_string_end): Fix handling the case of C string. src/bidi.c (bidi_count_bytes, bidi_char_at_pos): Accept an additional argument UNIBYTE, and support unibyte strings. All callers changed. (bidi_fetch_char): Support unibyte strings.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog16
-rw-r--r--src/bidi.c87
-rw-r--r--src/dispextern.h1
-rw-r--r--src/xdisp.c70
4 files changed, 102 insertions, 72 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 8d5275f9702..8cb94b3ff22 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,19 @@
12011-07-01 Eli Zaretskii <eliz@gnu.org>
2
3 * dispextern.h (struct bidi_string_data): New member `unibyte'.
4
5 * xdisp.c (handle_single_display_spec, next_overlay_string)
6 (get_overlay_strings_1, reseat_1, reseat_to_string)
7 (push_display_prop): Set up the `unibyte' member of bidi_it.string
8 correctly. Don't assume unibyte strings are not bidi-reordered.
9 (compute_display_string_pos)
10 (compute_display_string_end): Fix handling the case of C string.
11
12 * bidi.c (bidi_count_bytes, bidi_char_at_pos): Accept an
13 additional argument UNIBYTE, and support unibyte strings. All
14 callers changed.
15 (bidi_fetch_char): Support unibyte strings.
16
12011-06-25 Eli Zaretskii <eliz@gnu.org> 172011-06-25 Eli Zaretskii <eliz@gnu.org>
2 18
3 * xdisp.c (set_iterator_to_next, get_visually_first_element): Use 19 * xdisp.c (set_iterator_to_next, get_visually_first_element): Use
diff --git a/src/bidi.c b/src/bidi.c
index 5c9239d60f0..87978058a5b 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -721,23 +721,29 @@ bidi_line_init (struct bidi_it *bidi_it)
721 Fetching characters 721 Fetching characters
722 ***********************************************************************/ 722 ***********************************************************************/
723 723
724/* Count bytes in multibyte string S between BEG/BEGBYTE and END. BEG 724/* Count bytes in string S between BEG/BEGBYTE and END. BEG and END
725 and END are zero-based character positions in S, BEGBYTE is byte 725 are zero-based character positions in S, BEGBYTE is byte position
726 position corresponding to BEG. */ 726 corresponding to BEG. UNIBYTE, if non-zero, means S is a unibyte
727 string. */
727static inline EMACS_INT 728static inline EMACS_INT
728bidi_count_bytes (const unsigned char *s, const EMACS_INT beg, 729bidi_count_bytes (const unsigned char *s, const EMACS_INT beg,
729 const EMACS_INT begbyte, const EMACS_INT end) 730 const EMACS_INT begbyte, const EMACS_INT end, int unibyte)
730{ 731{
731 EMACS_INT pos = beg; 732 EMACS_INT pos = beg;
732 const unsigned char *p = s + begbyte, *start = p; 733 const unsigned char *p = s + begbyte, *start = p;
733 734
734 if (!CHAR_HEAD_P (*p)) 735 if (unibyte)
735 abort (); 736 p = s + end;
736 737 else
737 while (pos < end)
738 { 738 {
739 p += BYTES_BY_CHAR_HEAD (*p); 739 if (!CHAR_HEAD_P (*p))
740 pos++; 740 abort ();
741
742 while (pos < end)
743 {
744 p += BYTES_BY_CHAR_HEAD (*p);
745 pos++;
746 }
741 } 747 }
742 748
743 return p - start; 749 return p - start;
@@ -745,12 +751,18 @@ bidi_count_bytes (const unsigned char *s, const EMACS_INT beg,
745 751
746/* Fetch and returns the character at byte position BYTEPOS. If S is 752/* Fetch and returns the character at byte position BYTEPOS. If S is
747 non-NULL, fetch the character from string S; otherwise fetch the 753 non-NULL, fetch the character from string S; otherwise fetch the
748 character from the current buffer. */ 754 character from the current buffer. UNIBYTE non-zero means S is a
755 unibyte string. */
749static inline int 756static inline int
750bidi_char_at_pos (EMACS_INT bytepos, const unsigned char *s) 757bidi_char_at_pos (EMACS_INT bytepos, const unsigned char *s, int unibyte)
751{ 758{
752 if (s) 759 if (s)
753 return STRING_CHAR (s + bytepos); 760 {
761 if (unibyte)
762 return s[bytepos];
763 else
764 return STRING_CHAR (s + bytepos);
765 }
754 else 766 else
755 return FETCH_MULTIBYTE_CHAR (bytepos); 767 return FETCH_MULTIBYTE_CHAR (bytepos);
756} 768}
@@ -804,12 +816,14 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos,
804 ch = 0xFFFC; 816 ch = 0xFFFC;
805 disp_end_pos = compute_display_string_end (*disp_pos, string); 817 disp_end_pos = compute_display_string_end (*disp_pos, string);
806 *nchars = disp_end_pos - *disp_pos; 818 *nchars = disp_end_pos - *disp_pos;
819 if (*nchars <= 0)
820 abort ();
807 if (string->s) 821 if (string->s)
808 *ch_len = bidi_count_bytes (string->s, *disp_pos, bytepos, 822 *ch_len = bidi_count_bytes (string->s, *disp_pos, bytepos,
809 disp_end_pos); 823 disp_end_pos, string->unibyte);
810 else if (STRINGP (string->lstring)) 824 else if (STRINGP (string->lstring))
811 *ch_len = bidi_count_bytes (SDATA (string->lstring), *disp_pos, 825 *ch_len = bidi_count_bytes (SDATA (string->lstring), *disp_pos,
812 bytepos, disp_end_pos); 826 bytepos, disp_end_pos, string->unibyte);
813 else 827 else
814 *ch_len = CHAR_TO_BYTE (disp_end_pos) - bytepos; 828 *ch_len = CHAR_TO_BYTE (disp_end_pos) - bytepos;
815 } 829 }
@@ -819,15 +833,32 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos,
819 { 833 {
820 EMACS_INT len; 834 EMACS_INT len;
821 835
822 ch = STRING_CHAR_AND_LENGTH (string->s + bytepos, len); 836 if (!string->unibyte)
823 *ch_len = len; 837 {
838 ch = STRING_CHAR_AND_LENGTH (string->s + bytepos, len);
839 *ch_len = len;
840 }
841 else
842 {
843 ch = UNIBYTE_TO_CHAR (string->s[bytepos]);
844 *ch_len = 1;
845 }
824 } 846 }
825 else if (STRINGP (string->lstring)) 847 else if (STRINGP (string->lstring))
826 { 848 {
827 EMACS_INT len; 849 EMACS_INT len;
828 850
829 ch = STRING_CHAR_AND_LENGTH (SDATA (string->lstring) + bytepos, len); 851 if (!string->unibyte)
830 *ch_len = len; 852 {
853 ch = STRING_CHAR_AND_LENGTH (SDATA (string->lstring) + bytepos,
854 len);
855 *ch_len = len;
856 }
857 else
858 {
859 ch = UNIBYTE_TO_CHAR (SREF (string->lstring, bytepos));
860 *ch_len = 1;
861 }
831 } 862 }
832 else 863 else
833 { 864 {
@@ -971,7 +1002,8 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p)
971 pos = bidi_it->charpos; 1002 pos = bidi_it->charpos;
972 s = STRINGP (bidi_it->string.lstring) ? 1003 s = STRINGP (bidi_it->string.lstring) ?
973 SDATA (bidi_it->string.lstring) : bidi_it->string.s; 1004 SDATA (bidi_it->string.lstring) : bidi_it->string.s;
974 if (bytepos > begbyte && bidi_char_at_pos (bytepos, s) == '\n') 1005 if (bytepos > begbyte
1006 && bidi_char_at_pos (bytepos, s, bidi_it->string.unibyte) == '\n')
975 { 1007 {
976 bytepos++; 1008 bytepos++;
977 pos++; 1009 pos++;
@@ -1123,7 +1155,8 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1123 1155
1124 if (bidi_it->charpos < 0) 1156 if (bidi_it->charpos < 0)
1125 bidi_it->charpos = 0; 1157 bidi_it->charpos = 0;
1126 bidi_it->bytepos = bidi_count_bytes (p, 0, 0, bidi_it->charpos); 1158 bidi_it->bytepos = bidi_count_bytes (p, 0, 0, bidi_it->charpos,
1159 bidi_it->string.unibyte);
1127 } 1160 }
1128 else 1161 else
1129 { 1162 {
@@ -1308,7 +1341,8 @@ bidi_resolve_explicit (struct bidi_it *bidi_it)
1308 && bidi_it->ignore_bn_limit == -1 /* only if not already known */ 1341 && bidi_it->ignore_bn_limit == -1 /* only if not already known */
1309 && bidi_it->charpos < eob /* not already at EOB */ 1342 && bidi_it->charpos < eob /* not already at EOB */
1310 && bidi_explicit_dir_char (bidi_char_at_pos (bidi_it->bytepos 1343 && bidi_explicit_dir_char (bidi_char_at_pos (bidi_it->bytepos
1311 + bidi_it->ch_len, s))) 1344 + bidi_it->ch_len, s,
1345 bidi_it->string.unibyte)))
1312 { 1346 {
1313 /* Avoid pushing and popping embedding levels if the level run 1347 /* Avoid pushing and popping embedding levels if the level run
1314 is empty, as this breaks level runs where it shouldn't. 1348 is empty, as this breaks level runs where it shouldn't.
@@ -1321,7 +1355,8 @@ bidi_resolve_explicit (struct bidi_it *bidi_it)
1321 bidi_copy_it (&saved_it, bidi_it); 1355 bidi_copy_it (&saved_it, bidi_it);
1322 1356
1323 while (bidi_explicit_dir_char (bidi_char_at_pos (bidi_it->bytepos 1357 while (bidi_explicit_dir_char (bidi_char_at_pos (bidi_it->bytepos
1324 + bidi_it->ch_len, s))) 1358 + bidi_it->ch_len, s,
1359 bidi_it->string.unibyte)))
1325 { 1360 {
1326 /* This advances to the next character, skipping any 1361 /* This advances to the next character, skipping any
1327 characters covered by display strings. */ 1362 characters covered by display strings. */
@@ -1459,7 +1494,8 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
1459 next_char = 1494 next_char =
1460 bidi_it->charpos + bidi_it->nchars >= eob 1495 bidi_it->charpos + bidi_it->nchars >= eob
1461 ? BIDI_EOB 1496 ? BIDI_EOB
1462 : bidi_char_at_pos (bidi_it->bytepos + bidi_it->ch_len, s); 1497 : bidi_char_at_pos (bidi_it->bytepos + bidi_it->ch_len, s,
1498 bidi_it->string.unibyte);
1463 type_of_next = bidi_get_type (next_char, override); 1499 type_of_next = bidi_get_type (next_char, override);
1464 1500
1465 if (type_of_next == WEAK_BN 1501 if (type_of_next == WEAK_BN
@@ -1517,7 +1553,8 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
1517 next_char = 1553 next_char =
1518 bidi_it->charpos + bidi_it->nchars >= eob 1554 bidi_it->charpos + bidi_it->nchars >= eob
1519 ? BIDI_EOB 1555 ? BIDI_EOB
1520 : bidi_char_at_pos (bidi_it->bytepos + bidi_it->ch_len, s); 1556 : bidi_char_at_pos (bidi_it->bytepos + bidi_it->ch_len, s,
1557 bidi_it->string.unibyte);
1521 type_of_next = bidi_get_type (next_char, override); 1558 type_of_next = bidi_get_type (next_char, override);
1522 1559
1523 if (type_of_next == WEAK_ET 1560 if (type_of_next == WEAK_ET
diff --git a/src/dispextern.h b/src/dispextern.h
index 16fa3abdd19..9586edab63b 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1821,6 +1821,7 @@ struct bidi_string_data {
1821 EMACS_INT bufpos; /* buffer position of lstring, or 0 if N/A */ 1821 EMACS_INT bufpos; /* buffer position of lstring, or 0 if N/A */
1822 unsigned from_disp_str : 1; /* 1 means the string comes from a 1822 unsigned from_disp_str : 1; /* 1 means the string comes from a
1823 display property */ 1823 display property */
1824 unsigned unibyte : 1; /* 1 means the string is unibyte */
1824}; 1825};
1825 1826
1826/* Data type for reordering bidirectional text. */ 1827/* Data type for reordering bidirectional text. */
diff --git a/src/xdisp.c b/src/xdisp.c
index 3b934547471..43913eb886e 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -3113,8 +3113,9 @@ compute_display_string_pos (struct text_pos *position,
3113 Lisp_Object object = 3113 Lisp_Object object =
3114 (string && STRINGP (string->lstring)) ? string->lstring : Qnil; 3114 (string && STRINGP (string->lstring)) ? string->lstring : Qnil;
3115 Lisp_Object pos, spec; 3115 Lisp_Object pos, spec;
3116 EMACS_INT eob = STRINGP (object) ? string->schars : ZV; 3116 int string_p = (string && (STRINGP (string->lstring) || string->s));
3117 EMACS_INT begb = STRINGP (object) ? 0 : BEGV; 3117 EMACS_INT eob = string_p ? string->schars : ZV;
3118 EMACS_INT begb = string_p ? 0 : BEGV;
3118 EMACS_INT bufpos, charpos = CHARPOS (*position); 3119 EMACS_INT bufpos, charpos = CHARPOS (*position);
3119 struct text_pos tpos; 3120 struct text_pos tpos;
3120 3121
@@ -3175,7 +3176,8 @@ compute_display_string_end (EMACS_INT charpos, struct bidi_string_data *string)
3175 Lisp_Object object = 3176 Lisp_Object object =
3176 (string && STRINGP (string->lstring)) ? string->lstring : Qnil; 3177 (string && STRINGP (string->lstring)) ? string->lstring : Qnil;
3177 Lisp_Object pos = make_number (charpos); 3178 Lisp_Object pos = make_number (charpos);
3178 EMACS_INT eob = STRINGP (object) ? string->schars : ZV; 3179 EMACS_INT eob =
3180 (STRINGP (object) || (string && string->s)) ? string->schars : ZV;
3179 3181
3180 if (charpos >= eob || (string->s && !STRINGP (object))) 3182 if (charpos >= eob || (string->s && !STRINGP (object)))
3181 return eob; 3183 return eob;
@@ -4496,19 +4498,6 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
4496 it->paragraph_embedding = 4498 it->paragraph_embedding =
4497 (it->bidi_p ? it->bidi_it.paragraph_dir : L2R); 4499 (it->bidi_p ? it->bidi_it.paragraph_dir : L2R);
4498 4500
4499 /* Do we need to reorder this display string? */
4500 if (it->multibyte_p)
4501 {
4502 if (BUFFERP (object))
4503 it->bidi_p =
4504 !NILP (BVAR (XBUFFER (object), bidi_display_reordering));
4505 else
4506 it->bidi_p =
4507 !NILP (BVAR (&buffer_defaults, bidi_display_reordering));
4508 }
4509 else
4510 it->bidi_p = 0;
4511
4512 /* Set up the bidi iterator for this display string. */ 4501 /* Set up the bidi iterator for this display string. */
4513 if (it->bidi_p) 4502 if (it->bidi_p)
4514 { 4503 {
@@ -4517,6 +4506,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
4517 it->bidi_it.string.schars = it->end_charpos; 4506 it->bidi_it.string.schars = it->end_charpos;
4518 it->bidi_it.string.bufpos = bufpos; 4507 it->bidi_it.string.bufpos = bufpos;
4519 it->bidi_it.string.from_disp_str = 1; 4508 it->bidi_it.string.from_disp_str = 1;
4509 it->bidi_it.string.unibyte = !it->multibyte_p;
4520 bidi_init_it (0, 0, FRAME_WINDOW_P (it->f), &it->bidi_it); 4510 bidi_init_it (0, 0, FRAME_WINDOW_P (it->f), &it->bidi_it);
4521 } 4511 }
4522 } 4512 }
@@ -4873,11 +4863,6 @@ next_overlay_string (struct it *it)
4873 it->prev_stop = 0; 4863 it->prev_stop = 0;
4874 it->base_level_stop = 0; 4864 it->base_level_stop = 0;
4875 4865
4876 /* Do we need to reorder this overlay string? */
4877 it->bidi_p =
4878 it->multibyte_p
4879 && !NILP (BVAR (current_buffer, bidi_display_reordering));
4880
4881 /* Set up the bidi iterator for this overlay string. */ 4866 /* Set up the bidi iterator for this overlay string. */
4882 if (it->bidi_p) 4867 if (it->bidi_p)
4883 { 4868 {
@@ -4886,6 +4871,7 @@ next_overlay_string (struct it *it)
4886 it->bidi_it.string.schars = SCHARS (it->string); 4871 it->bidi_it.string.schars = SCHARS (it->string);
4887 it->bidi_it.string.bufpos = it->overlay_strings_charpos; 4872 it->bidi_it.string.bufpos = it->overlay_strings_charpos;
4888 it->bidi_it.string.from_disp_str = it->string_from_display_prop_p; 4873 it->bidi_it.string.from_disp_str = it->string_from_display_prop_p;
4874 it->bidi_it.string.unibyte = !it->multibyte_p;
4889 bidi_init_it (0, 0, FRAME_WINDOW_P (it->f), &it->bidi_it); 4875 bidi_init_it (0, 0, FRAME_WINDOW_P (it->f), &it->bidi_it);
4890 } 4876 }
4891 } 4877 }
@@ -5159,11 +5145,6 @@ get_overlay_strings_1 (struct it *it, EMACS_INT charpos, int compute_stop_p)
5159 it->multibyte_p = STRING_MULTIBYTE (it->string); 5145 it->multibyte_p = STRING_MULTIBYTE (it->string);
5160 it->method = GET_FROM_STRING; 5146 it->method = GET_FROM_STRING;
5161 5147
5162 /* Do we need to reorder this overlay string? */
5163 it->bidi_p =
5164 it->multibyte_p
5165 && !NILP (BVAR (current_buffer, bidi_display_reordering));
5166
5167 /* Force paragraph direction to be that of the parent 5148 /* Force paragraph direction to be that of the parent
5168 buffer. */ 5149 buffer. */
5169 it->paragraph_embedding = (it->bidi_p ? it->bidi_it.paragraph_dir : L2R); 5150 it->paragraph_embedding = (it->bidi_p ? it->bidi_it.paragraph_dir : L2R);
@@ -5178,6 +5159,7 @@ get_overlay_strings_1 (struct it *it, EMACS_INT charpos, int compute_stop_p)
5178 it->bidi_it.string.schars = SCHARS (it->string); 5159 it->bidi_it.string.schars = SCHARS (it->string);
5179 it->bidi_it.string.bufpos = pos; 5160 it->bidi_it.string.bufpos = pos;
5180 it->bidi_it.string.from_disp_str = it->string_from_display_prop_p; 5161 it->bidi_it.string.from_disp_str = it->string_from_display_prop_p;
5162 it->bidi_it.string.unibyte = !it->multibyte_p;
5181 bidi_init_it (0, 0, FRAME_WINDOW_P (it->f), &it->bidi_it); 5163 bidi_init_it (0, 0, FRAME_WINDOW_P (it->f), &it->bidi_it);
5182 } 5164 }
5183 return 1; 5165 return 1;
@@ -5747,6 +5729,7 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p)
5747 it->bidi_it.string.s = NULL; 5729 it->bidi_it.string.s = NULL;
5748 it->bidi_it.string.lstring = Qnil; 5730 it->bidi_it.string.lstring = Qnil;
5749 it->bidi_it.string.bufpos = 0; 5731 it->bidi_it.string.bufpos = 0;
5732 it->bidi_it.string.unibyte = 0;
5750 } 5733 }
5751 5734
5752 if (set_stop_p) 5735 if (set_stop_p)
@@ -5799,9 +5782,7 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
5799 5782
5800 /* Bidirectional reordering of strings is controlled by the default 5783 /* Bidirectional reordering of strings is controlled by the default
5801 value of bidi-display-reordering. */ 5784 value of bidi-display-reordering. */
5802 it->bidi_p = 5785 it->bidi_p = !NILP (BVAR (&buffer_defaults, bidi_display_reordering));
5803 !NILP (BVAR (&buffer_defaults, bidi_display_reordering))
5804 && it->multibyte_p;
5805 5786
5806 if (s == NULL) 5787 if (s == NULL)
5807 { 5788 {
@@ -5819,6 +5800,7 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
5819 it->bidi_it.string.schars = it->end_charpos; 5800 it->bidi_it.string.schars = it->end_charpos;
5820 it->bidi_it.string.bufpos = 0; 5801 it->bidi_it.string.bufpos = 0;
5821 it->bidi_it.string.from_disp_str = 0; 5802 it->bidi_it.string.from_disp_str = 0;
5803 it->bidi_it.string.unibyte = !it->multibyte_p;
5822 bidi_init_it (charpos, IT_STRING_BYTEPOS (*it), 5804 bidi_init_it (charpos, IT_STRING_BYTEPOS (*it),
5823 FRAME_WINDOW_P (it->f), &it->bidi_it); 5805 FRAME_WINDOW_P (it->f), &it->bidi_it);
5824 } 5806 }
@@ -5835,25 +5817,24 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
5835 { 5817 {
5836 it->current.pos = c_string_pos (charpos, s, 1); 5818 it->current.pos = c_string_pos (charpos, s, 1);
5837 it->end_charpos = it->string_nchars = number_of_chars (s, 1); 5819 it->end_charpos = it->string_nchars = number_of_chars (s, 1);
5838
5839 if (it->bidi_p)
5840 {
5841 it->bidi_it.string.lstring = Qnil;
5842 it->bidi_it.string.s = s;
5843 it->bidi_it.string.schars = it->end_charpos;
5844 it->bidi_it.string.bufpos = 0;
5845 it->bidi_it.string.from_disp_str = 0;
5846 bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f),
5847 &it->bidi_it);
5848 }
5849 } 5820 }
5850 else 5821 else
5851 { 5822 {
5852 /* Unibyte (a.k.a. ASCII) C strings are never bidi-reordered. */
5853 IT_CHARPOS (*it) = IT_BYTEPOS (*it) = charpos; 5823 IT_CHARPOS (*it) = IT_BYTEPOS (*it) = charpos;
5854 it->end_charpos = it->string_nchars = strlen (s); 5824 it->end_charpos = it->string_nchars = strlen (s);
5855 } 5825 }
5856 5826
5827 if (it->bidi_p)
5828 {
5829 it->bidi_it.string.lstring = Qnil;
5830 it->bidi_it.string.s = s;
5831 it->bidi_it.string.schars = it->end_charpos;
5832 it->bidi_it.string.bufpos = 0;
5833 it->bidi_it.string.from_disp_str = 0;
5834 it->bidi_it.string.unibyte = !it->multibyte_p;
5835 bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f),
5836 &it->bidi_it);
5837 }
5857 it->method = GET_FROM_C_STRING; 5838 it->method = GET_FROM_C_STRING;
5858 } 5839 }
5859 5840
@@ -17788,12 +17769,6 @@ push_display_prop (struct it *it, Lisp_Object prop)
17788 buffer. */ 17769 buffer. */
17789 it->paragraph_embedding = (it->bidi_p ? it->bidi_it.paragraph_dir : L2R); 17770 it->paragraph_embedding = (it->bidi_p ? it->bidi_it.paragraph_dir : L2R);
17790 17771
17791 /* Do we need to reorder this string? */
17792 if (it->multibyte_p)
17793 it->bidi_p = !NILP (BVAR (current_buffer, bidi_display_reordering));
17794 else
17795 it->bidi_p = 0;
17796
17797 /* Set up the bidi iterator for this display string. */ 17772 /* Set up the bidi iterator for this display string. */
17798 if (it->bidi_p) 17773 if (it->bidi_p)
17799 { 17774 {
@@ -17802,6 +17777,7 @@ push_display_prop (struct it *it, Lisp_Object prop)
17802 it->bidi_it.string.schars = it->end_charpos; 17777 it->bidi_it.string.schars = it->end_charpos;
17803 it->bidi_it.string.bufpos = IT_CHARPOS (*it); 17778 it->bidi_it.string.bufpos = IT_CHARPOS (*it);
17804 it->bidi_it.string.from_disp_str = 1; 17779 it->bidi_it.string.from_disp_str = 1;
17780 it->bidi_it.string.unibyte = !it->multibyte_p;
17805 bidi_init_it (0, 0, FRAME_WINDOW_P (it->f), &it->bidi_it); 17781 bidi_init_it (0, 0, FRAME_WINDOW_P (it->f), &it->bidi_it);
17806 } 17782 }
17807 } 17783 }