components/popt/patches/popt-01-g11n-i18n-stdio.patch
author Girish Moodalbail <Girish.Moodalbail@oracle.COM>
Tue, 25 Nov 2014 13:43:12 -0800
changeset 3481 42f874f2a890
parent 1086 658961e6c9b9
permissions -rw-r--r--
20065334 problem in SERVICE/NEUTRON
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1086
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     1
Comment from the Desktop SUNWlibpopt.spec file:
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     2
date:2007-12-21 owner:fujiwara type:bug bugster:6186542 bugzilla:178413 state:upstream
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     3
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     4
--- popt-1.7/Makefile.am.orig	2007-12-21 19:40:03.495254000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     5
+++ popt-1.7/Makefile.am	2007-12-21 19:42:56.088304000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     6
@@ -15,13 +15,13 @@ noinst_HEADERS = findme.h poptint.h syst
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     7
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     8
 noinst_PROGRAMS = test1 test2 test3
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     9
 test1_SOURCES = test1.c
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    10
-test1_LDFLAGS = -all-static
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    11
+test1_LDFLAGS =
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    12
 test1_LDADD = $(lib_LTLIBRARIES)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    13
 test2_SOURCES = test2.c
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    14
-test2_LDFLAGS = -all-static
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    15
+test2_LDFLAGS =
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    16
 test2_LDADD = $(lib_LTLIBRARIES)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    17
 test3_SOURCES = test3.c
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    18
-test3_LDFLAGS = -all-static
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    19
+test3_LDFLAGS =
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    20
 test3_LDADD = $(lib_LTLIBRARIES)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    21
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    22
 noinst_SCRIPTS = testit.sh
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    23
@@ -33,7 +33,7 @@ TESTS = testit.sh
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    24
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    25
 include_HEADERS = popt.h
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    26
 lib_LTLIBRARIES = libpopt.la
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    27
-libpopt_la_SOURCES = popt.c findme.c poptparse.c poptconfig.c popthelp.c
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    28
+libpopt_la_SOURCES = popt.c findme.c poptparse.c poptconfig.c popthelp.c poptint.c
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    29
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    30
 man_MANS = popt.3
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    31
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    32
--- popt-1.7/configure.in.orig	2007-12-21 19:40:09.557770000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    33
+++ popt-1.7/configure.in	2007-12-21 20:07:17.961454000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    34
@@ -1,9 +1,8 @@
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    35
 AC_INIT(popt.h)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    36
 AC_CANONICAL_SYSTEM
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    37
 AC_PREREQ(2.12)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    38
-AC_CONFIG_HEADERS
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    39
 AM_INIT_AUTOMAKE(popt, 1.7)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    40
-AM_CONFIG_HEADER(config.h)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    41
+AC_CONFIG_HEADERS(config.h)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    42
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    43
 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"
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    44
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    45
@@ -50,7 +49,7 @@ else
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    46
 fi
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    47
 AC_SUBST(TARGET)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    48
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    49
-AC_CHECK_HEADERS(alloca.h float.h libintl.h mcheck.h unistd.h)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    50
+AC_CHECK_HEADERS(alloca.h float.h libintl.h mcheck.h unistd.h langinfo.h)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    51
 AC_MSG_CHECKING(for /usr/ucblib in LIBS)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    52
 if test -d /usr/ucblib ; then
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    53
 	if test "$build" = "mips-sni-sysv4" ; then
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    54
@@ -73,10 +72,10 @@ then
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    55
   AC_MSG_RESULT(yes)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    56
 fi
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    57
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    58
-AC_CHECK_FUNCS(strerror mtrace getuid geteuid)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    59
 AC_CHECK_FUNC(setreuid, [], [
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    60
     AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi])
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    61
 ])
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    62
+AC_CHECK_FUNCS(getuid geteuid mtrace __secure_getenv setregid strerror iconv)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    63
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    64
 AM_GNU_GETTEXT
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    65
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    66
--- popt-1.7/popt.h.orig	2007-12-21 20:31:45.455134000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    67
+++ popt-1.7/popt.h	2007-12-21 20:32:06.508963000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    68
@@ -34,6 +34,8 @@
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    69
 #define	POPT_ARG_FLOAT		8	/*!< arg will be converted to float */
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    70
 #define	POPT_ARG_DOUBLE		9	/*!< arg will be converted to double */
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    71
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    72
+#define POPT_ARG_MAINCALL   10U     /*!< return (*arg) (argc, argv) */
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    73
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    74
 #define POPT_ARG_MASK		0x0000FFFF
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    75
 /*@}*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    76
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    77
--- popt-1.7/popthelp.c.orig	2007-12-21 19:40:16.105761000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    78
+++ popt-1.7/popthelp.c	2007-12-21 19:57:18.972191000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    79
@@ -208,6 +208,8 @@ static void singleOptionHelp(FILE * fp, 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    80
     char * defs = NULL;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    81
     char * left;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    82
     int nb = maxLeftCol + 1;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    83
+    int displaypad = 0;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    84
+    int xx;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    85
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    86
     /* Make sure there's more than enough room in target buffer. */
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    87
     if (opt->longName)	nb += strlen(opt->longName);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    88
@@ -307,8 +309,25 @@ static void singleOptionHelp(FILE * fp, 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    89
 		break;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    90
 	    }
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    91
 	} else {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    92
-	    *le++ = '=';
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    93
-	    strcpy(le, argDescrip);		le += strlen(le);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    94
+	    size_t lelen;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    95
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    96
+	    *le++ = ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_MAINCALL)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    97
+	    ? ' ' : '=';
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    98
+	    strcpy(le, argDescrip);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    99
+	    lelen = strlen(le);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   100
+	    le += lelen;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   101
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   102
+#ifdef  POPT_WCHAR_HACK
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   103
+	    {   const char * scopy = argDescrip;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   104
+	      mbstate_t t;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   105
+	      size_t n;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   106
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   107
+	      memset ((void *)&t, 0, sizeof (t)); /* In initial state.  */
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   108
+	      /* Determine number of characters.  */
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   109
+	      n = mbsrtowcs (NULL, &scopy, strlen(scopy), &t);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   110
+	      displaypad = (int) (lelen-n);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   111
+	    }
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   112
+#endif
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   113
 	}
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   114
 	if (opt->argInfo & POPT_ARGFLAG_OPTIONAL)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   115
 	    *le++ = ']';
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   116
@@ -317,9 +336,9 @@ static void singleOptionHelp(FILE * fp, 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   117
 /*@=boundswrite@*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   118
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   119
     if (help)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   120
-	fprintf(fp,"  %-*s   ", maxLeftCol, left);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   121
+	xx = POPT_fprintf(fp,"  %-*s   ", (int)(maxLeftCol+displaypad), left);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   122
     else {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   123
-	fprintf(fp,"  %s\n", left); 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   124
+	xx = POPT_fprintf(fp,"  %s\n", left); 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   125
 	goto out;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   126
     }
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   127
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   128
@@ -335,22 +354,24 @@ static void singleOptionHelp(FILE * fp, 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   129
 	char format[16];
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   130
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   131
 	ch = help + lineLength - 1;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   132
-	while (ch > help && !isspace(*ch)) ch--;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   133
+	while (ch > help && !_isspaceptr(ch))
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   134
+	    ch = POPT_prev_char (ch);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   135
 	if (ch == help) break;		/* give up */
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   136
-	while (ch > (help + 1) && isspace(*ch)) ch--;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   137
+	while (ch > (help + 1) && _isspaceptr(ch))
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   138
+	    ch = POPT_prev_char (ch);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   139
 	ch++;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   140
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   141
 	sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   142
 	/*@-formatconst@*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   143
-	fprintf(fp, format, help, " ");
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   144
+	xx = POPT_fprintf(fp, format, help, " ");
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   145
 	/*@=formatconst@*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   146
 	help = ch;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   147
-	while (isspace(*help) && *help) help++;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   148
+	while (_isspaceptr(help) && *help) help++;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   149
 	helpLength = strlen(help);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   150
     }
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   151
 /*@=boundsread@*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   152
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   153
-    if (helpLength) fprintf(fp, "%s\n", help);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   154
+    if (helpLength) xx = POPT_fprintf(fp, "%s\n", help);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   155
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   156
 out:
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   157
     /*@-dependenttrans@*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   158
@@ -443,6 +464,7 @@ static void singleTableHelp(poptContext 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   159
 {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   160
     const struct poptOption * opt;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   161
     const char *sub_transdom;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   162
+    int xx;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   163
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   164
     if (table == poptAliasOptions) {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   165
 	itemHelp(fp, con->aliases, con->numAliases, left, NULL);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   166
@@ -466,7 +488,7 @@ static void singleTableHelp(poptContext 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   167
 	    sub_transdom = translation_domain;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   168
 	    
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   169
 	if (opt->descrip)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   170
-	    fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip));
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   171
+	    xx = POPT_fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip));
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   172
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   173
 	singleTableHelp(con, fp, opt->arg, left, sub_transdom);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   174
     }
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   175
--- popt-1.7/poptint.c.orig	1970-01-01 09:00:00.000000000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   176
+++ popt-1.7/poptint.c	2007-12-21 19:57:56.997312000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   177
@@ -0,0 +1,156 @@
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   178
+#include "system.h"
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   179
+#include <stdarg.h>
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   180
+#include "poptint.h"
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   181
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   182
+#ifdef HAVE_ICONV
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   183
+static /*@only@*/ /*@null@*/ char *
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   184
+strdup_locale_from_utf8 (/*@null@*/ char *buffer)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   185
+	/*@*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   186
+{
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   187
+    char *codeset = NULL;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   188
+    char *dest_str;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   189
+    iconv_t fd;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   190
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   191
+    if (buffer == NULL)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   192
+	return NULL;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   193
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   194
+#ifdef HAVE_LANGINFO_H
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   195
+/*@-type@*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   196
+    codeset = nl_langinfo (CODESET);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   197
+/*@=type@*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   198
+#endif
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   199
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   200
+    if (codeset && strcmp(codeset, "UTF-8")
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   201
+     && (fd = iconv_open(codeset, "UTF-8")) != (iconv_t)-1)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   202
+    {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   203
+	char *pin = buffer;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   204
+	char *pout = NULL;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   205
+	size_t ib, ob, dest_size;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   206
+	int done;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   207
+	int is_error;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   208
+	size_t err;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   209
+	char *shift_pin = NULL;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   210
+	int xx;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   211
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   212
+	err = iconv(fd, NULL, &ib, &pout, &ob);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   213
+	dest_size = ob = ib = strlen(buffer);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   214
+	dest_str = pout = malloc((dest_size + 1) * sizeof(*dest_str));
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   215
+	if (dest_str)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   216
+	    *dest_str = '\0';
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   217
+	done = is_error = 0;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   218
+	if (pout != NULL)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   219
+	while (!done && !is_error) {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   220
+	    err = iconv(fd, &pin, &ib, &pout, &ob);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   221
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   222
+	    if (err == (size_t)-1) {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   223
+		switch (errno) {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   224
+		case EINVAL:
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   225
+		    done = 1;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   226
+		    /*@switchbreak@*/ break;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   227
+		case E2BIG:
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   228
+		{   size_t used = pout - dest_str;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   229
+		    dest_size *= 2;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   230
+		    dest_str = realloc(dest_str, (dest_size + 1) * sizeof(*dest_str));
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   231
+		    if (dest_str == NULL) {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   232
+			is_error = 1;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   233
+			continue;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   234
+		    }
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   235
+		    pout = dest_str + used;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   236
+		    ob = dest_size - used;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   237
+		}   /*@switchbreak@*/ break;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   238
+		case EILSEQ:
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   239
+		    is_error = 1;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   240
+		    /*@switchbreak@*/ break;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   241
+		default:
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   242
+		    is_error = 1;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   243
+		    /*@switchbreak@*/ break;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   244
+		}
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   245
+	    } else {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   246
+		if (shift_pin == NULL) {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   247
+		    shift_pin = pin;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   248
+		    pin = NULL;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   249
+		    ib = 0;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   250
+		} else {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   251
+		    done = 1;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   252
+		}
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   253
+	    }
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   254
+	}
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   255
+	xx = iconv_close(fd);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   256
+	if (pout)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   257
+	    *pout = '\0';
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   258
+	if (dest_str != NULL)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   259
+	    dest_str = xstrdup(dest_str);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   260
+    } else {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   261
+	dest_str = xstrdup(buffer);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   262
+    }
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   263
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   264
+    return dest_str;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   265
+}
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   266
+#endif
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   267
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   268
+/*@-mustmod@*/	/* LCL: can't see the ap modification. */
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   269
+static /*@only@*/ /*@null@*/ char *
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   270
+strdup_vprintf (const char *format, va_list ap)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   271
+	/*@modifies ap @*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   272
+{
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   273
+    char *buffer;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   274
+    char c;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   275
+    va_list apc;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   276
+    int xx;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   277
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   278
+/*@-noeffectuncon -unrecog @*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   279
+    va_copy(apc, ap);	/* XXX linux amd64/ppc needs a copy. */
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   280
+/*@=noeffectuncon =unrecog @*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   281
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   282
+    buffer = calloc(sizeof(*buffer), vsnprintf (&c, 1, format, ap) + 1);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   283
+    if (buffer != NULL)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   284
+	xx = vsprintf(buffer, format, apc);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   285
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   286
+    va_end(apc);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   287
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   288
+    return buffer;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   289
+}
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   290
+/*@=mustmod@*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   291
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   292
+char *
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   293
+POPT_prev_char (const char *str)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   294
+{
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   295
+    char *p = (char *)str;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   296
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   297
+    while (1) {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   298
+	p--;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   299
+	if ((*p & 0xc0) != (char)0x80)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   300
+	    return (char *)p;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   301
+    }
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   302
+}
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   303
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   304
+int
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   305
+POPT_fprintf (FILE* stream, const char *format, ...)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   306
+{
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   307
+    int retval = 0;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   308
+    va_list args;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   309
+    char *buffer = NULL;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   310
+#ifdef HAVE_ICONV
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   311
+    char *locale_str = NULL;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   312
+#endif
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   313
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   314
+    va_start (args, format);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   315
+    buffer = strdup_vprintf(format, args);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   316
+    va_end (args);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   317
+    if (buffer == NULL)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   318
+	return retval;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   319
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   320
+#ifdef HAVE_ICONV
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   321
+    locale_str = strdup_locale_from_utf8(buffer);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   322
+    if (locale_str) {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   323
+	retval = fprintf(stream, "%s", locale_str);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   324
+	free(locale_str);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   325
+    } else
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   326
+#endif
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   327
+    {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   328
+	retval = fprintf(stream, "%s", buffer);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   329
+    }
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   330
+    free (buffer);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   331
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   332
+    return retval;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   333
+}
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   334
--- popt-1.7/poptint.h.orig	2007-12-21 19:40:22.696680000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   335
+++ popt-1.7/poptint.h	2007-12-21 20:00:39.593387000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   336
@@ -113,4 +113,37 @@ struct poptContext_s {
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   337
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   338
 #define N_(foo) foo
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   339
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   340
+#ifdef HAVE_ICONV
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   341
+#include <iconv.h>
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   342
+#if defined(__LCLINT__)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   343
+/*@-declundef -incondefs @*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   344
+extern /*@only@*/ iconv_t iconv_open(const char *__tocode, const char *__fromcode)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   345
+    /*@*/;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   346
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   347
+extern size_t iconv(iconv_t __cd, /*@null@*/ char ** __inbuf,
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   348
+            /*@out@*/ size_t * __inbytesleft,
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   349
+            /*@out@*/ char ** __outbuf,
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   350
+            /*@out@*/ size_t * __outbytesleft)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   351
+    /*@modifies __cd,
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   352
+        *__inbuf, *__inbytesleft, *__outbuf, *__outbytesleft @*/;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   353
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   354
+extern int iconv_close(/*@only@*/ iconv_t __cd)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   355
+    /*@modifies __cd @*/;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   356
+/*@=declundef =incondefs @*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   357
+#endif
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   358
+#endif
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   359
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   360
+#ifdef HAVE_LANGINFO_H
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   361
+#include <langinfo.h>
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   362
+#if defined(__LCLINT__)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   363
+/*@-declundef -incondefs @*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   364
+extern char *nl_langinfo (nl_item __item)
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   365
+    /*@*/;
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   366
+/*@=declundef =incondefs @*/
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   367
+#endif
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   368
+#endif
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   369
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   370
+int   POPT_fprintf (FILE* steam, const char *format, ...);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   371
+char *POPT_prev_char (const char *str);
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   372
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   373
 #endif
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   374
--- popt-1.7/system.h.orig	2007-12-21 20:01:08.290683000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   375
+++ popt-1.7/system.h	2007-12-21 20:01:59.455124000 +0900
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   376
@@ -13,6 +13,9 @@ extern __const __int32_t *__ctype_touppe
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   377
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   378
 #include <ctype.h>
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   379
 
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   380
+/* XXX isspace(3) has i18n encoding signednesss issues on Solaris. */
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   381
+#define _isspaceptr(_chp)   isspace((int)(*(unsigned char *)(_chp)))
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   382
+
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   383
 #include <errno.h>
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   384
 #include <fcntl.h>
658961e6c9b9 15820214 SUNBT7202654 Move popt from Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   385
 #include <limits.h>