Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Nov 2002 16:20:27 +0800 (CST)
From:      Cheng-Lung Sung <AlanSung@alansung.dragon2.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        clsung@dragon2.net
Subject:   ports/45741: [PATCH] centericq MSN UTF-8 (fixed getenv("LANG"))
Message-ID:  <200211260820.gAQ8KRea080891@alansung.dragon2.net>

next in thread | raw e-mail | index | archive | help

>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 <clsung@dragon2.net>
>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 <string>
 +#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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200211260820.gAQ8KRea080891>