diff options
author | F. Jason Park <jp@neverwas.me> | 2022-12-11 19:41:43 -0800 |
---|---|---|
committer | F. Jason Park <jp@neverwas.me> | 2022-12-14 06:40:55 -0800 |
commit | 09c0c6b2ba36c6b87e8e495710a580e909bbaf26 (patch) | |
tree | 9ca3ca08c2fd2a5fcd155674dcf00afa9b668667 /lisp/erc/erc.el | |
parent | 44b04c0ac1caef2283076d0784e0407940c14287 (diff) | |
download | emacs-09c0c6b2ba36c6b87e8e495710a580e909bbaf26.tar.gz |
Limit casemapping to appropriate ranges in ERC
* lisp/erc/erc-common.el (erc-downcase): Use case table for
`erc-downcase' so that case conversions are limited to the ASCII
interval.
* lisp/erc/erc.el (erc-casemapping--rfc1459-strict,
erc--casemapping-rfc1459): Make these case tables instead of
translation tables. The functions in case-table.el modify the
standard syntax table, but that doesn't seem to make sense here,
right?
* test/lisp/erc/erc-tests.el (erc-downcase): Add cases showing
mappings outside of the ASCII range. (Bug#59976.)
Diffstat (limited to 'lisp/erc/erc.el')
-rw-r--r-- | lisp/erc/erc.el | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 9d811617d2e..5e78096da56 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -407,15 +407,27 @@ erc-channel-user struct.") "Hash table of users on the current server. It associates nicknames with `erc-server-user' struct instances.") -(defconst erc--casemapping-rfc1459 - (make-translation-table - '((?\[ . ?\{) (?\] . ?\}) (?\\ . ?\|) (?~ . ?^)) - (mapcar (lambda (c) (cons c (+ c 32))) "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))) - (defconst erc--casemapping-rfc1459-strict - (make-translation-table - '((?\[ . ?\{) (?\] . ?\}) (?\\ . ?\|)) - (mapcar (lambda (c) (cons c (+ c 32))) "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))) + (let ((tbl (copy-sequence ascii-case-table)) + (cup (copy-sequence (char-table-extra-slot ascii-case-table 0)))) + (set-char-table-extra-slot tbl 0 cup) + (set-char-table-extra-slot tbl 1 nil) + (set-char-table-extra-slot tbl 2 nil) + (pcase-dolist (`(,uc . ,lc) '((?\[ . ?\{) (?\] . ?\}) (?\\ . ?\|))) + (aset tbl uc lc) + (aset tbl lc lc) + (aset cup uc uc)) + tbl)) + +(defconst erc--casemapping-rfc1459 + (let ((tbl (copy-sequence erc--casemapping-rfc1459-strict)) + (cup (copy-sequence (char-table-extra-slot + erc--casemapping-rfc1459-strict 0)))) + (set-char-table-extra-slot tbl 0 cup) + (aset tbl ?~ ?^) + (aset tbl ?^ ?^) + (aset cup ?~ ?~) + tbl)) (defun erc-add-server-user (nick user) "This function is for internal use only. |