+2004-12-07 Daiki Ueno <ueno@unixuser.org>
+
+ * test/test-riece-log.el (test-riece-log-encode-file-name): New
+ test case.
+ (test-riece-log-encode-file-name-mule): New test case.
+ (test-riece-log-decode-file-name): New test case.
+ (test-riece-log-decode-file-name-mule): New test case.
+
+ * riece-log.el (riece-log-file-name-coding-system): New user option.
+ (riece-log-encode-file-name): New function.
+ (riece-log-decode-file-name): New function.
+
2004-12-06 Daiki Ueno <ueno@unixuser.org>
* test/test-riece-log.el: New test cases.
:type 'symbol
:group 'riece-log)
+(defcustom riece-log-file-name-coding-system
+ (if (boundp 'file-name-coding-system)
+ file-name-coding-system)
+ "*Coding system used for filenames of log files."
+ :type 'symbol
+ :group 'riece-log)
+
(defcustom riece-log-open-directory-function 'find-file
"*Function for opening a directory."
:type 'function
(expand-file-name name (expand-file-name server riece-log-directory))
(expand-file-name name riece-log-directory))))
+(defun riece-log-encode-file-name (file-name)
+ (if riece-log-file-name-coding-system
+ (setq file-name
+ (encode-coding-string file-name
+ riece-log-file-name-coding-system)))
+ (let ((index 0))
+ (while (string-match "[^-0-9A-Za-z=_\x80-\xFF]" file-name index)
+ (setq file-name (replace-match
+ (format "=%02X"
+ (aref file-name (match-beginning 0)))
+ nil t file-name)
+ index (+ 3 index)))
+ file-name))
+
+(defun riece-log-decode-file-name (file-name)
+ (let ((index 0))
+ (while (string-match "=\\([0-7][0-9A-F]\\)" file-name index)
+ (setq file-name (replace-match
+ (char-to-string
+ (car (read-from-string
+ (concat "?\\x" (match-string 1 file-name)))))
+ nil t file-name)
+ index (1+ index)))
+ file-name)
+ (if riece-log-file-name-coding-system
+ (setq file-name
+ (decode-coding-string file-name
+ riece-log-file-name-coding-system)))
+ file-name)
+
(defun riece-log-flashback-1 (identity)
(if (eq riece-log-flashback t)
(let ((file (riece-log-get-file identity)))
+;;; -*- coding: iso-2022-7 -*-
+
(require 'riece-log)
(luna-define-class test-riece-log (lunit-test-case))
(with-temp-buffer
(riece-log-flashback (riece-make-identity "#riece" ""))
(buffer-string))))))
+
+(luna-define-method test-riece-log-encode-file-name ((case test-riece-log))
+ (let (riece-log-file-name-coding-system)
+ (lunit-assert-2
+ case
+ (equal "=23riece"
+ (riece-log-encode-file-name "#riece")))
+ (lunit-assert-2
+ case
+ (equal "=23riece=3A=2A=2Ejp"
+ (riece-log-encode-file-name "#riece:*.jp")))))
+
+(luna-define-method test-riece-log-encode-file-name-mule
+ ((case test-riece-log))
+ (let ((riece-log-file-name-coding-system 'iso-8859-1))
+ (lunit-assert-2
+ case
+ (equal "=23\xABriece\xBB"
+ (riece-log-encode-file-name
+ (format "#%criece%c"
+ (make-char 'latin-iso8859-1 43)
+ (make-char 'latin-iso8859-1 59))))))
+ (let ((riece-log-file-name-coding-system 'iso-2022-jp))
+ (lunit-assert-2
+ case
+ (equal "=23=1B=24B=24j=21=3C=249=1B=28B"
+ (riece-log-encode-file-name
+ (format "#%c%c%c"
+ (make-char 'japanese-jisx0208 36 106)
+ (make-char 'japanese-jisx0208 33 60)
+ (make-char 'japanese-jisx0208 36 57)))))))
+
+(luna-define-method test-riece-log-decode-file-name ((case test-riece-log))
+ (let (riece-log-file-name-coding-system)
+ (lunit-assert-2
+ case
+ (equal "#riece"
+ (riece-log-decode-file-name "=23riece")))
+ (lunit-assert-2
+ case
+ (equal "#riece:*.jp"
+ (riece-log-decode-file-name "=23riece=3A=2A=2Ejp")))))
+
+(luna-define-method test-riece-log-decode-file-name-mule
+ ((case test-riece-log))
+ (let ((riece-log-file-name-coding-system 'iso-8859-1))
+ (lunit-assert-2
+ case
+ (equal (format "#%criece%c"
+ (make-char 'latin-iso8859-1 43)
+ (make-char 'latin-iso8859-1 59))
+ (riece-log-decode-file-name
+ "=23\xABriece\xBB"))))
+ (let ((riece-log-file-name-coding-system 'iso-2022-jp))
+ (lunit-assert-2
+ case
+ (equal (format "#%c%c%c"
+ (make-char 'japanese-jisx0208 36 106)
+ (make-char 'japanese-jisx0208 33 60)
+ (make-char 'japanese-jisx0208 36 57))
+ (riece-log-decode-file-name
+ "=23=1B=24B=24j=21=3C=249=1B=28B")))))