From owner-freebsd-ports Tue Nov 26 0:30: 7 2002 Delivered-To: freebsd-ports@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5583237B401 for ; Tue, 26 Nov 2002 00:30:03 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 784C043EC2 for ; Tue, 26 Nov 2002 00:30:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id gAQ8U2x3071756 for ; Tue, 26 Nov 2002 00:30:02 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id gAQ8U20Z071755; Tue, 26 Nov 2002 00:30:02 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4DDEC37B401 for ; Tue, 26 Nov 2002 00:20:33 -0800 (PST) Received: from alansung.dragon2.net (140-109-226-5.adsl.sinica.edu.tw [140.109.226.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3002D43EC5 for ; Tue, 26 Nov 2002 00:20:32 -0800 (PST) (envelope-from AlanSung@alansung.dragon2.net) Received: from alansung.dragon2.net (localhost [127.0.0.1]) by alansung.dragon2.net (8.12.6/8.12.6) with ESMTP id gAQ8KSS4080892; Tue, 26 Nov 2002 16:20:31 +0800 (CST) (envelope-from AlanSung@alansung.dragon2.net) Received: (from AlanSung@localhost) by alansung.dragon2.net (8.12.6/8.12.6/Submit) id gAQ8KRea080891; Tue, 26 Nov 2002 16:20:27 +0800 (CST) Message-Id: <200211260820.gAQ8KRea080891@alansung.dragon2.net> Date: Tue, 26 Nov 2002 16:20:27 +0800 (CST) From: Cheng-Lung Sung Reply-To: Cheng-Lung Sung To: FreeBSD-gnats-submit@FreeBSD.org Cc: clsung@dragon2.net X-Send-Pr-Version: 3.113 Subject: ports/45741: [PATCH] centericq MSN UTF-8 (fixed getenv("LANG")) Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 45741 >Category: ports >Synopsis: [PATCH] centericq MSN UTF-8 (fixed getenv("LANG")) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Nov 26 00:30:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Cheng-Lung Sung >Release: FreeBSD 4.7-RELEASE i386 >Organization: NCTU CSIE FreeBSD Server >Environment: System: FreeBSD AlanSung.dragon2.net 4.7-RELEASE FreeBSD 4.7-RELEASE #1: Fri Oct 11 14:23:08 CST 2002 root@AlanSung.dragon2.net:/usr/obj/usr/src/sys/SungSung i386 gnu iconv library needed >Description: core dump when getenv("LANG") return NULL; also use a static char[] to store all UTF8/Str message >How-To-Repeat: core dump when getenv("LANG") return NULL; >Fix: diff -ruN /usr/ports/net/centericq/files/patch-msnhook.cc /tmp/centericq/files/patch-msnhook.cc --- /usr/ports/net/centericq/files/patch-msnhook.cc Mon Nov 25 10:26:43 2002 +++ /tmp/centericq/files/patch-msnhook.cc Tue Nov 26 16:13:38 2002 @@ -1,5 +1,5 @@ ---- src/hooks/msnhook.cc Mon Nov 24 10:16:27 2002 -+++ src/hooks/msnhook.cc Mon Nov 25 10:16:27 2002 +--- src/hooks/msnhook.cc Mon Oct 28 19:29:41 2002 ++++ src/hooks/msnhook.cc Tue Nov 26 16:10:34 2002 @@ -30,6 +30,7 @@ #include "eventmanager.h" #include "centericq.h" @@ -39,7 +39,7 @@ em.store(immessage(ic, imevent::incoming, text)); if(c) -@@ -453,3 +456,132 @@ +@@ -453,3 +456,136 @@ clist.get(contactroot)->playsound(imevent::email); } } @@ -68,6 +68,10 @@ + return loc_charset; + + lang = getenv("LANG"); ++ if (!lang) { ++ strcpy( loc_charset, DEFAULT_CHARSET ); ++ return loc_charset; ++ }; + ch = strrchr( lang, '.' ); + if (!ch) + strcpy( loc_charset, DEFAULT_CHARSET ); @@ -91,8 +95,8 @@ +char *StrToUtf8( const char *inbuf ) +{ + size_t length = strlen( inbuf ); -+ size_t outmaxlength = length * 4; /* FIXME: Is x4 multiplier enoght? */ -+ char *outbuf = (char*) malloc( outmaxlength + 1 ); ++ size_t outmaxlength = UTF8_BUF_LENGTH; ++ char *outbuf = utf8_buf; + char *outbuf_save = outbuf; + int ret; + @@ -111,9 +115,9 @@ +std::string StrToUtf8( const std::string &instr ) +{ + size_t length = instr.length(); -+ size_t outmaxlength = length * 4; /* FIXME: Is x4 multiplier enoght? */ ++ size_t outmaxlength = UTF8_BUF_LENGTH; + const char *inbuf = instr.c_str(); -+ char *outbuf = (char*) malloc( outmaxlength + 1 ); ++ char *outbuf = utf8_buf; + char *outbuf_save = outbuf; + int ret; + @@ -134,8 +138,8 @@ +char *Utf8ToStr( const char *inbuf ) +{ + size_t length = strlen( inbuf ); -+ size_t outmaxlength = length; -+ char *outbuf = (char*) malloc( outmaxlength + 1 ); ++ size_t outmaxlength = UTF8_BUF_LENGTH / 4; ++ char *outbuf = utf8_buf; + char *outbuf_save = outbuf; + int ret; + @@ -153,9 +157,9 @@ +std::string Utf8ToStr( const std::string &instr ) +{ + size_t length = instr.length(); -+ size_t outmaxlength = length; + const char *inbuf = instr.c_str(); -+ char *outbuf = (char*) malloc( outmaxlength + 1 ); ++ size_t outmaxlength = UTF8_BUF_LENGTH / 4; ++ char *outbuf = utf8_buf; + char *outbuf_save = outbuf; + int ret; + diff -ruN /usr/ports/net/centericq/files/patch-utf8conv.h /tmp/centericq/files/patch-utf8conv.h --- /usr/ports/net/centericq/files/patch-utf8conv.h Tue Nov 19 16:45:53 2002 +++ /tmp/centericq/files/patch-utf8conv.h Tue Nov 26 16:13:42 2002 @@ -1,13 +1,13 @@ --- src/hooks/utf8conv.h Thu Jan 1 08:00:00 1970 -+++ src/hooks/utf8conv.h Tue Nov 19 15:19:44 2002 -@@ -0,0 +1,56 @@ ++++ src/hooks/utf8conv.h Tue Nov 26 16:10:40 2002 +@@ -0,0 +1,58 @@ +/*-------------------------------------------------------*/ +/* utf8conv.h ( Utf8 Converter ) */ +/*-------------------------------------------------------*/ +/* target : Converting Utf8 from/to string/char */ +/* modifier : clsung@dragon2.net */ +/* create : unknown */ -+/* update : 02/11/19 */ ++/* update : 02/11/26 */ +/*-------------------------------------------------------*/ +#ifndef _UTF8CONV_ +#define _UTF8CONV_ @@ -21,8 +21,10 @@ +#endif +#include +#define DEFAULT_CHARSET "ISO-8859-1" ++#define UTF8_BUF_LENGTH 2048 +/* charset name cache buffer */ +static char loc_charset[32]; ++static char utf8_buf[UTF8_BUF_LENGTH]; // max 401 length or per message +/* +** Name: safe_iconv +** Purpose: 'Fault-tolerant' version if iconv. Replaces invalid seq with '?' >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message