diff options
| author | Eli Zaretskii | 2014-09-20 12:56:38 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2014-09-20 12:56:38 +0300 |
| commit | c58ad38af204a2bb871c6e9e721e352a6e2a7c6d (patch) | |
| tree | 4ff9f095d8ed82202da45202eda94d1814fcc096 /src | |
| parent | 0c068f1d4fb62737984c4134760cd67c6968fbbb (diff) | |
| download | emacs-c58ad38af204a2bb871c6e9e721e352a6e2a7c6d.tar.gz emacs-c58ad38af204a2bb871c6e9e721e352a6e2a7c6d.zip | |
Rewrite LRI/RLI/FSI handling in bidi_resolve_explicit_1.
Diffstat (limited to 'src')
| -rw-r--r-- | src/bidi.c | 124 |
1 files changed, 69 insertions, 55 deletions
diff --git a/src/bidi.c b/src/bidi.c index 3c204a82b78..8d26dde4cf2 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -1836,59 +1836,6 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it) | |||
| 1836 | && bidi_it->next_en_type == WEAK_EN)) | 1836 | && bidi_it->next_en_type == WEAK_EN)) |
| 1837 | type = WEAK_EN; | 1837 | type = WEAK_EN; |
| 1838 | break; | 1838 | break; |
| 1839 | case FSI: /* X5c */ | ||
| 1840 | end = string_p ? bidi_it->string.schars : ZV; | ||
| 1841 | disp_pos = bidi_it->disp_pos; | ||
| 1842 | disp_prop = bidi_it->disp_prop; | ||
| 1843 | nchars = bidi_it->nchars; | ||
| 1844 | ch_len = bidi_it->ch_len; | ||
| 1845 | typ1 = find_first_strong_char (bidi_it->charpos, bidi_it->bytepos, end, | ||
| 1846 | &disp_pos, &disp_prop, &bidi_it->string, | ||
| 1847 | bidi_it->w, string_p, bidi_it->frame_window_p, | ||
| 1848 | &ch_len, &nchars, true); | ||
| 1849 | if (typ1 != STRONG_R && typ1 != STRONG_AL) | ||
| 1850 | { | ||
| 1851 | type = LRI; | ||
| 1852 | goto fsi_as_lri; | ||
| 1853 | } | ||
| 1854 | else | ||
| 1855 | type = RLI; | ||
| 1856 | /* FALLTHROUGH */ | ||
| 1857 | case RLI: /* X5a */ | ||
| 1858 | if (override == NEUTRAL_DIR) | ||
| 1859 | bidi_it->type_after_w1 = type; | ||
| 1860 | else /* Unicode 8.0 correction. */ | ||
| 1861 | bidi_it->type_after_w1 = (override == L2R ? STRONG_L : STRONG_R); | ||
| 1862 | bidi_check_type (bidi_it->type_after_w1); | ||
| 1863 | if (current_level < BIDI_MAXDEPTH | ||
| 1864 | && bidi_it->invalid_levels == 0 | ||
| 1865 | && bidi_it->invalid_isolates == 0) | ||
| 1866 | { | ||
| 1867 | new_level = ((current_level + 1) & ~1) + 1; | ||
| 1868 | bidi_it->isolate_level++; | ||
| 1869 | bidi_push_embedding_level (bidi_it, new_level, NEUTRAL_DIR, true); | ||
| 1870 | } | ||
| 1871 | else | ||
| 1872 | bidi_it->invalid_isolates++; | ||
| 1873 | break; | ||
| 1874 | case LRI: /* X5b */ | ||
| 1875 | fsi_as_lri: | ||
| 1876 | if (override == NEUTRAL_DIR) | ||
| 1877 | bidi_it->type_after_w1 = type; | ||
| 1878 | else /* Unicode 8.0 correction. */ | ||
| 1879 | bidi_it->type_after_w1 = (override == L2R ? STRONG_L : STRONG_R); | ||
| 1880 | bidi_check_type (bidi_it->type_after_w1); | ||
| 1881 | if (current_level < BIDI_MAXDEPTH - 1 | ||
| 1882 | && bidi_it->invalid_levels == 0 | ||
| 1883 | && bidi_it->invalid_isolates == 0) | ||
| 1884 | { | ||
| 1885 | new_level = ((current_level + 2) & ~1); | ||
| 1886 | bidi_it->isolate_level++; | ||
| 1887 | bidi_push_embedding_level (bidi_it, new_level, NEUTRAL_DIR, true); | ||
| 1888 | } | ||
| 1889 | else | ||
| 1890 | bidi_it->invalid_isolates++; | ||
| 1891 | break; | ||
| 1892 | case PDI: /* X6a */ | 1839 | case PDI: /* X6a */ |
| 1893 | if (bidi_it->invalid_isolates) | 1840 | if (bidi_it->invalid_isolates) |
| 1894 | { | 1841 | { |
| @@ -1933,8 +1880,74 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it) | |||
| 1933 | type = WEAK_EN; | 1880 | type = WEAK_EN; |
| 1934 | break; | 1881 | break; |
| 1935 | default: | 1882 | default: |
| 1936 | /* Nothing. */ | 1883 | /* LRI, RLI, and FSI increment the embedding level of the |
| 1937 | break; | 1884 | _following_ charcaters, so we must look at the type of the |
| 1885 | previous character to support that. */ | ||
| 1886 | switch (bidi_it->prev.orig_type) | ||
| 1887 | { | ||
| 1888 | case FSI: /* X5c */ | ||
| 1889 | end = string_p ? bidi_it->string.schars : ZV; | ||
| 1890 | disp_pos = bidi_it->disp_pos; | ||
| 1891 | disp_prop = bidi_it->disp_prop; | ||
| 1892 | nchars = bidi_it->nchars; | ||
| 1893 | ch_len = bidi_it->ch_len; | ||
| 1894 | typ1 = find_first_strong_char (bidi_it->charpos, | ||
| 1895 | bidi_it->bytepos, end, | ||
| 1896 | &disp_pos, &disp_prop, | ||
| 1897 | &bidi_it->string, bidi_it->w, | ||
| 1898 | string_p, bidi_it->frame_window_p, | ||
| 1899 | &ch_len, &nchars, true); | ||
| 1900 | if (typ1 != STRONG_R && typ1 != STRONG_AL) | ||
| 1901 | { | ||
| 1902 | type = LRI; | ||
| 1903 | goto fsi_as_lri; | ||
| 1904 | } | ||
| 1905 | else | ||
| 1906 | type = RLI; | ||
| 1907 | /* FALLTHROUGH */ | ||
| 1908 | case RLI: /* X5a */ | ||
| 1909 | eassert (bidi_it->prev.charpos == bidi_it->charpos - 1); | ||
| 1910 | if (override == NEUTRAL_DIR) | ||
| 1911 | bidi_it->type_after_w1 = type; | ||
| 1912 | else /* Unicode 8.0 correction. */ | ||
| 1913 | bidi_it->type_after_w1 = (override == L2R ? STRONG_L : STRONG_R); | ||
| 1914 | bidi_check_type (bidi_it->type_after_w1); | ||
| 1915 | if (current_level < BIDI_MAXDEPTH | ||
| 1916 | && bidi_it->invalid_levels == 0 | ||
| 1917 | && bidi_it->invalid_isolates == 0) | ||
| 1918 | { | ||
| 1919 | new_level = ((current_level + 1) & ~1) + 1; | ||
| 1920 | bidi_it->isolate_level++; | ||
| 1921 | bidi_push_embedding_level (bidi_it, new_level, | ||
| 1922 | NEUTRAL_DIR, true); | ||
| 1923 | } | ||
| 1924 | else | ||
| 1925 | bidi_it->invalid_isolates++; | ||
| 1926 | break; | ||
| 1927 | case LRI: /* X5b */ | ||
| 1928 | fsi_as_lri: | ||
| 1929 | eassert (bidi_it->prev.charpos == bidi_it->charpos - 1); | ||
| 1930 | if (override == NEUTRAL_DIR) | ||
| 1931 | bidi_it->type_after_w1 = type; | ||
| 1932 | else /* Unicode 8.0 correction. */ | ||
| 1933 | bidi_it->type_after_w1 = (override == L2R ? STRONG_L : STRONG_R); | ||
| 1934 | bidi_check_type (bidi_it->type_after_w1); | ||
| 1935 | if (current_level < BIDI_MAXDEPTH - 1 | ||
| 1936 | && bidi_it->invalid_levels == 0 | ||
| 1937 | && bidi_it->invalid_isolates == 0) | ||
| 1938 | { | ||
| 1939 | new_level = ((current_level + 2) & ~1); | ||
| 1940 | bidi_it->isolate_level++; | ||
| 1941 | bidi_push_embedding_level (bidi_it, new_level, | ||
| 1942 | NEUTRAL_DIR, true); | ||
| 1943 | } | ||
| 1944 | else | ||
| 1945 | bidi_it->invalid_isolates++; | ||
| 1946 | break; | ||
| 1947 | default: | ||
| 1948 | /* Nothing. */ | ||
| 1949 | break; | ||
| 1950 | } | ||
| 1938 | } | 1951 | } |
| 1939 | 1952 | ||
| 1940 | bidi_it->type = type; | 1953 | bidi_it->type = type; |
| @@ -1983,6 +1996,7 @@ bidi_resolve_explicit (struct bidi_it *bidi_it) | |||
| 1983 | + bidi_it->ch_len, s, | 1996 | + bidi_it->ch_len, s, |
| 1984 | bidi_it->string.unibyte))) | 1997 | bidi_it->string.unibyte))) |
| 1985 | { | 1998 | { |
| 1999 | bidi_remember_char (&bidi_it->prev, bidi_it); | ||
| 1986 | /* This advances to the next character, skipping any | 2000 | /* This advances to the next character, skipping any |
| 1987 | characters covered by display strings. */ | 2001 | characters covered by display strings. */ |
| 1988 | level = bidi_resolve_explicit_1 (bidi_it); | 2002 | level = bidi_resolve_explicit_1 (bidi_it); |