aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii <[email protected]>2004-03-07 20:02:02 +0000
committerEli Zaretskii <[email protected]>2004-03-07 20:02:02 +0000
commit651f4d9f27e3703502afebaf3b075dd55e2067b2 (patch)
tree1d4b8383121a0d6cc18a4fe470f5d9dc3ccddc28
parent1abcd0881985c2228459e51911a752870b106adc (diff)
(rfc2368-unhexify-char): Deleted.
(rfc2368-unhexify-string): Use replace-regexp-in-string.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/mail/rfc2368.el36
2 files changed, 13 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f357a7dca3..a7aedbbe57 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2004-03-07 Dave Love <[email protected]>
+
+ * net/browse-url.el (rfc2368-parse-mailto-url): Autoload.
+ (browse-url-mail): Use it.
+
+ * mail/rfc2368.el (rfc2368-unhexify-char): Deleted.
+ (rfc2368-unhexify-string): Use replace-regexp-in-string.
+
2004-03-07 Francis J. Wright <[email protected]>
* woman.el (woman-man.conf-path): Doc fix.
diff --git a/lisp/mail/rfc2368.el b/lisp/mail/rfc2368.el
index 4bfeb91106..07ea44cef0 100644
--- a/lisp/mail/rfc2368.el
+++ b/lisp/mail/rfc2368.el
@@ -76,39 +76,13 @@
(defconst rfc2368-mailto-query-index 4
"Describes the portion of the url after '?'.")
-;; for dealing w/ unhexifying strings, my preferred approach is to use
-;; a 'string-replace-match-using-function' which can perform a
-;; string-replace-match and compute the replacement text based on a
-;; passed function -- however, emacs doesn't seem to have such a
-;; function yet :-(
-
-;; for the moment a rip-off of url-unhex (w3/url.el)
-(defun rfc2368-unhexify-char (char)
- "Unhexify CHAR -- e.g. %20 -> <SPC>."
- (if (> char ?9)
- (if (>= char ?a)
- (+ 10 (- char ?a))
- (+ 10 (- char ?A)))
- (- char ?0)))
-
-;; for the moment a rip-off of url-unhex-string (w3/url.el) (slightly modified)
(defun rfc2368-unhexify-string (string)
"Unhexify STRING -- e.g. 'hello%20there' -> 'hello there'."
- (let ((case-fold-search t)
- (result ""))
- (while (string-match "%[0-9a-f][0-9a-f]" string)
- (let* ((start (match-beginning 0))
- (hex-code (+ (* 16
- (rfc2368-unhexify-char (elt string (+ start 1))))
- (rfc2368-unhexify-char (elt string (+ start 2))))))
- (setq result (concat
- result (substring string 0 start)
- (char-to-string hex-code))
- string (substring string (match-end 0)))))
- ;; it seems clearer to do things this way than to just return:
- ;; (concat result string)
- (setq result (concat result string))
- result))
+ (replace-regexp-in-string "%[[:xdigit:]]\\{2\\}"
+ (lambda (match)
+ (string (string-to-number (substring match 1)
+ 16)))
+ string t t))
(defun rfc2368-parse-mailto-url (mailto-url)
"Parse MAILTO-URL, and return an alist of header-name, header-value pairs.