aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2014-09-20 18:00:08 +0300
committerEli Zaretskii2014-09-20 18:00:08 +0300
commit61a403ecde239da3712469adbb183d0ed25b81f1 (patch)
treeb5d6b5ab78ca0abead36a6489fd1482801ba6928
parentc58ad38af204a2bb871c6e9e721e352a6e2a7c6d (diff)
downloademacs-61a403ecde239da3712469adbb183d0ed25b81f1.tar.gz
emacs-61a403ecde239da3712469adbb183d0ed25b81f1.zip
Fixed bidi_resolve_explicit_1 wrt isolate initiators and PDF.
bidi_resolve_neutral needs to be fixed, as it now aborts at line 2432.
-rw-r--r--src/bidi.c55
1 files changed, 35 insertions, 20 deletions
diff --git a/src/bidi.c b/src/bidi.c
index 8d26dde4cf2..d928a00af30 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -1681,7 +1681,7 @@ static int
1681bidi_resolve_explicit_1 (struct bidi_it *bidi_it) 1681bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1682{ 1682{
1683 int curchar; 1683 int curchar;
1684 bidi_type_t type, typ1; 1684 bidi_type_t type, typ1, prev_type = UNKNOWN_BT;;
1685 int current_level; 1685 int current_level;
1686 int new_level; 1686 int new_level;
1687 bidi_dir_t override; 1687 bidi_dir_t override;
@@ -1719,6 +1719,17 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1719 } 1719 }
1720 eassert (bidi_it->bytepos == CHAR_TO_BYTE (bidi_it->charpos)); 1720 eassert (bidi_it->bytepos == CHAR_TO_BYTE (bidi_it->charpos));
1721 } 1721 }
1722 /* Determine the orginal bidi type of the previous character,
1723 which is needed for handling isolate initiators and PDF. The
1724 type of the previous character will only be non-trivial if
1725 our caller moved through some previous text in
1726 get_visually_first_element, in which case bidi_it->prev holds
1727 the information we want. */
1728 if (bidi_it->first_elt && bidi_it->prev.type != UNKNOWN_BT)
1729 {
1730 eassert (bidi_it->prev.charpos == bidi_it->charpos - 1);
1731 prev_type = bidi_it->prev.orig_type;
1732 }
1722 } 1733 }
1723 /* Don't move at end of buffer/string. */ 1734 /* Don't move at end of buffer/string. */
1724 else if (bidi_it->charpos < (string_p ? bidi_it->string.schars : ZV)) 1735 else if (bidi_it->charpos < (string_p ? bidi_it->string.schars : ZV))
@@ -1731,6 +1742,7 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1731 if (bidi_it->ch_len == 0) 1742 if (bidi_it->ch_len == 0)
1732 emacs_abort (); 1743 emacs_abort ();
1733 bidi_it->bytepos += bidi_it->ch_len; 1744 bidi_it->bytepos += bidi_it->ch_len;
1745 prev_type = bidi_it->orig_type;
1734 } 1746 }
1735 1747
1736 current_level = bidi_it->level_stack[bidi_it->stack_idx].level; /* X1 */ 1748 current_level = bidi_it->level_stack[bidi_it->stack_idx].level; /* X1 */
@@ -1864,26 +1876,18 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1864 bidi_it->type_after_w1 = type; 1876 bidi_it->type_after_w1 = type;
1865 bidi_check_type (bidi_it->type_after_w1); 1877 bidi_check_type (bidi_it->type_after_w1);
1866 type = WEAK_BN; /* X9/Retaining */ 1878 type = WEAK_BN; /* X9/Retaining */
1867 if (bidi_it->ignore_bn_limit <= -1) 1879 if (bidi_it->ignore_bn_limit > -1
1868 { 1880 && bidi_it->prev.type_after_w1 == WEAK_EN /* W5/Retaining */
1869 if (!bidi_it->invalid_isolates) 1881 || (bidi_it->next_en_pos > bidi_it->charpos
1870 { 1882 && bidi_it->next_en_type == WEAK_EN))
1871 if (bidi_it->invalid_levels)
1872 bidi_it->invalid_levels--;
1873 else if (!isolate_status && bidi_it->stack_idx > 1)
1874 bidi_pop_embedding_level (bidi_it);
1875 }
1876 }
1877 else if (bidi_it->prev.type_after_w1 == WEAK_EN /* W5/Retaining */
1878 || (bidi_it->next_en_pos > bidi_it->charpos
1879 && bidi_it->next_en_type == WEAK_EN))
1880 type = WEAK_EN; 1883 type = WEAK_EN;
1881 break; 1884 break;
1882 default: 1885 default:
1883 /* LRI, RLI, and FSI increment the embedding level of the 1886 /* LRI, RLI, and FSI increment, and PDF decrements, the
1884 _following_ charcaters, so we must look at the type of the 1887 embedding level of the _following_ characters, so we must
1885 previous character to support that. */ 1888 look at the type of the previous character to support
1886 switch (bidi_it->prev.orig_type) 1889 that. */
1890 switch (prev_type)
1887 { 1891 {
1888 case FSI: /* X5c */ 1892 case FSI: /* X5c */
1889 end = string_p ? bidi_it->string.schars : ZV; 1893 end = string_p ? bidi_it->string.schars : ZV;
@@ -1906,7 +1910,6 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1906 type = RLI; 1910 type = RLI;
1907 /* FALLTHROUGH */ 1911 /* FALLTHROUGH */
1908 case RLI: /* X5a */ 1912 case RLI: /* X5a */
1909 eassert (bidi_it->prev.charpos == bidi_it->charpos - 1);
1910 if (override == NEUTRAL_DIR) 1913 if (override == NEUTRAL_DIR)
1911 bidi_it->type_after_w1 = type; 1914 bidi_it->type_after_w1 = type;
1912 else /* Unicode 8.0 correction. */ 1915 else /* Unicode 8.0 correction. */
@@ -1926,7 +1929,6 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1926 break; 1929 break;
1927 case LRI: /* X5b */ 1930 case LRI: /* X5b */
1928 fsi_as_lri: 1931 fsi_as_lri:
1929 eassert (bidi_it->prev.charpos == bidi_it->charpos - 1);
1930 if (override == NEUTRAL_DIR) 1932 if (override == NEUTRAL_DIR)
1931 bidi_it->type_after_w1 = type; 1933 bidi_it->type_after_w1 = type;
1932 else /* Unicode 8.0 correction. */ 1934 else /* Unicode 8.0 correction. */
@@ -1944,6 +1946,19 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1944 else 1946 else
1945 bidi_it->invalid_isolates++; 1947 bidi_it->invalid_isolates++;
1946 break; 1948 break;
1949 case PDF: /* X7 */
1950 if (bidi_it->ignore_bn_limit <= -1)
1951 {
1952 if (!bidi_it->invalid_isolates)
1953 {
1954 if (bidi_it->invalid_levels)
1955 bidi_it->invalid_levels--;
1956 else if (!isolate_status && bidi_it->stack_idx >= 1)
1957 new_level = bidi_pop_embedding_level (bidi_it);
1958 }
1959 bidi_it->resolved_level = new_level;
1960 }
1961 break;
1947 default: 1962 default:
1948 /* Nothing. */ 1963 /* Nothing. */
1949 break; 1964 break;