diff options
| author | Chong Yidong | 2012-12-21 15:51:33 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-12-21 15:51:33 +0800 |
| commit | 34b4b7eb7e862ef4e39f5d712757acef421a2c2b (patch) | |
| tree | ea2a5b7d3d8a82311716bcaa45e57d93466e6ab2 | |
| parent | 3eb050925927e7060cb5ba192bf1d0f954c5980b (diff) | |
| download | emacs-34b4b7eb7e862ef4e39f5d712757acef421a2c2b.tar.gz emacs-34b4b7eb7e862ef4e39f5d712757acef421a2c2b.zip | |
Make read-char-by-name signal an error for invalid input.
* international/mule-cmds.el (read-char-by-name): Signal an error
if the user does not supply a valid character.
* editfns.c (Finsert_char): Since read-char-by-name now signals an
error for invalid chars, don't check for a nil return value.
Fixes: debbugs:13177
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/international/mule-cmds.el | 20 | ||||
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/editfns.c | 7 |
4 files changed, 23 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cd7dd97315b..a25836da996 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -5,6 +5,9 @@ | |||
| 5 | 5 | ||
| 6 | 2012-12-21 Chong Yidong <cyd@gnu.org> | 6 | 2012-12-21 Chong Yidong <cyd@gnu.org> |
| 7 | 7 | ||
| 8 | * international/mule-cmds.el (read-char-by-name): Signal an error | ||
| 9 | if the user does not supply a valid character (Bug#13177). | ||
| 10 | |||
| 8 | * simple.el (transpose-subr-1): Preserve marker positions by | 11 | * simple.el (transpose-subr-1): Preserve marker positions by |
| 9 | changing the insertion sequence (Bug#13122). | 12 | changing the insertion sequence (Bug#13122). |
| 10 | 13 | ||
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index f324446fa74..07b0f911cb2 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el | |||
| @@ -2953,14 +2953,18 @@ point or a number in hash notation, e.g. #o21430 for octal, | |||
| 2953 | (let ((completion-ignore-case t)) | 2953 | (let ((completion-ignore-case t)) |
| 2954 | (if (eq action 'metadata) | 2954 | (if (eq action 'metadata) |
| 2955 | '(metadata (category . unicode-name)) | 2955 | '(metadata (category . unicode-name)) |
| 2956 | (complete-with-action action (ucs-names) string pred))))))) | 2956 | (complete-with-action action (ucs-names) string pred)))))) |
| 2957 | (cond | 2957 | (char |
| 2958 | ((string-match-p "\\`[0-9a-fA-F]+\\'" input) | 2958 | (cond |
| 2959 | (string-to-number input 16)) | 2959 | ((string-match-p "\\`[0-9a-fA-F]+\\'" input) |
| 2960 | ((string-match-p "\\`#" input) | 2960 | (string-to-number input 16)) |
| 2961 | (read input)) | 2961 | ((string-match-p "\\`#" input) |
| 2962 | (t | 2962 | (read input)) |
| 2963 | (cdr (assoc-string input (ucs-names) t)))))) | 2963 | (t |
| 2964 | (cdr (assoc-string input (ucs-names) t)))))) | ||
| 2965 | (unless (characterp char) | ||
| 2966 | (error "Invalid character")) | ||
| 2967 | char)) | ||
| 2964 | 2968 | ||
| 2965 | (define-obsolete-function-alias 'ucs-insert 'insert-char "24.3") | 2969 | (define-obsolete-function-alias 'ucs-insert 'insert-char "24.3") |
| 2966 | (define-key ctl-x-map "8\r" 'insert-char) | 2970 | (define-key ctl-x-map "8\r" 'insert-char) |
diff --git a/src/ChangeLog b/src/ChangeLog index f9c629c1c56..24f32f141e9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-12-21 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * editfns.c (Finsert_char): Since read-char-by-name now signals an | ||
| 4 | error for invalid chars, don't check for a nil return value. | ||
| 5 | |||
| 1 | 2012-12-20 Dmitry Antipov <dmantipov@yandex.ru> | 6 | 2012-12-20 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 7 | ||
| 3 | Avoid calls to CHAR_TO_BYTE if byte position is known. | 8 | Avoid calls to CHAR_TO_BYTE if byte position is known. |
diff --git a/src/editfns.c b/src/editfns.c index d7fe1c1c4c4..bb5cc437d9b 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2361,10 +2361,9 @@ usage: (insert-before-markers-and-inherit &rest ARGS) */) | |||
| 2361 | } | 2361 | } |
| 2362 | 2362 | ||
| 2363 | DEFUN ("insert-char", Finsert_char, Sinsert_char, 1, 3, | 2363 | DEFUN ("insert-char", Finsert_char, Sinsert_char, 1, 3, |
| 2364 | "(list (or (read-char-by-name \"Insert character (Unicode name or hex): \")\ | 2364 | "(list (read-char-by-name \"Insert character (Unicode name or hex): \")\ |
| 2365 | (error \"You did not specify a valid character\"))\ | 2365 | (prefix-numeric-value current-prefix-arg)\ |
| 2366 | (prefix-numeric-value current-prefix-arg)\ | 2366 | t))", |
| 2367 | t))", | ||
| 2368 | doc: /* Insert COUNT copies of CHARACTER. | 2367 | doc: /* Insert COUNT copies of CHARACTER. |
| 2369 | Interactively, prompt for CHARACTER. You can specify CHARACTER in one | 2368 | Interactively, prompt for CHARACTER. You can specify CHARACTER in one |
| 2370 | of these ways: | 2369 | of these ways: |