+;;; @ CCL
+;;;
+(require 'ccl)
+
+(defconst ccl-use-symbol-as-program nil
+ "t if CCL related builtins accept symbol as CCL program.
+(20.2 with ExCCL, 20.3 or later)
+Otherwise nil (20.2 without ExCCL or former).
+
+Because emu provides functions accepting symbol as CCL program,
+user programs should not refer this variable.")
+
+(defun make-ccl-coding-system
+ (coding-system mnemonic doc-string decoder encoder)
+ "Define a new CODING-SYSTEM (symbol) by CCL programs
+DECODER (symbol) and ENCODER (symbol)."
+ (setq decoder (symbol-value decoder)
+ encoder (symbol-value encoder))
+ (make-coding-system coding-system 4 mnemonic doc-string
+ nil ; Mule takes one more optional argument: EOL-TYPE.
+ (cons decoder encoder)))
+
+(eval-when-compile
+ (define-ccl-program test-ccl-eof-block
+ '(1
+ (read r0)
+ (write "[EOF]")))
+
+ (make-ccl-coding-system
+ 'test-ccl-eof-block-cs ?T "CCL_EOF_BLOCK tester"
+ 'test-ccl-eof-block 'test-ccl-eof-block)
+ )
+
+(defconst ccl-encoder-eof-block-is-broken
+ (eval-when-compile
+ (not (equal (encode-coding-string "" 'test-ccl-eof-block-cs)
+ "[EOF]")))
+ "t if CCL_EOF_BLOCK is not executed when coding system encounts EOF on
+encoding.")
+
+(defconst ccl-decoder-eof-block-is-broken
+ (eval-when-compile
+ (not (equal (decode-coding-string "" 'test-ccl-eof-block-cs)
+ "[EOF]")))
+ "t if CCL_EOF_BLOCK is not executed when coding system encounts EOF on
+decoding.")
+
+(defconst ccl-eof-block-is-broken
+ (or ccl-encoder-eof-block-is-broken
+ ccl-decoder-eof-block-is-broken))
+
+(defun ccl-execute (ccl-prog reg)
+ "Execute CCL-PROG with registers initialized by REGISTERS.
+If CCL-PROG is symbol, it is dereferenced.
+\[Emacs 20.3 emulating function]"
+ (exec-ccl
+ (if (symbolp ccl-prog) (symbol-value ccl-prog) ccl-prog)
+ reg))
+
+(defun ccl-execute-on-string (ccl-prog status string &optional contin)
+ "Execute CCL-PROG with initial STATUS on STRING.
+If CCL-PROG is symbol, it is dereferenced.
+\[Emacs 20.3 emulating function]"
+ (exec-ccl-string
+ (if (symbolp ccl-prog) (symbol-value ccl-prog) ccl-prog)
+ string status))
+
+