GNU bug report logs -
#12051
24.1; rcirc-send-message doesn't take multibyte into account.
Previous Next
Reported by: Li Ian-Xue <b4283 <at> bephor.org>
Date: Thu, 26 Jul 2012 01:17:02 UTC
Severity: normal
Found in version 24.1
Done: Leo <sdl.web <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #22 received at 12051 <at> debbugs.gnu.org (full text, mbox):
On 2012-08-15 10:57 +0800, Eli Zaretskii wrote:
> You can always stop at known characters, like whitespace.
>
> Anyway, another way is simply to assume the worst possible expansion
> ratio, and estimate the byte count before encoding.
I make a small optimisation that calls encode-coding-region char by
char. Comments?
=== modified file 'lisp/net/rcirc.el'
--- lisp/net/rcirc.el 2012-08-15 12:26:48 +0000
+++ lisp/net/rcirc.el 2012-08-15 13:06:15 +0000
@@ -797,22 +797,24 @@
(defun rcirc-split-message (message)
"Split MESSAGE into chunks within `rcirc-max-message-length'."
;; `rcirc-encode-coding-system' can have buffer-local value.
- (let ((encoding rcirc-encode-coding-system))
+ (let ((encoding rcirc-encode-coding-system)
+ result oversize)
(with-temp-buffer
(insert message)
(goto-char (point-min))
- (let (result)
- (while (not (eobp))
- (goto-char (or (byte-to-position rcirc-max-message-length)
- (point-max)))
- ;; max message length is 512 including CRLF
- (while (and (not (bobp))
- (> (length (encode-coding-region
- (point-min) (point) encoding t))
- rcirc-max-message-length))
- (forward-char -1))
- (push (delete-and-extract-region (point-min) (point)) result))
- (nreverse result)))))
+ (while (not (eobp))
+ (goto-char (or (byte-to-position rcirc-max-message-length)
+ (point-max)))
+ ;; Max message length is 512 including CRLF
+ (setq oversize (- (length (encode-coding-region
+ (point-min) (point) encoding t))
+ rcirc-max-message-length))
+ (while (and (not (bobp)) (> oversize 0))
+ (decf oversize (length (encode-coding-region
+ (1- (point)) (point) encoding t)))
+ (forward-char -1))
+ (push (delete-and-extract-region (point-min) (point)) result)))
+ (nreverse result)))
(defun rcirc-send-message (process target message &optional noticep silent)
"Send TARGET associated with PROCESS a privmsg with text MESSAGE.
This bug report was last modified 12 years and 284 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.