diff options
| author | Stefan Monnier | 2006-07-31 21:36:43 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2006-07-31 21:36:43 +0000 |
| commit | 07e9b3f01c7b354a3f526295abbd5c422499d370 (patch) | |
| tree | 9b80f2a9e8fdf9c8538318e8adf040f9a8e5c8fc | |
| parent | fc0ba1d08092f5daedde890cb26e01883ab8afeb (diff) | |
| download | emacs-07e9b3f01c7b354a3f526295abbd5c422499d370.tar.gz emacs-07e9b3f01c7b354a3f526295abbd5c422499d370.zip | |
(url-hexify-string): Only utf-8 encode if it's a multibyte string.
(url-normalize-url): Remove unused var `grok'.
(url-truncate-url-for-viewing): Remove unused var `tail'.
| -rw-r--r-- | lisp/url/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/url/url-util.el | 29 |
2 files changed, 27 insertions, 9 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog index e29b4b6b67e..2bbe6085be4 100644 --- a/lisp/url/ChangeLog +++ b/lisp/url/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2006-07-31 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * url-util.el (url-hexify-string): Only utf-8 encode if it's | ||
| 4 | a multibyte string. | ||
| 5 | (url-normalize-url): Remove unused var `grok'. | ||
| 6 | (url-truncate-url-for-viewing): Remove unused var `tail'. | ||
| 7 | |||
| 1 | 2006-07-30 Thien-Thi Nguyen <ttn@gnu.org> | 8 | 2006-07-30 Thien-Thi Nguyen <ttn@gnu.org> |
| 2 | 9 | ||
| 3 | * url-util.el (url-hexify-string): Rewrite. | 10 | * url-util.el (url-hexify-string): Rewrite. |
diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el index 4293b0e301f..0aeb141c017 100644 --- a/lisp/url/url-util.el +++ b/lisp/url/url-util.el | |||
| @@ -163,7 +163,7 @@ Also replaces the \" character, so that the result may be safely used as | |||
| 163 | (defun url-normalize-url (url) | 163 | (defun url-normalize-url (url) |
| 164 | "Return a 'normalized' version of URL. | 164 | "Return a 'normalized' version of URL. |
| 165 | Strips out default port numbers, etc." | 165 | Strips out default port numbers, etc." |
| 166 | (let (type data grok retval) | 166 | (let (type data retval) |
| 167 | (setq data (url-generic-parse-url url) | 167 | (setq data (url-generic-parse-url url) |
| 168 | type (url-type data)) | 168 | type (url-type data)) |
| 169 | (if (member type '("www" "about" "mailto" "info")) | 169 | (if (member type '("www" "about" "mailto" "info")) |
| @@ -358,11 +358,24 @@ First, STRING is converted to utf-8, if necessary. Then, for each | |||
| 358 | character in the utf-8 string, those found in `url-unreserved-chars' | 358 | character in the utf-8 string, those found in `url-unreserved-chars' |
| 359 | are left as-is, all others are represented as a three-character | 359 | are left as-is, all others are represented as a three-character |
| 360 | string: \"%\" followed by two lowercase hex digits." | 360 | string: \"%\" followed by two lowercase hex digits." |
| 361 | (mapconcat (lambda (char) | 361 | ;; To go faster and avoid a lot of consing, we could do: |
| 362 | (if (memq char url-unreserved-chars) | 362 | ;; |
| 363 | (char-to-string char) | 363 | ;; (defconst url-hexify-table |
| 364 | (format "%%%02x" char))) | 364 | ;; (let ((map (make-vector 256 nil))) |
| 365 | (encode-coding-string string 'utf-8 t) | 365 | ;; (dotimes (byte 256) (aset map byte |
| 366 | ;; (if (memq byte url-unreserved-chars) | ||
| 367 | ;; (char-to-string byte) | ||
| 368 | ;; (format "%%%02x" byte)))) | ||
| 369 | ;; map)) | ||
| 370 | ;; | ||
| 371 | ;; (mapconcat (curry 'aref url-hexify-table) ...) | ||
| 372 | (mapconcat (lambda (byte) | ||
| 373 | (if (memq byte url-unreserved-chars) | ||
| 374 | (char-to-string byte) | ||
| 375 | (format "%%%02x" byte))) | ||
| 376 | (if (multibyte-string-p string) | ||
| 377 | (encode-coding-string string 'utf-8) | ||
| 378 | string) | ||
| 366 | "")) | 379 | "")) |
| 367 | 380 | ||
| 368 | ;;;###autoload | 381 | ;;;###autoload |
| @@ -390,7 +403,6 @@ then return the basename of the file with the extension stripped off." | |||
| 390 | WIDTH defaults to the current frame width." | 403 | WIDTH defaults to the current frame width." |
| 391 | (let* ((fr-width (or width (frame-width))) | 404 | (let* ((fr-width (or width (frame-width))) |
| 392 | (str-width (length url)) | 405 | (str-width (length url)) |
| 393 | (tail (file-name-nondirectory url)) | ||
| 394 | (fname nil) | 406 | (fname nil) |
| 395 | (modified 0) | 407 | (modified 0) |
| 396 | (urlobj nil)) | 408 | (urlobj nil)) |
| @@ -398,8 +410,7 @@ WIDTH defaults to the current frame width." | |||
| 398 | (if (and (>= str-width fr-width) | 410 | (if (and (>= str-width fr-width) |
| 399 | (string-match "?" url)) | 411 | (string-match "?" url)) |
| 400 | (setq url (concat (substring url 0 (match-beginning 0)) "?...") | 412 | (setq url (concat (substring url 0 (match-beginning 0)) "?...") |
| 401 | str-width (length url) | 413 | str-width (length url))) |
| 402 | tail (file-name-nondirectory url))) | ||
| 403 | (if (< str-width fr-width) | 414 | (if (< str-width fr-width) |
| 404 | nil ; Hey, we are done! | 415 | nil ; Hey, we are done! |
| 405 | (setq urlobj (url-generic-parse-url url) | 416 | (setq urlobj (url-generic-parse-url url) |