1 ;;; pccl-20.el --- Portable CCL utility for Emacs 20 and XEmacs-21-mule
3 ;; Copyright (C) 1998,1999,2000 Free Software Foundation, Inc.
5 ;; Author: Tanaka Akira <akr@m17n.org>
6 ;; Keywords: emulation, compatibility, Mule
8 ;; This file is part of APEL (A Portable Emacs Library).
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 (eval-when-compile (require 'ccl))
30 (broken-facility ccl-accept-symbol-as-program
31 "Emacs does not accept symbol as CCL program."
33 (define-ccl-program test-ccl-identity
34 '(1 ((read r0) (loop (write-read-repeat r0)))))
38 (if (fboundp 'ccl-vector-execute-on-string)
39 'ccl-vector-execute-on-string
40 'ccl-execute-on-string)
50 (static-if (featurep 'xemacs)
51 (defadvice make-coding-system (before ccl-compat (name type &rest ad-subr-args) activate)
52 (when (and (integerp type)
54 (characterp (ad-get-arg 2))
55 (stringp (ad-get-arg 3))
56 (consp (ad-get-arg 4))
57 (symbolp (car (ad-get-arg 4)))
58 (symbolp (cdr (ad-get-arg 4))))
65 'mnemonic (char-to-string (ad-get-arg 2))
66 'decode (symbol-value (car (ad-get-arg 4)))
67 'encode (symbol-value (cdr (ad-get-arg 4))))
70 (if (featurep 'xemacs)
71 (defun make-ccl-coding-system (name mnemonic docstring decoder encoder)
73 Define a new CODING-SYSTEM by CCL programs DECODER and ENCODER.
75 CODING-SYSTEM, DECODER and ENCODER must be symbol."
78 (list 'mnemonic (char-to-string mnemonic)
79 'decode (symbol-value decoder)
80 'encode (symbol-value encoder))))
81 (defun make-ccl-coding-system
82 (coding-system mnemonic docstring decoder encoder)
84 Define a new CODING-SYSTEM by CCL programs DECODER and ENCODER.
86 CODING-SYSTEM, DECODER and ENCODER must be symbol."
87 (when-broken ccl-accept-symbol-as-program
88 (setq decoder (symbol-value decoder))
89 (setq encoder (symbol-value encoder)))
90 (make-coding-system coding-system 4 mnemonic docstring
91 (cons decoder encoder)))
94 (when-broken ccl-accept-symbol-as-program
96 (when (subrp (symbol-function 'ccl-execute))
97 (fset 'ccl-vector-program-execute
98 (symbol-function 'ccl-execute))
99 (defun ccl-execute (ccl-prog reg)
101 Execute CCL-PROG with registers initialized by REGISTERS.
102 If CCL-PROG is symbol, it is dereferenced."
103 (ccl-vector-program-execute
104 (if (symbolp ccl-prog) (symbol-value ccl-prog) ccl-prog)
107 (when (subrp (symbol-function 'ccl-execute-on-string))
108 (fset 'ccl-vector-program-execute-on-string
109 (symbol-function 'ccl-execute-on-string))
110 (defun ccl-execute-on-string (ccl-prog status string &optional contin)
112 Execute CCL-PROG with initial STATUS on STRING.
113 If CCL-PROG is symbol, it is dereferenced."
114 (ccl-vector-program-execute-on-string
115 (if (symbolp ccl-prog) (symbol-value ccl-prog) ccl-prog)
116 status string contin)))
121 (define-ccl-program test-ccl-eof-block
128 (make-ccl-coding-system
129 'test-ccl-eof-block-cs ?T "CCL_EOF_BLOCK tester"
130 'test-ccl-eof-block 'test-ccl-eof-block)
133 (broken-facility ccl-execute-eof-block-on-encoding-null
134 "Emacs forgets executing CCL_EOF_BLOCK with encoding on empty input. (Fixed on Emacs 20.4)"
135 (equal (encode-coding-string "" 'test-ccl-eof-block-cs) "[EOF]"))
137 (broken-facility ccl-execute-eof-block-on-encoding-some
138 "Emacs forgets executing CCL_EOF_BLOCK with encoding on non-empty input. (Fixed on Emacs 20.3)"
139 (equal (encode-coding-string "a" 'test-ccl-eof-block-cs) "a[EOF]"))
141 (broken-facility ccl-execute-eof-block-on-decoding-null
142 "Emacs forgets executing CCL_EOF_BLOCK with decoding on empty input. (Fixed on Emacs 20.4)"
143 (equal (decode-coding-string "" 'test-ccl-eof-block-cs) "[EOF]"))
145 (broken-facility ccl-execute-eof-block-on-decoding-some
146 "Emacs forgets executing CCL_EOF_BLOCK with decoding on non-empty input. (Fixed on Emacs 20.4)"
147 (equal (decode-coding-string "a" 'test-ccl-eof-block-cs) "a[EOF]"))
149 (broken-facility ccl-execute-eof-block-on-encoding
150 "Emacs may forget executing CCL_EOF_BLOCK with encoding."
151 (not (or (broken-p 'ccl-execute-eof-block-on-encoding-null)
152 (broken-p 'ccl-execute-eof-block-on-encoding-some)))
155 (broken-facility ccl-execute-eof-block-on-decoding
156 "Emacs may forget executing CCL_EOF_BLOCK with decoding."
157 (not (or (broken-p 'ccl-execute-eof-block-on-decoding-null)
158 (broken-p 'ccl-execute-eof-block-on-decoding-some)))
161 (broken-facility ccl-execute-eof-block
162 "Emacs may forget executing CCL_EOF_BLOCK."
163 (not (or (broken-p 'ccl-execute-eof-block-on-encoding)
164 (broken-p 'ccl-execute-eof-block-on-decoding)))
172 (product-provide (provide 'pccl-20) (require 'apel-ver))
174 ;;; pccl-20.el ends here