Package: dumpasn1
Version: 20030222-1
Severity: normal
Tags: patch

Dumpasn1 have code to convert unicode values in BMPString into current
locale, but this code doesn't work, because there is no setlocale call
in the program.

Also i've found that call to wprintf function as written in dumpasn1 source
doesn't work properly on Debian system, and it is better to use Mac OS X
branch here. 

See attached patch.

-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.4.27-athlon
Locale: LANG=ru_RU.KOI8-R, LC_CTYPE=ru_RU.KOI8-R (charmap=KOI8-R)

Versions of packages dumpasn1 depends on:
ii  libc6                       2.3.2.ds1-22 GNU C Library: Shared libraries an

-- no debconf information
--- dumpasn1-20030222/dumpasn1.c	2004-04-16 17:59:14.000000000 +0400
+++ dumpasn1.c	2006-01-19 15:30:49.000000000 +0300
@@ -43,6 +43,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <locale.h>
 #ifdef OS390
   #include <unistd.h>
 #endif /* OS390 */
@@ -325,8 +326,8 @@
 
 	/* This one seems to be popular as well */
 	"c:\\program files\\utilities\\",
-
 	/* General environment-based paths */
+	"$APPDATA/dumpasn1/",
 	"$DUMPASN1_PATH/",
 
 	NULL
@@ -356,7 +357,8 @@
 	"$HOME/BIN/",
   #else
 	/* Debian has specific places where you're supposed to dump things */
-	"$HOME/", "/etc/dumpasn1/",
+        /* Thanx, Peter, but you forgot the dot. User conf files should start with a '.' (oku). */
+	"$HOME/.", "/etc/dumpasn1/",
   #endif /* DEBIAN-specific paths */
 
 	/* General environment-based paths */
@@ -798,7 +800,6 @@
 			for( i = 0; !isEnvTerminator( pathBuffer[ pathPos + i ] ); i++ );
 			memcpy( envName, pathBuffer + pathPos, i );
 			envName[ i ] = '\0';
-
 			/* Get the env.string and copy it over */
 			if( ( envString = getenv( envName ) ) != NULL )
 				{
@@ -1191,7 +1192,7 @@
 				warnBMP = TRUE;
 			else
 				{
-				const wchar_t wCh = ( ch << 8 ) | getc( inFile );
+				const wchar_t wCh[2] ={ ( ch << 8 ) | getc( inFile ),0};
 #if defined( __WIN32__ ) || ( defined( __UNIX__ ) && !defined( __MACH__ ) )
 				unsigned char outBuf[ 8 ];
 #else
@@ -1206,24 +1207,25 @@
 				   the data as non-Unicode.  There's one exception to this
 				   case, which is for a wrong-endianness Unicode string, for
 				   which the first character looks like a single ASCII char */
-				outLen = wcstombs( outBuf, &wCh, 1 );
+				outLen = wcstombs( outBuf, wCh, 8 );
 				if( outLen < 1 )
 					/* Can't be displayed as Unicode, fall back to
 					   displaying it as normal text */
-					ungetc( wCh & 0xFF, inFile );
+					ungetc( wCh[0] & 0xFF, inFile );
 				else
 					{
 					lineLength++;
 					i++;	/* We've read two characters for a wchar_t */
-#if defined( __WIN32__ ) || ( defined( __UNIX__ ) && !defined( __MACH__ ) )
-					wprintf( L"%c", wCh );
+#if defined( __WIN32__ ) 
+					wprintf( L"%c", wCh[0] );
+#elif	 defined( __UNIX__ ) 
+					fprintf( output, "%s", outBuf );
 #else
 					/* This could use some improvement */
   #ifndef __MACH__
 					for( p = outBuf; *p != '\0'; p++ )
 						*p = asciiToEbcdic( *p );
-  #endif /* OS X */
-					fprintf( output, "%s", outBuf );
+  #endif 
 #endif /* OS-specific charset handling */
 					fPos += 2;
 					continue;
@@ -2150,7 +2152,14 @@
 #endif /* __OS390__ */
 	long offset = 0;
 	int moreArgs = TRUE, doCheckOnly = FALSE;
-
+	
+	setlocale(LC_ALL,
+#ifdef __WIN32__
+			".OCP"
+#else			
+			""
+#endif			
+);
 #ifdef __OS390__
 	memset( pathPtr, '\0', sizeof( pathPtr ) );
 	getcwd( pathPtr, sizeof( pathPtr ) );

Reply via email to