Subject: pkg/19008: dia-0.90 pkg fix
To: None <gnats-bugs@gnats.netbsd.org>
From: Jarkko Torppa <torppa@cute.fi>
List: netbsd-bugs
Date: 11/10/2002 21:50:01
>Number:         19008
>Category:       pkg
>Synopsis:       fix for dia-0.90 package
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 10 11:51:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Jarkko Torppa
>Release:        NetBSD 1.6
>Organization:
>Environment:
System: NetBSD keppi 1.6 NetBSD 1.6 (KEPPI) #7: Sun Sep 15 13:39:01 EEST 2002 root@keppi:/usr/src/sys/arch/i386/compile/KEPPI i386
Architecture: i386
Machine: i386
>Description:
dia pakcage is diabled at the moment, because of segfault during startup.

I had explanation for this in the gnome-bugzilla report I sent to them
some time ago, but I cannot find it right now (bugzilla.gnome.org seems
to be non responsive).
>How-To-Repeat:
try to build it
>Fix:

Here is patch that I made to this some time ago, also submitted to gnome-bugtraccking
some time ago but they did not care as current version uses totally different code
for charset handling.

There are still some other problems with dia 0.90 when opening somewhat complex files
that have been made with 0.88. With this patch I feel that this works well enought
that it can be enabled again.

Here is patch
--- ../dia-0.90/lib/charconv.c  Fri May 17 02:06:50 2002
+++ lib/charconv.c      Sun Nov 10 20:36:11 2002
@@ -69,6 +69,8 @@
 {
   static char *this_charset = NULL;
   static int local_is_utf8 = 0;
+  unicode_iconv_t t1=(unicode_iconv_t)(-1);
+  unicode_iconv_t t2=(unicode_iconv_t)(-1);
 
   if (this_charset) {
     *charset = this_charset;
@@ -108,7 +110,25 @@
   }
 
   this_charset = *charset;
-  local_is_utf8 = (*charset) && (0==strcmp(*charset,"UTF-8"));
+  /* Set local to UTF8 if it unicode_iconv_open does not understand
+     our charset */
+  if(*charset) {
+    if(strcmp(*charset,"UTF-8") != 0) {
+      if( (t1=unicode_iconv_open(*charset,"UTF-8")) == (unicode_iconv_t)(-1) ||
+         (t2=unicode_iconv_open("UTF-8",*charset)) == (unicode_iconv_t)(-1) ){
+       g_warning("unicode_iconv_open() does not understand your charset %s.\n"
+                 "Using UTF-8 as local. Maybe you should set LC_CTYPE or CHARSET ?",
+                 *charset);
+       local_is_utf8 = 1;
+       *charset = "UTF-8";
+      }
+    } else
+      local_is_utf8 = 1;
+  }
+  if(t1 != (unicode_iconv_t)(-1))
+    unicode_iconv_close(t1);
+  if(t2 != (unicode_iconv_t)(-1))
+    unicode_iconv_close(t2);
   
   return local_is_utf8;
 }

>Release-Note:
>Audit-Trail:
>Unformatted:
 Dia package with make id of 
 # $NetBSD: Makefile,v 1.10 2002/10/19 10:54:52 rh Exp $