diff options
| author | Miles Bader | 2005-06-06 02:39:45 +0000 |
|---|---|---|
| committer | Miles Bader | 2005-06-06 02:39:45 +0000 |
| commit | fdffd346262841cb194225ea0acd8059c57ec2d4 (patch) | |
| tree | d8b3699131f7d1b94bc46c7d8be62af6b8b5ebfe /src/ccl.c | |
| parent | a5c508fe3a3f456c987283156315d0384d38fe9e (diff) | |
| parent | a9b4333620eb259e974445066a8e64cee0c21d69 (diff) | |
| download | emacs-fdffd346262841cb194225ea0acd8059c57ec2d4.tar.gz emacs-fdffd346262841cb194225ea0acd8059c57ec2d4.zip | |
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-57
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 324-352)
- Merge from gnus--rel--5.10
- Update from CVS
- etc/emacs-buffer.gdb: Remove RCS keywords
* gnus--rel--5.10 (patch 70-79)
- Update from CVS
- Merge from emacs--cvs-trunk--0
Diffstat (limited to 'src/ccl.c')
| -rw-r--r-- | src/ccl.c | 72 |
1 files changed, 56 insertions, 16 deletions
| @@ -55,10 +55,12 @@ Lisp_Object Qcode_conversion_map_id; | |||
| 55 | Lisp_Object Qccl_program_idx; | 55 | Lisp_Object Qccl_program_idx; |
| 56 | 56 | ||
| 57 | /* Table of registered CCL programs. Each element is a vector of | 57 | /* Table of registered CCL programs. Each element is a vector of |
| 58 | NAME, CCL_PROG, and RESOLVEDP where NAME (symbol) is the name of | 58 | NAME, CCL_PROG, RESOLVEDP, and UPDATEDP, where NAME (symbol) is the |
| 59 | the program, CCL_PROG (vector) is the compiled code of the program, | 59 | name of the program, CCL_PROG (vector) is the compiled code of the |
| 60 | RESOLVEDP (t or nil) is the flag to tell if symbols in CCL_PROG is | 60 | program, RESOLVEDP (t or nil) is the flag to tell if symbols in |
| 61 | already resolved to index numbers or not. */ | 61 | CCL_PROG is already resolved to index numbers or not, UPDATEDP (t |
| 62 | or nil) is the flat to tell if the CCL program is updated after it | ||
| 63 | was once used. */ | ||
| 62 | Lisp_Object Vccl_program_table; | 64 | Lisp_Object Vccl_program_table; |
| 63 | 65 | ||
| 64 | /* Vector of registered hash tables for translation. */ | 66 | /* Vector of registered hash tables for translation. */ |
| @@ -1850,14 +1852,16 @@ resolve_symbol_ccl_program (ccl) | |||
| 1850 | symbols, return Qnil. */ | 1852 | symbols, return Qnil. */ |
| 1851 | 1853 | ||
| 1852 | static Lisp_Object | 1854 | static Lisp_Object |
| 1853 | ccl_get_compiled_code (ccl_prog) | 1855 | ccl_get_compiled_code (ccl_prog, idx) |
| 1854 | Lisp_Object ccl_prog; | 1856 | Lisp_Object ccl_prog; |
| 1857 | int *idx; | ||
| 1855 | { | 1858 | { |
| 1856 | Lisp_Object val, slot; | 1859 | Lisp_Object val, slot; |
| 1857 | 1860 | ||
| 1858 | if (VECTORP (ccl_prog)) | 1861 | if (VECTORP (ccl_prog)) |
| 1859 | { | 1862 | { |
| 1860 | val = resolve_symbol_ccl_program (ccl_prog); | 1863 | val = resolve_symbol_ccl_program (ccl_prog); |
| 1864 | *idx = -1; | ||
| 1861 | return (VECTORP (val) ? val : Qnil); | 1865 | return (VECTORP (val) ? val : Qnil); |
| 1862 | } | 1866 | } |
| 1863 | if (!SYMBOLP (ccl_prog)) | 1867 | if (!SYMBOLP (ccl_prog)) |
| @@ -1869,9 +1873,10 @@ ccl_get_compiled_code (ccl_prog) | |||
| 1869 | return Qnil; | 1873 | return Qnil; |
| 1870 | slot = AREF (Vccl_program_table, XINT (val)); | 1874 | slot = AREF (Vccl_program_table, XINT (val)); |
| 1871 | if (! VECTORP (slot) | 1875 | if (! VECTORP (slot) |
| 1872 | || ASIZE (slot) != 3 | 1876 | || ASIZE (slot) != 4 |
| 1873 | || ! VECTORP (AREF (slot, 1))) | 1877 | || ! VECTORP (AREF (slot, 1))) |
| 1874 | return Qnil; | 1878 | return Qnil; |
| 1879 | *idx = XINT (val); | ||
| 1875 | if (NILP (AREF (slot, 2))) | 1880 | if (NILP (AREF (slot, 2))) |
| 1876 | { | 1881 | { |
| 1877 | val = resolve_symbol_ccl_program (AREF (slot, 1)); | 1882 | val = resolve_symbol_ccl_program (AREF (slot, 1)); |
| @@ -1900,7 +1905,7 @@ setup_ccl_program (ccl, ccl_prog) | |||
| 1900 | { | 1905 | { |
| 1901 | struct Lisp_Vector *vp; | 1906 | struct Lisp_Vector *vp; |
| 1902 | 1907 | ||
| 1903 | ccl_prog = ccl_get_compiled_code (ccl_prog); | 1908 | ccl_prog = ccl_get_compiled_code (ccl_prog, &ccl->idx); |
| 1904 | if (! VECTORP (ccl_prog)) | 1909 | if (! VECTORP (ccl_prog)) |
| 1905 | return -1; | 1910 | return -1; |
| 1906 | vp = XVECTOR (ccl_prog); | 1911 | vp = XVECTOR (ccl_prog); |
| @@ -1908,6 +1913,13 @@ setup_ccl_program (ccl, ccl_prog) | |||
| 1908 | ccl->prog = vp->contents; | 1913 | ccl->prog = vp->contents; |
| 1909 | ccl->eof_ic = XINT (vp->contents[CCL_HEADER_EOF]); | 1914 | ccl->eof_ic = XINT (vp->contents[CCL_HEADER_EOF]); |
| 1910 | ccl->buf_magnification = XINT (vp->contents[CCL_HEADER_BUF_MAG]); | 1915 | ccl->buf_magnification = XINT (vp->contents[CCL_HEADER_BUF_MAG]); |
| 1916 | if (ccl->idx >= 0) | ||
| 1917 | { | ||
| 1918 | Lisp_Object slot; | ||
| 1919 | |||
| 1920 | slot = AREF (Vccl_program_table, ccl->idx); | ||
| 1921 | ASET (slot, 3, Qnil); | ||
| 1922 | } | ||
| 1911 | } | 1923 | } |
| 1912 | ccl->ic = CCL_HEADER_MAIN; | 1924 | ccl->ic = CCL_HEADER_MAIN; |
| 1913 | for (i = 0; i < 8; i++) | 1925 | for (i = 0; i < 8; i++) |
| @@ -1921,6 +1933,33 @@ setup_ccl_program (ccl, ccl_prog) | |||
| 1921 | return 0; | 1933 | return 0; |
| 1922 | } | 1934 | } |
| 1923 | 1935 | ||
| 1936 | |||
| 1937 | /* Check if CCL is updated or not. If not, re-setup members of CCL. */ | ||
| 1938 | |||
| 1939 | int | ||
| 1940 | check_ccl_update (ccl) | ||
| 1941 | struct ccl_program *ccl; | ||
| 1942 | { | ||
| 1943 | struct Lisp_Vector *vp; | ||
| 1944 | Lisp_Object slot, ccl_prog; | ||
| 1945 | |||
| 1946 | if (ccl->idx < 0) | ||
| 1947 | return 0; | ||
| 1948 | slot = AREF (Vccl_program_table, ccl->idx); | ||
| 1949 | if (NILP (AREF (slot, 3))) | ||
| 1950 | return 0; | ||
| 1951 | ccl_prog = ccl_get_compiled_code (AREF (slot, 0), &ccl->idx); | ||
| 1952 | if (! VECTORP (ccl_prog)) | ||
| 1953 | return -1; | ||
| 1954 | ccl->size = ASIZE (ccl_prog); | ||
| 1955 | ccl->prog = XVECTOR (ccl_prog)->contents; | ||
| 1956 | ccl->eof_ic = XINT (AREF (ccl_prog, CCL_HEADER_EOF)); | ||
| 1957 | ccl->buf_magnification = XINT (AREF (ccl_prog, CCL_HEADER_BUF_MAG)); | ||
| 1958 | ASET (slot, 3, Qnil); | ||
| 1959 | return 0; | ||
| 1960 | } | ||
| 1961 | |||
| 1962 | |||
| 1924 | DEFUN ("ccl-program-p", Fccl_program_p, Sccl_program_p, 1, 1, 0, | 1963 | DEFUN ("ccl-program-p", Fccl_program_p, Sccl_program_p, 1, 1, 0, |
| 1925 | doc: /* Return t if OBJECT is a CCL program name or a compiled CCL program code. | 1964 | doc: /* Return t if OBJECT is a CCL program name or a compiled CCL program code. |
| 1926 | See the documentation of `define-ccl-program' for the detail of CCL program. */) | 1965 | See the documentation of `define-ccl-program' for the detail of CCL program. */) |
| @@ -2178,8 +2217,9 @@ Return index number of the registered CCL program. */) | |||
| 2178 | if (EQ (name, AREF (slot, 0))) | 2217 | if (EQ (name, AREF (slot, 0))) |
| 2179 | { | 2218 | { |
| 2180 | /* Update this slot. */ | 2219 | /* Update this slot. */ |
| 2181 | AREF (slot, 1) = ccl_prog; | 2220 | ASET (slot, 1, ccl_prog); |
| 2182 | AREF (slot, 2) = resolved; | 2221 | ASET (slot, 2, resolved); |
| 2222 | ASET (slot, 3, Qt); | ||
| 2183 | return make_number (idx); | 2223 | return make_number (idx); |
| 2184 | } | 2224 | } |
| 2185 | } | 2225 | } |
| @@ -2192,19 +2232,19 @@ Return index number of the registered CCL program. */) | |||
| 2192 | 2232 | ||
| 2193 | new_table = Fmake_vector (make_number (len * 2), Qnil); | 2233 | new_table = Fmake_vector (make_number (len * 2), Qnil); |
| 2194 | for (j = 0; j < len; j++) | 2234 | for (j = 0; j < len; j++) |
| 2195 | AREF (new_table, j) | 2235 | ASET (new_table, j, AREF (Vccl_program_table, j)); |
| 2196 | = AREF (Vccl_program_table, j); | ||
| 2197 | Vccl_program_table = new_table; | 2236 | Vccl_program_table = new_table; |
| 2198 | } | 2237 | } |
| 2199 | 2238 | ||
| 2200 | { | 2239 | { |
| 2201 | Lisp_Object elt; | 2240 | Lisp_Object elt; |
| 2202 | 2241 | ||
| 2203 | elt = Fmake_vector (make_number (3), Qnil); | 2242 | elt = Fmake_vector (make_number (4), Qnil); |
| 2204 | AREF (elt, 0) = name; | 2243 | ASET (elt, 0, name); |
| 2205 | AREF (elt, 1) = ccl_prog; | 2244 | ASET (elt, 1, ccl_prog); |
| 2206 | AREF (elt, 2) = resolved; | 2245 | ASET (elt, 2, resolved); |
| 2207 | AREF (Vccl_program_table, idx) = elt; | 2246 | ASET (elt, 3, Qt); |
| 2247 | ASET (Vccl_program_table, idx, elt); | ||
| 2208 | } | 2248 | } |
| 2209 | 2249 | ||
| 2210 | Fput (name, Qccl_program_idx, make_number (idx)); | 2250 | Fput (name, Qccl_program_idx, make_number (idx)); |