96b077
Patch by Jeff Johnson <jbj@rpm5.org> for popt >= 1.13, which reverts all POPT_fprintf()
96b077
usage cases to avoid broken umlauts in --help output at some non-UTF8 locales. It should
96b077
not break anything, just restore the behaviour of popt 1.12 again to not introduce a new
96b077
regression. Clueless modified by Robert Scheck <robert@rpm5.org> to hide the last found
96b077
two locale regression as well.
96b077
96b077
--- popt-1.13/popthelp.c				2007-11-04 16:46:25.000000000 +0100
96b077
+++ popt-1.13/popthelp.c.popt_fprintf			2007-12-30 22:10:24.000000000 +0100
96b077
@@ -281,7 +281,6 @@
96b077
     char * left;
96b077
     size_t nb = maxLeftCol + 1;
96b077
     int displaypad = 0;
96b077
-    int xx;
96b077
 
96b077
     /* Make sure there's more than enough room in target buffer. */
96b077
     if (opt->longName)	nb += strlen(opt->longName);
96b077
@@ -406,9 +405,9 @@
96b077
     }
96b077
 
96b077
     if (help)
96b077
-	xx = POPT_fprintf(fp,"  %-*s   ", (int)(maxLeftCol+displaypad), left);
96b077
+	fprintf(fp,"  %-*s   ", (int)(maxLeftCol+displaypad), left);
96b077
     else {
96b077
-	xx = POPT_fprintf(fp,"  %s\n", left); 
96b077
+	fprintf(fp,"  %s\n", left);
96b077
 	goto out;
96b077
     }
96b077
 
96b077
@@ -428,18 +427,19 @@
96b077
 	if (ch == help) break;		/* give up */
96b077
 	while (ch > (help + 1) && _isspaceptr(ch))
96b077
 	    ch = POPT_prev_char (ch);
96b077
-	ch++;
96b077
+	ch = POPT_next_char(ch);
96b077
 
96b077
 	sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), (int) indentLength);
96b077
 	/*@-formatconst@*/
96b077
-	xx = POPT_fprintf(fp, format, help, " ");
96b077
+	fprintf(fp, format, help, " ");
96b077
 	/*@=formatconst@*/
96b077
 	help = ch;
96b077
-	while (_isspaceptr(help) && *help) help++;
96b077
+	while (_isspaceptr(help) && *help)
96b077
+	    help = POPT_next_char(help);
96b077
 	helpLength = strlen(help);
96b077
     }
96b077
 
96b077
-    if (helpLength) xx = POPT_fprintf(fp, "%s\n", help);
96b077
+    if (helpLength) fprintf(fp, "%s\n", help);
96b077
     help = NULL;
96b077
 
96b077
 out:
96b077
@@ -553,7 +553,6 @@
96b077
 {
96b077
     const struct poptOption * opt;
96b077
     const char *sub_transdom;
96b077
-    int xx;
96b077
 
96b077
     if (table == poptAliasOptions) {
96b077
 	itemHelp(fp, con->aliases, con->numAliases, columns, NULL);
96b077
@@ -577,7 +576,7 @@
96b077
 	    sub_transdom = translation_domain;
96b077
 	    
96b077
 	if (opt->descrip)
96b077
-	    xx = POPT_fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip));
96b077
+	    fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip));
96b077
 
96b077
 	singleTableHelp(con, fp, opt->arg, columns, sub_transdom);
96b077
     }
96b077
@@ -767,7 +766,7 @@
96b077
 	    translation_domain = (const char *)opt->arg;
96b077
 	} else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
96b077
 	    if (done) {
96b077
-		int i;
96b077
+		int i = done->nopts;
96b077
 		if (done->opts != NULL)
96b077
 		for (i = 0; i < done->nopts; i++) {
96b077
 		    const void * that = done->opts[i];
96b077
--- popt-1.13/poptint.c					2007-11-04 16:56:24.000000000 +0100
96b077
+++ popt-1.13/poptint.c.popt_fprintf			2007-12-30 22:10:24.000000000 +0100
96b077
@@ -124,6 +124,18 @@
96b077
     }
96b077
 }
96b077
 
96b077
+char *
96b077
+POPT_next_char (const char *str)
96b077
+{
96b077
+    char *p = (char *)str;
96b077
+
96b077
+    while (1) {
96b077
+       p++;
96b077
+       if ((*p & 0xc0) != (char)0x80)
96b077
+           return (char *)p;
96b077
+    }
96b077
+}
96b077
+
96b077
 int
96b077
 POPT_fprintf (FILE* stream, const char *format, ...)
96b077
 {
96b077
--- popt-1.13/poptint.h					2007-12-11 19:02:29.000000000 +0100
96b077
+++ popt-1.13/poptint.h.popt_fprintf			2007-12-30 22:10:24.000000000 +0100
96b077
@@ -144,11 +144,14 @@
96b077
 #endif
96b077
 #endif
96b077
 
96b077
+char *POPT_prev_char (/*@returned@*/ const char *str)
96b077
+	/*@*/;
96b077
+
96b077
+char *POPT_next_char (/*@returned@*/ const char *str)
96b077
+	/*@*/;
96b077
+
96b077
 int   POPT_fprintf (FILE* stream, const char *format, ...)
96b077
 	/*@globals fileSystem @*/
96b077
 	/*@modifies stream, fileSystem @*/;
96b077
 
96b077
-char *POPT_prev_char (/*@returned@*/ const char *str)
96b077
-	/*@*/;
96b077
-
96b077
 #endif