/usr/share/emacs/site-lisp/w3m/w3m-ccl.el is in w3m-el 1.4.4-10.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | ;;; w3m-ccl.el --- CCL programs to process Unicode and internal characters.
;; Copyright (C) 2001, 2003, 2004, 2005
;; TSUCHIYA Masatoshi <tsuchiya@namazu.org>
;; Authors: TSUCHIYA Masatoshi <tsuchiya@namazu.org>,
;; ARISAWA Akihiro <ari@mbf.sphere.ne.jp>
;; Keywords: w3m, WWW, hypermedia
;; This file is a part of emacs-w3m.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, you can either send email to this
;; program's maintainer or write to: The Free Software Foundation,
;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
;;; Commentary:
;; This file contains CCL programs to process Unicode and internal
;; characters of w3m. For more detail about emacs-w3m, see:
;;
;; http://emacs-w3m.namazu.org/
;;; MEMO:
;; It is possible to support multi scripts without Mule-UCS. For more
;; detail, see [emacs-w3m:01950]
;;; Code:
(eval-and-compile
(cond
((featurep 'xemacs)
(require 'pccl))
((boundp 'MULE)
(let ((features (cons 'w3m-ccl features)))
(require 'w3m-om)) ;; for `charset-id'
(require 'pccl))
(t
(require 'ccl))))
;;; CCL programs:
(eval-when-compile
(when (and (not (fboundp 'charset-id))
(fboundp 'charset-id-internal))
(defalias 'charset-id 'charset-id-internal)))
(eval-and-compile
(defconst w3m-internal-characters-alist
'((?\x90 . ? ) ; ANSP (use for empty anchor)
(?\x91 . ? ) ; IMSP (blank around image)
(?\xa0 . ? )) ; NBSP (non breakble space)
"Alist of internal characters v.s. ASCII characters.")
(defun w3m-ccl-write-repeat (charset &optional r0 r1)
(unless r0
(setq r0 'r0))
(unless r1
(setq r1 (if (eq r0 'r1) 'r0 'r1)))
(let ((unibyte (memq charset '(latin-iso8859-1 katakana-jisx0201))))
(if (fboundp 'ccl-compile-write-multibyte-character)
(` (((, r1) &= ?\x7f)
(,@ (unless unibyte
(` (((, r1) |= (((, r0) & ?\x7f) << 7))))))
((, r0) = (, (charset-id charset)))
(write-multibyte-character (, r0) (, r1))
(repeat)))
(` ((write (, (charset-id charset)))
(,@ (unless unibyte
(` ((write (, r0))))))
(write-repeat (, r1)))))))
(defconst w3m-ccl-write-euc-japan-character
(when (fboundp 'ccl-compile-read-multibyte-character)
`((read-multibyte-character r1 r0)
(if (r1 == ,(charset-id 'ascii))
;; (1) ASCII characters
(write-repeat r0))
(if (r1 == ,(charset-id 'latin-jisx0201))
;; (2) Latin Part of Japanese JISX0201.1976
;; Convert to ASCII
(write-repeat r0))
(r2 = (r1 == ,(charset-id 'japanese-jisx0208-1978)))
(if ((r1 == ,(charset-id 'japanese-jisx0208)) | r2)
;; (3) Characters of Japanese JISX0208.
((r1 = ((r0 & 127) | 128))
(r0 = ((r0 >> 7) | 128))
(write r0)
(write-repeat r1)))
(if (r1 == ,(charset-id 'katakana-jisx0201))
;; (4) Katakana Part of Japanese JISX0201.1976
((r0 |= 128)
(write ?\x8e)
(write-repeat r0)))))
"CCL program to write characters represented in `euc-japan'.")
(defconst w3m-ccl-write-iso-latin-1-character
(when (fboundp 'ccl-compile-read-multibyte-character)
`((read-multibyte-character r1 r0)
(if (r1 == ,(charset-id 'ascii))
;; (1) ASCII characters
(write-repeat r0))
(if (r1 == ,(charset-id 'latin-jisx0201))
;; (2) Latin Part of Japanese JISX0201.1976
;; Convert to ASCII
(write-repeat r0))
(if (r1 == ,(charset-id 'latin-iso8859-1))
;; (3) Latin-1 characters
((r0 |= ?\x80)
(write-repeat r0)))))
"CCL program to write characters represented in `iso-latin-1'.")
(defconst w3m-ccl-generate-ncr
`((r1 = 0)
(r2 = 0)
(loop
(r1 = (r1 << 4))
(r1 |= (r0 & 15))
(r0 = (r0 >> 4))
(if (r0 == 0)
(break)
((r2 += 1)
(repeat))))
(write "&#x")
(loop
(branch (r1 & 15)
,@(mapcar
(lambda (i)
(list 'write (string-to-char (format "%x" i))))
'(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))
(r1 = (r1 >> 4))
(if (r2 == 0)
((write ?\;)
(break))
((r2 -= 1)
(repeat))))
(repeat))
"CCL program to generate a string which represents a UCS codepoint
in NCR (Numeric Character References)."))
(define-ccl-program w3m-euc-japan-decoder
(` (2
(loop
(read r0)
;; Process normal EUC characters.
(if (r0 < ?\x80)
(write-repeat r0))
(if (r0 > ?\xa0)
((read r1)
(,@ (w3m-ccl-write-repeat 'japanese-jisx0208))))
(if (r0 == ?\x8e)
((read r1)
(,@ (w3m-ccl-write-repeat 'katakana-jisx0201))))
(if (r0 == ?\x8f)
((read r0)
(read r1)
(,@ (w3m-ccl-write-repeat 'japanese-jisx0212))))
;; Process internal characters used in w3m.
(,@ (mapcar (lambda (pair)
(` (if (r0 == (, (car pair)))
(write-repeat (, (cdr pair))))))
w3m-internal-characters-alist))
(write-repeat r0)))))
(unless (get 'w3m-euc-japan-encoder 'ccl-program-idx)
(define-ccl-program w3m-euc-japan-encoder
(` (1 (loop (read r0) (write-repeat r0))))))
(define-ccl-program w3m-iso-latin-1-decoder
(` (2
(loop
(read r0)
;; Process ASCII characters.
(if (r0 < ?\x80)
(write-repeat r0))
;; Process Latin-1 characters.
(if (r0 > ?\xa0)
((,@ (w3m-ccl-write-repeat 'latin-iso8859-1 'r1))))
;; Process internal characters used in w3m.
(,@ (mapcar (lambda (pair)
(` (if (r0 == (, (car pair)))
(write-repeat (, (cdr pair))))))
w3m-internal-characters-alist))
(write-repeat r0)))))
(unless (get 'w3m-iso-latin-1-encoder 'ccl-program-idx)
(define-ccl-program w3m-iso-latin-1-encoder
(` (1 (loop (read r0) (write-repeat r0))))))
(provide 'w3m-ccl)
;;; w3m-ccl.el ends here
|