From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.bugs Subject: bug#12051: 24.1; rcirc-send-message doesn't take multibyte into account. Date: Mon, 13 Aug 2012 09:53:42 +0800 Message-ID: References: <87boj3byqy.fsf@acerpad.localdomain> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1344822999 7846 80.91.229.3 (13 Aug 2012 01:56:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 13 Aug 2012 01:56:39 +0000 (UTC) Cc: 12051@debbugs.gnu.org To: Li Ian-Xue Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 13 03:56:40 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T0jtX-0007bZ-3H for geb-bug-gnu-emacs@m.gmane.org; Mon, 13 Aug 2012 03:56:39 +0200 Original-Received: from localhost ([::1]:37031 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0jtW-0005fO-9t for geb-bug-gnu-emacs@m.gmane.org; Sun, 12 Aug 2012 21:56:38 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0jtT-0005fF-1S for bug-gnu-emacs@gnu.org; Sun, 12 Aug 2012 21:56:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T0jtQ-0008RZ-RK for bug-gnu-emacs@gnu.org; Sun, 12 Aug 2012 21:56:34 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0jtQ-0008RR-OC for bug-gnu-emacs@gnu.org; Sun, 12 Aug 2012 21:56:32 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1T0k1d-0003bl-T7 for bug-gnu-emacs@gnu.org; Sun, 12 Aug 2012 22:05:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Leo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Aug 2012 02:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12051 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12051-submit@debbugs.gnu.org id=B12051.134482347513821 (code B ref 12051); Mon, 13 Aug 2012 02:05:01 +0000 Original-Received: (at 12051) by debbugs.gnu.org; 13 Aug 2012 02:04:35 +0000 Original-Received: from localhost ([127.0.0.1]:52202 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0k1C-0003ar-Oa for submit@debbugs.gnu.org; Sun, 12 Aug 2012 22:04:35 -0400 Original-Received: from mail-pb0-f44.google.com ([209.85.160.44]:38236) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T0k1A-0003aj-0A for 12051@debbugs.gnu.org; Sun, 12 Aug 2012 22:04:33 -0400 Original-Received: by pbbrr4 with SMTP id rr4so8436619pbb.3 for <12051@debbugs.gnu.org>; Sun, 12 Aug 2012 18:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=jo5Z3slIXgpSalzwFcUmLEGe+z/Mf6RQFPTMSr1YECM=; b=E/eb9JshXaGVdlpUTDci/VEkGVgLDtvg6s36IuCY/s67u7HVFkvZeflVJx9Iae2Flx KYZ+hpAlXXqtiwdCM4SNFhSkBqqNhp6N4LYANqSJivTwvDpS+dCSupu0cm7ej1yNmMfG eOtWlq1zIMTAaxvFR+fxOOMU1ajwXz0gTGFTDNLiyEoJMFy0VcudL7ObgqICx8k/lrmR GVAgw7QRRn5A0z3WuMow3T9zrg2HFTkxd9r1OjDj3Et0gyNRecfVojgVy3dOdPOQ82w7 D3G+vRU1u/mp8HRL8Et2Ue3UYZknTtOOrl2cudZOqmig+uk9SStn3b1fbxMHQnU0nL7/ ra5Q== Original-Received: by 10.68.221.3 with SMTP id qa3mr30904094pbc.42.1344822959335; Sun, 12 Aug 2012 18:55:59 -0700 (PDT) Original-Received: from localhost ([119.255.41.67]) by mx.google.com with ESMTPS id mr2sm932940pbb.16.2012.08.12.18.55.56 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 12 Aug 2012 18:55:58 -0700 (PDT) In-Reply-To: <87boj3byqy.fsf@acerpad.localdomain> (Li Ian-Xue's message of "Thu, 26 Jul 2012 00:18:29 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (OS X 10.8) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:63090 Archived-At: --=-=-= Content-Type: text/plain On 2012-07-26 00:18 +0800, Li Ian-Xue wrote: > I discovered recently that the irc client `rcirc', although has an > max-message-length set, but it simply uses (length str) for detecting > the output length, which is not desirable for multibyte users because > usually our characters encode to more than one byte, and this causes an > error that the client actually sends out more bytes than the standard > has required (512 bytes to my understanding). Could you test if the attached patch fixes this problem? Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Fix-bug-12051.patch Content-Description: 0001-Fix-bug-12051.patch diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index e34b7c79..19f54a8e 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -794,26 +794,34 @@ (defun rcirc-buffer-nick (&optional buffer) (defvar rcirc-max-message-length 420 "Messages longer than this value will be split.") +(defun rcirc-split-message (message) + (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))) + (while (and (not (bobp)) + (> (length + (encode-coding-region (point-min) (point) + rcirc-encode-coding-system t)) + rcirc-max-message-length)) + (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. If NOTICEP is non-nil, send a notice instead of privmsg. If SILENT is non-nil, do not print the message in any irc buffer." ;; max message length is 512 including CRLF - (let* ((response (if noticep "NOTICE" "PRIVMSG")) - (oversize (> (length message) rcirc-max-message-length)) - (text (if oversize - (substring message 0 rcirc-max-message-length) - message)) - (text (if (string= text "") - " " - text)) - (more (if oversize - (substring message rcirc-max-message-length)))) + (let ((response (if noticep "NOTICE" "PRIVMSG"))) (rcirc-get-buffer-create process target) - (rcirc-send-string process (concat response " " target " :" text)) - (unless silent - (rcirc-print process (rcirc-nick process) response target text)) - (when more (rcirc-send-message process target more noticep)))) + (dolist (msg (rcirc-split-message message)) + (rcirc-send-string process (concat response " " target " :" msg)) + (unless silent + (rcirc-print process (rcirc-nick process) response target msg))))) (defvar rcirc-input-ring nil) (defvar rcirc-input-ring-index 0) -- 1.7.9.6 (Apple Git-31.1) --=-=-=--