Updated by gnulib-sync
Showing
63 changed files
with
760 additions
and
474 deletions
1 | /* Safe automatic memory allocation. | 1 | /* Safe automatic memory allocation. |
2 | Copyright (C) 2003-2004 Free Software Foundation, Inc. | 2 | Copyright (C) 2003-2006 Free Software Foundation, Inc. |
3 | Written by Bruno Haible <bruno@clisp.org>, 2003. | 3 | Written by Bruno Haible <bruno@clisp.org>, 2003. |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
... | @@ -23,6 +23,12 @@ | ... | @@ -23,6 +23,12 @@ |
23 | #include <stddef.h> | 23 | #include <stddef.h> |
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | 25 | ||
26 | |||
27 | #ifdef __cplusplus | ||
28 | extern "C" { | ||
29 | #endif | ||
30 | |||
31 | |||
26 | /* safe_alloca(N) is equivalent to alloca(N) when it is safe to call | 32 | /* safe_alloca(N) is equivalent to alloca(N) when it is safe to call |
27 | alloca(N); otherwise it returns NULL. It either returns N bytes of | 33 | alloca(N); otherwise it returns NULL. It either returns N bytes of |
28 | memory allocated on the stack, that lasts until the function returns, | 34 | memory allocated on the stack, that lasts until the function returns, |
... | @@ -69,6 +75,11 @@ extern void freesa (void *p); | ... | @@ -69,6 +75,11 @@ extern void freesa (void *p); |
69 | If this would be useful in your application. please speak up. */ | 75 | If this would be useful in your application. please speak up. */ |
70 | 76 | ||
71 | 77 | ||
78 | #ifdef __cplusplus | ||
79 | } | ||
80 | #endif | ||
81 | |||
82 | |||
72 | /* ------------------- Auxiliary, non-public definitions ------------------- */ | 83 | /* ------------------- Auxiliary, non-public definitions ------------------- */ |
73 | 84 | ||
74 | /* Determine the alignment of a type at compile time. */ | 85 | /* Determine the alignment of a type at compile time. */ |
... | @@ -81,6 +92,10 @@ extern void freesa (void *p); | ... | @@ -81,6 +92,10 @@ extern void freesa (void *p); |
81 | /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof | 92 | /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof |
82 | values. */ | 93 | values. */ |
83 | # define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) | 94 | # define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) |
95 | #elif defined _AIX | ||
96 | /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof | ||
97 | values. */ | ||
98 | # define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) | ||
84 | #else | 99 | #else |
85 | # define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) | 100 | # define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) |
86 | #endif | 101 | #endif | ... | ... |
1 | /* Error handler for noninteractive utilities | 1 | /* Error handler for noninteractive utilities |
2 | Copyright (C) 1990-1998, 2000-2003, 2004 Free Software Foundation, Inc. | 2 | Copyright (C) 1990-1998, 2000-2005, 2006 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. | 3 | This file is part of the GNU C Library. |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
... | @@ -34,6 +34,9 @@ | ... | @@ -34,6 +34,9 @@ |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #ifdef _LIBC | 36 | #ifdef _LIBC |
37 | # include <libintl.h> | ||
38 | # include <stdbool.h> | ||
39 | # include <stdint.h> | ||
37 | # include <wchar.h> | 40 | # include <wchar.h> |
38 | # define mbsrtowcs __mbsrtowcs | 41 | # define mbsrtowcs __mbsrtowcs |
39 | #endif | 42 | #endif |
... | @@ -59,6 +62,7 @@ unsigned int error_message_count; | ... | @@ -59,6 +62,7 @@ unsigned int error_message_count; |
59 | 62 | ||
60 | # define program_name program_invocation_name | 63 | # define program_name program_invocation_name |
61 | # include <errno.h> | 64 | # include <errno.h> |
65 | # include <limits.h> | ||
62 | # include <libio/libioP.h> | 66 | # include <libio/libioP.h> |
63 | 67 | ||
64 | /* In GNU libc we want do not want to use the common name `error' directly. | 68 | /* In GNU libc we want do not want to use the common name `error' directly. |
... | @@ -88,23 +92,19 @@ extern void __error_at_line (int status, int errnum, const char *file_name, | ... | @@ -88,23 +92,19 @@ extern void __error_at_line (int status, int errnum, const char *file_name, |
88 | char *strerror_r (); | 92 | char *strerror_r (); |
89 | # endif | 93 | # endif |
90 | 94 | ||
91 | # ifndef SIZE_MAX | ||
92 | # define SIZE_MAX ((size_t) -1) | ||
93 | # endif | ||
94 | |||
95 | /* The calling program should define program_name and set it to the | 95 | /* The calling program should define program_name and set it to the |
96 | name of the executing program. */ | 96 | name of the executing program. */ |
97 | extern char *program_name; | 97 | extern char *program_name; |
98 | 98 | ||
99 | # if HAVE_STRERROR_R || defined strerror_r | 99 | # if HAVE_STRERROR_R || defined strerror_r |
100 | # define __strerror_r strerror_r | 100 | # define __strerror_r strerror_r |
101 | # endif | 101 | # endif /* HAVE_STRERROR_R || defined strerror_r */ |
102 | #endif /* not _LIBC */ | 102 | #endif /* not _LIBC */ |
103 | 103 | ||
104 | static void | 104 | static void |
105 | print_errno_message (int errnum) | 105 | print_errno_message (int errnum) |
106 | { | 106 | { |
107 | char const *s = NULL; | 107 | char const *s; |
108 | 108 | ||
109 | #if defined HAVE_STRERROR_R || _LIBC | 109 | #if defined HAVE_STRERROR_R || _LIBC |
110 | char errbuf[1024]; | 110 | char errbuf[1024]; |
... | @@ -113,23 +113,23 @@ print_errno_message (int errnum) | ... | @@ -113,23 +113,23 @@ print_errno_message (int errnum) |
113 | # else | 113 | # else |
114 | if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) | 114 | if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) |
115 | s = errbuf; | 115 | s = errbuf; |
116 | else | ||
117 | s = 0; | ||
116 | # endif | 118 | # endif |
119 | #else | ||
120 | s = strerror (errnum); | ||
117 | #endif | 121 | #endif |
118 | 122 | ||
119 | #if !_LIBC | 123 | #if !_LIBC |
120 | if (! s && ! (s = strerror (errnum))) | 124 | if (! s) |
121 | s = _("Unknown system error"); | 125 | s = _("Unknown system error"); |
122 | #endif | 126 | #endif |
123 | 127 | ||
124 | #if _LIBC | 128 | #if _LIBC |
125 | if (_IO_fwide (stderr, 0) > 0) | 129 | __fxprintf (NULL, ": %s", s); |
126 | { | 130 | #else |
127 | __fwprintf (stderr, L": %s", s); | ||
128 | return; | ||
129 | } | ||
130 | #endif | ||
131 | |||
132 | fprintf (stderr, ": %s", s); | 131 | fprintf (stderr, ": %s", s); |
132 | #endif | ||
133 | } | 133 | } |
134 | 134 | ||
135 | static void | 135 | static void |
... | @@ -140,26 +140,65 @@ error_tail (int status, int errnum, const char *message, va_list args) | ... | @@ -140,26 +140,65 @@ error_tail (int status, int errnum, const char *message, va_list args) |
140 | { | 140 | { |
141 | # define ALLOCA_LIMIT 2000 | 141 | # define ALLOCA_LIMIT 2000 |
142 | size_t len = strlen (message) + 1; | 142 | size_t len = strlen (message) + 1; |
143 | const wchar_t *wmessage = L"out of memory"; | 143 | wchar_t *wmessage = NULL; |
144 | wchar_t *wbuf = (len < ALLOCA_LIMIT | ||
145 | ? alloca (len * sizeof *wbuf) | ||
146 | : len <= SIZE_MAX / sizeof *wbuf | ||
147 | ? malloc (len * sizeof *wbuf) | ||
148 | : NULL); | ||
149 | |||
150 | if (wbuf) | ||
151 | { | ||
152 | size_t res; | ||
153 | mbstate_t st; | 144 | mbstate_t st; |
154 | const char *tmp = message; | 145 | size_t res; |
146 | const char *tmp; | ||
147 | bool use_malloc = false; | ||
148 | |||
149 | while (1) | ||
150 | { | ||
151 | if (__libc_use_alloca (len * sizeof (wchar_t))) | ||
152 | wmessage = (wchar_t *) alloca (len * sizeof (wchar_t)); | ||
153 | else | ||
154 | { | ||
155 | if (!use_malloc) | ||
156 | wmessage = NULL; | ||
157 | |||
158 | wchar_t *p = (wchar_t *) realloc (wmessage, | ||
159 | len * sizeof (wchar_t)); | ||
160 | if (p == NULL) | ||
161 | { | ||
162 | free (wmessage); | ||
163 | fputws_unlocked (L"out of memory\n", stderr); | ||
164 | return; | ||
165 | } | ||
166 | wmessage = p; | ||
167 | use_malloc = true; | ||
168 | } | ||
169 | |||
155 | memset (&st, '\0', sizeof (st)); | 170 | memset (&st, '\0', sizeof (st)); |
156 | res = mbsrtowcs (wbuf, &tmp, len, &st); | 171 | tmp = message; |
157 | wmessage = res == (size_t) -1 ? L"???" : wbuf; | 172 | |
173 | res = mbsrtowcs (wmessage, &tmp, len, &st); | ||
174 | if (res != len) | ||
175 | break; | ||
176 | |||
177 | if (__builtin_expect (len >= SIZE_MAX / 2, 0)) | ||
178 | { | ||
179 | /* This really should not happen if everything is fine. */ | ||
180 | res = (size_t) -1; | ||
181 | break; | ||
182 | } | ||
183 | |||
184 | len *= 2; | ||
185 | } | ||
186 | |||
187 | if (res == (size_t) -1) | ||
188 | { | ||
189 | /* The string cannot be converted. */ | ||
190 | if (use_malloc) | ||
191 | { | ||
192 | free (wmessage); | ||
193 | use_malloc = false; | ||
194 | } | ||
195 | wmessage = (wchar_t *) L"???"; | ||
158 | } | 196 | } |
159 | 197 | ||
160 | __vfwprintf (stderr, wmessage, args); | 198 | __vfwprintf (stderr, wmessage, args); |
161 | if (! (len < ALLOCA_LIMIT)) | 199 | |
162 | free (wbuf); | 200 | if (use_malloc) |
201 | free (wmessage); | ||
163 | } | 202 | } |
164 | else | 203 | else |
165 | #endif | 204 | #endif |
... | @@ -170,11 +209,10 @@ error_tail (int status, int errnum, const char *message, va_list args) | ... | @@ -170,11 +209,10 @@ error_tail (int status, int errnum, const char *message, va_list args) |
170 | if (errnum) | 209 | if (errnum) |
171 | print_errno_message (errnum); | 210 | print_errno_message (errnum); |
172 | #if _LIBC | 211 | #if _LIBC |
173 | if (_IO_fwide (stderr, 0) > 0) | 212 | __fxprintf (NULL, "\n"); |
174 | putwc (L'\n', stderr); | 213 | #else |
175 | else | ||
176 | #endif | ||
177 | putc ('\n', stderr); | 214 | putc ('\n', stderr); |
215 | #endif | ||
178 | fflush (stderr); | 216 | fflush (stderr); |
179 | if (status) | 217 | if (status) |
180 | exit (status); | 218 | exit (status); |
... | @@ -207,11 +245,10 @@ error (int status, int errnum, const char *message, ...) | ... | @@ -207,11 +245,10 @@ error (int status, int errnum, const char *message, ...) |
207 | else | 245 | else |
208 | { | 246 | { |
209 | #if _LIBC | 247 | #if _LIBC |
210 | if (_IO_fwide (stderr, 0) > 0) | 248 | __fxprintf (NULL, "%s: ", program_name); |
211 | __fwprintf (stderr, L"%s: ", program_name); | 249 | #else |
212 | else | ||
213 | #endif | ||
214 | fprintf (stderr, "%s: ", program_name); | 250 | fprintf (stderr, "%s: ", program_name); |
251 | #endif | ||
215 | } | 252 | } |
216 | 253 | ||
217 | va_start (args, message); | 254 | va_start (args, message); |
... | @@ -267,22 +304,19 @@ error_at_line (int status, int errnum, const char *file_name, | ... | @@ -267,22 +304,19 @@ error_at_line (int status, int errnum, const char *file_name, |
267 | else | 304 | else |
268 | { | 305 | { |
269 | #if _LIBC | 306 | #if _LIBC |
270 | if (_IO_fwide (stderr, 0) > 0) | 307 | __fxprintf (NULL, "%s:", program_name); |
271 | __fwprintf (stderr, L"%s: ", program_name); | 308 | #else |
272 | else | ||
273 | #endif | ||
274 | fprintf (stderr, "%s:", program_name); | 309 | fprintf (stderr, "%s:", program_name); |
310 | #endif | ||
275 | } | 311 | } |
276 | 312 | ||
277 | if (file_name != NULL) | ||
278 | { | ||
279 | #if _LIBC | 313 | #if _LIBC |
280 | if (_IO_fwide (stderr, 0) > 0) | 314 | __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ", |
281 | __fwprintf (stderr, L"%s:%d: ", file_name, line_number); | 315 | file_name, line_number); |
282 | else | 316 | #else |
317 | fprintf (stderr, file_name != NULL ? "%s:%d: " : " ", | ||
318 | file_name, line_number); | ||
283 | #endif | 319 | #endif |
284 | fprintf (stderr, "%s:%d: ", file_name, line_number); | ||
285 | } | ||
286 | 320 | ||
287 | va_start (args, message); | 321 | va_start (args, message); |
288 | error_tail (status, errnum, message, args); | 322 | error_tail (status, errnum, message, args); | ... | ... |
1 | /* Declaration for error-reporting function | 1 | /* Declaration for error-reporting function |
2 | Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc. | 2 | Copyright (C) 1995, 1996, 1997, 2003, 2006 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. | 3 | This file is part of the GNU C Library. |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
21 | 21 | ||
22 | #ifndef __attribute__ | 22 | #ifndef __attribute__ |
23 | /* This feature is available in gcc versions 2.5 and later. */ | 23 | /* This feature is available in gcc versions 2.5 and later. */ |
24 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) | 24 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ |
25 | # define __attribute__(Spec) /* empty */ | 25 | # define __attribute__(Spec) /* empty */ |
26 | # endif | 26 | # endif |
27 | /* The __-protected variants of `format' and `printf' attributes | 27 | /* The __-protected variants of `format' and `printf' attributes | ... | ... |
... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
21 | /* Get exit() declaration. */ | 21 | /* Get exit() declaration. */ |
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | 23 | ||
24 | /* Some systems do not define EXIT_*, even with STDC_HEADERS. */ | 24 | /* Some systems do not define EXIT_*, despite otherwise supporting C89. */ |
25 | #ifndef EXIT_SUCCESS | 25 | #ifndef EXIT_SUCCESS |
26 | # define EXIT_SUCCESS 0 | 26 | # define EXIT_SUCCESS 0 |
27 | #endif | 27 | #endif | ... | ... |
1 | /* Failure exit status | 1 | /* Failure exit status |
2 | 2 | ||
3 | Copyright (C) 2002, 2003 Free Software Foundation, Inc. | 3 | Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by | ... | ... |
1 | /* Determine the number of screen columns needed for a string. | 1 | /* Determine the number of screen columns needed for a string. |
2 | Copyright (C) 2000-2005 Free Software Foundation, Inc. | 2 | Copyright (C) 2000-2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -32,7 +32,7 @@ | ... | @@ -32,7 +32,7 @@ |
32 | /* Get isprint(). */ | 32 | /* Get isprint(). */ |
33 | #include <ctype.h> | 33 | #include <ctype.h> |
34 | 34 | ||
35 | /* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */ | 35 | /* Get mbstate_t, mbrtowc(), mbsinit(). */ |
36 | #if HAVE_WCHAR_H | 36 | #if HAVE_WCHAR_H |
37 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | 37 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before |
38 | <wchar.h>. | 38 | <wchar.h>. |
... | @@ -43,15 +43,15 @@ | ... | @@ -43,15 +43,15 @@ |
43 | # include <wchar.h> | 43 | # include <wchar.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | /* Get iswprint(), iswcntrl(). */ | 46 | /* Get wcwidth(). */ |
47 | #include "wcwidth.h" | ||
48 | |||
49 | /* Get iswcntrl(). */ | ||
47 | #if HAVE_WCTYPE_H | 50 | #if HAVE_WCTYPE_H |
48 | # include <wctype.h> | 51 | # include <wctype.h> |
49 | #endif | 52 | #endif |
50 | #if !defined iswprint && !HAVE_ISWPRINT | ||
51 | # define iswprint(wc) 1 | ||
52 | #endif | ||
53 | #if !defined iswcntrl && !HAVE_ISWCNTRL | 53 | #if !defined iswcntrl && !HAVE_ISWCNTRL |
54 | # define iswcntrl(wc) 0 | 54 | # define iswcntrl(wc) (((wc) & ~0x1f) == 0 || (wc) == 0x7f) |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | #ifndef mbsinit | 57 | #ifndef mbsinit |
... | @@ -60,33 +60,6 @@ | ... | @@ -60,33 +60,6 @@ |
60 | # endif | 60 | # endif |
61 | #endif | 61 | #endif |
62 | 62 | ||
63 | #ifndef HAVE_DECL_WCWIDTH | ||
64 | "this configure-time declaration test was not run" | ||
65 | #endif | ||
66 | #if !HAVE_DECL_WCWIDTH | ||
67 | int wcwidth (); | ||
68 | #endif | ||
69 | |||
70 | #ifndef wcwidth | ||
71 | # if !HAVE_WCWIDTH | ||
72 | /* wcwidth doesn't exist, so assume all printable characters have | ||
73 | width 1. */ | ||
74 | # define wcwidth(wc) ((wc) == 0 ? 0 : iswprint (wc) ? 1 : -1) | ||
75 | # endif | ||
76 | #endif | ||
77 | |||
78 | /* Get ISPRINT. */ | ||
79 | #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) | ||
80 | # define IN_CTYPE_DOMAIN(c) 1 | ||
81 | #else | ||
82 | # define IN_CTYPE_DOMAIN(c) isascii(c) | ||
83 | #endif | ||
84 | /* Undefine to protect against the definition in wctype.h of Solaris 2.6. */ | ||
85 | #undef ISPRINT | ||
86 | #define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) | ||
87 | #undef ISCNTRL | ||
88 | #define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c)) | ||
89 | |||
90 | /* Returns the number of columns needed to represent the multibyte | 63 | /* Returns the number of columns needed to represent the multibyte |
91 | character string pointed to by STRING. If a non-printable character | 64 | character string pointed to by STRING. If a non-printable character |
92 | occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned. | 65 | occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned. |
... | @@ -210,10 +183,10 @@ mbsnwidth (const char *string, size_t nbytes, int flags) | ... | @@ -210,10 +183,10 @@ mbsnwidth (const char *string, size_t nbytes, int flags) |
210 | { | 183 | { |
211 | unsigned char c = (unsigned char) *p++; | 184 | unsigned char c = (unsigned char) *p++; |
212 | 185 | ||
213 | if (ISPRINT (c)) | 186 | if (isprint (c)) |
214 | width++; | 187 | width++; |
215 | else if (!(flags & MBSW_REJECT_UNPRINTABLE)) | 188 | else if (!(flags & MBSW_REJECT_UNPRINTABLE)) |
216 | width += (ISCNTRL (c) ? 0 : 1); | 189 | width += (iscntrl (c) ? 0 : 1); |
217 | else | 190 | else |
218 | return -1; | 191 | return -1; |
219 | } | 192 | } | ... | ... |
1 | /* obstack.c - subroutines used implicitly by object stack macros | 1 | /* obstack.c - subroutines used implicitly by object stack macros |
2 | 2 | ||
3 | Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, | 3 | Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, |
4 | 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, | 4 | 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software |
5 | Inc. | 5 | Foundation, Inc. |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
... | @@ -55,13 +55,7 @@ | ... | @@ -55,13 +55,7 @@ |
55 | 55 | ||
56 | #ifndef ELIDE_CODE | 56 | #ifndef ELIDE_CODE |
57 | 57 | ||
58 | |||
59 | # if HAVE_INTTYPES_H | ||
60 | # include <inttypes.h> | ||
61 | # endif | ||
62 | # if HAVE_STDINT_H || defined _LIBC | ||
63 | # include <stdint.h> | 58 | # include <stdint.h> |
64 | # endif | ||
65 | 59 | ||
66 | /* Determine default alignment. */ | 60 | /* Determine default alignment. */ |
67 | union fooround | 61 | union fooround | ... | ... |
... | @@ -27,7 +27,9 @@ | ... | @@ -27,7 +27,9 @@ |
27 | 27 | ||
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <string.h> | 29 | #include <string.h> |
30 | #include <unistd.h> | 30 | #if _LIBC || HAVE_UNISTD_H |
31 | # include <unistd.h> | ||
32 | #endif | ||
31 | 33 | ||
32 | #if !_LIBC | 34 | #if !_LIBC |
33 | # include "allocsa.h" | 35 | # include "allocsa.h" | ... | ... |
1 | /* Formatted output to strings. | 1 | /* Formatted output to strings. |
2 | Copyright (C) 2004 Free Software Foundation, Inc. | 2 | Copyright (C) 2004, 2006 Free Software Foundation, Inc. |
3 | Written by Simon Josefsson. | 3 | Written by Simon Josefsson and Paul Eggert. |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
... | @@ -22,13 +22,19 @@ | ... | @@ -22,13 +22,19 @@ |
22 | 22 | ||
23 | #include "snprintf.h" | 23 | #include "snprintf.h" |
24 | 24 | ||
25 | #include <errno.h> | ||
26 | #include <limits.h> | ||
25 | #include <stdarg.h> | 27 | #include <stdarg.h> |
26 | #include <stdlib.h> | 28 | #include <stdlib.h> |
27 | #include <string.h> | 29 | #include <string.h> |
28 | 30 | ||
29 | #include "minmax.h" | ||
30 | #include "vasnprintf.h" | 31 | #include "vasnprintf.h" |
31 | 32 | ||
33 | /* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ | ||
34 | #ifndef EOVERFLOW | ||
35 | # define EOVERFLOW E2BIG | ||
36 | #endif | ||
37 | |||
32 | /* Print formatted output to string STR. Similar to sprintf, but | 38 | /* Print formatted output to string STR. Similar to sprintf, but |
33 | additional length SIZE limit how much is written into STR. Returns | 39 | additional length SIZE limit how much is written into STR. Returns |
34 | string length of formatted string (which may be larger than SIZE). | 40 | string length of formatted string (which may be larger than SIZE). |
... | @@ -39,22 +45,34 @@ snprintf (char *str, size_t size, const char *format, ...) | ... | @@ -39,22 +45,34 @@ snprintf (char *str, size_t size, const char *format, ...) |
39 | { | 45 | { |
40 | char *output; | 46 | char *output; |
41 | size_t len; | 47 | size_t len; |
48 | size_t lenbuf = size; | ||
42 | va_list args; | 49 | va_list args; |
43 | 50 | ||
44 | va_start (args, format); | 51 | va_start (args, format); |
45 | len = size; | 52 | output = vasnprintf (str, &lenbuf, format, args); |
46 | output = vasnprintf (str, &len, format, args); | 53 | len = lenbuf; |
47 | va_end (args); | 54 | va_end (args); |
48 | 55 | ||
49 | if (!output) | 56 | if (!output) |
50 | return -1; | 57 | return -1; |
51 | 58 | ||
52 | if (str != NULL) | ||
53 | if (len > size - 1) /* equivalent to: (size > 0 && len >= size) */ | ||
54 | str[size - 1] = '\0'; | ||
55 | |||
56 | if (output != str) | 59 | if (output != str) |
60 | { | ||
61 | if (size) | ||
62 | { | ||
63 | size_t pruned_len = (len < size ? len : size - 1); | ||
64 | memcpy (str, output, pruned_len); | ||
65 | str[pruned_len] = '\0'; | ||
66 | } | ||
67 | |||
57 | free (output); | 68 | free (output); |
69 | } | ||
70 | |||
71 | if (INT_MAX < len) | ||
72 | { | ||
73 | errno = EOVERFLOW; | ||
74 | return -1; | ||
75 | } | ||
58 | 76 | ||
59 | return len; | 77 | return len; |
60 | } | 78 | } | ... | ... |
1 | /* Formatted output to strings. | 1 | /* Formatted output to strings. |
2 | Copyright (C) 1999, 2002 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -22,10 +22,17 @@ | ... | @@ -22,10 +22,17 @@ |
22 | /* Specification. */ | 22 | /* Specification. */ |
23 | #include "vasprintf.h" | 23 | #include "vasprintf.h" |
24 | 24 | ||
25 | #include <errno.h> | ||
26 | #include <limits.h> | ||
25 | #include <stdlib.h> | 27 | #include <stdlib.h> |
26 | 28 | ||
27 | #include "vasnprintf.h" | 29 | #include "vasnprintf.h" |
28 | 30 | ||
31 | /* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ | ||
32 | #ifndef EOVERFLOW | ||
33 | # define EOVERFLOW E2BIG | ||
34 | #endif | ||
35 | |||
29 | int | 36 | int |
30 | vasprintf (char **resultp, const char *format, va_list args) | 37 | vasprintf (char **resultp, const char *format, va_list args) |
31 | { | 38 | { |
... | @@ -34,9 +41,14 @@ vasprintf (char **resultp, const char *format, va_list args) | ... | @@ -34,9 +41,14 @@ vasprintf (char **resultp, const char *format, va_list args) |
34 | if (result == NULL) | 41 | if (result == NULL) |
35 | return -1; | 42 | return -1; |
36 | 43 | ||
44 | if (length > INT_MAX) | ||
45 | { | ||
46 | free (result); | ||
47 | errno = EOVERFLOW; | ||
48 | return -1; | ||
49 | } | ||
50 | |||
37 | *resultp = result; | 51 | *resultp = result; |
38 | /* Return the number of resulting bytes, excluding the trailing NUL. | 52 | /* Return the number of resulting bytes, excluding the trailing NUL. */ |
39 | If it wouldn't fit in an 'int', vasnprintf() would have returned NULL | ||
40 | and set errno to EOVERFLOW. */ | ||
41 | return length; | 53 | return length; |
42 | } | 54 | } | ... | ... |
... | @@ -11,8 +11,8 @@ | ... | @@ -11,8 +11,8 @@ |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU General Public License for more details. | 12 | GNU General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU General Public License along | 14 | You should have received a copy of the GNU General Public License |
15 | with this program; if not, write to the Free Software Foundation, | 15 | along with this program; if not, write to the Free Software Foundation, |
16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
17 | 17 | ||
18 | #ifndef _VASPRINTF_H | 18 | #ifndef _VASPRINTF_H | ... | ... |
1 | # argp.m4 serial 6 | 1 | # argp.m4 serial 7 |
2 | dnl Copyright (C) 2003-2006 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2003-2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
... | @@ -7,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. | ... | @@ -7,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. |
7 | AC_DEFUN([gl_ARGP], | 7 | AC_DEFUN([gl_ARGP], |
8 | [ | 8 | [ |
9 | AC_REQUIRE([AC_C_INLINE]) | 9 | AC_REQUIRE([AC_C_INLINE]) |
10 | AC_REQUIRE([AC_C_RESTRICT]) | ||
10 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | 11 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
11 | AC_REQUIRE([gl_GETOPT_SUBSTITUTE]) | 12 | AC_REQUIRE([gl_GETOPT_SUBSTITUTE]) |
12 | 13 | ||
... | @@ -14,13 +15,13 @@ AC_DEFUN([gl_ARGP], | ... | @@ -14,13 +15,13 @@ AC_DEFUN([gl_ARGP], |
14 | [AC_DEFINE(HAVE_DECL_PROGRAM_INVOCATION_NAME, 1, | 15 | [AC_DEFINE(HAVE_DECL_PROGRAM_INVOCATION_NAME, 1, |
15 | [Define if program_invocation_name is declared])], | 16 | [Define if program_invocation_name is declared])], |
16 | [AC_DEFINE(GNULIB_PROGRAM_INVOCATION_NAME, 1, | 17 | [AC_DEFINE(GNULIB_PROGRAM_INVOCATION_NAME, 1, |
17 | [Define to 1 to add extern declaration of program_invocation_name to argp-namefrob.h])], | 18 | [Define to 1 to add extern declaration of program_invocation_name to argp.h])], |
18 | [#include <errno.h>]) | 19 | [#include <errno.h>]) |
19 | AC_CHECK_DECL([program_invocation_short_name], | 20 | AC_CHECK_DECL([program_invocation_short_name], |
20 | [AC_DEFINE(HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME, 1, | 21 | [AC_DEFINE(HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME, 1, |
21 | [Define if program_invocation_short_name is declared])], | 22 | [Define if program_invocation_short_name is declared])], |
22 | [AC_DEFINE(GNULIB_PROGRAM_INVOCATION_SHORT_NAME, 1, | 23 | [AC_DEFINE(GNULIB_PROGRAM_INVOCATION_SHORT_NAME, 1, |
23 | [Define to 1 to add extern declaration of program_invocation_short_name to argp-namefrob.h])], | 24 | [Define to 1 to add extern declaration of program_invocation_short_name to argp.h])], |
24 | [#include <errno.h>]) | 25 | [#include <errno.h>]) |
25 | 26 | ||
26 | # Check if program_invocation_name and program_invocation_short_name | 27 | # Check if program_invocation_name and program_invocation_short_name | ... | ... |
1 | #serial 8 | 1 | #serial 9 |
2 | 2 | ||
3 | dnl From Jim Meyering. | 3 | dnl From Jim Meyering. |
4 | dnl | 4 | dnl |
5 | dnl Check whether struct dirent has a member named d_type. | 5 | dnl Check whether struct dirent has a member named d_type. |
6 | dnl | 6 | dnl |
7 | 7 | ||
8 | # Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004 Free Software | 8 | # Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software |
9 | # Foundation, Inc. | 9 | # Foundation, Inc. |
10 | # | 10 | # |
11 | # This file is free software; the Free Software Foundation | 11 | # This file is free software; the Free Software Foundation |
... | @@ -13,26 +13,12 @@ dnl | ... | @@ -13,26 +13,12 @@ dnl |
13 | # with or without modifications, as long as this notice is preserved. | 13 | # with or without modifications, as long as this notice is preserved. |
14 | 14 | ||
15 | AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE], | 15 | AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE], |
16 | [AC_REQUIRE([AC_HEADER_DIRENT])dnl | 16 | [AC_CACHE_CHECK([for d_type member in directory struct], |
17 | AC_CACHE_CHECK([for d_type member in directory struct], | ||
18 | jm_cv_struct_dirent_d_type, | 17 | jm_cv_struct_dirent_d_type, |
19 | [AC_TRY_LINK(dnl | 18 | [AC_TRY_LINK(dnl |
20 | [ | 19 | [ |
21 | #include <sys/types.h> | 20 | #include <sys/types.h> |
22 | #ifdef HAVE_DIRENT_H | 21 | #include <dirent.h> |
23 | # include <dirent.h> | ||
24 | #else /* not HAVE_DIRENT_H */ | ||
25 | # define dirent direct | ||
26 | # ifdef HAVE_SYS_NDIR_H | ||
27 | # include <sys/ndir.h> | ||
28 | # endif /* HAVE_SYS_NDIR_H */ | ||
29 | # ifdef HAVE_SYS_DIR_H | ||
30 | # include <sys/dir.h> | ||
31 | # endif /* HAVE_SYS_DIR_H */ | ||
32 | # ifdef HAVE_NDIR_H | ||
33 | # include <ndir.h> | ||
34 | # endif /* HAVE_NDIR_H */ | ||
35 | #endif /* HAVE_DIRENT_H */ | ||
36 | ], | 22 | ], |
37 | [struct dirent dp; dp.d_type = 0;], | 23 | [struct dirent dp; dp.d_type = 0;], |
38 | 24 | ... | ... |
1 | # exitfail.m4 serial 5 | 1 | # exitfail.m4 serial 6 |
2 | dnl Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | AC_DEFUN([gl_EXITFAIL], | 7 | AC_DEFUN([gl_EXITFAIL], |
8 | [ | 8 | [ |
9 | AC_LIBSOURCES([exitfail.c, exitfail.h]) | ||
10 | AC_LIBOBJ([exitfail]) | 9 | AC_LIBOBJ([exitfail]) |
11 | 10 | ||
12 | dnl No prerequisites of lib/exitfail.c. | 11 | dnl No prerequisites of lib/exitfail.c. | ... | ... |
1 | # Check for fnmatch. | 1 | # Check for fnmatch. |
2 | 2 | ||
3 | # This is a modified version of autoconf's AC_FUNC_FNMATCH. | 3 | # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software |
4 | # This file should be simplified after Autoconf 2.57 is required. | ||
5 | |||
6 | # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software | ||
7 | # Foundation, Inc. | 4 | # Foundation, Inc. |
8 | # This file is free software; the Free Software Foundation | 5 | # This file is free software; the Free Software Foundation |
9 | # gives unlimited permission to copy and/or distribute it, | 6 | # gives unlimited permission to copy and/or distribute it, |
10 | # with or without modifications, as long as this notice is preserved. | 7 | # with or without modifications, as long as this notice is preserved. |
11 | 8 | ||
9 | # Autoconf defines AC_FUNC_FNMATCH, but that is obsolescent. | ||
10 | # New applications should use the macros below instead. | ||
11 | |||
12 | # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE) | 12 | # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE) |
13 | # ------------------------------------------------------------------------- | 13 | # ------------------------------------------------------------------------- |
14 | # If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise | 14 | # If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise |
... | @@ -61,10 +61,9 @@ AS_IF([test $$2 = yes], [$3], [$4]) | ... | @@ -61,10 +61,9 @@ AS_IF([test $$2 = yes], [$3], [$4]) |
61 | # ------------------ | 61 | # ------------------ |
62 | # Prepare the replacement of fnmatch. | 62 | # Prepare the replacement of fnmatch. |
63 | AC_DEFUN([_MU_LIBOBJ_FNMATCH], | 63 | AC_DEFUN([_MU_LIBOBJ_FNMATCH], |
64 | [AC_REQUIRE([AC_C_CONST])dnl | 64 | [AC_REQUIRE([AC_FUNC_ALLOCA])dnl |
65 | AC_REQUIRE([AC_FUNC_ALLOCA])dnl | ||
66 | AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl | 65 | AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl |
67 | AC_CHECK_DECLS([getenv]) | 66 | AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>]) |
68 | AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy]) | 67 | AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy]) |
69 | AC_CHECK_HEADERS([wchar.h wctype.h]) | 68 | AC_CHECK_HEADERS([wchar.h wctype.h]) |
70 | MU_LIBOBJ([fnmatch]) | 69 | MU_LIBOBJ([fnmatch]) | ... | ... |
1 | # getdelim.m4 serial 1 | 1 | # getdelim.m4 serial 2 |
2 | 2 | ||
3 | dnl Copyright (C) 2005 Free Software dnl Foundation, Inc. | 3 | dnl Copyright (C) 2005, 2006 Free Software dnl Foundation, Inc. |
4 | dnl | 4 | dnl |
5 | dnl This file is free software; the Free Software Foundation | 5 | dnl This file is free software; the Free Software Foundation |
6 | dnl gives unlimited permission to copy and/or distribute it, | 6 | dnl gives unlimited permission to copy and/or distribute it, |
... | @@ -10,7 +10,6 @@ AC_PREREQ(2.52) | ... | @@ -10,7 +10,6 @@ AC_PREREQ(2.52) |
10 | 10 | ||
11 | AC_DEFUN([gl_FUNC_GETDELIM], | 11 | AC_DEFUN([gl_FUNC_GETDELIM], |
12 | [ | 12 | [ |
13 | MU_LIBSOURCES([getdelim.c, getdelim.h]) | ||
14 | 13 | ||
15 | dnl Persuade glibc <stdio.h> to declare getdelim(). | 14 | dnl Persuade glibc <stdio.h> to declare getdelim(). |
16 | AC_REQUIRE([AC_GNU_SOURCE]) | 15 | AC_REQUIRE([AC_GNU_SOURCE]) | ... | ... |
1 | # getline.m4 serial 13 | 1 | # getline.m4 serial 15 |
2 | 2 | ||
3 | dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 Free Software | 3 | dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 Free Software |
4 | dnl Foundation, Inc. | 4 | dnl Foundation, Inc. |
5 | dnl | 5 | dnl |
6 | dnl This file is free software; the Free Software Foundation | 6 | dnl This file is free software; the Free Software Foundation |
... | @@ -15,8 +15,6 @@ dnl have a function by that name in -linet that doesn't have anything | ... | @@ -15,8 +15,6 @@ dnl have a function by that name in -linet that doesn't have anything |
15 | dnl to do with the function we need. | 15 | dnl to do with the function we need. |
16 | AC_DEFUN([gl_FUNC_GETLINE], | 16 | AC_DEFUN([gl_FUNC_GETLINE], |
17 | [ | 17 | [ |
18 | MU_LIBSOURCES([getline.c, getline.h]) | ||
19 | |||
20 | dnl Persuade glibc <stdio.h> to declare getline(). | 18 | dnl Persuade glibc <stdio.h> to declare getline(). |
21 | AC_REQUIRE([AC_GNU_SOURCE]) | 19 | AC_REQUIRE([AC_GNU_SOURCE]) |
22 | 20 | ||
... | @@ -47,7 +45,18 @@ AC_DEFUN([gl_FUNC_GETLINE], | ... | @@ -47,7 +45,18 @@ AC_DEFUN([gl_FUNC_GETLINE], |
47 | } | 45 | } |
48 | ], am_cv_func_working_getline=yes dnl The library version works. | 46 | ], am_cv_func_working_getline=yes dnl The library version works. |
49 | , am_cv_func_working_getline=no dnl The library version does NOT work. | 47 | , am_cv_func_working_getline=no dnl The library version does NOT work. |
50 | , am_cv_func_working_getline=no dnl We're cross compiling. | 48 | , dnl We're cross compiling. Assume it works on glibc2 systems. |
49 | [AC_EGREP_CPP([Lucky GNU user], | ||
50 | [ | ||
51 | #include <features.h> | ||
52 | #ifdef __GNU_LIBRARY__ | ||
53 | #if (__GLIBC__ >= 2) | ||
54 | Lucky GNU user | ||
55 | #endif | ||
56 | #endif | ||
57 | ], | ||
58 | [am_cv_func_working_getline=yes], | ||
59 | [am_cv_func_working_getline=no])] | ||
51 | )]) | 60 | )]) |
52 | fi | 61 | fi |
53 | 62 | ... | ... |
1 | #serial 2 | 1 | #serial 3 |
2 | 2 | ||
3 | # Copyright (C) 2005, 2006 Free Software Foundation, Inc. | 3 | # Copyright (C) 2005, 2006 Free Software Foundation, Inc. |
4 | # | 4 | # |
... | @@ -14,7 +14,6 @@ dnl | ... | @@ -14,7 +14,6 @@ dnl |
14 | AC_DEFUN([gl_GETLOGIN_R_SUBSTITUTE], | 14 | AC_DEFUN([gl_GETLOGIN_R_SUBSTITUTE], |
15 | [ | 15 | [ |
16 | gl_PREREQ_GETLOGIN_R | 16 | gl_PREREQ_GETLOGIN_R |
17 | MU_LIBSOURCE([getlogin_r.h]) | ||
18 | MU_LIBOBJ([getlogin_r]) | 17 | MU_LIBOBJ([getlogin_r]) |
19 | ]) | 18 | ]) |
20 | 19 | ... | ... |
1 | # getopt.m4 serial 12 | 1 | # getopt.m4 serial 13 |
2 | dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | # The getopt module assume you want GNU getopt, with getopt_long etc, | 7 | # The getopt module assume you want GNU getopt, with getopt_long etc, |
8 | # rather than vanilla POSIX getopt. This means your your code should | 8 | # rather than vanilla POSIX getopt. This means your code should |
9 | # always include <getopt.h> for the getopt prototypes. | 9 | # always include <getopt.h> for the getopt prototypes. |
10 | 10 | ||
11 | AC_DEFUN([gl_GETOPT_SUBSTITUTE], | 11 | AC_DEFUN([gl_GETOPT_SUBSTITUTE], | ... | ... |
1 | # getpass.m4 serial 7 | 1 | # getpass.m4 serial 9 |
2 | dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
... | @@ -7,8 +7,6 @@ dnl with or without modifications, as long as this notice is preserved. | ... | @@ -7,8 +7,6 @@ dnl with or without modifications, as long as this notice is preserved. |
7 | # Provide a getpass() function if the system doesn't have it. | 7 | # Provide a getpass() function if the system doesn't have it. |
8 | AC_DEFUN([gl_FUNC_GETPASS], | 8 | AC_DEFUN([gl_FUNC_GETPASS], |
9 | [ | 9 | [ |
10 | AC_LIBSOURCES([getpass.c, getpass.h]) | ||
11 | |||
12 | AC_REPLACE_FUNCS(getpass) | 10 | AC_REPLACE_FUNCS(getpass) |
13 | AC_CHECK_DECLS_ONCE(getpass) | 11 | AC_CHECK_DECLS_ONCE(getpass) |
14 | if test $ac_cv_func_getpass = no; then | 12 | if test $ac_cv_func_getpass = no; then |
... | @@ -20,8 +18,6 @@ AC_DEFUN([gl_FUNC_GETPASS], | ... | @@ -20,8 +18,6 @@ AC_DEFUN([gl_FUNC_GETPASS], |
20 | # arbitrary length (not just 8 bytes as on HP-UX). | 18 | # arbitrary length (not just 8 bytes as on HP-UX). |
21 | AC_DEFUN([gl_FUNC_GETPASS_GNU], | 19 | AC_DEFUN([gl_FUNC_GETPASS_GNU], |
22 | [ | 20 | [ |
23 | AC_LIBSOURCES([getpass.c, getpass.h]) | ||
24 | |||
25 | AC_CHECK_DECLS_ONCE(getpass) | 21 | AC_CHECK_DECLS_ONCE(getpass) |
26 | dnl TODO: Detect when GNU getpass() is already found in glibc. | 22 | dnl TODO: Detect when GNU getpass() is already found in glibc. |
27 | AC_LIBOBJ(getpass) | 23 | AC_LIBOBJ(getpass) |
... | @@ -42,4 +38,5 @@ AC_DEFUN([gl_PREREQ_GETPASS], [ | ... | @@ -42,4 +38,5 @@ AC_DEFUN([gl_PREREQ_GETPASS], [ |
42 | AC_CHECK_DECLS_ONCE([fputs_unlocked]) | 38 | AC_CHECK_DECLS_ONCE([fputs_unlocked]) |
43 | AC_CHECK_DECLS_ONCE([funlockfile]) | 39 | AC_CHECK_DECLS_ONCE([funlockfile]) |
44 | AC_CHECK_DECLS_ONCE([putc_unlocked]) | 40 | AC_CHECK_DECLS_ONCE([putc_unlocked]) |
41 | : | ||
45 | ]) | 42 | ]) | ... | ... |
1 | # glob.m4 serial 3 | 1 | # glob.m4 serial 7 |
2 | dnl Copyright (C) 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | # The glob module assumes you want GNU glob, with glob_pattern_p etc, | 7 | # The glob module assumes you want GNU glob, with glob_pattern_p etc, |
8 | # rather than vanilla POSIX glob. This means your your code should | 8 | # rather than vanilla POSIX glob. This means your code should |
9 | # always include <glob.h> for the glob prototypes. | 9 | # always include <glob.h> for the glob prototypes. |
10 | 10 | ||
11 | AC_DEFUN([gl_GLOB_SUBSTITUTE], | 11 | AC_DEFUN([gl_GLOB_SUBSTITUTE], |
... | @@ -13,7 +13,6 @@ AC_DEFUN([gl_GLOB_SUBSTITUTE], | ... | @@ -13,7 +13,6 @@ AC_DEFUN([gl_GLOB_SUBSTITUTE], |
13 | gl_PREREQ_GLOB | 13 | gl_PREREQ_GLOB |
14 | 14 | ||
15 | GLOB_H=glob.h | 15 | GLOB_H=glob.h |
16 | MU_LIBSOURCES([glob.c, glob_.h, glob-libc.h]) | ||
17 | MU_LIBOBJ([glob]) | 16 | MU_LIBOBJ([glob]) |
18 | AC_SUBST([GLOB_H]) | 17 | AC_SUBST([GLOB_H]) |
19 | ]) | 18 | ]) |
... | @@ -73,8 +72,8 @@ if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) return 1;]]), | ... | @@ -73,8 +72,8 @@ if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) return 1;]]), |
73 | # Prerequisites of lib/glob.*. | 72 | # Prerequisites of lib/glob.*. |
74 | AC_DEFUN([gl_PREREQ_GLOB], | 73 | AC_DEFUN([gl_PREREQ_GLOB], |
75 | [ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])dnl | 74 | [ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])dnl |
75 | AC_REQUIRE([AC_C_RESTRICT])dnl | ||
76 | AC_REQUIRE([AC_GNU_SOURCE])dnl | 76 | AC_REQUIRE([AC_GNU_SOURCE])dnl |
77 | AC_REQUIRE([AC_HEADER_DIRENT])dnl | ||
78 | AC_CHECK_HEADERS_ONCE([sys/cdefs.h unistd.h])dnl | 77 | AC_CHECK_HEADERS_ONCE([sys/cdefs.h unistd.h])dnl |
79 | AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r])dnl | 78 | AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r])dnl |
80 | :]) | 79 | :]) | ... | ... |
1 | # intmax_t.m4 serial 4 | 1 | # intmax_t.m4 serial 5 |
2 | dnl Copyright (C) 1997-2004 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
... | @@ -46,7 +46,7 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T], | ... | @@ -46,7 +46,7 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T], |
46 | #if HAVE_INTTYPES_H_WITH_UINTMAX | 46 | #if HAVE_INTTYPES_H_WITH_UINTMAX |
47 | #include <inttypes.h> | 47 | #include <inttypes.h> |
48 | #endif | 48 | #endif |
49 | ], [intmax_t x = -1;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)]) | 49 | ], [intmax_t x = -1; return !x;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)]) |
50 | if test $gt_cv_c_intmax_t = yes; then | 50 | if test $gt_cv_c_intmax_t = yes; then |
51 | AC_DEFINE(HAVE_INTMAX_T, 1, | 51 | AC_DEFINE(HAVE_INTMAX_T, 1, |
52 | [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.]) | 52 | [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.]) | ... | ... |
1 | #serial 5 | 1 | #serial 6 |
2 | dnl Copyright (C) 2004, 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | AC_DEFUN([gl_INTTOSTR], | 7 | AC_DEFUN([gl_INTTOSTR], |
8 | [ | 8 | [ |
9 | MU_LIBSOURCES([inttostr.c, inttostr.h, intprops.h]) | ||
10 | |||
11 | dnl We don't technically need to list the following .c files, since their | ||
12 | dnl functions are named in the MU_LIBOBJ calls, but this is an unusual | ||
13 | dnl module and it seems a little clearer to do so. | ||
14 | MU_LIBSOURCES([imaxtostr.c, offtostr.c, umaxtostr.c]) | ||
15 | |||
16 | MU_LIBOBJ([imaxtostr]) | 9 | MU_LIBOBJ([imaxtostr]) |
17 | MU_LIBOBJ([offtostr]) | 10 | MU_LIBOBJ([offtostr]) |
18 | MU_LIBOBJ([umaxtostr]) | 11 | MU_LIBOBJ([umaxtostr]) |
... | @@ -25,8 +18,6 @@ AC_DEFUN([gl_INTTOSTR], | ... | @@ -25,8 +18,6 @@ AC_DEFUN([gl_INTTOSTR], |
25 | 18 | ||
26 | # Prerequisites of lib/inttostr.h. | 19 | # Prerequisites of lib/inttostr.h. |
27 | AC_DEFUN([gl_PREREQ_INTTOSTR], [ | 20 | AC_DEFUN([gl_PREREQ_INTTOSTR], [ |
28 | AC_REQUIRE([gl_AC_TYPE_INTMAX_T]) | ||
29 | AC_REQUIRE([gl_AC_TYPE_UINTMAX_T]) | ||
30 | AC_REQUIRE([AC_TYPE_OFF_T]) | 21 | AC_REQUIRE([AC_TYPE_OFF_T]) |
31 | : | 22 | : |
32 | ]) | 23 | ]) | ... | ... |
1 | # inttypes_h.m4 serial 6 | 1 | # inttypes_h.m4 serial 7 |
2 | dnl Copyright (C) 1997-2004 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
... | @@ -15,7 +15,7 @@ AC_DEFUN([gl_AC_HEADER_INTTYPES_H], | ... | @@ -15,7 +15,7 @@ AC_DEFUN([gl_AC_HEADER_INTTYPES_H], |
15 | [AC_TRY_COMPILE( | 15 | [AC_TRY_COMPILE( |
16 | [#include <sys/types.h> | 16 | [#include <sys/types.h> |
17 | #include <inttypes.h>], | 17 | #include <inttypes.h>], |
18 | [uintmax_t i = (uintmax_t) -1;], | 18 | [uintmax_t i = (uintmax_t) -1; return !i;], |
19 | gl_cv_header_inttypes_h=yes, | 19 | gl_cv_header_inttypes_h=yes, |
20 | gl_cv_header_inttypes_h=no)]) | 20 | gl_cv_header_inttypes_h=no)]) |
21 | if test $gl_cv_header_inttypes_h = yes; then | 21 | if test $gl_cv_header_inttypes_h = yes; then | ... | ... |
1 | # longlong.m4 serial 5 | 1 | # longlong.m4 serial 7 |
2 | dnl Copyright (C) 1999-2004 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 1999-2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | dnl From Paul Eggert. | 7 | dnl From Paul Eggert. |
8 | 8 | ||
9 | # Define HAVE_LONG_LONG if 'long long' works. | 9 | # Define HAVE_LONG_LONG_INT if 'long long int' works. |
10 | # This fixes a bug in Autoconf 2.60, but can be removed once we | ||
11 | # assume 2.61 everywhere. | ||
10 | 12 | ||
13 | AC_DEFUN([AC_TYPE_LONG_LONG_INT], | ||
14 | [ | ||
15 | AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], | ||
16 | [AC_LINK_IFELSE( | ||
17 | [AC_LANG_PROGRAM( | ||
18 | [[long long int ll = 9223372036854775807ll; | ||
19 | long long int nll = -9223372036854775807LL; | ||
20 | typedef int a[((-9223372036854775807LL < 0 | ||
21 | && 0 < 9223372036854775807ll) | ||
22 | ? 1 : -1)]; | ||
23 | int i = 63;]], | ||
24 | [[long long int llmax = 9223372036854775807ll; | ||
25 | return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) | ||
26 | | (llmax / ll) | (llmax % ll));]])], | ||
27 | [ac_cv_type_long_long_int=yes], | ||
28 | [ac_cv_type_long_long_int=no])]) | ||
29 | if test $ac_cv_type_long_long_int = yes; then | ||
30 | AC_DEFINE([HAVE_LONG_LONG_INT], 1, | ||
31 | [Define to 1 if the system has the type `long long int'.]) | ||
32 | fi | ||
33 | ]) | ||
34 | |||
35 | # This macro is obsolescent and should go away soon. | ||
11 | AC_DEFUN([gl_AC_TYPE_LONG_LONG], | 36 | AC_DEFUN([gl_AC_TYPE_LONG_LONG], |
12 | [ | 37 | [ |
13 | AC_CACHE_CHECK([for long long], ac_cv_type_long_long, | 38 | AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) |
14 | [AC_TRY_LINK([long long ll = 1LL; int i = 63;], | 39 | ac_cv_type_long_long=$ac_cv_type_long_long_int |
15 | [long long llmax = (long long) -1; | ||
16 | return ll << i | ll >> i | llmax / ll | llmax % ll;], | ||
17 | ac_cv_type_long_long=yes, | ||
18 | ac_cv_type_long_long=no)]) | ||
19 | if test $ac_cv_type_long_long = yes; then | 40 | if test $ac_cv_type_long_long = yes; then |
20 | AC_DEFINE(HAVE_LONG_LONG, 1, | 41 | AC_DEFINE(HAVE_LONG_LONG, 1, |
21 | [Define if you have the 'long long' type.]) | 42 | [Define if you have the 'long long' type.]) | ... | ... |
1 | # mbchar.m4 serial 2 | 1 | # mbchar.m4 serial 4 |
2 | dnl Copyright (C) 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2005-2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
... | @@ -10,11 +10,14 @@ dnl From Bruno Haible. | ... | @@ -10,11 +10,14 @@ dnl From Bruno Haible. |
10 | AC_DEFUN([gl_MBCHAR], | 10 | AC_DEFUN([gl_MBCHAR], |
11 | [ | 11 | [ |
12 | AC_REQUIRE([AC_GNU_SOURCE]) | 12 | AC_REQUIRE([AC_GNU_SOURCE]) |
13 | dnl The following line is that so the user can test | 13 | dnl The following line is that so the user can test HAVE_WCHAR_H |
14 | dnl HAVE_WCHAR_H && HAVE_WCTYPE_H before #include "mbchar.h". | 14 | dnl before #include "mbchar.h". |
15 | AC_CHECK_HEADERS_ONCE(wchar.h wctype.h) | 15 | AC_CHECK_HEADERS_ONCE([wchar.h]) |
16 | dnl Compile mbchar.c only if HAVE_WCHAR_H && HAVE_WCTYPE_H. | 16 | dnl Compile mbchar.c only if HAVE_WCHAR_H. |
17 | if test $ac_cv_header_wchar_h = yes && test $ac_cv_header_wctype_h = yes; then | 17 | if test $ac_cv_header_wchar_h = yes; then |
18 | MU_LIBOBJ([mbchar]) | 18 | MU_LIBOBJ([mbchar]) |
19 | dnl Prerequisites of mbchar.h and mbchar.c. | ||
20 | AC_CHECK_HEADERS_ONCE([wctype.h]) | ||
21 | AC_CHECK_FUNCS([iswcntrl]) | ||
19 | fi | 22 | fi |
20 | ]) | 23 | ]) | ... | ... |
1 | # mbswidth.m4 serial 11 | 1 | # mbswidth.m4 serial 12 |
2 | dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2000-2002, 2004, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
... | @@ -9,33 +9,11 @@ dnl From Bruno Haible. | ... | @@ -9,33 +9,11 @@ dnl From Bruno Haible. |
9 | 9 | ||
10 | AC_DEFUN([gl_MBSWIDTH], | 10 | AC_DEFUN([gl_MBSWIDTH], |
11 | [ | 11 | [ |
12 | AC_CHECK_HEADERS_ONCE(wchar.h wctype.h) | 12 | AC_CHECK_HEADERS_ONCE([wchar.h wctype.h]) |
13 | AC_CHECK_FUNCS_ONCE(isascii iswprint mbsinit) | 13 | AC_CHECK_FUNCS_ONCE([isascii mbsinit]) |
14 | AC_CHECK_FUNCS(iswcntrl wcwidth) | 14 | AC_CHECK_FUNCS([iswcntrl]) |
15 | gl_FUNC_MBRTOWC | 15 | gl_FUNC_MBRTOWC |
16 | 16 | ||
17 | AC_CACHE_CHECK([whether wcwidth is declared], ac_cv_have_decl_wcwidth, | ||
18 | [AC_TRY_COMPILE([ | ||
19 | /* AIX 3.2.5 declares wcwidth in <string.h>. */ | ||
20 | #if HAVE_STRING_H | ||
21 | # include <string.h> | ||
22 | #endif | ||
23 | #if HAVE_WCHAR_H | ||
24 | # include <wchar.h> | ||
25 | #endif | ||
26 | ], [ | ||
27 | #ifndef wcwidth | ||
28 | char *p = (char *) wcwidth; | ||
29 | #endif | ||
30 | ], ac_cv_have_decl_wcwidth=yes, ac_cv_have_decl_wcwidth=no)]) | ||
31 | if test $ac_cv_have_decl_wcwidth = yes; then | ||
32 | ac_val=1 | ||
33 | else | ||
34 | ac_val=0 | ||
35 | fi | ||
36 | AC_DEFINE_UNQUOTED(HAVE_DECL_WCWIDTH, $ac_val, | ||
37 | [Define to 1 if you have the declaration of wcwidth(), and to 0 otherwise.]) | ||
38 | |||
39 | dnl UnixWare 7.1.1 <wchar.h> has a declaration of a function mbswidth() | 17 | dnl UnixWare 7.1.1 <wchar.h> has a declaration of a function mbswidth() |
40 | dnl that clashes with ours. | 18 | dnl that clashes with ours. |
41 | AC_CACHE_CHECK([whether mbswidth is declared in <wchar.h>], | 19 | AC_CACHE_CHECK([whether mbswidth is declared in <wchar.h>], | ... | ... |
1 | # md5.m4 serial 8 | 1 | # md5.m4 serial 9 |
2 | dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | AC_DEFUN([gl_MD5], | 7 | AC_DEFUN([gl_MD5], |
8 | [ | 8 | [ |
9 | MU_LIBSOURCES([md5.c, md5.h]) | ||
10 | MU_LIBOBJ([md5]) | 9 | MU_LIBOBJ([md5]) |
11 | 10 | ||
12 | dnl Prerequisites of lib/md5.c. | 11 | dnl Prerequisites of lib/md5.c. | ... | ... |
1 | # mempcpy.m4 serial 3 | 1 | # mempcpy.m4 serial 4 |
2 | dnl Copyright (C) 2003, 2004 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | AC_DEFUN([gl_FUNC_MEMPCPY], | 7 | AC_DEFUN([gl_FUNC_MEMPCPY], |
8 | [ | 8 | [ |
9 | MU_LIBSOURCES([mempcpy.c, mempcpy.h]) | ||
10 | 9 | ||
11 | dnl Persuade glibc <string.h> to declare mempcpy(). | 10 | dnl Persuade glibc <string.h> to declare mempcpy(). |
12 | AC_REQUIRE([AC_GNU_SOURCE]) | 11 | AC_REQUIRE([AC_GNU_SOURCE]) | ... | ... |
1 | # onceonly_2_57.m4 serial 3 | 1 | # onceonly_2_57.m4 serial 4 |
2 | dnl Copyright (C) 2002-2003, 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc. |
3 | dnl This file is free software, distributed under the terms of the GNU | 3 | dnl This file is free software, distributed under the terms of the GNU |
4 | dnl General Public License. As a special exception to the GNU General | 4 | dnl General Public License. As a special exception to the GNU General |
5 | dnl Public License, this file may be distributed as part of a program | 5 | dnl Public License, this file may be distributed as part of a program |
... | @@ -10,7 +10,7 @@ dnl This file defines some "once only" variants of standard autoconf macros. | ... | @@ -10,7 +10,7 @@ dnl This file defines some "once only" variants of standard autoconf macros. |
10 | dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS | 10 | dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS |
11 | dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS | 11 | dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS |
12 | dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS | 12 | dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS |
13 | dnl AC_REQUIRE([AC_HEADER_STDC]) like AC_HEADER_STDC | 13 | dnl AC_REQUIRE([AC_FUNC_STRCOLL]) like AC_FUNC_STRCOLL |
14 | dnl The advantage is that the check for each of the headers/functions/decls | 14 | dnl The advantage is that the check for each of the headers/functions/decls |
15 | dnl will be put only once into the 'configure' file. It keeps the size of | 15 | dnl will be put only once into the 'configure' file. It keeps the size of |
16 | dnl the 'configure' file down, and avoids redundant output when 'configure' | 16 | dnl the 'configure' file down, and avoids redundant output when 'configure' | ... | ... |
1 | #serial 36 | 1 | #serial 39 |
2 | 2 | ||
3 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, | 3 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, |
4 | # 2006 Free Software Foundation, Inc. | 4 | # 2006 Free Software Foundation, Inc. |
... | @@ -14,10 +14,6 @@ AC_PREREQ([2.50]) | ... | @@ -14,10 +14,6 @@ AC_PREREQ([2.50]) |
14 | 14 | ||
15 | AC_DEFUN([gl_REGEX], | 15 | AC_DEFUN([gl_REGEX], |
16 | [ | 16 | [ |
17 | MU_LIBSOURCES( | ||
18 | [regcomp.c, regex.c, regex.h, | ||
19 | regex_internal.c, regex_internal.h, regexec.c]) | ||
20 | |||
21 | AC_ARG_WITH([included-regex], | 17 | AC_ARG_WITH([included-regex], |
22 | [AC_HELP_STRING([--without-included-regex], | 18 | [AC_HELP_STRING([--without-included-regex], |
23 | [don't compile regex; this is the default on | 19 | [don't compile regex; this is the default on |
... | @@ -28,7 +24,7 @@ AC_DEFUN([gl_REGEX], | ... | @@ -28,7 +24,7 @@ AC_DEFUN([gl_REGEX], |
28 | yes|no) ac_use_included_regex=$with_included_regex | 24 | yes|no) ac_use_included_regex=$with_included_regex |
29 | ;; | 25 | ;; |
30 | '') | 26 | '') |
31 | # If the system regex support is good enough that it passes the the | 27 | # If the system regex support is good enough that it passes the |
32 | # following run test, then default to *not* using the included regex.c. | 28 | # following run test, then default to *not* using the included regex.c. |
33 | # If cross compiling, assume the test would fail and use the included | 29 | # If cross compiling, assume the test would fail and use the included |
34 | # regex.c. The first failing regular expression is from `Spencer ere | 30 | # regex.c. The first failing regular expression is from `Spencer ere |
... | @@ -163,8 +159,9 @@ AC_DEFUN([gl_REGEX], | ... | @@ -163,8 +159,9 @@ AC_DEFUN([gl_REGEX], |
163 | AC_DEFUN([gl_PREREQ_REGEX], | 159 | AC_DEFUN([gl_PREREQ_REGEX], |
164 | [ | 160 | [ |
165 | AC_REQUIRE([AC_GNU_SOURCE]) | 161 | AC_REQUIRE([AC_GNU_SOURCE]) |
166 | AC_REQUIRE([gl_C_RESTRICT]) | 162 | AC_REQUIRE([AC_C_RESTRICT]) |
167 | AC_REQUIRE([AM_LANGINFO_CODESET]) | 163 | AC_REQUIRE([AM_LANGINFO_CODESET]) |
168 | AC_CHECK_HEADERS_ONCE([locale.h wchar.h wctype.h]) | 164 | AC_CHECK_HEADERS_ONCE([locale.h wchar.h wctype.h]) |
169 | AC_CHECK_FUNCS_ONCE([isblank mbrtowc mempcpy wcrtomb wcscoll]) | 165 | AC_CHECK_FUNCS_ONCE([mbrtowc mempcpy wcrtomb wcscoll]) |
166 | AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>]) | ||
170 | ]) | 167 | ]) | ... | ... |
1 | # sha1.m4 serial 6 | 1 | # sha1.m4 serial 7 |
2 | dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | AC_DEFUN([gl_SHA1], | 7 | AC_DEFUN([gl_SHA1], |
8 | [ | 8 | [ |
9 | MU_LIBSOURCES([sha1.c, sha1.h]) | ||
10 | MU_LIBOBJ([sha1]) | 9 | MU_LIBOBJ([sha1]) |
11 | 10 | ||
12 | dnl Prerequisites of lib/sha1.c. | 11 | dnl Prerequisites of lib/sha1.c. | ... | ... |
1 | #serial 2 | 1 | #serial 3 |
2 | 2 | ||
3 | # Copyright (C) 2005 Free Software Foundation, Inc. | 3 | # Copyright (C) 2005, 2006 Free Software Foundation, Inc. |
4 | # | 4 | # |
5 | # This file is free software; the Free Software Foundation | 5 | # This file is free software; the Free Software Foundation |
6 | # gives unlimited permission to copy and/or distribute it, | 6 | # gives unlimited permission to copy and/or distribute it, |
... | @@ -8,7 +8,5 @@ | ... | @@ -8,7 +8,5 @@ |
8 | 8 | ||
9 | AC_DEFUN([gl_STAT_MACROS], | 9 | AC_DEFUN([gl_STAT_MACROS], |
10 | [ | 10 | [ |
11 | MU_LIBSOURCES([stat-macros.h]) | ||
12 | |||
13 | AC_REQUIRE([AC_HEADER_STAT]) | 11 | AC_REQUIRE([AC_HEADER_STAT]) |
14 | ]) | 12 | ]) | ... | ... |
This diff is collapsed.
Click to expand it.
1 | # stdint_h.m4 serial 5 | 1 | # stdint_h.m4 serial 6 |
2 | dnl Copyright (C) 1997-2004 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
... | @@ -15,7 +15,7 @@ AC_DEFUN([gl_AC_HEADER_STDINT_H], | ... | @@ -15,7 +15,7 @@ AC_DEFUN([gl_AC_HEADER_STDINT_H], |
15 | [AC_TRY_COMPILE( | 15 | [AC_TRY_COMPILE( |
16 | [#include <sys/types.h> | 16 | [#include <sys/types.h> |
17 | #include <stdint.h>], | 17 | #include <stdint.h>], |
18 | [uintmax_t i = (uintmax_t) -1;], | 18 | [uintmax_t i = (uintmax_t) -1; return !i;], |
19 | gl_cv_header_stdint_h=yes, | 19 | gl_cv_header_stdint_h=yes, |
20 | gl_cv_header_stdint_h=no)]) | 20 | gl_cv_header_stdint_h=no)]) |
21 | if test $gl_cv_header_stdint_h = yes; then | 21 | if test $gl_cv_header_stdint_h = yes; then | ... | ... |
1 | # strdup.m4 serial 6 | 1 | # strdup.m4 serial 7 |
2 | dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | AC_DEFUN([gl_FUNC_STRDUP], | 7 | AC_DEFUN([gl_FUNC_STRDUP], |
8 | [ | 8 | [ |
9 | MU_LIBSOURCES([strdup.c, strdup.h]) | ||
10 | |||
11 | MU_REPLACE_FUNCS(strdup) | 9 | MU_REPLACE_FUNCS(strdup) |
12 | AC_CHECK_DECLS_ONCE(strdup) | 10 | AC_CHECK_DECLS_ONCE(strdup) |
13 | gl_PREREQ_STRDUP | 11 | gl_PREREQ_STRDUP | ... | ... |
1 | # strndup.m4 serial 6 | 1 | # strndup.m4 serial 8 |
2 | dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
... | @@ -6,8 +6,6 @@ dnl with or without modifications, as long as this notice is preserved. | ... | @@ -6,8 +6,6 @@ dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | AC_DEFUN([gl_FUNC_STRNDUP], | 7 | AC_DEFUN([gl_FUNC_STRNDUP], |
8 | [ | 8 | [ |
9 | MU_LIBSOURCES([strndup.c, strndup.h]) | ||
10 | |||
11 | dnl Persuade glibc <string.h> to declare strndup(). | 9 | dnl Persuade glibc <string.h> to declare strndup(). |
12 | AC_REQUIRE([AC_GNU_SOURCE]) | 10 | AC_REQUIRE([AC_GNU_SOURCE]) |
13 | 11 | ||
... | @@ -27,13 +25,15 @@ AC_DEFUN([gl_FUNC_STRNDUP], | ... | @@ -27,13 +25,15 @@ AC_DEFUN([gl_FUNC_STRNDUP], |
27 | return s[13] != '\0';]])], | 25 | return s[13] != '\0';]])], |
28 | [gl_cv_func_strndup=yes], | 26 | [gl_cv_func_strndup=yes], |
29 | [gl_cv_func_strndup=no], | 27 | [gl_cv_func_strndup=no], |
28 | [AC_CHECK_FUNC([strndup], | ||
30 | [AC_EGREP_CPP([too risky], [ | 29 | [AC_EGREP_CPP([too risky], [ |
31 | #ifdef _AIX | 30 | #ifdef _AIX |
32 | too risky | 31 | too risky |
33 | #endif | 32 | #endif |
34 | ], | 33 | ], |
35 | [gl_cv_func_strndup=no], | 34 | [gl_cv_func_strndup=no], |
36 | [gl_cv_func_strndup=yes])])]) | 35 | [gl_cv_func_strndup=yes])], |
36 | [gl_cv_func_strndup=no])])]) | ||
37 | if test $gl_cv_func_strndup = yes; then | 37 | if test $gl_cv_func_strndup = yes; then |
38 | AC_DEFINE([HAVE_STRNDUP], 1, | 38 | AC_DEFINE([HAVE_STRNDUP], 1, |
39 | [Define if you have the strndup() function and it works.]) | 39 | [Define if you have the strndup() function and it works.]) | ... | ... |
1 | # strnlen.m4 serial 5 | 1 | # strnlen.m4 serial 6 |
2 | dnl Copyright (C) 2002-2003, 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002-2003, 2005, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | AC_DEFUN([gl_FUNC_STRNLEN], | 7 | AC_DEFUN([gl_FUNC_STRNLEN], |
8 | [ | 8 | [ |
9 | MU_LIBSOURCES([strnlen.c, strnlen.h]) | ||
10 | |||
11 | dnl Persuade glibc <string.h> to declare strnlen(). | 9 | dnl Persuade glibc <string.h> to declare strnlen(). |
12 | AC_REQUIRE([AC_GNU_SOURCE]) | 10 | AC_REQUIRE([AC_GNU_SOURCE]) |
13 | 11 | ... | ... |
1 | # strtok_r.m4 serial 2 | 1 | # strtok_r.m4 serial 3 |
2 | dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
... | @@ -13,5 +13,5 @@ AC_DEFUN([gl_FUNC_STRTOK_R], | ... | @@ -13,5 +13,5 @@ AC_DEFUN([gl_FUNC_STRTOK_R], |
13 | 13 | ||
14 | # Prerequisites of lib/strtok_r.h and lib/strtok_r.c. | 14 | # Prerequisites of lib/strtok_r.h and lib/strtok_r.c. |
15 | AC_DEFUN([gl_PREREQ_STRTOK_R], [ | 15 | AC_DEFUN([gl_PREREQ_STRTOK_R], [ |
16 | AC_REQUIRE([gl_C_RESTRICT]) | 16 | AC_REQUIRE([AC_C_RESTRICT]) |
17 | ]) | 17 | ]) | ... | ... |
1 | # xalloc.m4 serial 12 | 1 | # xalloc.m4 serial 13 |
2 | dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | AC_DEFUN([gl_XALLOC], | 7 | AC_DEFUN([gl_XALLOC], |
8 | [ | 8 | [ |
9 | AC_LIBSOURCES([xmalloc.c, xalloc.h]) | ||
10 | AC_LIBOBJ([xmalloc]) | 9 | AC_LIBOBJ([xmalloc]) |
11 | 10 | ||
12 | gl_PREREQ_XALLOC | 11 | gl_PREREQ_XALLOC | ... | ... |
... | @@ -1475,45 +1475,50 @@ argp_doc (const struct argp *argp, const struct argp_state *state, | ... | @@ -1475,45 +1475,50 @@ argp_doc (const struct argp *argp, const struct argp_state *state, |
1475 | { | 1475 | { |
1476 | const char *text; | 1476 | const char *text; |
1477 | const char *inp_text; | 1477 | const char *inp_text; |
1478 | size_t inp_text_len = 0; | ||
1479 | const char *trans_text; | ||
1478 | void *input = 0; | 1480 | void *input = 0; |
1479 | int anything = 0; | 1481 | int anything = 0; |
1480 | size_t inp_text_limit = 0; | ||
1481 | const char *doc = dgettext (argp->argp_domain, argp->doc); | ||
1482 | const struct argp_child *child = argp->children; | 1482 | const struct argp_child *child = argp->children; |
1483 | 1483 | ||
1484 | if (doc) | 1484 | if (argp->doc) |
1485 | { | 1485 | { |
1486 | char *vt = strchr (doc, '\v'); | 1486 | char *vt = strchr (argp->doc, '\v'); |
1487 | inp_text = post ? (vt ? vt + 1 : 0) : doc; | 1487 | if (vt) |
1488 | inp_text_limit = (!post && vt) ? (vt - doc) : 0; | 1488 | { |
1489 | if (post) | ||
1490 | inp_text = vt + 1; | ||
1491 | else | ||
1492 | { | ||
1493 | inp_text_len = vt - argp->doc; | ||
1494 | inp_text = __strndup (argp->doc, inp_text_len); | ||
1495 | } | ||
1489 | } | 1496 | } |
1490 | else | 1497 | else |
1491 | inp_text = 0; | 1498 | inp_text = post ? 0 : argp->doc; |
1499 | trans_text = dgettext (argp->argp_domain, inp_text); | ||
1500 | } | ||
1501 | else | ||
1502 | trans_text = inp_text = 0; | ||
1492 | 1503 | ||
1493 | if (argp->help_filter) | 1504 | if (argp->help_filter) |
1494 | /* We have to filter the doc strings. */ | 1505 | /* We have to filter the doc strings. */ |
1495 | { | 1506 | { |
1496 | if (inp_text_limit) | ||
1497 | /* Copy INP_TEXT so that it's nul-terminated. */ | ||
1498 | inp_text = __strndup (inp_text, inp_text_limit); | ||
1499 | input = __argp_input (argp, state); | 1507 | input = __argp_input (argp, state); |
1500 | text = | 1508 | text = |
1501 | (*argp->help_filter) (post | 1509 | (*argp->help_filter) (post |
1502 | ? ARGP_KEY_HELP_POST_DOC | 1510 | ? ARGP_KEY_HELP_POST_DOC |
1503 | : ARGP_KEY_HELP_PRE_DOC, | 1511 | : ARGP_KEY_HELP_PRE_DOC, |
1504 | inp_text, input); | 1512 | trans_text, input); |
1505 | } | 1513 | } |
1506 | else | 1514 | else |
1507 | text = (const char *) inp_text; | 1515 | text = (const char *) trans_text; |
1508 | 1516 | ||
1509 | if (text) | 1517 | if (text) |
1510 | { | 1518 | { |
1511 | if (pre_blank) | 1519 | if (pre_blank) |
1512 | __argp_fmtstream_putc (stream, '\n'); | 1520 | __argp_fmtstream_putc (stream, '\n'); |
1513 | 1521 | ||
1514 | if (text == inp_text && inp_text_limit) | ||
1515 | __argp_fmtstream_write (stream, inp_text, inp_text_limit); | ||
1516 | else | ||
1517 | __argp_fmtstream_puts (stream, text); | 1522 | __argp_fmtstream_puts (stream, text); |
1518 | 1523 | ||
1519 | if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream)) | 1524 | if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream)) |
... | @@ -1522,9 +1527,10 @@ argp_doc (const struct argp *argp, const struct argp_state *state, | ... | @@ -1522,9 +1527,10 @@ argp_doc (const struct argp *argp, const struct argp_state *state, |
1522 | anything = 1; | 1527 | anything = 1; |
1523 | } | 1528 | } |
1524 | 1529 | ||
1525 | if (text && text != inp_text) | 1530 | if (text && text != trans_text) |
1526 | free ((char *) text); /* Free TEXT returned from the help filter. */ | 1531 | free ((char *) text); /* Free TEXT returned from the help filter. */ |
1527 | if (inp_text && inp_text_limit && argp->help_filter) | 1532 | |
1533 | if (inp_text && inp_text_len) | ||
1528 | free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */ | 1534 | free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */ |
1529 | 1535 | ||
1530 | if (post && argp->help_filter) | 1536 | if (post && argp->help_filter) | ... | ... |
... | @@ -141,20 +141,6 @@ | ... | @@ -141,20 +141,6 @@ |
141 | # define putchar_unlocked(x) putchar (x) | 141 | # define putchar_unlocked(x) putchar (x) |
142 | # endif | 142 | # endif |
143 | 143 | ||
144 | /* GNULIB makes sure both program_invocation_name and | ||
145 | program_invocation_short_name are available */ | ||
146 | #ifdef GNULIB_PROGRAM_INVOCATION_NAME | ||
147 | extern char *program_invocation_name; | ||
148 | # undef HAVE_DECL_PROGRAM_INVOCATION_NAME | ||
149 | # define HAVE_DECL_PROGRAM_INVOCATION_NAME 1 | ||
150 | #endif | ||
151 | |||
152 | #ifdef GNULIB_PROGRAM_INVOCATION_SHORT_NAME | ||
153 | extern char *program_invocation_short_name; | ||
154 | # undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME | ||
155 | # define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 1 | ||
156 | #endif | ||
157 | |||
158 | #endif /* !_LIBC */ | 144 | #endif /* !_LIBC */ |
159 | 145 | ||
160 | #ifndef __set_errno | 146 | #ifndef __set_errno | ... | ... |
... | @@ -877,6 +877,20 @@ __argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags, | ... | @@ -877,6 +877,20 @@ __argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags, |
877 | to be parsed (which in some cases isn't actually an error). */ | 877 | to be parsed (which in some cases isn't actually an error). */ |
878 | int arg_ebadkey = 0; | 878 | int arg_ebadkey = 0; |
879 | 879 | ||
880 | #ifndef _LIBC | ||
881 | if (!(flags & ARGP_PARSE_ARGV0)) | ||
882 | { | ||
883 | #ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME | ||
884 | if (!program_invocation_name) | ||
885 | program_invocation_name = argv[0]; | ||
886 | #endif | ||
887 | #ifdef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME | ||
888 | if (!program_invocation_short_name) | ||
889 | program_invocation_short_name = __argp_base_name (argv[0]); | ||
890 | #endif | ||
891 | } | ||
892 | #endif | ||
893 | |||
880 | if (! (flags & ARGP_NO_HELP)) | 894 | if (! (flags & ARGP_NO_HELP)) |
881 | /* Add our own options. */ | 895 | /* Add our own options. */ |
882 | { | 896 | { | ... | ... |
1 | /* Default definition for ARGP_PROGRAM_VERSION. | 1 | /* Default definition for ARGP_PROGRAM_VERSION. |
2 | Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. | 2 | Copyright (C) 1996, 1997, 1999, 2006 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. | 3 | This file is part of the GNU C Library. |
4 | Written by Miles Bader <miles@gnu.ai.mit.edu>. | 4 | Written by Miles Bader <miles@gnu.ai.mit.edu>. |
5 | 5 | ||
... | @@ -19,6 +19,6 @@ | ... | @@ -19,6 +19,6 @@ |
19 | 19 | ||
20 | /* If set by the user program to a non-zero value, then a default option | 20 | /* If set by the user program to a non-zero value, then a default option |
21 | --version is added (unless the ARGP_NO_HELP flag is used), which will | 21 | --version is added (unless the ARGP_NO_HELP flag is used), which will |
22 | print this this string followed by a newline and exit (unless the | 22 | print this string followed by a newline and exit (unless the |
23 | ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */ | 23 | ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */ |
24 | const char *argp_program_version; | 24 | const char *argp_program_version; | ... | ... |
... | @@ -94,7 +94,10 @@ struct argp_option | ... | @@ -94,7 +94,10 @@ struct argp_option |
94 | /* The doc string for this option. If both NAME and KEY are 0, This string | 94 | /* The doc string for this option. If both NAME and KEY are 0, This string |
95 | will be printed outdented from the normal option column, making it | 95 | will be printed outdented from the normal option column, making it |
96 | useful as a group header (it will be the first thing printed in its | 96 | useful as a group header (it will be the first thing printed in its |
97 | group); in this usage, it's conventional to end the string with a `:'. */ | 97 | group); in this usage, it's conventional to end the string with a `:'. |
98 | |||
99 | Write the initial value as N_("TEXT") if you want xgettext to collect | ||
100 | it into a POT file. */ | ||
98 | const char *doc; | 101 | const char *doc; |
99 | 102 | ||
100 | /* The group this option is in. In a long help message, options are sorted | 103 | /* The group this option is in. In a long help message, options are sorted |
... | @@ -243,7 +246,9 @@ struct argp | ... | @@ -243,7 +246,9 @@ struct argp |
243 | 246 | ||
244 | /* If non-NULL, a string containing extra text to be printed before and | 247 | /* If non-NULL, a string containing extra text to be printed before and |
245 | after the options in a long help message (separated by a vertical tab | 248 | after the options in a long help message (separated by a vertical tab |
246 | `\v' character). */ | 249 | `\v' character). |
250 | Write the initial value as N_("BEFORE-TEXT") "\v" N_("AFTER-TEXT") if | ||
251 | you want xgettext to collect the two pieces of text into a POT file. */ | ||
247 | const char *doc; | 252 | const char *doc; |
248 | 253 | ||
249 | /* A vector of argp_children structures, terminated by a member with a 0 | 254 | /* A vector of argp_children structures, terminated by a member with a 0 |
... | @@ -418,6 +423,20 @@ extern error_t __argp_parse (const struct argp *__restrict __argp, | ... | @@ -418,6 +423,20 @@ extern error_t __argp_parse (const struct argp *__restrict __argp, |
418 | 423 | ||
419 | /* Global variables. */ | 424 | /* Global variables. */ |
420 | 425 | ||
426 | /* GNULIB makes sure both program_invocation_name and | ||
427 | program_invocation_short_name are available */ | ||
428 | #ifdef GNULIB_PROGRAM_INVOCATION_NAME | ||
429 | extern char *program_invocation_name; | ||
430 | # undef HAVE_DECL_PROGRAM_INVOCATION_NAME | ||
431 | # define HAVE_DECL_PROGRAM_INVOCATION_NAME 1 | ||
432 | #endif | ||
433 | |||
434 | #ifdef GNULIB_PROGRAM_INVOCATION_SHORT_NAME | ||
435 | extern char *program_invocation_short_name; | ||
436 | # undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME | ||
437 | # define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 1 | ||
438 | #endif | ||
439 | |||
421 | /* If defined or set by the user program to a non-zero value, then a default | 440 | /* If defined or set by the user program to a non-zero value, then a default |
422 | option --version is added (unless the ARGP_NO_HELP flag is used), which | 441 | option --version is added (unless the ARGP_NO_HELP flag is used), which |
423 | will print this string followed by a newline and exit (unless the | 442 | will print this string followed by a newline and exit (unless the | ... | ... |
... | @@ -86,34 +86,10 @@ extern int fnmatch (const char *pattern, const char *string, int flags); | ... | @@ -86,34 +86,10 @@ extern int fnmatch (const char *pattern, const char *string, int flags); |
86 | #if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU | 86 | #if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU |
87 | 87 | ||
88 | 88 | ||
89 | # if defined STDC_HEADERS || !defined isascii | 89 | # if ! (defined isblank || HAVE_DECL_ISBLANK) |
90 | # define ISASCII(c) 1 | 90 | # define isblank(c) ((c) == ' ' || (c) == '\t') |
91 | # else | ||
92 | # define ISASCII(c) isascii(c) | ||
93 | # endif | ||
94 | |||
95 | # ifdef isblank | ||
96 | # define ISBLANK(c) (ISASCII (c) && isblank (c)) | ||
97 | # else | ||
98 | # define ISBLANK(c) ((c) == ' ' || (c) == '\t') | ||
99 | # endif | ||
100 | # ifdef isgraph | ||
101 | # define ISGRAPH(c) (ISASCII (c) && isgraph (c)) | ||
102 | # else | ||
103 | # define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c)) | ||
104 | # endif | 91 | # endif |
105 | 92 | ||
106 | # define ISPRINT(c) (ISASCII (c) && isprint (c)) | ||
107 | # define ISDIGIT(c) (ISASCII (c) && isdigit (c)) | ||
108 | # define ISALNUM(c) (ISASCII (c) && isalnum (c)) | ||
109 | # define ISALPHA(c) (ISASCII (c) && isalpha (c)) | ||
110 | # define ISCNTRL(c) (ISASCII (c) && iscntrl (c)) | ||
111 | # define ISLOWER(c) (ISASCII (c) && islower (c)) | ||
112 | # define ISPUNCT(c) (ISASCII (c) && ispunct (c)) | ||
113 | # define ISSPACE(c) (ISASCII (c) && isspace (c)) | ||
114 | # define ISUPPER(c) (ISASCII (c) && isupper (c)) | ||
115 | # define ISXDIGIT(c) (ISASCII (c) && isxdigit (c)) | ||
116 | |||
117 | # define STREQ(s1, s2) ((strcmp (s1, s2) == 0)) | 93 | # define STREQ(s1, s2) ((strcmp (s1, s2) == 0)) |
118 | 94 | ||
119 | # if defined _LIBC || WIDE_CHAR_SUPPORT | 95 | # if defined _LIBC || WIDE_CHAR_SUPPORT |
... | @@ -169,11 +145,7 @@ static int posixly_correct; | ... | @@ -169,11 +145,7 @@ static int posixly_correct; |
169 | # endif | 145 | # endif |
170 | 146 | ||
171 | /* Note that this evaluates C many times. */ | 147 | /* Note that this evaluates C many times. */ |
172 | # ifdef _LIBC | ||
173 | # define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c)) | 148 | # define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c)) |
174 | # else | ||
175 | # define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c)) | ||
176 | # endif | ||
177 | # define CHAR char | 149 | # define CHAR char |
178 | # define UCHAR unsigned char | 150 | # define UCHAR unsigned char |
179 | # define INT int | 151 | # define INT int | ... | ... |
... | @@ -288,18 +288,18 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, | ... | @@ -288,18 +288,18 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, |
288 | goto matched; | 288 | goto matched; |
289 | # endif | 289 | # endif |
290 | #else | 290 | #else |
291 | if ((STREQ (str, L_("alnum")) && ISALNUM ((UCHAR) *n)) | 291 | if ((STREQ (str, L_("alnum")) && isalnum ((UCHAR) *n)) |
292 | || (STREQ (str, L_("alpha")) && ISALPHA ((UCHAR) *n)) | 292 | || (STREQ (str, L_("alpha")) && isalpha ((UCHAR) *n)) |
293 | || (STREQ (str, L_("blank")) && ISBLANK ((UCHAR) *n)) | 293 | || (STREQ (str, L_("blank")) && isblank ((UCHAR) *n)) |
294 | || (STREQ (str, L_("cntrl")) && ISCNTRL ((UCHAR) *n)) | 294 | || (STREQ (str, L_("cntrl")) && iscntrl ((UCHAR) *n)) |
295 | || (STREQ (str, L_("digit")) && ISDIGIT ((UCHAR) *n)) | 295 | || (STREQ (str, L_("digit")) && isdigit ((UCHAR) *n)) |
296 | || (STREQ (str, L_("graph")) && ISGRAPH ((UCHAR) *n)) | 296 | || (STREQ (str, L_("graph")) && isgraph ((UCHAR) *n)) |
297 | || (STREQ (str, L_("lower")) && ISLOWER ((UCHAR) *n)) | 297 | || (STREQ (str, L_("lower")) && islower ((UCHAR) *n)) |
298 | || (STREQ (str, L_("print")) && ISPRINT ((UCHAR) *n)) | 298 | || (STREQ (str, L_("print")) && isprint ((UCHAR) *n)) |
299 | || (STREQ (str, L_("punct")) && ISPUNCT ((UCHAR) *n)) | 299 | || (STREQ (str, L_("punct")) && ispunct ((UCHAR) *n)) |
300 | || (STREQ (str, L_("space")) && ISSPACE ((UCHAR) *n)) | 300 | || (STREQ (str, L_("space")) && isspace ((UCHAR) *n)) |
301 | || (STREQ (str, L_("upper")) && ISUPPER ((UCHAR) *n)) | 301 | || (STREQ (str, L_("upper")) && isupper ((UCHAR) *n)) |
302 | || (STREQ (str, L_("xdigit")) && ISXDIGIT ((UCHAR) *n))) | 302 | || (STREQ (str, L_("xdigit")) && isxdigit ((UCHAR) *n))) |
303 | goto matched; | 303 | goto matched; |
304 | #endif | 304 | #endif |
305 | c = *p++; | 305 | c = *p++; | ... | ... |
1 | /* Convenience header for conditional use of GNU <libintl.h>. | 1 | /* Convenience header for conditional use of GNU <libintl.h>. |
2 | Copyright (C) 1995-1998, 2000-2002, 2004 Free Software Foundation, Inc. | 2 | Copyright (C) 1995-1998, 2000-2002, 2004-2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -75,4 +75,168 @@ | ... | @@ -75,4 +75,168 @@ |
75 | initializer for static 'char[]' or 'const char[]' variables. */ | 75 | initializer for static 'char[]' or 'const char[]' variables. */ |
76 | #define gettext_noop(String) String | 76 | #define gettext_noop(String) String |
77 | 77 | ||
78 | /* The separator between msgctxt and msgid in a .mo file. */ | ||
79 | #define GETTEXT_CONTEXT_GLUE "\004" | ||
80 | |||
81 | /* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a | ||
82 | MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be | ||
83 | short and rarely need to change. | ||
84 | The letter 'p' stands for 'particular' or 'special'. */ | ||
85 | #define pgettext(Msgctxt, Msgid) \ | ||
86 | pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) | ||
87 | #define dpgettext(Domainname, Msgctxt, Msgid) \ | ||
88 | pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) | ||
89 | #define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ | ||
90 | pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) | ||
91 | #define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ | ||
92 | npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
93 | #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ | ||
94 | npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
95 | #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ | ||
96 | npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) | ||
97 | |||
98 | #ifdef __GNUC__ | ||
99 | __inline | ||
100 | #else | ||
101 | #ifdef __cplusplus | ||
102 | inline | ||
103 | #endif | ||
104 | #endif | ||
105 | static const char * | ||
106 | pgettext_aux (const char *domain, | ||
107 | const char *msg_ctxt_id, const char *msgid, | ||
108 | int category) | ||
109 | { | ||
110 | const char *translation = dcgettext (domain, msg_ctxt_id, category); | ||
111 | if (translation == msg_ctxt_id) | ||
112 | return msgid; | ||
113 | else | ||
114 | return translation; | ||
115 | } | ||
116 | |||
117 | #ifdef __GNUC__ | ||
118 | __inline | ||
119 | #else | ||
120 | #ifdef __cplusplus | ||
121 | inline | ||
122 | #endif | ||
123 | #endif | ||
124 | static const char * | ||
125 | npgettext_aux (const char *domain, | ||
126 | const char *msg_ctxt_id, const char *msgid, | ||
127 | const char *msgid_plural, unsigned long int n, | ||
128 | int category) | ||
129 | { | ||
130 | const char *translation = | ||
131 | dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); | ||
132 | if (translation == msg_ctxt_id || translation == msgid_plural) | ||
133 | return (n == 1 ? msgid : msgid_plural); | ||
134 | else | ||
135 | return translation; | ||
136 | } | ||
137 | |||
138 | /* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID | ||
139 | can be arbitrary expressions. But for string literals these macros are | ||
140 | less efficient than those above. */ | ||
141 | |||
142 | #include <string.h> | ||
143 | |||
144 | #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \ | ||
145 | (__GNUC__ >= 3 || defined __cplusplus) | ||
146 | |||
147 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
148 | #include <stdlib.h> | ||
149 | #endif | ||
150 | |||
151 | #define pgettext_expr(Msgctxt, Msgid) \ | ||
152 | dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) | ||
153 | #define dpgettext_expr(Domainname, Msgctxt, Msgid) \ | ||
154 | dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) | ||
155 | |||
156 | #ifdef __GNUC__ | ||
157 | __inline | ||
158 | #else | ||
159 | #ifdef __cplusplus | ||
160 | inline | ||
161 | #endif | ||
162 | #endif | ||
163 | static const char * | ||
164 | dcpgettext_expr (const char *domain, | ||
165 | const char *msgctxt, const char *msgid, | ||
166 | int category) | ||
167 | { | ||
168 | size_t msgctxt_len = strlen (msgctxt) + 1; | ||
169 | size_t msgid_len = strlen (msgid) + 1; | ||
170 | const char *translation; | ||
171 | #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
172 | char msg_ctxt_id[msgctxt_len + msgid_len]; | ||
173 | #else | ||
174 | char buf[1024]; | ||
175 | char *msg_ctxt_id = | ||
176 | (msgctxt_len + msgid_len <= sizeof (buf) | ||
177 | ? buf | ||
178 | : (char *) malloc (msgctxt_len + msgid_len)); | ||
179 | if (msg_ctxt_id != NULL) | ||
180 | #endif | ||
181 | { | ||
182 | memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); | ||
183 | msg_ctxt_id[msgctxt_len - 1] = '\004'; | ||
184 | memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); | ||
185 | translation = dcgettext (domain, msg_ctxt_id, category); | ||
186 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
187 | if (msg_ctxt_id != buf) | ||
188 | free (msg_ctxt_id); | ||
189 | #endif | ||
190 | if (translation != msg_ctxt_id) | ||
191 | return translation; | ||
192 | } | ||
193 | return msgid; | ||
194 | } | ||
195 | |||
196 | #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ | ||
197 | dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
198 | #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ | ||
199 | dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) | ||
200 | |||
201 | #ifdef __GNUC__ | ||
202 | __inline | ||
203 | #else | ||
204 | #ifdef __cplusplus | ||
205 | inline | ||
206 | #endif | ||
207 | #endif | ||
208 | static const char * | ||
209 | dcnpgettext_expr (const char *domain, | ||
210 | const char *msgctxt, const char *msgid, | ||
211 | const char *msgid_plural, unsigned long int n, | ||
212 | int category) | ||
213 | { | ||
214 | size_t msgctxt_len = strlen (msgctxt) + 1; | ||
215 | size_t msgid_len = strlen (msgid) + 1; | ||
216 | const char *translation; | ||
217 | #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
218 | char msg_ctxt_id[msgctxt_len + msgid_len]; | ||
219 | #else | ||
220 | char buf[1024]; | ||
221 | char *msg_ctxt_id = | ||
222 | (msgctxt_len + msgid_len <= sizeof (buf) | ||
223 | ? buf | ||
224 | : (char *) malloc (msgctxt_len + msgid_len)); | ||
225 | if (msg_ctxt_id != NULL) | ||
226 | #endif | ||
227 | { | ||
228 | memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); | ||
229 | msg_ctxt_id[msgctxt_len - 1] = '\004'; | ||
230 | memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); | ||
231 | translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); | ||
232 | #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS | ||
233 | if (msg_ctxt_id != buf) | ||
234 | free (msg_ctxt_id); | ||
235 | #endif | ||
236 | if (!(translation == msg_ctxt_id || translation == msgid_plural)) | ||
237 | return translation; | ||
238 | } | ||
239 | return (n == 1 ? msgid : msgid_plural); | ||
240 | } | ||
241 | |||
78 | #endif /* _LIBGETTEXT_H */ | 242 | #endif /* _LIBGETTEXT_H */ | ... | ... |
... | @@ -47,31 +47,12 @@ | ... | @@ -47,31 +47,12 @@ |
47 | # define __set_errno(val) errno = (val) | 47 | # define __set_errno(val) errno = (val) |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__ | 50 | #include <dirent.h> |
51 | # include <dirent.h> | ||
52 | # define NAMLEN(dirent) strlen((dirent)->d_name) | ||
53 | #else | ||
54 | # define dirent direct | ||
55 | # define NAMLEN(dirent) (dirent)->d_namlen | ||
56 | # ifdef HAVE_SYS_NDIR_H | ||
57 | # include <sys/ndir.h> | ||
58 | # endif | ||
59 | # ifdef HAVE_SYS_DIR_H | ||
60 | # include <sys/dir.h> | ||
61 | # endif | ||
62 | # ifdef HAVE_NDIR_H | ||
63 | # include <ndir.h> | ||
64 | # endif | ||
65 | # ifdef HAVE_VMSDIR_H | ||
66 | # include "vmsdir.h" | ||
67 | # endif /* HAVE_VMSDIR_H */ | ||
68 | #endif | ||
69 | 51 | ||
70 | 52 | ||
71 | /* In GNU systems, <dirent.h> defines this macro for us. */ | 53 | /* In GNU systems, <dirent.h> defines this macro for us. */ |
72 | #ifdef _D_NAMLEN | 54 | #ifndef _D_EXACT_NAMLEN |
73 | # undef NAMLEN | 55 | # define _D_EXACT_NAMLEN(dirent) strlen ((dirent)->d_name) |
74 | # define NAMLEN(d) _D_NAMLEN(d) | ||
75 | #endif | 56 | #endif |
76 | 57 | ||
77 | /* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available | 58 | /* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available |
... | @@ -97,13 +78,6 @@ | ... | @@ -97,13 +78,6 @@ |
97 | 78 | ||
98 | /* If the system has the `struct dirent64' type we use it internally. */ | 79 | /* If the system has the `struct dirent64' type we use it internally. */ |
99 | #if defined _LIBC && !defined COMPILE_GLOB64 | 80 | #if defined _LIBC && !defined COMPILE_GLOB64 |
100 | # if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__ | ||
101 | # define CONVERT_D_NAMLEN(d64, d32) | ||
102 | # else | ||
103 | # define CONVERT_D_NAMLEN(d64, d32) \ | ||
104 | (d64)->d_namlen = (d32)->d_namlen; | ||
105 | # endif | ||
106 | |||
107 | # if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__ | 81 | # if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__ |
108 | # define CONVERT_D_INO(d64, d32) | 82 | # define CONVERT_D_INO(d64, d32) |
109 | # else | 83 | # else |
... | @@ -119,8 +93,7 @@ | ... | @@ -119,8 +93,7 @@ |
119 | # endif | 93 | # endif |
120 | 94 | ||
121 | # define CONVERT_DIRENT_DIRENT64(d64, d32) \ | 95 | # define CONVERT_DIRENT_DIRENT64(d64, d32) \ |
122 | memcpy ((d64)->d_name, (d32)->d_name, NAMLEN (d32) + 1); \ | 96 | memcpy ((d64)->d_name, (d32)->d_name, _D_EXACT_NAMLEN (d32) + 1); \ |
123 | CONVERT_D_NAMLEN (d64, d32) \ | ||
124 | CONVERT_D_INO (d64, d32) \ | 97 | CONVERT_D_INO (d64, d32) \ |
125 | CONVERT_D_TYPE (d64, d32) | 98 | CONVERT_D_TYPE (d64, d32) |
126 | #endif | 99 | #endif |
... | @@ -511,7 +484,6 @@ glob (pattern, flags, errfunc, pglob) | ... | @@ -511,7 +484,6 @@ glob (pattern, flags, errfunc, pglob) |
511 | 484 | ||
512 | oldcount = pglob->gl_pathc + pglob->gl_offs; | 485 | oldcount = pglob->gl_pathc + pglob->gl_offs; |
513 | 486 | ||
514 | #ifndef VMS | ||
515 | if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~') | 487 | if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~') |
516 | { | 488 | { |
517 | if (dirname[1] == '\0' || dirname[1] == '/') | 489 | if (dirname[1] == '\0' || dirname[1] == '/') |
... | @@ -679,7 +651,6 @@ glob (pattern, flags, errfunc, pglob) | ... | @@ -679,7 +651,6 @@ glob (pattern, flags, errfunc, pglob) |
679 | } | 651 | } |
680 | # endif /* Not Amiga && not WINDOWS32. */ | 652 | # endif /* Not Amiga && not WINDOWS32. */ |
681 | } | 653 | } |
682 | #endif /* Not VMS. */ | ||
683 | 654 | ||
684 | /* Now test whether we looked for "~" or "~NAME". In this case we | 655 | /* Now test whether we looked for "~" or "~NAME". In this case we |
685 | can give the answer now. */ | 656 | can give the answer now. */ |
... | @@ -1132,7 +1103,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, | ... | @@ -1132,7 +1103,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, |
1132 | { | 1103 | { |
1133 | int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) | 1104 | int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) |
1134 | | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) | 1105 | | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) |
1135 | #if defined _AMIGA || defined VMS | 1106 | #if defined _AMIGA || defined __VMS |
1136 | | FNM_CASEFOLD | 1107 | | FNM_CASEFOLD |
1137 | #endif | 1108 | #endif |
1138 | ); | 1109 | ); |
... | @@ -1205,7 +1176,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, | ... | @@ -1205,7 +1176,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, |
1205 | struct globlink *new = | 1176 | struct globlink *new = |
1206 | __alloca (sizeof (struct globlink)); | 1177 | __alloca (sizeof (struct globlink)); |
1207 | char *p; | 1178 | char *p; |
1208 | len = NAMLEN (d); | 1179 | len = _D_EXACT_NAMLEN (d); |
1209 | new->name = | 1180 | new->name = |
1210 | malloc (len + 1 + ((flags & GLOB_MARK) && isdir)); | 1181 | malloc (len + 1 + ((flags & GLOB_MARK) && isdir)); |
1211 | if (new->name == NULL) | 1182 | if (new->name == NULL) | ... | ... |
... | @@ -46,10 +46,6 @@ | ... | @@ -46,10 +46,6 @@ |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | 48 | ||
49 | #ifndef HAVE_DIRENT_H | ||
50 | # define dirent direct | ||
51 | #endif | ||
52 | |||
53 | #define glob rpl_glob | 49 | #define glob rpl_glob |
54 | #define globfree rpl_globfree | 50 | #define globfree rpl_globfree |
55 | #define glob_pattern_p rpl_glob_pattern_p | 51 | #define glob_pattern_p rpl_glob_pattern_p | ... | ... |
1 | /* inttostr.h -- convert integers to printable strings | 1 | /* inttostr.h -- convert integers to printable strings |
2 | 2 | ||
3 | Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. | 3 | Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software |
4 | Foundation, Inc. | ||
4 | 5 | ||
5 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
... | @@ -18,13 +19,7 @@ | ... | @@ -18,13 +19,7 @@ |
18 | 19 | ||
19 | /* Written by Paul Eggert */ | 20 | /* Written by Paul Eggert */ |
20 | 21 | ||
21 | #if HAVE_INTTYPES_H | 22 | #include <stdint.h> |
22 | # include <inttypes.h> | ||
23 | #endif | ||
24 | #if HAVE_STDINT_H | ||
25 | # include <stdint.h> | ||
26 | #endif | ||
27 | |||
28 | #include <sys/types.h> | 23 | #include <sys/types.h> |
29 | 24 | ||
30 | #include "intprops.h" | 25 | #include "intprops.h" | ... | ... |
1 | /* Multibyte character data type. | 1 | /* Multibyte character data type. |
2 | Copyright (C) 2001, 2005 Free Software Foundation, Inc. | 2 | Copyright (C) 2001, 2005-2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -156,7 +156,133 @@ | ... | @@ -156,7 +156,133 @@ |
156 | #include <time.h> | 156 | #include <time.h> |
157 | #include <wchar.h> | 157 | #include <wchar.h> |
158 | 158 | ||
159 | #include <wctype.h> | 159 | /* BeOS 5 has the functions but no <wctype.h>. */ |
160 | #if HAVE_WCTYPE_H | ||
161 | # include <wctype.h> | ||
162 | #endif | ||
163 | /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions. | ||
164 | Assume all 12 functions are implemented the same way, or not at all. */ | ||
165 | #if !defined iswalnum && !HAVE_ISWCNTRL | ||
166 | static inline int | ||
167 | iswalnum (wint_t wc) | ||
168 | { | ||
169 | return (wc >= 0 && wc < 128 | ||
170 | ? (wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z') | ||
171 | : 0); | ||
172 | } | ||
173 | # define iswalnum iswalnum | ||
174 | #endif | ||
175 | #if !defined iswalpha && !HAVE_ISWCNTRL | ||
176 | static inline int | ||
177 | iswalpha (wint_t wc) | ||
178 | { | ||
179 | return (wc >= 0 && wc < 128 | ||
180 | ? (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z' | ||
181 | : 0); | ||
182 | } | ||
183 | # define iswalpha iswalpha | ||
184 | #endif | ||
185 | #if !defined iswblank && !HAVE_ISWCNTRL | ||
186 | static inline int | ||
187 | iswblank (wint_t wc) | ||
188 | { | ||
189 | return (wc >= 0 && wc < 128 | ||
190 | ? wc == ' ' || wc == '\t' | ||
191 | : 0); | ||
192 | } | ||
193 | # define iswblank iswblank | ||
194 | #endif | ||
195 | #if !defined iswcntrl && !HAVE_ISWCNTRL | ||
196 | static inline int | ||
197 | iswcntrl (wint_t wc) | ||
198 | { | ||
199 | return (wc >= 0 && wc < 128 | ||
200 | ? (wc & ~0x1f) == 0 || wc == 0x7f | ||
201 | : 0); | ||
202 | } | ||
203 | # define iswcntrl iswcntrl | ||
204 | #endif | ||
205 | #if !defined iswdigit && !HAVE_ISWCNTRL | ||
206 | static inline int | ||
207 | iswdigit (wint_t wc) | ||
208 | { | ||
209 | return (wc >= '0' && wc <= '9'); | ||
210 | } | ||
211 | # define iswdigit iswdigit | ||
212 | #endif | ||
213 | #if !defined iswgraph && !HAVE_ISWCNTRL | ||
214 | static inline int | ||
215 | iswgraph (wint_t wc) | ||
216 | { | ||
217 | return (wc >= 0 && wc < 128 | ||
218 | ? wc >= '!' && wc <= '~' | ||
219 | : 1); | ||
220 | } | ||
221 | # define iswgraph iswgraph | ||
222 | #endif | ||
223 | #if !defined iswlower && !HAVE_ISWCNTRL | ||
224 | static inline int | ||
225 | iswlower (wint_t wc) | ||
226 | { | ||
227 | return (wc >= 0 && wc < 128 | ||
228 | ? wc >= 'a' && wc <= 'z' | ||
229 | : 0); | ||
230 | } | ||
231 | # define iswlower iswlower | ||
232 | #endif | ||
233 | #if !defined iswprint && !HAVE_ISWCNTRL | ||
234 | static inline int | ||
235 | iswprint (wint_t wc) | ||
236 | { | ||
237 | return (wc >= 0 && wc < 128 | ||
238 | ? wc >= ' ' && wc <= '~' | ||
239 | : 1); | ||
240 | } | ||
241 | # define iswprint iswprint | ||
242 | #endif | ||
243 | #if !defined iswpunct && !HAVE_ISWCNTRL | ||
244 | static inline int | ||
245 | iswpunct (wint_t wc) | ||
246 | { | ||
247 | return (wc >= 0 && wc < 128 | ||
248 | ? wc >= '!' && wc <= '~' | ||
249 | && !((wc >= '0' && wc <= '9') | ||
250 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')) | ||
251 | : 1); | ||
252 | } | ||
253 | # define iswpunct iswpunct | ||
254 | #endif | ||
255 | #if !defined iswspace && !HAVE_ISWCNTRL | ||
256 | static inline int | ||
257 | iswspace (wint_t wc) | ||
258 | { | ||
259 | return (wc >= 0 && wc < 128 | ||
260 | ? wc == ' ' || wc == '\t' | ||
261 | || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r' | ||
262 | : 0); | ||
263 | } | ||
264 | # define iswspace iswspace | ||
265 | #endif | ||
266 | #if !defined iswupper && !HAVE_ISWCNTRL | ||
267 | static inline int | ||
268 | iswupper (wint_t wc) | ||
269 | { | ||
270 | return (wc >= 0 && wc < 128 | ||
271 | ? wc >= 'A' && wc <= 'Z' | ||
272 | : 0); | ||
273 | } | ||
274 | # define iswupper iswupper | ||
275 | #endif | ||
276 | #if !defined iswxdigit && !HAVE_ISWCNTRL | ||
277 | static inline int | ||
278 | iswxdigit (wint_t wc) | ||
279 | { | ||
280 | return (wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'); | ||
281 | } | ||
282 | # define iswxdigit iswxdigit | ||
283 | #endif | ||
284 | |||
285 | #include "wcwidth.h" | ||
160 | 286 | ||
161 | #define MBCHAR_BUF_SIZE 24 | 287 | #define MBCHAR_BUF_SIZE 24 |
162 | 288 | ... | ... |
1 | /* Decomposed printf argument list. | 1 | /* Decomposed printf argument list. |
2 | Copyright (C) 1999, 2002-2003, 2006 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2002-2003, 2005-2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -79,7 +79,13 @@ printf_fetchargs (va_list args, arguments *a) | ... | @@ -79,7 +79,13 @@ printf_fetchargs (va_list args, arguments *a) |
79 | break; | 79 | break; |
80 | #ifdef HAVE_WINT_T | 80 | #ifdef HAVE_WINT_T |
81 | case TYPE_WIDE_CHAR: | 81 | case TYPE_WIDE_CHAR: |
82 | ap->a.a_wide_char = va_arg (args, wint_t); | 82 | /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by |
83 | default argument promotions", this is not the case in mingw32, | ||
84 | where wint_t is 'unsigned short'. */ | ||
85 | ap->a.a_wide_char = | ||
86 | (sizeof (wint_t) < sizeof (int) | ||
87 | ? va_arg (args, int) | ||
88 | : va_arg (args, wint_t)); | ||
83 | break; | 89 | break; |
84 | #endif | 90 | #endif |
85 | case TYPE_STRING: | 91 | case TYPE_STRING: | ... | ... |
... | @@ -37,12 +37,6 @@ extern "C" { | ... | @@ -37,12 +37,6 @@ extern "C" { |
37 | # define __USE_GNU_REGEX 1 | 37 | # define __USE_GNU_REGEX 1 |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #ifdef __VMS | ||
41 | /* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it | ||
42 | should be there. */ | ||
43 | # include <stddef.h> | ||
44 | #endif | ||
45 | |||
46 | #ifdef _REGEX_LARGE_OFFSETS | 40 | #ifdef _REGEX_LARGE_OFFSETS |
47 | 41 | ||
48 | /* Use types and values that are wide enough to represent signed and | 42 | /* Use types and values that are wide enough to represent signed and |
... | @@ -641,9 +635,10 @@ extern int re_exec (const char *); | ... | @@ -641,9 +635,10 @@ extern int re_exec (const char *); |
641 | # endif | 635 | # endif |
642 | # endif | 636 | # endif |
643 | #endif | 637 | #endif |
644 | /* gcc 3.1 and up support the [restrict] syntax, but g++ doesn't. */ | 638 | /* gcc 3.1 and up support the [restrict] syntax. */ |
645 | #ifndef __restrict_arr | 639 | #ifndef __restrict_arr |
646 | # if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) && !defined __cplusplus | 640 | # if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \ |
641 | && !defined __GNUG__ | ||
647 | # define __restrict_arr __restrict | 642 | # define __restrict_arr __restrict |
648 | # else | 643 | # else |
649 | # define __restrict_arr | 644 | # define __restrict_arr | ... | ... |
... | @@ -488,27 +488,34 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc) | ... | @@ -488,27 +488,34 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc) |
488 | mbstate_t prev_st; | 488 | mbstate_t prev_st; |
489 | Idx rawbuf_idx; | 489 | Idx rawbuf_idx; |
490 | size_t mbclen; | 490 | size_t mbclen; |
491 | wchar_t wc = 0; | 491 | wint_t wc = WEOF; |
492 | 492 | ||
493 | /* Skip the characters which are not necessary to check. */ | 493 | /* Skip the characters which are not necessary to check. */ |
494 | for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len; | 494 | for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len; |
495 | rawbuf_idx < new_raw_idx;) | 495 | rawbuf_idx < new_raw_idx;) |
496 | { | 496 | { |
497 | wchar_t wc2; | ||
497 | Idx remain_len; | 498 | Idx remain_len; |
498 | remain_len = pstr->len - rawbuf_idx; | 499 | remain_len = pstr->len - rawbuf_idx; |
499 | prev_st = pstr->cur_state; | 500 | prev_st = pstr->cur_state; |
500 | mbclen = mbrtowc (&wc, (const char *) pstr->raw_mbs + rawbuf_idx, | 501 | mbclen = mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx, |
501 | remain_len, &pstr->cur_state); | 502 | remain_len, &pstr->cur_state); |
502 | if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0)) | 503 | if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0)) |
503 | { | 504 | { |
504 | /* We treat these cases as a singlebyte character. */ | 505 | /* We treat these cases as a single byte character. */ |
506 | if (mbclen == 0 || remain_len == 0) | ||
507 | wc = L'\0'; | ||
508 | else | ||
509 | wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx); | ||
505 | mbclen = 1; | 510 | mbclen = 1; |
506 | pstr->cur_state = prev_st; | 511 | pstr->cur_state = prev_st; |
507 | } | 512 | } |
513 | else | ||
514 | wc = wc2; | ||
508 | /* Then proceed the next character. */ | 515 | /* Then proceed the next character. */ |
509 | rawbuf_idx += mbclen; | 516 | rawbuf_idx += mbclen; |
510 | } | 517 | } |
511 | *last_wc = (wint_t) wc; | 518 | *last_wc = wc; |
512 | return rawbuf_idx; | 519 | return rawbuf_idx; |
513 | } | 520 | } |
514 | #endif /* RE_ENABLE_I18N */ | 521 | #endif /* RE_ENABLE_I18N */ |
... | @@ -627,7 +634,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) | ... | @@ -627,7 +634,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) |
627 | } | 634 | } |
628 | #endif | 635 | #endif |
629 | pstr->valid_len = 0; | 636 | pstr->valid_len = 0; |
630 | pstr->valid_raw_len = 0; | ||
631 | #ifdef RE_ENABLE_I18N | 637 | #ifdef RE_ENABLE_I18N |
632 | if (pstr->mb_cur_max > 1) | 638 | if (pstr->mb_cur_max > 1) |
633 | { | 639 | { |
... | @@ -690,6 +696,16 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) | ... | @@ -690,6 +696,16 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) |
690 | 696 | ||
691 | if (wc == WEOF) | 697 | if (wc == WEOF) |
692 | pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx; | 698 | pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx; |
699 | if (wc == WEOF) | ||
700 | pstr->tip_context | ||
701 | = re_string_context_at (pstr, pstr->valid_raw_len - 1, eflags); | ||
702 | else | ||
703 | pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0) | ||
704 | && IS_WIDE_WORD_CHAR (wc)) | ||
705 | ? CONTEXT_WORD | ||
706 | : ((IS_WIDE_NEWLINE (wc) | ||
707 | && pstr->newline_anchor) | ||
708 | ? CONTEXT_NEWLINE : 0)); | ||
693 | if (BE (pstr->valid_len, 0)) | 709 | if (BE (pstr->valid_len, 0)) |
694 | { | 710 | { |
695 | for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx) | 711 | for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx) |
... | @@ -698,17 +714,12 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) | ... | @@ -698,17 +714,12 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) |
698 | memset (pstr->mbs, -1, pstr->valid_len); | 714 | memset (pstr->mbs, -1, pstr->valid_len); |
699 | } | 715 | } |
700 | pstr->valid_raw_len = pstr->valid_len; | 716 | pstr->valid_raw_len = pstr->valid_len; |
701 | pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0) | ||
702 | && IS_WIDE_WORD_CHAR (wc)) | ||
703 | ? CONTEXT_WORD | ||
704 | : ((IS_WIDE_NEWLINE (wc) | ||
705 | && pstr->newline_anchor) | ||
706 | ? CONTEXT_NEWLINE : 0)); | ||
707 | } | 717 | } |
708 | else | 718 | else |
709 | #endif /* RE_ENABLE_I18N */ | 719 | #endif /* RE_ENABLE_I18N */ |
710 | { | 720 | { |
711 | int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1]; | 721 | int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1]; |
722 | pstr->valid_raw_len = 0; | ||
712 | if (pstr->trans) | 723 | if (pstr->trans) |
713 | c = pstr->trans[c]; | 724 | c = pstr->trans[c]; |
714 | pstr->tip_context = (bitset_contain (pstr->word_char, c) | 725 | pstr->tip_context = (bitset_contain (pstr->word_char, c) | ... | ... |
... | @@ -43,20 +43,17 @@ | ... | @@ -43,20 +43,17 @@ |
43 | #if defined HAVE_WCTYPE_H || defined _LIBC | 43 | #if defined HAVE_WCTYPE_H || defined _LIBC |
44 | # include <wctype.h> | 44 | # include <wctype.h> |
45 | #endif /* HAVE_WCTYPE_H || _LIBC */ | 45 | #endif /* HAVE_WCTYPE_H || _LIBC */ |
46 | #if defined HAVE_STDINT_H || defined _LIBC | 46 | #include <stdint.h> |
47 | # include <stdint.h> | ||
48 | #endif /* HAVE_STDINT_H || _LIBC */ | ||
49 | #if defined _LIBC | 47 | #if defined _LIBC |
50 | # include <bits/libc-lock.h> | 48 | # include <bits/libc-lock.h> |
51 | #else | 49 | #else |
52 | # define __libc_lock_define(CLASS,NAME) | ||
53 | # define __libc_lock_init(NAME) do { } while (0) | 50 | # define __libc_lock_init(NAME) do { } while (0) |
54 | # define __libc_lock_lock(NAME) do { } while (0) | 51 | # define __libc_lock_lock(NAME) do { } while (0) |
55 | # define __libc_lock_unlock(NAME) do { } while (0) | 52 | # define __libc_lock_unlock(NAME) do { } while (0) |
56 | #endif | 53 | #endif |
57 | 54 | ||
58 | /* In case that the system doesn't have isblank(). */ | 55 | /* In case that the system doesn't have isblank(). */ |
59 | #if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank | 56 | #if !defined _LIBC && !HAVE_DECL_ISBLANK && !defined isblank |
60 | # define isblank(ch) ((ch) == ' ' || (ch) == '\t') | 57 | # define isblank(ch) ((ch) == ' ' || (ch) == '\t') |
61 | #endif | 58 | #endif |
62 | 59 | ||
... | @@ -711,7 +708,9 @@ struct re_dfa_t | ... | @@ -711,7 +708,9 @@ struct re_dfa_t |
711 | #ifdef DEBUG | 708 | #ifdef DEBUG |
712 | char* re_str; | 709 | char* re_str; |
713 | #endif | 710 | #endif |
711 | #ifdef _LIBC | ||
714 | __libc_lock_define (, lock) | 712 | __libc_lock_define (, lock) |
713 | #endif | ||
715 | }; | 714 | }; |
716 | 715 | ||
717 | #define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set)) | 716 | #define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set)) | ... | ... |
1 | /* stat-related macros | 1 | /* stat-related macros |
2 | 2 | ||
3 | Copyright (C) 1993, 1994, 2001, 2002, 2004 Free Software Foundation, Inc. | 3 | Copyright (C) 1993, 1994, 2001, 2002, 2004, 2006 Free Software |
4 | Foundation, Inc. | ||
4 | 5 | ||
5 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
... | @@ -33,7 +34,6 @@ | ... | @@ -33,7 +34,6 @@ |
33 | # undef S_ISBLK | 34 | # undef S_ISBLK |
34 | # undef S_ISCHR | 35 | # undef S_ISCHR |
35 | # undef S_ISDIR | 36 | # undef S_ISDIR |
36 | # undef S_ISDOOR | ||
37 | # undef S_ISFIFO | 37 | # undef S_ISFIFO |
38 | # undef S_ISLNK | 38 | # undef S_ISLNK |
39 | # undef S_ISNAM | 39 | # undef S_ISNAM |
... | @@ -70,12 +70,8 @@ | ... | @@ -70,12 +70,8 @@ |
70 | # endif | 70 | # endif |
71 | 71 | ||
72 | # ifndef S_ISDOOR /* Solaris 2.5 and up */ | 72 | # ifndef S_ISDOOR /* Solaris 2.5 and up */ |
73 | # ifdef S_IFDOOR | ||
74 | # define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR) | ||
75 | # else | ||
76 | # define S_ISDOOR(m) 0 | 73 | # define S_ISDOOR(m) 0 |
77 | # endif | 74 | # endif |
78 | # endif | ||
79 | 75 | ||
80 | # ifndef S_ISFIFO | 76 | # ifndef S_ISFIFO |
81 | # ifdef S_IFIFO | 77 | # ifdef S_IFIFO |
... | @@ -119,6 +115,10 @@ | ... | @@ -119,6 +115,10 @@ |
119 | # endif | 115 | # endif |
120 | # endif | 116 | # endif |
121 | 117 | ||
118 | # ifndef S_ISPORT /* Solaris 10 and up */ | ||
119 | # define S_ISPORT(m) 0 | ||
120 | # endif | ||
121 | |||
122 | # ifndef S_ISREG | 122 | # ifndef S_ISREG |
123 | # ifdef S_IFREG | 123 | # ifdef S_IFREG |
124 | # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) | 124 | # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) |
... | @@ -161,7 +161,7 @@ | ... | @@ -161,7 +161,7 @@ |
161 | # endif | 161 | # endif |
162 | # endif | 162 | # endif |
163 | 163 | ||
164 | /* contiguous */ | 164 | /* high performance ("contiguous data") */ |
165 | # ifndef S_ISCTG | 165 | # ifndef S_ISCTG |
166 | # define S_ISCTG(p) 0 | 166 | # define S_ISCTG(p) 0 |
167 | # endif | 167 | # endif |
... | @@ -176,6 +176,11 @@ | ... | @@ -176,6 +176,11 @@ |
176 | # define S_ISOFL(p) 0 | 176 | # define S_ISOFL(p) 0 |
177 | # endif | 177 | # endif |
178 | 178 | ||
179 | /* 4.4BSD whiteout */ | ||
180 | # ifndef S_ISWHT | ||
181 | # define S_ISWHT(m) 0 | ||
182 | # endif | ||
183 | |||
179 | /* If any of the following are undefined, | 184 | /* If any of the following are undefined, |
180 | define them to their de facto standard values. */ | 185 | define them to their de facto standard values. */ |
181 | # if !S_ISUID | 186 | # if !S_ISUID | ... | ... |
This diff is collapsed.
Click to expand it.
1 | /* Find the length of STRING + 1, but scan at most MAXLEN bytes. | 1 | /* Find the length of STRING + 1, but scan at most MAXLEN bytes. |
2 | Copyright (C) 2005 Free Software Foundation, Inc. | 2 | Copyright (C) 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify it | 4 | This program is free software; you can redistribute it and/or modify |
5 | under the terms of the GNU Library General Public License as published | 5 | it under the terms of the GNU General Public License as published by |
6 | by the Free Software Foundation; either version 2, or (at your option) | 6 | the Free Software Foundation; either version 2, or (at your option) |
7 | any later version. | 7 | any later version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, | 9 | This program is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | Library General Public License for more details. | 12 | GNU General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public | 14 | You should have received a copy of the GNU General Public License |
15 | License along with this program; if not, write to the Free Software | 15 | along with this program; if not, write to the Free Software Foundation, |
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | 16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
17 | USA. */ | ||
18 | 17 | ||
19 | #ifdef HAVE_CONFIG_H | 18 | #ifdef HAVE_CONFIG_H |
20 | # include <config.h> | 19 | # include <config.h> | ... | ... |
1 | /* Find the length of STRING + 1, but scan at most MAXLEN bytes. | 1 | /* Find the length of STRING + 1, but scan at most MAXLEN bytes. |
2 | Copyright (C) 2005 Free Software Foundation, Inc. | 2 | Copyright (C) 2005 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify it | 4 | This program is free software; you can redistribute it and/or modify |
5 | under the terms of the GNU Library General Public License as published | 5 | it under the terms of the GNU General Public License as published by |
6 | by the Free Software Foundation; either version 2, or (at your option) | 6 | the Free Software Foundation; either version 2, or (at your option) |
7 | any later version. | 7 | any later version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, | 9 | This program is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | Library General Public License for more details. | 12 | GNU General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public | 14 | You should have received a copy of the GNU General Public License |
15 | License along with this program; if not, write to the Free Software | 15 | along with this program; if not, write to the Free Software Foundation, |
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | 16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
17 | USA. */ | ||
18 | 17 | ||
19 | #ifndef _STRNLEN1_H | 18 | #ifndef _STRNLEN1_H |
20 | #define _STRNLEN1_H | 19 | #define _STRNLEN1_H | ... | ... |
... | @@ -40,7 +40,7 @@ | ... | @@ -40,7 +40,7 @@ |
40 | #include <stdlib.h> /* abort(), malloc(), realloc(), free() */ | 40 | #include <stdlib.h> /* abort(), malloc(), realloc(), free() */ |
41 | #include <string.h> /* memcpy(), strlen() */ | 41 | #include <string.h> /* memcpy(), strlen() */ |
42 | #include <errno.h> /* errno */ | 42 | #include <errno.h> /* errno */ |
43 | #include <limits.h> /* CHAR_BIT, INT_MAX */ | 43 | #include <limits.h> /* CHAR_BIT */ |
44 | #include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */ | 44 | #include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */ |
45 | #if WIDE_CHAR_VERSION | 45 | #if WIDE_CHAR_VERSION |
46 | # include "wprintf-parse.h" | 46 | # include "wprintf-parse.h" |
... | @@ -51,11 +51,6 @@ | ... | @@ -51,11 +51,6 @@ |
51 | /* Checked size_t computations. */ | 51 | /* Checked size_t computations. */ |
52 | #include "xsize.h" | 52 | #include "xsize.h" |
53 | 53 | ||
54 | /* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ | ||
55 | #ifndef EOVERFLOW | ||
56 | # define EOVERFLOW E2BIG | ||
57 | #endif | ||
58 | |||
59 | #ifdef HAVE_WCHAR_T | 54 | #ifdef HAVE_WCHAR_T |
60 | # ifdef HAVE_WCSLEN | 55 | # ifdef HAVE_WCSLEN |
61 | # define local_wcslen wcslen | 56 | # define local_wcslen wcslen |
... | @@ -869,19 +864,12 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar | ... | @@ -869,19 +864,12 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar |
869 | free (buf_malloced); | 864 | free (buf_malloced); |
870 | CLEANUP (); | 865 | CLEANUP (); |
871 | *lengthp = length; | 866 | *lengthp = length; |
872 | if (length > INT_MAX) | 867 | /* Note that we can produce a big string of a length > INT_MAX. POSIX |
873 | goto length_overflow; | 868 | says that snprintf() fails with errno = EOVERFLOW in this case, but |
869 | that's only because snprintf() returns an 'int'. This function does | ||
870 | not have this limitation. */ | ||
874 | return result; | 871 | return result; |
875 | 872 | ||
876 | length_overflow: | ||
877 | /* We could produce such a big string, but its length doesn't fit into | ||
878 | an 'int'. POSIX says that snprintf() fails with errno = EOVERFLOW in | ||
879 | this case. */ | ||
880 | if (result != resultbuf) | ||
881 | free (result); | ||
882 | errno = EOVERFLOW; | ||
883 | return NULL; | ||
884 | |||
885 | out_of_memory: | 873 | out_of_memory: |
886 | if (!(result == resultbuf || result == NULL)) | 874 | if (!(result == resultbuf || result == NULL)) |
887 | free (result); | 875 | free (result); | ... | ... |
1 | /* Formatted output to strings. | 1 | /* Formatted output to strings. |
2 | Copyright (C) 2004 Free Software Foundation, Inc. | 2 | Copyright (C) 2004, 2006 Free Software Foundation, Inc. |
3 | Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>. | 3 | Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>. |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
... | @@ -23,6 +23,8 @@ | ... | @@ -23,6 +23,8 @@ |
23 | /* Specification. */ | 23 | /* Specification. */ |
24 | #include "vsnprintf.h" | 24 | #include "vsnprintf.h" |
25 | 25 | ||
26 | #include <errno.h> | ||
27 | #include <limits.h> | ||
26 | #include <stdarg.h> | 28 | #include <stdarg.h> |
27 | #include <stdio.h> | 29 | #include <stdio.h> |
28 | #include <stdlib.h> | 30 | #include <stdlib.h> |
... | @@ -30,6 +32,11 @@ | ... | @@ -30,6 +32,11 @@ |
30 | 32 | ||
31 | #include "vasnprintf.h" | 33 | #include "vasnprintf.h" |
32 | 34 | ||
35 | /* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ | ||
36 | #ifndef EOVERFLOW | ||
37 | # define EOVERFLOW E2BIG | ||
38 | #endif | ||
39 | |||
33 | /* Print formatted output to string STR. Similar to vsprintf, but | 40 | /* Print formatted output to string STR. Similar to vsprintf, but |
34 | additional length SIZE limit how much is written into STR. Returns | 41 | additional length SIZE limit how much is written into STR. Returns |
35 | string length of formatted string (which may be larger than SIZE). | 42 | string length of formatted string (which may be larger than SIZE). |
... | @@ -40,19 +47,31 @@ vsnprintf (char *str, size_t size, const char *format, va_list args) | ... | @@ -40,19 +47,31 @@ vsnprintf (char *str, size_t size, const char *format, va_list args) |
40 | { | 47 | { |
41 | char *output; | 48 | char *output; |
42 | size_t len; | 49 | size_t len; |
50 | size_t lenbuf = size; | ||
43 | 51 | ||
44 | len = size; | 52 | output = vasnprintf (str, &lenbuf, format, args); |
45 | output = vasnprintf (str, &len, format, args); | 53 | len = lenbuf; |
46 | 54 | ||
47 | if (!output) | 55 | if (!output) |
48 | return -1; | 56 | return -1; |
49 | 57 | ||
50 | if (str != NULL) | ||
51 | if (len > size - 1) /* equivalent to: (size > 0 && len >= size) */ | ||
52 | str[size - 1] = '\0'; | ||
53 | |||
54 | if (output != str) | 58 | if (output != str) |
59 | { | ||
60 | if (size) | ||
61 | { | ||
62 | size_t pruned_len = (len < size ? len : size - 1); | ||
63 | memcpy (str, output, pruned_len); | ||
64 | str[pruned_len] = '\0'; | ||
65 | } | ||
66 | |||
55 | free (output); | 67 | free (output); |
68 | } | ||
69 | |||
70 | if (len > INT_MAX) | ||
71 | { | ||
72 | errno = EOVERFLOW; | ||
73 | return -1; | ||
74 | } | ||
56 | 75 | ||
57 | return len; | 76 | return len; |
58 | } | 77 | } | ... | ... |
-
Please register or sign in to post a comment