unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Leo <sdl.web@gmail.com>
Cc: b4283@bephor.org, 12051@debbugs.gnu.org
Subject: bug#12051: 24.1; rcirc-send-message doesn't take multibyte into account.
Date: Tue, 14 Aug 2012 18:45:46 +0300	[thread overview]
Message-ID: <83k3x1jx3p.fsf@gnu.org> (raw)
In-Reply-To: <m21ujb8sm1.fsf@gmail.com>

> From: Leo <sdl.web@gmail.com>
> Date: Mon, 13 Aug 2012 09:53:42 +0800
> Cc: 12051@debbugs.gnu.org
> 
> Could you test if the attached patch fixes this problem? Thanks.
> 
> 
> [2:text/x-patch Hide]
> 
> 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)))))

Isn't it better and simpler to split the string after it is encoded
inside rcirc-send-string?





  parent reply	other threads:[~2012-08-14 15:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-25 16:18 bug#12051: 24.1; rcirc-send-message doesn't take multibyte into account Li Ian-Xue
2012-08-13  1:53 ` Leo
2012-08-14 13:11   ` Leo
2012-08-14 15:45   ` Eli Zaretskii [this message]
     [not found]     ` <874no4apau.fsf@acerpad.localdomain>
2012-08-15  2:57       ` Eli Zaretskii
2012-08-15 13:10         ` Leo
2012-08-15 13:29           ` Chong Yidong
2012-08-15 15:45             ` Chong Yidong
2012-08-15 22:55               ` Leo
2012-08-15 16:59           ` Eli Zaretskii
2012-08-15 17:53             ` Li Ian-Xue
2012-08-15 22:54               ` Leo
2012-08-15 23:00             ` Leo
2012-08-16  2:50               ` Eli Zaretskii
2012-08-16  3:16                 ` Leo
2012-08-16 15:20                   ` Eli Zaretskii
2012-08-16 17:17                     ` Leo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83k3x1jx3p.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=12051@debbugs.gnu.org \
    --cc=b4283@bephor.org \
    --cc=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).