From nobody@FreeBSD.org  Wed Jul 11 07:26:30 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 31970106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 11 Jul 2012 07:26:30 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 046EF8FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 11 Jul 2012 07:26:30 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q6B7QTkr005796
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 11 Jul 2012 07:26:29 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q6B7QTE2005795;
	Wed, 11 Jul 2012 07:26:29 GMT
	(envelope-from nobody)
Message-Id: <201207110726.q6B7QTE2005795@red.freebsd.org>
Date: Wed, 11 Jul 2012 07:26:29 GMT
From: Kuan-Chung Chiu <buganini@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] add patch to fix utf-8 decoding bug for irc/irssi
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         169780
>Category:       ports
>Synopsis:       [patch] add patch to fix utf-8 decoding bug for irc/irssi
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    vanilla
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 11 07:30:02 UTC 2012
>Closed-Date:    Mon Aug 13 15:08:20 UTC 2012
>Last-Modified:  Mon Aug 13 15:10:12 UTC 2012
>Originator:     Kuan-Chung Chiu
>Release:        
>Organization:
Sixnology
>Environment:
>Description:
Fetch from:
http://bugs.irssi.org/index.php?do=details&task_id=870&project=5
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

diff -ruN irssi.orig/Makefile irssi/Makefile
--- irssi.orig/Makefile	2012-07-11 15:19:59.000000000 +0800
+++ irssi/Makefile	2012-07-11 15:23:37.000000000 +0800
@@ -7,7 +7,7 @@
 
 PORTNAME=	irssi
 PORTVERSION=	0.8.15
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES?=	irc
 MASTER_SITES=	http://mirror.irssi.org/
 
diff -ruN irssi.orig/files/patch-irssi-utf8 irssi/files/patch-irssi-utf8
--- irssi.orig/files/patch-irssi-utf8	1970-01-01 08:00:00.000000000 +0800
+++ irssi/files/patch-irssi-utf8	2012-06-10 13:10:50.000000000 +0800
@@ -0,0 +1,40 @@
+Index: src/fe-common/core/utf8.h
+===================================================================
+--- src/fe-common/core/utf8.h	(revision 5189)
++++ src/fe-common/core/utf8.h	(working copy)
+@@ -12,5 +12,6 @@
+ int mk_wcwidth(unichar c);
+ 
+ #define unichar_isprint(c) (((c) & ~0x80) >= 32)
++#define is_utf8_leading(c) (((c) & 0xc0) != 0x80)
+ 
+ #endif
+Index: src/fe-text/textbuffer.c
+===================================================================
+--- src/fe-text/textbuffer.c	(revision 5189)
++++ src/fe-text/textbuffer.c	(working copy)
+@@ -23,6 +23,7 @@
+ #include "module.h"
+ #include "misc.h"
+ #include "formats.h"
++#include "utf8.h"
+ 
+ #include "textbuffer.h"
+ 
+@@ -157,6 +158,16 @@
+ 		if (left > 0 && data[left-1] == 0)
+ 			left--; /* don't split the commands */
+ 
++		/* don't split utf-8 character. (assume we can split non-utf8 anywhere. */
++		if (left < TEXT_CHUNK_USABLE_SIZE && !is_utf8_leading(data[left])) {
++			int i;
++			for (i = 1; i < 4 && left >= i; i++)
++				if (is_utf8_leading(data[left - i])) {
++					left -= i;
++					break;
++				}
++		}
++
+ 		memcpy(chunk->buffer + chunk->pos, data, left);
+ 		chunk->pos += left;
+ 


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-ports-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Jul 12 04:57:00 UTC 2012 
Responsible-Changed-Why:  
ports PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169780 
Responsible-Changed-From-To: freebsd-ports-bugs->vanilla 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Thu Jul 12 04:57:20 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169780 
State-Changed-From-To: open->closed 
State-Changed-By: vanilla 
State-Changed-When: Mon Aug 13 15:08:19 UTC 2012 
State-Changed-Why:  
Committed, thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169780 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/169780: commit references a PR
Date: Mon, 13 Aug 2012 15:08:12 +0000 (UTC)

 Author: vanilla
 Date: Mon Aug 13 15:08:03 2012
 New Revision: 302471
 URL: http://svn.freebsd.org/changeset/ports/302471
 
 Log:
   1: fix utf-8 decoding.
   2: convert to optionng.
   
   PR:		ports/169780
   Submitted by:	Kuan-Chung Chiu <buganini@gmail.com> [1]
 
 Added:
   head/irc/irssi/files/patch-irssi-utf8   (contents, props changed)
 Modified:
   head/irc/irssi/Makefile
 
 Modified: head/irc/irssi/Makefile
 ==============================================================================
 --- head/irc/irssi/Makefile	Mon Aug 13 14:45:36 2012	(r302470)
 +++ head/irc/irssi/Makefile	Mon Aug 13 15:08:03 2012	(r302471)
 @@ -7,14 +7,14 @@
  
  PORTNAME=	irssi
  PORTVERSION=	0.8.15
 -PORTREVISION=	3
 +PORTREVISION=	4
  CATEGORIES?=	irc
  MASTER_SITES=	http://mirror.irssi.org/
  
  MAINTAINER?=	vanilla@FreeBSD.org
  COMMENT?=	A modular IRC client with many features
  
 -LIB_DEPENDS=	glib-2.0:${PORTSDIR}/devel/glib20
 +LIB_DEPENDS=	glib-2:${PORTSDIR}/devel/glib20
  
  CONFLICTS=	irssi-devel-[0-9]* zh-irssi-[0-9]*
  
 @@ -26,11 +26,14 @@ WANT_PERL=	yes
  
  MAN1=		irssi.1
  
 -OPTIONS=	PERL "Enable perl support" on \
 -		PROXY "Enable proxy support" off \
 -		SOCKS "Enable socks proxy support" off \
 -		IPV6 "Enable IPv6" on \
 -		BOT "Enable bot" off
 +OPTIONS_DEFINE=	PERL PROXY SOCKS IPV6 BOT
 +PERL_DESC=	Perl support
 +PROXY_DESC=	Proxy support
 +SOCKS_DESC=	Socks proxy support
 +IPV6_DESC=	IPV6 support
 +BOT_DESC=	Bot support
 +OPTIONS_DEFAULT=	PERL IPV6
 +
  # USE_OPENSSL must be defined before bsd.port.pre.mk so use old schema
  # for WITH_SSL option
  
 @@ -40,11 +43,11 @@ CONFIGURE_ARGS+=	--disable-ssl
  USE_OPENSSL=	yes
  .endif
  
 -.include <bsd.port.pre.mk>
 +.include <bsd.port.options.mk>
  
  # Process options.
  
 -.if !defined(WITHOUT_PERL)
 +.if ${PORT_OPTIONS:MPERL}
  USE_PERL5=	yes
  CONFIGURE_ARGS+=	--with-perl-lib=site
  PLIST_SUB+=	WITH_PERL=""
 @@ -53,23 +56,23 @@ CONFIGURE_ARGS+=	--without-perl
  PLIST_SUB+=	WITH_PERL="@comment "
  .endif
  
 -.if defined(WITH_PROXY)
 +.if ${PORT_OPTIONS:MPROXY}
  CONFIGURE_ARGS+=	--with-proxy
  PLIST_SUB+=	WITH_PROXY=""
  .else
  PLIST_SUB+=	WITH_PROXY="@comment "
  .endif
  
 -.if defined(WITH_SOCKS)
 +.if ${PORT_OPTIONS:MSOCKS}
  CONFIGURE_ARGS+=	--with-socks
  .endif
  
 -.if defined(WITHOUT_IPV6)
 +.if !${PORT_OPTIONS:MIPV6}
  CONFIGURE_ARGS+=	--disable-ipv6
  CATEGORIES+=	ipv6
  .endif
  
 -.if defined(WITH_BOT)
 +.if ${PORT_OPTIONS:MBOT}
  CONFIGURE_ARGS+=	--with-bot
  PLIST_SUB+=	WITH_BOT=""
  .else
 @@ -92,4 +95,4 @@ post-install:
  	@${ECHO_MSG} "You may install x11-themes/irssi-themes for"
  	@${ECHO_MSG} " additional themes."
  
 -.include <bsd.port.post.mk>
 +.include <bsd.port.mk>
 
 Added: head/irc/irssi/files/patch-irssi-utf8
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/irc/irssi/files/patch-irssi-utf8	Mon Aug 13 15:08:03 2012	(r302471)
 @@ -0,0 +1,38 @@
 +#
 +# $FreeBSD$
 +#
 +--- src/fe-common/core/utf8.h	(revision 5189)
 ++++ src/fe-common/core/utf8.h	(working copy)
 +@@ -12,5 +12,6 @@
 + int mk_wcwidth(unichar c);
 + 
 + #define unichar_isprint(c) (((c) & ~0x80) >= 32)
 ++#define is_utf8_leading(c) (((c) & 0xc0) != 0x80)
 + 
 + #endif
 +--- src/fe-text/textbuffer.c	(revision 5189)
 ++++ src/fe-text/textbuffer.c	(working copy)
 +@@ -23,6 +23,7 @@
 + #include "module.h"
 + #include "misc.h"
 + #include "formats.h"
 ++#include "utf8.h"
 + 
 + #include "textbuffer.h"
 + 
 +@@ -157,6 +158,16 @@
 + 		if (left > 0 && data[left-1] == 0)
 + 			left--; /* don't split the commands */
 + 
 ++		/* don't split utf-8 character. (assume we can split non-utf8 anywhere. */
 ++		if (left < TEXT_CHUNK_USABLE_SIZE && !is_utf8_leading(data[left])) {
 ++			int i;
 ++			for (i = 1; i < 4 && left >= i; i++)
 ++				if (is_utf8_leading(data[left - i])) {
 ++					left -= i;
 ++					break;
 ++				}
 ++		}
 ++
 + 		memcpy(chunk->buffer + chunk->pos, data, left);
 + 		chunk->pos += left;
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 
>Unformatted:
