12258N/A noinst_PROGRAMS = test1 test2 test3
12258N/A test1_LDADD = $(lib_LTLIBRARIES)
12258N/A test2_LDADD = $(lib_LTLIBRARIES)
12258N/A test3_LDADD = $(lib_LTLIBRARIES)
12258N/A ALL_LINGUAS="cs da de es eu_ES fi fr gl hu id is it ja ko no pl pt pt_BR ro ru sk sl sr sv tr uk wa zh
zh_CN.GB2312"
12258N/A if test "$build" = "mips-sni-sysv4" ; then
18057N/A-AC_CHECK_FUNCS(strerror mtrace getuid geteuid)
12258N/A AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >
/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi])
12258N/A+AC_CHECK_FUNCS(getuid geteuid mtrace __secure_getenv setregid strerror iconv)
12258N/A #define POPT_ARG_FLOAT 8 /*!< arg will be converted to float */
12258N/A #define POPT_ARG_DOUBLE 9 /*!< arg will be converted to double */
17380N/A+#define POPT_ARG_MAINCALL 10U /*!< return (*arg) (argc, argv) */
12258N/A #define POPT_ARG_MASK 0x0000FFFF
12258N/A@@ -208,6 +208,8 @@ static void singleOptionHelp(FILE * fp,
18228N/A /* Make sure there's more than enough room in target buffer. */
18228N/A if (opt->longName) nb += strlen(opt->longName);
12258N/A@@ -307,8 +309,25 @@ static void singleOptionHelp(FILE * fp,
12258N/A- strcpy(le, argDescrip); le += strlen(le);
12258N/A+ *le++ = ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_MAINCALL)
12258N/A+ { const char * scopy = argDescrip;
12258N/A+ memset ((void *)&t, 0, sizeof (t)); /* In initial state. */
12258N/A+ /* Determine number of characters. */
12258N/A+ n = mbsrtowcs (NULL, &scopy, strlen(scopy), &t);
12258N/A if (opt->argInfo & POPT_ARGFLAG_OPTIONAL)
12275N/A@@ -317,9 +336,9 @@ static void singleOptionHelp(FILE * fp,
18298N/A- fprintf(fp," %-*s ", maxLeftCol, left);
18057N/A+ xx = POPT_fprintf(fp," %-*s ", (int)(maxLeftCol+displaypad), left);
13606N/A+ xx = POPT_fprintf(fp," %s\n", left);
13313N/A@@ -335,22 +354,24 @@ static void singleOptionHelp(FILE * fp,
13097N/A- while (ch > help && !isspace(*ch)) ch--;
12990N/A+ while (ch > help && !_isspaceptr(ch))
12970N/A if (ch == help) break; /* give up */
12970N/A- while (ch > (help + 1) && isspace(*ch)) ch--;
12678N/A+ while (ch > (help + 1) && _isspaceptr(ch))
12325N/A sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
12284N/A- fprintf(fp, format, help, " ");
12284N/A+ xx = POPT_fprintf(fp, format, help, " ");
12277N/A- while (isspace(*help) && *help) help++;
12275N/A+ while (_isspaceptr(help) && *help) help++;
12258N/A- if (helpLength) fprintf(fp, "%s\n", help);
12258N/A+ if (helpLength) xx = POPT_fprintf(fp, "%s\n", help);
@@ -443,6 +464,7 @@ static void singleTableHelp(poptContext
const struct poptOption * opt;
const char *sub_transdom;
if (table == poptAliasOptions) {
itemHelp(fp, con->aliases, con->numAliases, left, NULL);
@@ -466,7 +488,7 @@ static void singleTableHelp(poptContext
sub_transdom = translation_domain;
- fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip));
+ xx = POPT_fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip));
singleTableHelp(con, fp, opt->arg, left, sub_transdom);
+static /*@only@*/ /*@null@*/ char *
+strdup_locale_from_utf8 (/*@null@*/ char *buffer)
+ codeset = nl_langinfo (CODESET);
+ if (codeset && strcmp(codeset, "UTF-8")
+ && (fd = iconv_open(codeset, "UTF-8")) != (iconv_t)-1)
+ size_t ib, ob, dest_size;
+ char *shift_pin = NULL;
+ err = iconv(fd, NULL, &ib, &pout, &ob);
+ dest_size = ob = ib = strlen(buffer);
+ dest_str = pout = malloc((dest_size + 1) * sizeof(*dest_str));
+ while (!done && !is_error) {
+ err = iconv(fd, &pin, &ib, &pout, &ob);
+ if (err == (size_t)-1) {
+ /*@switchbreak@*/ break;
+ { size_t used = pout - dest_str;
+ dest_str = realloc(dest_str, (dest_size + 1) * sizeof(*dest_str));
+ if (dest_str == NULL) {
+ pout = dest_str + used;
+ } /*@switchbreak@*/ break;
+ /*@switchbreak@*/ break;
+ /*@switchbreak@*/ break;
+ if (shift_pin == NULL) {
+ dest_str = xstrdup(dest_str);
+ dest_str = xstrdup(buffer);
+/*@-mustmod@*/ /* LCL: can't see the ap modification. */
+static /*@only@*/ /*@null@*/ char *
+strdup_vprintf (const char *format, va_list ap)
+/*@-noeffectuncon -unrecog @*/
+ va_copy(apc, ap); /* XXX linux
amd64/ppc needs a copy. */
+/*@=noeffectuncon =unrecog @*/
+ buffer = calloc(sizeof(*buffer), vsnprintf (&c, 1, format, ap) + 1);
+ xx = vsprintf(buffer, format, apc);
+POPT_prev_char (const char *str)
+ if ((*p & 0xc0) != (char)0x80)
+POPT_fprintf (FILE* stream, const char *format, ...)
+ char *locale_str = NULL;
+ va_start (args, format);
+ buffer = strdup_vprintf(format, args);
+ locale_str = strdup_locale_from_utf8(buffer);
+ retval = fprintf(stream, "%s", locale_str);
+ retval = fprintf(stream, "%s", buffer);
@@ -113,4 +113,37 @@ struct poptContext_s {
+/*@-declundef -incondefs @*/
+extern /*@only@*/ iconv_t iconv_open(const char *__tocode, const char *__fromcode)
+extern size_t iconv(iconv_t __cd, /*@null@*/ char ** __inbuf,
+ /*@out@*/ size_t * __inbytesleft,
+ /*@out@*/ char ** __outbuf,
+ /*@out@*/ size_t * __outbytesleft)
+ *__inbuf, *__inbytesleft, *__outbuf, *__outbytesleft @*/;
+extern int iconv_close(/*@only@*/ iconv_t __cd)
+/*@=declundef =incondefs @*/
+/*@-declundef -incondefs @*/
+extern char *nl_langinfo (nl_item __item)
+/*@=declundef =incondefs @*/
+int POPT_fprintf (FILE* steam, const char *format, ...);
+char *POPT_prev_char (const char *str);
@@ -13,6 +13,9 @@ extern __const __int32_t *__ctype_touppe
+/* XXX isspace(3) has i18n encoding signednesss issues on Solaris. */
+#define _isspaceptr(_chp) isspace((int)(*(unsigned char *)(_chp)))