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