RPM Community Forums

Mailing List Message of <popt-devel>

Re: popt-1.13 release

From: Takao Fujiwara - Tokyo S/W Center <Takao.Fujiwara@Sun.COM>
Date: Fri 25 Jan 2008 - 08:44:30 CET
Message-id: <4799935E.5040101@Sun.COM>
I'm attaching the additional patch to fix several problems.
Please check it.

Thanks,
fujiwara

Robert Scheck wrote:
> On Wed, 16 Jan 2008, Takao Fujiwara - Tokyo S/W Center wrote:
> 
>>I burned DVD, installed Fedora 8 and could reproduced your problem.
>>Some of applications do not set bind_textdomain_codeset().
>>
>>I think the attached patch will fix your main problem with removing your 
>>change of the workaround.
> 
> 
> Yes, the patch solves mostly the problem. But there's still one problem
> with POPT_printf() (?) left, looks like a minor one, nevertheless it is
> a regression:
> 
> popt 1.13 with your last patch: LANG=de_DE@euro kudzu --help
> 
> Verwendung: kudzu [OPTION...]
>   -s, --safe                                                        sicheren Erkennungsmodus verwenden, der Hardware-Funktionen nicht beeinträchtigt
>   -t, --timeout=INTEGER                                             Zeitüberschreitung in Sekunden festlegen
>   -p, --probe                                                       nur suchen, Informationen auf der Standardausgabe ausgeben
>   -b, --bus=STRING                                                  nur angegebenen 'bus' untersuchen
>   -c, --class=STRING                                                nur nach der angegebene 'class' suchen
>   -f, --file=Datei für das Einlesen der Hardware-Informationen     erkannte Hardware aus Datei lesen
>   -k, --kernel=Kernelversion                                        Nach Modulen für eine bestimmte Kernelversion suchen
>   -q, --quiet                                                       Konfiguration ohne Benutzereingaben durchführen
> 
> Help options:
>   -?, --help                                                        Show this help message
>   --usage                                                           Display brief usage message
> 
> And this is popt 1.13 with my latest patch: LANG=de_DE@euro kudzu --help
> 
> Verwendung: kudzu [OPTION...]
>   -s, --safe                                                       sicheren Erkennungsmodus verwenden, der Hardware-Funktionen nicht beeinträchtigt
>   -t, --timeout=INTEGER                                            Zeitüberschreitung in Sekunden festlegen
>   -p, --probe                                                      nur suchen, Informationen auf der Standardausgabe ausgeben
>   -b, --bus=STRING                                                 nur angegebenen 'bus' untersuchen
>   -c, --class=STRING                                               nur nach der angegebene 'class' suchen
>   -f, --file=Datei für das Einlesen der Hardware-Informationen     erkannte Hardware aus Datei lesen
>   -k, --kernel=Kernelversion                                       Nach Modulen für eine bestimmte Kernelversion suchen
>   -q, --quiet                                                      Konfiguration ohne Benutzereingaben durchführen
> 
> Help options:
>   -?, --help                                                       Show this help message
>   --usage                                                          Display brief usage message
> 
> As of my point of view, something regarding POPT_printf() (?) and umlauts
> at "-f, --file=Datei für das Einlesen der Hardware-Informationen" seems to
> be mis-handled. Something is making that string one character smaller as it
> was and should be. Maybe we're even lacking the use of POPT_printf() some
> where in the code?
> 
> Are you able to catch this minor thing also up? Thank you. And of course,
> thank you very much for your past work and for figuring out the real issue;
> I'm no C programmer, I'm just able to understand the code at least a bit.
> 
> 
> Greetings,
>   Robert
> 


--- popt/popthelp.c.orig	2008-01-16 02:19:01.000000000 +0900
+++ popt/popthelp.c	2008-01-25 02:18:08.000000000 +0900
@@ -15,13 +15,6 @@
 #include <sys/ioctl.h>
 #endif
 
-#define	POPT_WCHAR_HACK
-#ifdef 	POPT_WCHAR_HACK
-#include <wchar.h>			/* for mbsrtowcs */
-/*@access mbstate_t @*/
-#endif
-
-
 #include "poptint.h"
 
 /*@access poptContext@*/
@@ -374,6 +367,16 @@ static void singleOptionHelp(FILE * fp, 
 	    case POPT_ARG_STRING:
 		*le++ = (opt->longName != NULL ? '=' : ' ');
 		strcpy(le, argDescrip);		le += strlen(le);
+		{   const char * scopy = argDescrip;
+		    size_t n = 0;
+
+		    while (*scopy != '\0') {
+			scopy = POPT_next_char (scopy);
+			n++;
+		    }
+
+		    displaypad = (int) (strlen (argDescrip) - n);
+		}
 		break;
 	    default:
 		break;
@@ -387,18 +390,17 @@ static void singleOptionHelp(FILE * fp, 
 	    lelen = strlen(le);
 	    le += lelen;
 
-#ifdef	POPT_WCHAR_HACK
 	    {	const char * scopy = argDescrip;
-		mbstate_t t;
-		size_t n;
+		size_t n = 0;
 
-		memset ((void *)&t, 0, sizeof (t));	/* In initial state.  */
 		/* Determine number of characters.  */
-		n = mbsrtowcs (NULL, &scopy, strlen(scopy), &t);
+		while (*scopy != '\0') {
+		    scopy = POPT_next_char (scopy);
+		    n++;
+		}
 
 		displaypad = (int) (lelen-n);
 	    }
-#endif
 	}
 	if (opt->argInfo & POPT_ARGFLAG_OPTIONAL)
 	    *le++ = ']';
@@ -420,6 +422,7 @@ static void singleOptionHelp(FILE * fp, 
     helpLength = strlen(help);
     while (helpLength > lineLength) {
 	const char * ch;
+	char * formatted_help = NULL;
 	char format[16];
 
 	ch = help + lineLength - 1;
@@ -430,9 +433,12 @@ static void singleOptionHelp(FILE * fp, 
 	    ch = POPT_prev_char (ch);
 	ch++;
 
-	sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), (int) indentLength);
+	formatted_help = xstrdup (help);
+	formatted_help[ch - help] = '\0';
+	sprintf(format, "%%s\n%%%ds", (int) indentLength);
 	/*@-formatconst@*/
-	xx = POPT_fprintf(fp, format, help, " ");
+	xx = POPT_fprintf(fp, format, formatted_help, " ");
+	free (formatted_help);
 	/*@=formatconst@*/
 	help = ch;
 	while (_isspaceptr(help) && *help) help++;
@@ -594,7 +600,7 @@ static size_t showHelpIntro(poptContext 
     size_t len = (size_t)6;
     const char * fn;
 
-    fprintf(fp, POPT_("Usage:"));
+    POPT_fprintf(fp, POPT_("Usage:"));
     if (!(con->flags & POPT_CONTEXT_KEEP_FIRST)) {
 /*@-type@*/	/* LCL: wazzup? */
 	fn = con->optionStack->argv[0];
@@ -614,9 +620,9 @@ void poptPrintHelp(poptContext con, FILE
 
     (void) showHelpIntro(con, fp);
     if (con->otherHelp)
-	fprintf(fp, " %s\n", con->otherHelp);
+	POPT_fprintf(fp, " %s\n", con->otherHelp);
     else
-	fprintf(fp, " %s\n", POPT_("[OPTION...]"));
+	POPT_fprintf(fp, " %s\n", POPT_("[OPTION...]"));
 
     if (columns) {
 	columns->cur = maxArgWidth(con->options, NULL);
--- popt/poptint.c.orig	2008-01-16 00:28:39.000000000 +0900
+++ popt/poptint.c	2008-01-25 02:20:34.000000000 +0900
@@ -2,6 +2,35 @@
 #include <stdarg.h>
 #include "poptint.h"
 
+const char utf8_skip_data[256] = {
+  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+  3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
+};
+
+#if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__)
+char *
+_D_ (const char * dom, const char * str)
+{
+    char * codeset = NULL;
+    char * retval = NULL;
+
+    if (!dom) 
+	dom = textdomain (NULL);
+    codeset = bind_textdomain_codeset (dom, NULL);
+    bind_textdomain_codeset (dom, "UTF-8");
+    retval = dgettext(dom, str);
+    bind_textdomain_codeset (dom, codeset);
+
+    return retval;
+}
+#endif
+
 #ifdef HAVE_ICONV
 static /*@only@*/ /*@null@*/ char *
 strdup_locale_from_utf8 (/*@null@*/ char *buffer)
--- popt/poptint.h.orig	2008-01-16 02:01:07.000000000 +0900
+++ popt/poptint.h	2008-01-25 01:44:43.000000000 +0900
@@ -104,8 +104,10 @@ struct poptContext_s {
 #define _(foo) foo
 #endif
 
+extern const char utf8_skip_data[];
+#define POPT_next_char(p) (char *)((p) + utf8_skip_data[*(const unsigned char *)(p)])
 #if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__)
-#define D_(dom, str) dgettext(dom, str)
+#define D_(dom, str) _D_(dom, str)
 #define POPT_(foo) D_("popt", foo)
 #else
 #define D_(dom, str) str
Received on Fri Jan 25 08:44:49 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.