Updated by gnulib-sync
Showing
52 changed files
with
490 additions
and
555 deletions
... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
17 | If not, write to the Free Software Foundation, | 17 | If not, write to the Free Software Foundation, |
18 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
19 | 19 | ||
20 | #if HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | # include <config.h> | 21 | # include <config.h> |
22 | #endif | 22 | #endif |
23 | 23 | ... | ... |
1 | /* Copyright (C) 1992-2001, 2003, 2004 Free Software Foundation, Inc. | 1 | /* Copyright (C) 1992-2001, 2003, 2004, 2005 Free Software Foundation, Inc. |
2 | This file is part of the GNU C Library. | 2 | This file is part of the GNU C Library. |
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 |
... | @@ -15,47 +15,32 @@ | ... | @@ -15,47 +15,32 @@ |
15 | with this program; if not, write to the Free Software Foundation, | 15 | 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 | #if HAVE_CONFIG_H | 18 | #ifdef HAVE_CONFIG_H |
19 | # include <config.h> | 19 | # include <config.h> |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | #if !_LIBC | 22 | #include "getpass.h" |
23 | # include "getpass.h" | ||
24 | #endif | ||
25 | 23 | ||
26 | #if _LIBC | 24 | #include <stdio.h> |
27 | # define HAVE_STDIO_EXT_H 1 | 25 | |
28 | #endif | 26 | #if !defined _WIN32 |
29 | 27 | ||
30 | #include <stdbool.h> | 28 | #include <stdbool.h> |
31 | 29 | ||
32 | #include <stdio.h> | ||
33 | #if HAVE_STDIO_EXT_H | 30 | #if HAVE_STDIO_EXT_H |
34 | # include <stdio_ext.h> | 31 | # include <stdio_ext.h> |
35 | #else | ||
36 | # define __fsetlocking(stream, type) /* empty */ | ||
37 | #endif | 32 | #endif |
38 | #if !_LIBC | 33 | #if !HAVE___FSETLOCKING |
39 | # include "getline.h" | 34 | # define __fsetlocking(stream, type) /* empty */ |
40 | #endif | 35 | #endif |
41 | 36 | ||
42 | #include <termios.h> | 37 | #if HAVE_TERMIOS_H |
43 | #include <unistd.h> | 38 | # include <termios.h> |
44 | |||
45 | #if _LIBC | ||
46 | # include <wchar.h> | ||
47 | #endif | 39 | #endif |
48 | 40 | ||
49 | #if _LIBC | 41 | #include "getline.h" |
50 | # define NOTCANCEL_MODE "c" | ||
51 | #else | ||
52 | # define NOTCANCEL_MODE | ||
53 | #endif | ||
54 | 42 | ||
55 | #if _LIBC | 43 | #if USE_UNLOCKED_IO |
56 | # define flockfile(s) _IO_flockfile (s) | ||
57 | # define funlockfile(s) _IO_funlockfile (s) | ||
58 | #elif USE_UNLOCKED_IO | ||
59 | # include "unlocked-io.h" | 44 | # include "unlocked-io.h" |
60 | #else | 45 | #else |
61 | # if !HAVE_DECL_FFLUSH_UNLOCKED | 46 | # if !HAVE_DECL_FFLUSH_UNLOCKED |
... | @@ -80,18 +65,6 @@ | ... | @@ -80,18 +65,6 @@ |
80 | # endif | 65 | # endif |
81 | #endif | 66 | #endif |
82 | 67 | ||
83 | #if _LIBC | ||
84 | # include <bits/libc-lock.h> | ||
85 | #else | ||
86 | # define __libc_cleanup_push(function, arg) /* empty */ | ||
87 | # define __libc_cleanup_pop(execute) /* empty */ | ||
88 | #endif | ||
89 | |||
90 | #if !_LIBC | ||
91 | # define __getline getline | ||
92 | # define __tcgetattr tcgetattr | ||
93 | #endif | ||
94 | |||
95 | /* It is desirable to use this bit on systems that have it. | 68 | /* It is desirable to use this bit on systems that have it. |
96 | The only bit of terminal state we want to twiddle is echoing, which is | 69 | The only bit of terminal state we want to twiddle is echoing, which is |
97 | done in software; there is no need to change the state of the terminal | 70 | done in software; there is no need to change the state of the terminal |
... | @@ -114,7 +87,7 @@ getpass (const char *prompt) | ... | @@ -114,7 +87,7 @@ getpass (const char *prompt) |
114 | FILE *tty; | 87 | FILE *tty; |
115 | FILE *in, *out; | 88 | FILE *in, *out; |
116 | struct termios s, t; | 89 | struct termios s, t; |
117 | bool tty_changed; | 90 | bool tty_changed = false; |
118 | static char *buf; | 91 | static char *buf; |
119 | static size_t bufsize; | 92 | static size_t bufsize; |
120 | ssize_t nread; | 93 | ssize_t nread; |
... | @@ -122,7 +95,7 @@ getpass (const char *prompt) | ... | @@ -122,7 +95,7 @@ getpass (const char *prompt) |
122 | /* Try to write to and read from the terminal if we can. | 95 | /* Try to write to and read from the terminal if we can. |
123 | If we can't open the terminal, use stderr and stdin. */ | 96 | If we can't open the terminal, use stderr and stdin. */ |
124 | 97 | ||
125 | tty = fopen ("/dev/tty", "w+" NOTCANCEL_MODE); | 98 | tty = fopen ("/dev/tty", "w+"); |
126 | if (tty == NULL) | 99 | if (tty == NULL) |
127 | { | 100 | { |
128 | in = stdin; | 101 | in = stdin; |
... | @@ -136,39 +109,26 @@ getpass (const char *prompt) | ... | @@ -136,39 +109,26 @@ getpass (const char *prompt) |
136 | out = in = tty; | 109 | out = in = tty; |
137 | } | 110 | } |
138 | 111 | ||
139 | /* Make sure the stream we opened is closed even if the thread is | ||
140 | canceled. */ | ||
141 | __libc_cleanup_push (call_fclose, tty); | ||
142 | |||
143 | flockfile (out); | 112 | flockfile (out); |
144 | 113 | ||
145 | /* Turn echoing off if it is on now. */ | 114 | /* Turn echoing off if it is on now. */ |
146 | 115 | #if HAVE_TCGETATTR | |
147 | if (__tcgetattr (fileno (in), &t) == 0) | 116 | if (tcgetattr (fileno (in), &t) == 0) |
148 | { | 117 | { |
149 | /* Save the old one. */ | 118 | /* Save the old one. */ |
150 | s = t; | 119 | s = t; |
151 | /* Tricky, tricky. */ | 120 | /* Tricky, tricky. */ |
152 | t.c_lflag &= ~(ECHO|ISIG); | 121 | t.c_lflag &= ~(ECHO | ISIG); |
153 | tty_changed = (tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &t) == 0); | 122 | tty_changed = (tcsetattr (fileno (in), TCSAFLUSH | TCSASOFT, &t) == 0); |
154 | } | 123 | } |
155 | else | 124 | #endif |
156 | tty_changed = false; | ||
157 | 125 | ||
158 | /* Write the prompt. */ | 126 | /* Write the prompt. */ |
159 | #ifdef USE_IN_LIBIO | 127 | fputs_unlocked (prompt, out); |
160 | if (_IO_fwide (out, 0) > 0) | ||
161 | __fwprintf (out, L"%s", prompt); | ||
162 | else | ||
163 | #endif | ||
164 | fputs_unlocked (prompt, out); | ||
165 | fflush_unlocked (out); | 128 | fflush_unlocked (out); |
166 | 129 | ||
167 | /* Read the password. */ | 130 | /* Read the password. */ |
168 | nread = __getline (&buf, &bufsize, in); | 131 | nread = getline (&buf, &bufsize, in); |
169 | |||
170 | #if !_LIBC | ||
171 | /* As far as is known, glibc doesn't need this no-op fseek. */ | ||
172 | 132 | ||
173 | /* According to the C standard, input may not be followed by output | 133 | /* According to the C standard, input may not be followed by output |
174 | on the same stream without an intervening call to a file | 134 | on the same stream without an intervening call to a file |
... | @@ -180,7 +140,6 @@ getpass (const char *prompt) | ... | @@ -180,7 +140,6 @@ getpass (const char *prompt) |
180 | from POSIX version to POSIX version, so play it safe and invoke | 140 | from POSIX version to POSIX version, so play it safe and invoke |
181 | fseek even if in != out. */ | 141 | fseek even if in != out. */ |
182 | fseek (out, 0, SEEK_CUR); | 142 | fseek (out, 0, SEEK_CUR); |
183 | #endif | ||
184 | 143 | ||
185 | if (buf != NULL) | 144 | if (buf != NULL) |
186 | { | 145 | { |
... | @@ -193,25 +152,75 @@ getpass (const char *prompt) | ... | @@ -193,25 +152,75 @@ getpass (const char *prompt) |
193 | if (tty_changed) | 152 | if (tty_changed) |
194 | { | 153 | { |
195 | /* Write the newline that was not echoed. */ | 154 | /* Write the newline that was not echoed. */ |
196 | #ifdef USE_IN_LIBIO | 155 | putc_unlocked ('\n', out); |
197 | if (_IO_fwide (out, 0) > 0) | ||
198 | putwc_unlocked (L'\n', out); | ||
199 | else | ||
200 | #endif | ||
201 | putc_unlocked ('\n', out); | ||
202 | } | 156 | } |
203 | } | 157 | } |
204 | } | 158 | } |
205 | 159 | ||
206 | /* Restore the original setting. */ | 160 | /* Restore the original setting. */ |
161 | #if HAVE_TCSETATTR | ||
207 | if (tty_changed) | 162 | if (tty_changed) |
208 | (void) tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &s); | 163 | tcsetattr (fileno (in), TCSAFLUSH | TCSASOFT, &s); |
164 | #endif | ||
209 | 165 | ||
210 | funlockfile (out); | 166 | funlockfile (out); |
211 | 167 | ||
212 | __libc_cleanup_pop (0); | ||
213 | |||
214 | call_fclose (tty); | 168 | call_fclose (tty); |
215 | 169 | ||
216 | return buf; | 170 | return buf; |
217 | } | 171 | } |
172 | |||
173 | #else /* WIN32 */ | ||
174 | |||
175 | /* Windows implementation by Martin Lambers <marlam@marlam.de>, | ||
176 | improved by Simon Josefsson. */ | ||
177 | |||
178 | /* For PASS_MAX. */ | ||
179 | #include <limits.h> | ||
180 | |||
181 | #ifndef PASS_MAX | ||
182 | # define PASS_MAX 512 | ||
183 | #endif | ||
184 | |||
185 | char * | ||
186 | getpass (const char *prompt) | ||
187 | { | ||
188 | char getpassbuf[PASS_MAX + 1]; | ||
189 | size_t i = 0; | ||
190 | int c; | ||
191 | |||
192 | if (prompt) | ||
193 | { | ||
194 | fputs (prompt, stderr); | ||
195 | fflush (stderr); | ||
196 | } | ||
197 | |||
198 | for (;;) | ||
199 | { | ||
200 | c = _getch (); | ||
201 | if (c == '\r') | ||
202 | { | ||
203 | getpassbuf[i] = '\0'; | ||
204 | break; | ||
205 | } | ||
206 | else if (i < PASS_MAX) | ||
207 | { | ||
208 | getpassbuf[i++] = c; | ||
209 | } | ||
210 | |||
211 | if (i >= PASS_MAX) | ||
212 | { | ||
213 | getpassbuf[i] = '\0'; | ||
214 | break; | ||
215 | } | ||
216 | } | ||
217 | |||
218 | if (prompt) | ||
219 | { | ||
220 | fputs ("\r\n", stderr); | ||
221 | fflush (stderr); | ||
222 | } | ||
223 | |||
224 | return strdup (getpassbuf); | ||
225 | } | ||
226 | #endif | ... | ... |
... | @@ -53,12 +53,25 @@ | ... | @@ -53,12 +53,25 @@ |
53 | ? (t) -1 \ | 53 | ? (t) -1 \ |
54 | : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) | 54 | : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) |
55 | 55 | ||
56 | /* Return zero if T can be determined to be an unsigned type. | ||
57 | Otherwise, return 1. | ||
58 | When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a | ||
59 | tighter bound. Otherwise, it overestimates the true bound by one byte | ||
60 | when applied to unsigned types of size 2, 4, 16, ... bytes. | ||
61 | The symbol signed_type_or_expr__ is private to this header file. */ | ||
62 | #if __GNUC__ >= 2 | ||
63 | # define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t)) | ||
64 | #else | ||
65 | # define signed_type_or_expr__(t) 1 | ||
66 | #endif | ||
67 | |||
56 | /* Bound on length of the string representing an integer type or expression T. | 68 | /* Bound on length of the string representing an integer type or expression T. |
57 | Subtract 1 for the sign bit if t is signed; log10 (2.0) < 146/485; | 69 | Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485; |
58 | add 1 for integer division truncation; add 1 more for a minus sign | 70 | add 1 for integer division truncation; add 1 more for a minus sign |
59 | if needed. */ | 71 | if needed. */ |
60 | #define INT_STRLEN_BOUND(t) \ | 72 | #define INT_STRLEN_BOUND(t) \ |
61 | ((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2) | 73 | ((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \ |
74 | + signed_type_or_expr__ (t) + 1) | ||
62 | 75 | ||
63 | /* Bound on buffer size needed to represent an integer type or expression T, | 76 | /* Bound on buffer size needed to represent an integer type or expression T, |
64 | including the terminating null. */ | 77 | including the terminating null. */ | ... | ... |
... | @@ -51,10 +51,6 @@ | ... | @@ -51,10 +51,6 @@ |
51 | # endif | 51 | # endif |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #if defined _LIBC && defined USE_IN_LIBIO | ||
55 | # include <wchar.h> | ||
56 | #endif | ||
57 | |||
58 | #include <stddef.h> | 54 | #include <stddef.h> |
59 | 55 | ||
60 | #ifndef ELIDE_CODE | 56 | #ifndef ELIDE_CODE |
... | @@ -433,12 +429,11 @@ print_and_abort (void) | ... | @@ -433,12 +429,11 @@ print_and_abort (void) |
433 | happen because the "memory exhausted" message appears in other places | 429 | happen because the "memory exhausted" message appears in other places |
434 | like this and the translation should be reused instead of creating | 430 | like this and the translation should be reused instead of creating |
435 | a very similar string which requires a separate translation. */ | 431 | a very similar string which requires a separate translation. */ |
436 | # if defined _LIBC && defined USE_IN_LIBIO | 432 | # ifdef _LIBC |
437 | if (_IO_fwide (stderr, 0) > 0) | 433 | (void) __fxprintf (NULL, "%s\n", _("memory exhausted")); |
438 | __fwprintf (stderr, L"%s\n", _("memory exhausted")); | 434 | # else |
439 | else | 435 | fprintf (stderr, "%s\n", _("memory exhausted")); |
440 | # endif | 436 | # endif |
441 | fprintf (stderr, "%s\n", _("memory exhausted")); | ||
442 | exit (obstack_exit_failure); | 437 | exit (obstack_exit_failure); |
443 | } | 438 | } |
444 | 439 | ... | ... |
1 | /* obstack.h - object stack macros | 1 | /* obstack.h - object stack macros |
2 | Copyright (C) 1988-1994,1996-1999,2003,2004 Free Software Foundation, Inc. | 2 | Copyright (C) 1988-1994,1996-1999,2003,2004,2005 |
3 | 3 | Free Software Foundation, Inc. | |
4 | This file is part of the GNU C Library. Its master source is NOT part of | 4 | This file is part of the GNU C Library. |
5 | the C library, however. The master source lives in /gd/gnu/lib. | ||
6 | |||
7 | NOTE: The canonical source of this file is maintained with the GNU C Library. | ||
8 | Bugs can be reported to bug-glibc@gnu.org. | ||
9 | 5 | ||
10 | 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 |
11 | 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 |
... | @@ -464,7 +460,7 @@ __extension__ \ | ... | @@ -464,7 +460,7 @@ __extension__ \ |
464 | (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr)) | 460 | (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr)) |
465 | 461 | ||
466 | # define obstack_int_grow_fast(h,aint) \ | 462 | # define obstack_int_grow_fast(h,aint) \ |
467 | (((int *) ((h)->next_free += sizeof (int)))[-1] = (aptr)) | 463 | (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint)) |
468 | 464 | ||
469 | # define obstack_blank(h,length) \ | 465 | # define obstack_blank(h,length) \ |
470 | ( (h)->temp.tempint = (length), \ | 466 | ( (h)->temp.tempint = (length), \ | ... | ... |
... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
17 | along with this program; if not, write to the Free Software Foundation, | 17 | along with this program; if not, write to the Free Software Foundation, |
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
19 | 19 | ||
20 | #if HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | # include <config.h> | 21 | # include <config.h> |
22 | #endif | 22 | #endif |
23 | 23 | ... | ... |
... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
17 | along with this program; if not, write to the Free Software Foundation, | 17 | along with this program; if not, write to the Free Software Foundation, |
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
19 | 19 | ||
20 | #if HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | # include <config.h> | 21 | # include <config.h> |
22 | #endif | 22 | #endif |
23 | 23 | ... | ... |
... | @@ -3,7 +3,8 @@ | ... | @@ -3,7 +3,8 @@ |
3 | # This is a modified version of autoconf's AC_FUNC_FNMATCH. | 3 | # This is a modified version of autoconf's AC_FUNC_FNMATCH. |
4 | # This file should be simplified after Autoconf 2.57 is required. | 4 | # This file should be simplified after Autoconf 2.57 is required. |
5 | 5 | ||
6 | # Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. | 6 | # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software |
7 | # Foundation, Inc. | ||
7 | # This file is free software; the Free Software Foundation | 8 | # This file is free software; the Free Software Foundation |
8 | # gives unlimited permission to copy and/or distribute it, | 9 | # gives unlimited permission to copy and/or distribute it, |
9 | # with or without modifications, as long as this notice is preserved. | 10 | # with or without modifications, as long as this notice is preserved. |
... | @@ -27,9 +28,15 @@ AC_DEFUN([_AC_FUNC_FNMATCH_IF], | ... | @@ -27,9 +28,15 @@ AC_DEFUN([_AC_FUNC_FNMATCH_IF], |
27 | # include <fnmatch.h> | 28 | # include <fnmatch.h> |
28 | # define y(a, b, c) (fnmatch (a, b, c) == 0) | 29 | # define y(a, b, c) (fnmatch (a, b, c) == 0) |
29 | # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH) | 30 | # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH) |
31 | static int | ||
32 | fnm (char const *pattern, char const *string, int flags) | ||
33 | { | ||
34 | return fnmatch (pattern, string, flags); | ||
35 | } | ||
30 | ], | 36 | ], |
31 | [exit | 37 | [exit |
32 | (!(y ("a*", "abc", 0) | 38 | (!((fnm ? fnm : fnmatch) ("a*", "", 0) == FNM_NOMATCH |
39 | && y ("a*", "abc", 0) | ||
33 | && n ("d*/*1", "d/s/1", FNM_PATHNAME) | 40 | && n ("d*/*1", "d/s/1", FNM_PATHNAME) |
34 | && y ("a\\\\bc", "abc", 0) | 41 | && y ("a\\\\bc", "abc", 0) |
35 | && n ("a\\\\bc", "abc", FNM_NOESCAPE) | 42 | && n ("a\\\\bc", "abc", FNM_NOESCAPE) |
... | @@ -50,19 +57,19 @@ AS_IF([test $$2 = yes], [$3], [$4]) | ... | @@ -50,19 +57,19 @@ AS_IF([test $$2 = yes], [$3], [$4]) |
50 | ])# _AC_FUNC_FNMATCH_IF | 57 | ])# _AC_FUNC_FNMATCH_IF |
51 | 58 | ||
52 | 59 | ||
53 | # _AC_LIBOBJ_FNMATCH | 60 | # _MU_LIBOBJ_FNMATCH |
54 | # ------------------ | 61 | # ------------------ |
55 | # Prepare the replacement of fnmatch. | 62 | # Prepare the replacement of fnmatch. |
56 | AC_DEFUN([_AC_LIBOBJ_FNMATCH], | 63 | AC_DEFUN([_MU_LIBOBJ_FNMATCH], |
57 | [AC_REQUIRE([AC_C_CONST])dnl | 64 | [AC_REQUIRE([AC_C_CONST])dnl |
58 | AC_REQUIRE([AC_FUNC_ALLOCA])dnl | 65 | AC_REQUIRE([AC_FUNC_ALLOCA])dnl |
59 | AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl | 66 | AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl |
60 | AC_CHECK_DECLS([getenv]) | 67 | AC_CHECK_DECLS([getenv]) |
61 | AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy]) | 68 | AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy]) |
62 | AC_CHECK_HEADERS([wchar.h wctype.h]) | 69 | AC_CHECK_HEADERS([wchar.h wctype.h]) |
63 | AC_LIBOBJ([fnmatch]) | 70 | MU_LIBOBJ([fnmatch]) |
64 | FNMATCH_H=fnmatch.h | 71 | FNMATCH_H=fnmatch.h |
65 | ])# _AC_LIBOBJ_FNMATCH | 72 | ])# _MU_LIBOBJ_FNMATCH |
66 | 73 | ||
67 | 74 | ||
68 | AC_DEFUN([gl_FUNC_FNMATCH_POSIX], | 75 | AC_DEFUN([gl_FUNC_FNMATCH_POSIX], |
... | @@ -70,7 +77,7 @@ AC_DEFUN([gl_FUNC_FNMATCH_POSIX], | ... | @@ -70,7 +77,7 @@ AC_DEFUN([gl_FUNC_FNMATCH_POSIX], |
70 | FNMATCH_H= | 77 | FNMATCH_H= |
71 | _AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_posix], | 78 | _AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_posix], |
72 | [rm -f lib/fnmatch.h], | 79 | [rm -f lib/fnmatch.h], |
73 | [_AC_LIBOBJ_FNMATCH]) | 80 | [_MU_LIBOBJ_FNMATCH]) |
74 | if test $ac_cv_func_fnmatch_posix != yes; then | 81 | if test $ac_cv_func_fnmatch_posix != yes; then |
75 | dnl We must choose a different name for our function, since on ELF systems | 82 | dnl We must choose a different name for our function, since on ELF systems |
76 | dnl a broken fnmatch() in libc.so would override our fnmatch() if it is | 83 | dnl a broken fnmatch() in libc.so would override our fnmatch() if it is |
... | @@ -90,7 +97,7 @@ AC_DEFUN([gl_FUNC_FNMATCH_GNU], | ... | @@ -90,7 +97,7 @@ AC_DEFUN([gl_FUNC_FNMATCH_GNU], |
90 | FNMATCH_H= | 97 | FNMATCH_H= |
91 | _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu], | 98 | _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu], |
92 | [rm -f lib/fnmatch.h], | 99 | [rm -f lib/fnmatch.h], |
93 | [_AC_LIBOBJ_FNMATCH]) | 100 | [_MU_LIBOBJ_FNMATCH]) |
94 | if test $ac_cv_func_fnmatch_gnu != yes; then | 101 | if test $ac_cv_func_fnmatch_gnu != yes; then |
95 | dnl We must choose a different name for our function, since on ELF systems | 102 | dnl We must choose a different name for our function, since on ELF systems |
96 | dnl a broken fnmatch() in libc.so would override our fnmatch() if it is | 103 | dnl a broken fnmatch() in libc.so would override our fnmatch() if it is | ... | ... |
1 | # getopt.m4 serial 10 | 1 | # getopt.m4 serial 11 |
2 | dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002, 2003, 2004, 2005 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, |
... | @@ -27,8 +27,10 @@ AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], | ... | @@ -27,8 +27,10 @@ AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], |
27 | 27 | ||
28 | AC_DEFUN([gl_GETOPT_CHECK_HEADERS], | 28 | AC_DEFUN([gl_GETOPT_CHECK_HEADERS], |
29 | [ | 29 | [ |
30 | GETOPT_H= | 30 | if test -z "$GETOPT_H"; then |
31 | AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h]) | 31 | AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h]) |
32 | fi | ||
33 | |||
32 | if test -z "$GETOPT_H"; then | 34 | if test -z "$GETOPT_H"; then |
33 | AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h]) | 35 | AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h]) |
34 | fi | 36 | fi | ... | ... |
... | @@ -35,7 +35,7 @@ AC_DEFUN([gl_FUNC_GETPASS_GNU], | ... | @@ -35,7 +35,7 @@ AC_DEFUN([gl_FUNC_GETPASS_GNU], |
35 | 35 | ||
36 | # Prerequisites of lib/getpass.c. | 36 | # Prerequisites of lib/getpass.c. |
37 | AC_DEFUN([gl_PREREQ_GETPASS], [ | 37 | AC_DEFUN([gl_PREREQ_GETPASS], [ |
38 | AC_CHECK_HEADERS_ONCE(stdio_ext.h) | 38 | AC_CHECK_HEADERS_ONCE(stdio_ext.h termios.h) |
39 | AC_CHECK_FUNCS_ONCE(__fsetlocking tcgetattr tcsetattr) | ||
39 | AC_CHECK_DECLS_ONCE([fflush_unlocked flockfile fputs_unlocked funlockfile putc_unlocked]) | 40 | AC_CHECK_DECLS_ONCE([fflush_unlocked flockfile fputs_unlocked funlockfile putc_unlocked]) |
40 | : | ||
41 | ]) | 41 | ]) | ... | ... |
1 | # inttypes.m4 serial 1 (gettext-0.11.4) | 1 | # inttypes.m4 serial 1 (gettext-0.11.4) |
2 | dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 1997-2002 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; the Free Software Foundation |
4 | dnl General Public License. As a special exception to the GNU General | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl Public License, this file may be distributed as part of a program | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | dnl that contains a configuration script generated by Autoconf, under | ||
7 | dnl the same distribution terms as the rest of that program. | ||
8 | 6 | ||
9 | dnl From Paul Eggert. | 7 | dnl From Paul Eggert. |
10 | 8 | ... | ... |
1 | # longdouble.m4 serial 1 (gettext-0.12) | 1 | # longdouble.m4 serial 1 (gettext-0.12) |
2 | dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002-2003 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; the Free Software Foundation |
4 | dnl General Public License. As a special exception to the GNU General | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl Public License, this file may be distributed as part of a program | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | dnl that contains a configuration script generated by Autoconf, under | ||
7 | dnl the same distribution terms as the rest of that program. | ||
8 | 6 | ||
9 | dnl From Bruno Haible. | 7 | dnl From Bruno Haible. |
10 | dnl Test whether the compiler supports the 'long double' type. | 8 | dnl Test whether the compiler supports the 'long double' type. | ... | ... |
1 | # mbchar.m4 serial 1 | 1 | # mbchar.m4 serial 2 |
2 | dnl Copyright (C) 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2005 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, |
... | @@ -10,5 +10,11 @@ dnl From Bruno Haible. | ... | @@ -10,5 +10,11 @@ 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 | : | 13 | dnl The following line is that so the user can test |
14 | dnl HAVE_WCHAR_H && HAVE_WCTYPE_H before #include "mbchar.h". | ||
15 | AC_CHECK_HEADERS_ONCE(wchar.h wctype.h) | ||
16 | dnl Compile mbchar.c only if HAVE_WCHAR_H && HAVE_WCTYPE_H. | ||
17 | if test $ac_cv_header_wchar_h = yes && test $ac_cv_header_wctype_h = yes; then | ||
18 | MU_LIBOBJ([mbchar]) | ||
19 | fi | ||
14 | ]) | 20 | ]) | ... | ... |
1 | # md5.m4 serial 7 | 1 | # md5.m4 serial 8 |
2 | dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002, 2003, 2004, 2005 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, |
... | @@ -9,9 +9,6 @@ AC_DEFUN([gl_MD5], | ... | @@ -9,9 +9,6 @@ AC_DEFUN([gl_MD5], |
9 | MU_LIBSOURCES([md5.c, md5.h]) | 9 | MU_LIBSOURCES([md5.c, md5.h]) |
10 | MU_LIBOBJ([md5]) | 10 | MU_LIBOBJ([md5]) |
11 | 11 | ||
12 | dnl Prerequisites of lib/md5.h. | ||
13 | AC_REQUIRE([gl_AC_TYPE_UINT32_T]) | ||
14 | |||
15 | dnl Prerequisites of lib/md5.c. | 12 | dnl Prerequisites of lib/md5.c. |
16 | AC_REQUIRE([AC_C_BIGENDIAN]) | 13 | AC_REQUIRE([AC_C_BIGENDIAN]) |
17 | : | 14 | : | ... | ... |
1 | # minmax.m4 serial 1 | 1 | # minmax.m4 serial 2 |
2 | dnl Copyright (C) 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2005 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_PREREQ(2.52) | ||
8 | |||
7 | AC_DEFUN([gl_MINMAX], | 9 | AC_DEFUN([gl_MINMAX], |
8 | [ | 10 | [ |
9 | AC_REQUIRE([gl_PREREQ_MINMAX]) | 11 | AC_REQUIRE([gl_PREREQ_MINMAX]) |
... | @@ -17,12 +19,13 @@ AC_DEFUN([gl_PREREQ_MINMAX], | ... | @@ -17,12 +19,13 @@ AC_DEFUN([gl_PREREQ_MINMAX], |
17 | ]) | 19 | ]) |
18 | 20 | ||
19 | dnl gl_MINMAX_IN_HEADER(HEADER) | 21 | dnl gl_MINMAX_IN_HEADER(HEADER) |
22 | dnl The parameter has to be a literal header name; it cannot be macro, | ||
23 | dnl nor a shell variable. (Because autoheader collects only AC_DEFINE | ||
24 | dnl invocations with a literal macro name.) | ||
20 | AC_DEFUN([gl_MINMAX_IN_HEADER], | 25 | AC_DEFUN([gl_MINMAX_IN_HEADER], |
21 | [ | 26 | [ |
22 | define([header],[translit([$1],[./-], | 27 | m4_pushdef([header], AS_TR_SH([$1])) |
23 | [___])]) | 28 | m4_pushdef([HEADER], AS_TR_CPP([$1])) |
24 | define([HEADER],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], | ||
25 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) | ||
26 | AC_CACHE_CHECK([whether <$1> defines MIN and MAX], | 29 | AC_CACHE_CHECK([whether <$1> defines MIN and MAX], |
27 | [gl_cv_minmax_in_]header, | 30 | [gl_cv_minmax_in_]header, |
28 | [AC_TRY_COMPILE([#include <$1> | 31 | [AC_TRY_COMPILE([#include <$1> |
... | @@ -33,6 +36,6 @@ int x = MIN (42, 17);], [], | ... | @@ -33,6 +36,6 @@ int x = MIN (42, 17);], [], |
33 | AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1, | 36 | AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1, |
34 | [Define to 1 if <$1> defines the MIN and MAX macros.]) | 37 | [Define to 1 if <$1> defines the MIN and MAX macros.]) |
35 | fi | 38 | fi |
36 | undefine([HEADER]) | 39 | m4_popdef([HEADER]) |
37 | undefine([header]) | 40 | m4_popdef([header]) |
38 | ]) | 41 | ]) | ... | ... |
1 | #serial 24 | 1 | #serial 30 |
2 | 2 | ||
3 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free | 3 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free |
4 | # Software Foundation, Inc. | 4 | # Software Foundation, Inc. |
... | @@ -10,121 +10,155 @@ | ... | @@ -10,121 +10,155 @@ |
10 | dnl Initially derived from code in GNU grep. | 10 | dnl Initially derived from code in GNU grep. |
11 | dnl Mostly written by Jim Meyering. | 11 | dnl Mostly written by Jim Meyering. |
12 | 12 | ||
13 | AC_PREREQ([2.50]) | ||
14 | |||
13 | AC_DEFUN([gl_REGEX], | 15 | AC_DEFUN([gl_REGEX], |
14 | [ | 16 | [ |
15 | gl_INCLUDED_REGEX([lib/regex.c]) | 17 | AC_REQUIRE([AC_SYS_LARGEFILE]) dnl for a sufficently-wide off_t |
16 | ]) | 18 | AC_DEFINE([_REGEX_LARGE_OFFSETS], 1, |
17 | 19 | [Define if you want regoff_t to be at least as wide POSIX requires.]) | |
18 | dnl Usage: gl_INCLUDED_REGEX([lib/regex.c]) | 20 | |
19 | dnl | 21 | MU_LIBSOURCES( |
20 | AC_DEFUN([gl_INCLUDED_REGEX], | 22 | [regcomp.c, regex.c, regex.h, |
21 | [ | 23 | regex_internal.c, regex_internal.h, regexec.c]) |
22 | MU_LIBSOURCES( | 24 | |
23 | [regcomp.c, regex.c, regex.h, | 25 | AC_ARG_WITH([included-regex], |
24 | regex_internal.c, regex_internal.h, regexec.c]) | 26 | [AC_HELP_STRING([--without-included-regex], |
25 | 27 | [don't compile regex; this is the default on | |
26 | dnl Even packages that don't use regex.c can use this macro. | 28 | systems with recent-enough versions of the GNU C |
27 | dnl Of course, for them it doesn't do anything. | 29 | Library (use with caution on other systems)])]) |
28 | 30 | ||
29 | # Assume we'll default to using the included regex.c. | 31 | case $with_included_regex in |
30 | ac_use_included_regex=yes | 32 | yes|no) ac_use_included_regex=$with_included_regex |
31 | 33 | ;; | |
32 | # However, if the system regex support is good enough that it passes the | 34 | '') |
33 | # the following run test, then default to *not* using the included regex.c. | 35 | # If the system regex support is good enough that it passes the the |
36 | # following run test, then default to *not* using the included regex.c. | ||
34 | # If cross compiling, assume the test would fail and use the included | 37 | # If cross compiling, assume the test would fail and use the included |
35 | # regex.c. The first failing regular expression is from `Spencer ere | 38 | # regex.c. The first failing regular expression is from `Spencer ere |
36 | # test #75' in grep-2.3. | 39 | # test #75' in grep-2.3. |
37 | AC_CACHE_CHECK([for working re_compile_pattern], | 40 | AC_CACHE_CHECK([for working re_compile_pattern], |
38 | [gl_cv_func_working_re_compile_pattern], | 41 | [gl_cv_func_re_compile_pattern_broken], |
39 | [AC_RUN_IFELSE( | 42 | [AC_RUN_IFELSE( |
40 | [AC_LANG_PROGRAM( | 43 | [AC_LANG_PROGRAM( |
41 | [AC_INCLUDES_DEFAULT | 44 | [AC_INCLUDES_DEFAULT |
42 | #include <regex.h>], | 45 | #include <regex.h>], |
43 | [[static struct re_pattern_buffer regex; | 46 | [[static struct re_pattern_buffer regex; |
44 | const char *s; | 47 | const char *s; |
45 | struct re_registers regs; | 48 | struct re_registers regs; |
46 | re_set_syntax (RE_SYNTAX_POSIX_EGREP); | 49 | /* Use the POSIX-compliant spelling with leading REG_, |
47 | memset (®ex, 0, sizeof (regex)); | 50 | rather than the traditional GNU spelling with leading RE_, |
48 | s = re_compile_pattern ("a[:@:>@:]b\n", 9, ®ex); | 51 | so that we reject older libc implementations. */ |
49 | /* This should fail with _Invalid character class name_ error. */ | 52 | re_set_syntax (REG_SYNTAX_POSIX_EGREP); |
50 | if (!s) | 53 | memset (®ex, 0, sizeof (regex)); |
51 | exit (1); | 54 | s = re_compile_pattern ("a[:@:>@:]b\n", 9, ®ex); |
52 | 55 | /* This should fail with _Invalid character class name_ error. */ | |
53 | /* This should succeed, but does not for e.g. glibc-2.1.3. */ | 56 | if (!s) |
54 | memset (®ex, 0, sizeof (regex)); | 57 | exit (1); |
55 | s = re_compile_pattern ("{1", 2, ®ex); | 58 | |
56 | 59 | /* This should succeed, but does not for e.g. glibc-2.1.3. */ | |
57 | if (s) | 60 | memset (®ex, 0, sizeof (regex)); |
58 | exit (1); | 61 | s = re_compile_pattern ("{1", 2, ®ex); |
59 | 62 | ||
60 | /* The following example is derived from a problem report | 63 | if (s) |
61 | against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */ | 64 | exit (1); |
62 | memset (®ex, 0, sizeof (regex)); | 65 | |
63 | s = re_compile_pattern ("[an\371]*n", 7, ®ex); | 66 | /* The following example is derived from a problem report |
64 | if (s) | 67 | against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */ |
65 | exit (1); | 68 | memset (®ex, 0, sizeof (regex)); |
66 | 69 | s = re_compile_pattern ("[an\371]*n", 7, ®ex); | |
67 | /* This should match, but does not for e.g. glibc-2.2.1. */ | 70 | if (s) |
68 | if (re_match (®ex, "an", 2, 0, ®s) != 2) | 71 | exit (1); |
69 | exit (1); | 72 | |
70 | 73 | /* This should match, but does not for e.g. glibc-2.2.1. */ | |
71 | memset (®ex, 0, sizeof (regex)); | 74 | if (re_match (®ex, "an", 2, 0, ®s) != 2) |
72 | s = re_compile_pattern ("x", 1, ®ex); | 75 | exit (1); |
73 | if (s) | 76 | |
74 | exit (1); | 77 | memset (®ex, 0, sizeof (regex)); |
75 | 78 | s = re_compile_pattern ("x", 1, ®ex); | |
76 | /* The version of regex.c in e.g. GNU libc-2.2.93 did not | 79 | if (s) |
77 | work with a negative RANGE argument. */ | 80 | exit (1); |
78 | if (re_search (®ex, "wxy", 3, 2, -2, ®s) != 1) | 81 | |
79 | exit (1); | 82 | /* The version of regex.c in e.g. GNU libc-2.2.93 did not |
80 | 83 | work with a negative RANGE argument. */ | |
81 | /* The version of regex.c in older versions of gnulib | 84 | if (re_search (®ex, "wxy", 3, 2, -2, ®s) != 1) |
82 | * ignored RE_ICASE. Detect that problem too. */ | 85 | exit (1); |
83 | memset (®ex, 0, sizeof (regex)); | 86 | |
84 | re_set_syntax(RE_SYNTAX_EMACS|RE_ICASE); | 87 | /* The version of regex.c in older versions of gnulib |
85 | s = re_compile_pattern ("x", 1, ®ex); | 88 | ignored REG_IGNORE_CASE (which was then called RE_ICASE). |
86 | if (s) | 89 | Detect that problem too. */ |
87 | exit (1); | 90 | memset (®ex, 0, sizeof (regex)); |
88 | 91 | re_set_syntax (REG_SYNTAX_EMACS | REG_IGNORE_CASE); | |
89 | if (re_search (®ex, "WXY", 3, 0, 3, ®s) < 0) | 92 | s = re_compile_pattern ("x", 1, ®ex); |
90 | exit (1); | 93 | if (s) |
91 | 94 | exit (1); | |
92 | /* REG_STARTEND was added to glibc on 2004-01-15. | 95 | |
93 | Reject older versions. */ | 96 | if (re_search (®ex, "WXY", 3, 0, 3, ®s) < 0) |
94 | if (! REG_STARTEND) | 97 | exit (1); |
95 | exit (1); | 98 | |
96 | 99 | /* REG_STARTEND was added to glibc on 2004-01-15. | |
97 | exit (0);]])], | 100 | Reject older versions. */ |
98 | [gl_cv_func_working_re_compile_pattern=yes], | 101 | if (! REG_STARTEND) |
99 | [gl_cv_func_working_re_compile_pattern=no], | 102 | exit (1); |
100 | dnl When crosscompiling, assume it is broken. | 103 | |
101 | [gl_cv_func_working_re_compile_pattern=no])]) | 104 | /* Reject hosts whose regoff_t values are too narrow. |
102 | if test $gl_cv_func_working_re_compile_pattern = yes; then | 105 | These include glibc 2.3.5 on hosts with 64-bit off_t |
103 | ac_use_included_regex=no | 106 | and 32-bit int, and Solaris 10 on hosts with 32-bit int |
104 | fi | 107 | and _FILE_OFFSET_BITS=64. */ |
105 | 108 | if (sizeof (regoff_t) < sizeof (off_t)) | |
106 | test -n "$1" || AC_MSG_ERROR([missing argument]) | 109 | exit (1); |
107 | m4_syscmd([test -f '$1']) | 110 | |
108 | ifelse(m4_sysval, 0, | 111 | exit (0);]])], |
109 | [ | 112 | [gl_cv_func_re_compile_pattern_broken=no], |
110 | AC_ARG_WITH([included-regex], | 113 | [gl_cv_func_re_compile_pattern_broken=yes], |
111 | [ --without-included-regex don't compile regex; this is the default on | 114 | dnl When crosscompiling, assume it is broken. |
112 | systems with recent-enough versions of the GNU C | 115 | [gl_cv_func_re_compile_pattern_broken=yes])]) |
113 | Library (use with caution on other systems)], | 116 | ac_use_included_regex=$gl_cv_func_re_compile_pattern_broken |
114 | [gl_with_regex=$withval], | 117 | ;; |
115 | [gl_with_regex=$ac_use_included_regex]) | 118 | *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex]) |
116 | if test "X$gl_with_regex" = Xyes; then | 119 | ;; |
117 | MU_LIBOBJ([regex]) | 120 | esac |
118 | gl_PREREQ_REGEX | 121 | |
119 | fi | 122 | if test $ac_use_included_regex = yes; then |
120 | ], | 123 | AC_DEFINE([re_syntax_options], [rpl_re_syntax_options], |
121 | ) | 124 | [Define to rpl_re_syntax_options if the replacement should be used.]) |
122 | ] | 125 | AC_DEFINE([re_set_syntax], [rpl_re_set_syntax], |
123 | ) | 126 | [Define to rpl_re_set_syntax if the replacement should be used.]) |
127 | AC_DEFINE([re_compile_pattern], [rpl_re_compile_pattern], | ||
128 | [Define to rpl_re_compile_pattern if the replacement should be used.]) | ||
129 | AC_DEFINE([re_compile_fastmap], [rpl_re_compile_fastmap], | ||
130 | [Define to rpl_re_compile_fastmap if the replacement should be used.]) | ||
131 | AC_DEFINE([re_search], [rpl_re_search], | ||
132 | [Define to rpl_re_search if the replacement should be used.]) | ||
133 | AC_DEFINE([re_search_2], [rpl_re_search_2], | ||
134 | [Define to rpl_re_search_2 if the replacement should be used.]) | ||
135 | AC_DEFINE([re_match], [rpl_re_match], | ||
136 | [Define to rpl_re_match if the replacement should be used.]) | ||
137 | AC_DEFINE([re_match_2], [rpl_re_match_2], | ||
138 | [Define to rpl_re_match_2 if the replacement should be used.]) | ||
139 | AC_DEFINE([re_set_registers], [rpl_re_set_registers], | ||
140 | [Define to rpl_re_set_registers if the replacement should be used.]) | ||
141 | AC_DEFINE([re_comp], [rpl_re_comp], | ||
142 | [Define to rpl_re_comp if the replacement should be used.]) | ||
143 | AC_DEFINE([re_exec], [rpl_re_exec], | ||
144 | [Define to rpl_re_exec if the replacement should be used.]) | ||
145 | AC_DEFINE([regcomp], [rpl_regcomp], | ||
146 | [Define to rpl_regcomp if the replacement should be used.]) | ||
147 | AC_DEFINE([regexec], [rpl_regexec], | ||
148 | [Define to rpl_regexec if the replacement should be used.]) | ||
149 | AC_DEFINE([regerror], [rpl_regerror], | ||
150 | [Define to rpl_regerror if the replacement should be used.]) | ||
151 | AC_DEFINE([regfree], [rpl_regfree], | ||
152 | [Define to rpl_regfree if the replacement should be used.]) | ||
153 | MU_LIBOBJ([regex]) | ||
154 | gl_PREREQ_REGEX | ||
155 | fi | ||
156 | ]) | ||
124 | 157 | ||
125 | # Prerequisites of lib/regex.c and lib/regex_internal.c. | 158 | # Prerequisites of lib/regex.c and lib/regex_internal.c. |
126 | AC_DEFUN([gl_PREREQ_REGEX], | 159 | AC_DEFUN([gl_PREREQ_REGEX], |
127 | [ | 160 | [ |
161 | AC_REQUIRE([AC_GNU_SOURCE]) | ||
128 | AC_REQUIRE([gl_C_RESTRICT]) | 162 | AC_REQUIRE([gl_C_RESTRICT]) |
129 | AC_REQUIRE([AM_LANGINFO_CODESET]) | 163 | AC_REQUIRE([AM_LANGINFO_CODESET]) |
130 | AC_CHECK_HEADERS_ONCE([locale.h wchar.h wctype.h]) | 164 | AC_CHECK_HEADERS_ONCE([locale.h wchar.h wctype.h]) | ... | ... |
1 | # signed.m4 serial 1 (gettext-0.10.40) | 1 | # signed.m4 serial 1 (gettext-0.10.40) |
2 | dnl Copyright (C) 2001-2002 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2001-2002 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; the Free Software Foundation |
4 | dnl General Public License. As a special exception to the GNU General | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl Public License, this file may be distributed as part of a program | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | dnl that contains a configuration script generated by Autoconf, under | ||
7 | dnl the same distribution terms as the rest of that program. | ||
8 | 6 | ||
9 | dnl From Bruno Haible. | 7 | dnl From Bruno Haible. |
10 | 8 | ... | ... |
1 | # size_max.m4 serial 2 | 1 | # size_max.m4 serial 3 |
2 | dnl Copyright (C) 2003 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2003, 2005 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; the Free Software Foundation |
4 | dnl General Public License. As a special exception to the GNU General | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl Public License, this file may be distributed as part of a program | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | dnl that contains a configuration script generated by Autoconf, under | ||
7 | dnl the same distribution terms as the rest of that program. | ||
8 | 6 | ||
9 | dnl From Bruno Haible. | 7 | dnl From Bruno Haible. |
10 | 8 | ||
... | @@ -28,9 +26,9 @@ Found it | ... | @@ -28,9 +26,9 @@ Found it |
28 | dnl than the type 'unsigned long'. | 26 | dnl than the type 'unsigned long'. |
29 | dnl The _AC_COMPUTE_INT macro works up to LONG_MAX, since it uses 'expr', | 27 | dnl The _AC_COMPUTE_INT macro works up to LONG_MAX, since it uses 'expr', |
30 | dnl which is guaranteed to work from LONG_MIN to LONG_MAX. | 28 | dnl which is guaranteed to work from LONG_MIN to LONG_MAX. |
31 | _AC_COMPUTE_INT([~(size_t)0 / 10], res_hi, | 29 | _AC_COMPUTE_INT([(size_t)~(size_t)0 / 10], res_hi, |
32 | [#include <stddef.h>], result=?) | 30 | [#include <stddef.h>], result=?) |
33 | _AC_COMPUTE_INT([~(size_t)0 % 10], res_lo, | 31 | _AC_COMPUTE_INT([(size_t)~(size_t)0 % 10], res_lo, |
34 | [#include <stddef.h>], result=?) | 32 | [#include <stddef.h>], result=?) |
35 | _AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint, | 33 | _AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint, |
36 | [#include <stddef.h>], result=?) | 34 | [#include <stddef.h>], result=?) |
... | @@ -50,7 +48,7 @@ Found it | ... | @@ -50,7 +48,7 @@ Found it |
50 | fi | 48 | fi |
51 | else | 49 | else |
52 | dnl Shouldn't happen, but who knows... | 50 | dnl Shouldn't happen, but who knows... |
53 | result='~(size_t)0' | 51 | result='((size_t)~(size_t)0)' |
54 | fi | 52 | fi |
55 | fi | 53 | fi |
56 | AC_MSG_RESULT([$result]) | 54 | AC_MSG_RESULT([$result]) | ... | ... |
1 | # Check for stdbool.h that conforms to C99. | 1 | # Check for stdbool.h that conforms to C99. |
2 | 2 | ||
3 | dnl Copyright (C) 2002-2004 Free Software Foundation, Inc. | 3 | dnl Copyright (C) 2002-2005 Free Software Foundation, Inc. |
4 | dnl This file is free software; the Free Software Foundation | 4 | dnl This file is free software; the Free Software Foundation |
5 | dnl gives unlimited permission to copy and/or distribute it, | 5 | dnl gives unlimited permission to copy and/or distribute it, |
6 | dnl with or without modifications, as long as this notice is preserved. | 6 | dnl with or without modifications, as long as this notice is preserved. |
... | @@ -28,6 +28,9 @@ AC_DEFUN([AM_STDBOOL_H], | ... | @@ -28,6 +28,9 @@ AC_DEFUN([AM_STDBOOL_H], |
28 | AC_SUBST([HAVE__BOOL]) | 28 | AC_SUBST([HAVE__BOOL]) |
29 | ]) | 29 | ]) |
30 | 30 | ||
31 | # AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future. | ||
32 | AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H]) | ||
33 | |||
31 | # This macro is only needed in autoconf <= 2.59. Newer versions of autoconf | 34 | # This macro is only needed in autoconf <= 2.59. Newer versions of autoconf |
32 | # have this macro built-in. | 35 | # have this macro built-in. |
33 | 36 | ||
... | @@ -70,10 +73,12 @@ AC_DEFUN([AC_HEADER_STDBOOL], | ... | @@ -70,10 +73,12 @@ AC_DEFUN([AC_HEADER_STDBOOL], |
70 | enum { j = false, k = true, l = false * true, m = true * 256 }; | 73 | enum { j = false, k = true, l = false * true, m = true * 256 }; |
71 | _Bool n[m]; | 74 | _Bool n[m]; |
72 | char o[sizeof n == m * sizeof n[0] ? 1 : -1]; | 75 | char o[sizeof n == m * sizeof n[0] ? 1 : -1]; |
76 | char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; | ||
73 | ], | 77 | ], |
74 | [ | 78 | [ |
75 | return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k + !l | 79 | /* Refer to every declared value, to avoid compiler optimizations. */ |
76 | + !m + !n + !o); | 80 | return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l |
81 | + !m + !n + !o + !p); | ||
77 | ], | 82 | ], |
78 | [ac_cv_header_stdbool_h=yes], | 83 | [ac_cv_header_stdbool_h=yes], |
79 | [ac_cv_header_stdbool_h=no])]) | 84 | [ac_cv_header_stdbool_h=no])]) | ... | ... |
1 | # strcase.m4 serial 2 | 1 | # strcase.m4 serial 3 |
2 | dnl Copyright (C) 2002, 2005 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002, 2005 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, |
... | @@ -29,7 +29,8 @@ AC_DEFUN([gl_FUNC_STRNCASECMP], | ... | @@ -29,7 +29,8 @@ AC_DEFUN([gl_FUNC_STRNCASECMP], |
29 | 29 | ||
30 | # Prerequisites of lib/strcasecmp.c. | 30 | # Prerequisites of lib/strcasecmp.c. |
31 | AC_DEFUN([gl_PREREQ_STRCASECMP], [ | 31 | AC_DEFUN([gl_PREREQ_STRCASECMP], [ |
32 | gl_FUNC_MBRTOWC | 32 | AC_REQUIRE([gl_FUNC_MBRTOWC]) |
33 | : | ||
33 | ]) | 34 | ]) |
34 | 35 | ||
35 | # Prerequisites of lib/strncasecmp.c. | 36 | # Prerequisites of lib/strncasecmp.c. | ... | ... |
1 | # wchar_t.m4 serial 1 (gettext-0.12) | 1 | # wchar_t.m4 serial 1 (gettext-0.12) |
2 | dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002-2003 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; the Free Software Foundation |
4 | dnl General Public License. As a special exception to the GNU General | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl Public License, this file may be distributed as part of a program | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | dnl that contains a configuration script generated by Autoconf, under | ||
7 | dnl the same distribution terms as the rest of that program. | ||
8 | 6 | ||
9 | dnl From Bruno Haible. | 7 | dnl From Bruno Haible. |
10 | dnl Test whether <stddef.h> has the 'wchar_t' type. | 8 | dnl Test whether <stddef.h> has the 'wchar_t' type. | ... | ... |
1 | # wint_t.m4 serial 1 (gettext-0.12) | 1 | # wint_t.m4 serial 1 (gettext-0.12) |
2 | dnl Copyright (C) 2003 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2003 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; the Free Software Foundation |
4 | dnl General Public License. As a special exception to the GNU General | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl Public License, this file may be distributed as part of a program | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | dnl that contains a configuration script generated by Autoconf, under | ||
7 | dnl the same distribution terms as the rest of that program. | ||
8 | 6 | ||
9 | dnl From Bruno Haible. | 7 | dnl From Bruno Haible. |
10 | dnl Test whether <wchar.h> has the 'wint_t' type. | 8 | dnl Test whether <wchar.h> has the 'wint_t' type. | ... | ... |
1 | # xsize.m4 serial 2 | 1 | # xsize.m4 serial 3 |
2 | dnl Copyright (C) 2003 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2003-2004 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; the Free Software Foundation |
4 | dnl General Public License. As a special exception to the GNU General | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl Public License, this file may be distributed as part of a program | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | dnl that contains a configuration script generated by Autoconf, under | ||
7 | dnl the same distribution terms as the rest of that program. | ||
8 | 6 | ||
9 | AC_DEFUN([gl_XSIZE], | 7 | AC_DEFUN([gl_XSIZE], |
10 | [ | 8 | [ |
11 | dnl Prerequisites of lib/xsize.h. | 9 | dnl Prerequisites of lib/xsize.h. |
12 | AC_REQUIRE([gl_SIZE_MAX]) | 10 | AC_REQUIRE([gl_SIZE_MAX]) |
11 | AC_REQUIRE([AC_C_INLINE]) | ||
13 | AC_CHECK_HEADERS(stdint.h) | 12 | AC_CHECK_HEADERS(stdint.h) |
14 | ]) | 13 | ]) | ... | ... |
... | @@ -15,10 +15,10 @@ | ... | @@ -15,10 +15,10 @@ |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License along | 16 | You should have received a copy of the GNU General Public License along |
17 | with this program; if not, write to the Free Software Foundation, | 17 | with this program; if not, write to the Free Software Foundation, |
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
19 | 19 | ||
20 | #ifdef HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | #include <config.h> | 21 | # include <config.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #include <sysexits.h> | 24 | #include <sysexits.h> | ... | ... |
... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License along | 16 | You should have received a copy of the GNU General Public License along |
17 | with this program; if not, write to the Free Software Foundation, | 17 | with this program; if not, write to the Free Software Foundation, |
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
19 | 19 | ||
20 | /* This package emulates glibc `line_wrap_stream' semantics for systems that | 20 | /* This package emulates glibc `line_wrap_stream' semantics for systems that |
21 | don't have that. If the system does have it, it is just a wrapper for | 21 | don't have that. If the system does have it, it is just a wrapper for |
... | @@ -25,10 +25,6 @@ | ... | @@ -25,10 +25,6 @@ |
25 | #ifndef _ARGP_FMTSTREAM_H | 25 | #ifndef _ARGP_FMTSTREAM_H |
26 | #define _ARGP_FMTSTREAM_H | 26 | #define _ARGP_FMTSTREAM_H |
27 | 27 | ||
28 | #ifdef HAVE_CONFIG_H | ||
29 | #include <config.h> | ||
30 | #endif | ||
31 | |||
32 | #include <stdio.h> | 28 | #include <stdio.h> |
33 | #include <string.h> | 29 | #include <string.h> |
34 | #include <unistd.h> | 30 | #include <unistd.h> | ... | ... |
... | @@ -15,10 +15,10 @@ | ... | @@ -15,10 +15,10 @@ |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License along | 16 | You should have received a copy of the GNU General Public License along |
17 | with this program; if not, write to the Free Software Foundation, | 17 | with this program; if not, write to the Free Software Foundation, |
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
19 | 19 | ||
20 | #ifdef HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | #include <config.h> | 21 | # include <config.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #define ARGP_FS_EI | 24 | #define ARGP_FS_EI | ... | ... |
... | @@ -18,7 +18,7 @@ | ... | @@ -18,7 +18,7 @@ |
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
19 | 19 | ||
20 | #ifdef HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | #include <config.h> | 21 | # include <config.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #include <alloca.h> | 24 | #include <alloca.h> |
... | @@ -81,8 +81,8 @@ static const struct argp_option argp_default_options[] = | ... | @@ -81,8 +81,8 @@ static const struct argp_option argp_default_options[] = |
81 | { | 81 | { |
82 | {"help", '?', 0, 0, N_("Give this help list"), -1}, | 82 | {"help", '?', 0, 0, N_("Give this help list"), -1}, |
83 | {"usage", OPT_USAGE, 0, 0, N_("Give a short usage message"), 0}, | 83 | {"usage", OPT_USAGE, 0, 0, N_("Give a short usage message"), 0}, |
84 | {"program-name",OPT_PROGNAME,"NAME", OPTION_HIDDEN, N_("Set the program name"), 0}, | 84 | {"program-name",OPT_PROGNAME,N_("NAME"), OPTION_HIDDEN, N_("Set the program name"), 0}, |
85 | {"HANG", OPT_HANG, "SECS", OPTION_ARG_OPTIONAL | OPTION_HIDDEN, | 85 | {"HANG", OPT_HANG, N_("SECS"), OPTION_ARG_OPTIONAL | OPTION_HIDDEN, |
86 | N_("Hang for SECS seconds (default 3600)"), 0}, | 86 | N_("Hang for SECS seconds (default 3600)"), 0}, |
87 | {NULL, 0, 0, 0, NULL, 0} | 87 | {NULL, 0, 0, 0, NULL, 0} |
88 | }; | 88 | }; | ... | ... |
... | @@ -18,7 +18,7 @@ | ... | @@ -18,7 +18,7 @@ |
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
19 | 19 | ||
20 | #ifdef HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | #include <config.h> | 21 | # include <config.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #include "argp.h" | 24 | #include "argp.h" | ... | ... |
... | @@ -15,10 +15,10 @@ | ... | @@ -15,10 +15,10 @@ |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License along | 16 | You should have received a copy of the GNU General Public License along |
17 | with this program; if not, write to the Free Software Foundation, | 17 | with this program; if not, write to the Free Software Foundation, |
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
19 | 19 | ||
20 | #ifdef HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | #include <config.h> | 21 | # include <config.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #if defined _LIBC || defined HAVE_FEATURES_H | 24 | #if defined _LIBC || defined HAVE_FEATURES_H | ... | ... |
... | @@ -19,15 +19,22 @@ | ... | @@ -19,15 +19,22 @@ |
19 | 19 | ||
20 | /* Ported from glibc by Simon Josefsson. */ | 20 | /* Ported from glibc by Simon Josefsson. */ |
21 | 21 | ||
22 | #if HAVE_CONFIG_H | 22 | #ifdef HAVE_CONFIG_H |
23 | # include <config.h> | 23 | # include <config.h> |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | #include "getdelim.h" | ||
27 | |||
28 | #include <limits.h> | ||
26 | #include <stdlib.h> | 29 | #include <stdlib.h> |
27 | #include <errno.h> | 30 | #include <errno.h> |
28 | 31 | ||
29 | #include "getdelim.h" | 32 | #ifndef SIZE_MAX |
30 | 33 | # define SIZE_MAX ((size_t) -1) | |
34 | #endif | ||
35 | #ifndef SSIZE_MAX | ||
36 | # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) | ||
37 | #endif | ||
31 | #if !HAVE_FLOCKFILE | 38 | #if !HAVE_FLOCKFILE |
32 | # undef flockfile | 39 | # undef flockfile |
33 | # define flockfile(x) ((void) 0) | 40 | # define flockfile(x) ((void) 0) |
... | @@ -46,9 +53,8 @@ | ... | @@ -46,9 +53,8 @@ |
46 | ssize_t | 53 | ssize_t |
47 | getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) | 54 | getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) |
48 | { | 55 | { |
49 | int result; | 56 | ssize_t result; |
50 | ssize_t cur_len = 0; | 57 | size_t cur_len = 0; |
51 | ssize_t len; | ||
52 | 58 | ||
53 | if (lineptr == NULL || n == NULL || fp == NULL) | 59 | if (lineptr == NULL || n == NULL || fp == NULL) |
54 | { | 60 | { |
... | @@ -71,20 +77,26 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) | ... | @@ -71,20 +77,26 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) |
71 | 77 | ||
72 | for (;;) | 78 | for (;;) |
73 | { | 79 | { |
74 | char *t; | ||
75 | int i; | 80 | int i; |
76 | 81 | ||
77 | i = getc (fp); | 82 | i = getc (fp); |
78 | if (i == EOF) | 83 | if (i == EOF) |
79 | break; | 84 | { |
85 | result = -1; | ||
86 | break; | ||
87 | } | ||
80 | 88 | ||
81 | /* Make enough space for len+1 (for final NUL) bytes. */ | 89 | /* Make enough space for len+1 (for final NUL) bytes. */ |
82 | if (cur_len + 1 >= *n) | 90 | if (cur_len + 1 >= *n) |
83 | { | 91 | { |
84 | size_t needed = 2 * (cur_len + 1) + 1; /* Be generous. */ | 92 | size_t needed_max = |
93 | SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; | ||
94 | size_t needed = 2 * *n + 1; /* Be generous. */ | ||
85 | char *new_lineptr; | 95 | char *new_lineptr; |
86 | 96 | ||
87 | if (needed < cur_len) | 97 | if (needed_max < needed) |
98 | needed = needed_max; | ||
99 | if (cur_len + 1 >= needed) | ||
88 | { | 100 | { |
89 | result = -1; | 101 | result = -1; |
90 | goto unlock_return; | 102 | goto unlock_return; |
... | @@ -108,7 +120,7 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) | ... | @@ -108,7 +120,7 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) |
108 | break; | 120 | break; |
109 | } | 121 | } |
110 | (*lineptr)[cur_len] = '\0'; | 122 | (*lineptr)[cur_len] = '\0'; |
111 | result = cur_len; | 123 | result = cur_len ? cur_len : result; |
112 | 124 | ||
113 | unlock_return: | 125 | unlock_return: |
114 | funlockfile (fp); | 126 | funlockfile (fp); | ... | ... |
... | @@ -18,7 +18,7 @@ | ... | @@ -18,7 +18,7 @@ |
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
19 | 19 | ||
20 | #ifdef HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | #include <config.h> | 21 | # include <config.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #ifdef _LIBC | 24 | #ifdef _LIBC | ... | ... |
1 | /* Declarations for getopt. | 1 | /* Declarations for getopt. |
2 | Copyright (C) 1989-1994,1996-1999,2001,2003,2004 | 2 | Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005 |
3 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
4 | This file is part of the GNU C Library. | 4 | This file is part of the GNU C Library. |
5 | 5 | ||
... | @@ -34,9 +34,7 @@ | ... | @@ -34,9 +34,7 @@ |
34 | #if defined __GETOPT_PREFIX && !defined __need_getopt | 34 | #if defined __GETOPT_PREFIX && !defined __need_getopt |
35 | # include <stdlib.h> | 35 | # include <stdlib.h> |
36 | # include <stdio.h> | 36 | # include <stdio.h> |
37 | # if HAVE_UNISTD_H | 37 | # include <unistd.h> |
38 | # include <unistd.h> | ||
39 | # endif | ||
40 | # undef __need_getopt | 38 | # undef __need_getopt |
41 | # undef getopt | 39 | # undef getopt |
42 | # undef getopt_long | 40 | # undef getopt_long | ... | ... |
... | @@ -182,21 +182,29 @@ typedef struct mbchar mbchar_t; | ... | @@ -182,21 +182,29 @@ typedef struct mbchar mbchar_t; |
182 | #define mb_iseq(mbc, sc) ((mbc).wc_valid && (mbc).wc == (sc)) | 182 | #define mb_iseq(mbc, sc) ((mbc).wc_valid && (mbc).wc == (sc)) |
183 | #define mb_isnul(mbc) ((mbc).wc_valid && (mbc).wc == 0) | 183 | #define mb_isnul(mbc) ((mbc).wc_valid && (mbc).wc == 0) |
184 | #define mb_cmp(mbc1, mbc2) \ | 184 | #define mb_cmp(mbc1, mbc2) \ |
185 | ((mbc1).wc_valid && (mbc2).wc_valid \ | 185 | ((mbc1).wc_valid \ |
186 | ? (int) (mbc1).wc - (int) (mbc2).wc \ | 186 | ? ((mbc2).wc_valid \ |
187 | : (mbc1).bytes == (mbc2).bytes \ | 187 | ? (int) (mbc1).wc - (int) (mbc2).wc \ |
188 | ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ | 188 | : -1) \ |
189 | : (mbc1).bytes < (mbc2).bytes \ | 189 | : ((mbc2).wc_valid \ |
190 | ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ | 190 | ? 1 \ |
191 | : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1)) | 191 | : (mbc1).bytes == (mbc2).bytes \ |
192 | ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ | ||
193 | : (mbc1).bytes < (mbc2).bytes \ | ||
194 | ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ | ||
195 | : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1))) | ||
192 | #define mb_casecmp(mbc1, mbc2) \ | 196 | #define mb_casecmp(mbc1, mbc2) \ |
193 | ((mbc1).wc_valid && (mbc2).wc_valid \ | 197 | ((mbc1).wc_valid \ |
194 | ? (int) towlower ((mbc1).wc) - (int) towlower ((mbc2).wc) \ | 198 | ? ((mbc2).wc_valid \ |
195 | : (mbc1).bytes == (mbc2).bytes \ | 199 | ? (int) towlower ((mbc1).wc) - (int) towlower ((mbc2).wc) \ |
196 | ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ | 200 | : -1) \ |
197 | : (mbc1).bytes < (mbc2).bytes \ | 201 | : ((mbc2).wc_valid \ |
198 | ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ | 202 | ? 1 \ |
199 | : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1)) | 203 | : (mbc1).bytes == (mbc2).bytes \ |
204 | ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ | ||
205 | : (mbc1).bytes < (mbc2).bytes \ | ||
206 | ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ | ||
207 | : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1))) | ||
200 | #define mb_equal(mbc1, mbc2) \ | 208 | #define mb_equal(mbc1, mbc2) \ |
201 | ((mbc1).wc_valid && (mbc2).wc_valid \ | 209 | ((mbc1).wc_valid && (mbc2).wc_valid \ |
202 | ? (mbc1).wc == (mbc2).wc \ | 210 | ? (mbc1).wc == (mbc2).wc \ | ... | ... |
This diff is collapsed.
Click to expand it.
1 | /* md5.h - Declaration of functions and data types used for MD5 sum | 1 | /* Declaration of functions and data types used for MD5 sum computing |
2 | computing library functions. | 2 | library functions. |
3 | 3 | Copyright (C) 1995-1997,1999,2000,2001,2004,2005 | |
4 | Copyright (C) 1995, 1996, 1999, 2000, 2003, 2004 Free Software | 4 | Free Software Foundation, Inc. |
5 | Foundation, Inc. | 5 | This file is part of the GNU C Library. |
6 | |||
7 | NOTE: The canonical source of this file is maintained with the GNU C | ||
8 | Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. | ||
9 | 6 | ||
10 | This program is free software; you can redistribute it and/or modify it | 7 | This program is free software; you can redistribute it and/or modify it |
11 | under the terms of the GNU General Public License as published by the | 8 | under the terms of the GNU General Public License as published by the |
... | @@ -25,27 +22,55 @@ | ... | @@ -25,27 +22,55 @@ |
25 | #define _MD5_H 1 | 22 | #define _MD5_H 1 |
26 | 23 | ||
27 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | #include <stdint.h> | ||
26 | |||
27 | #define MD5_DIGEST_SIZE 16 | ||
28 | #define MD5_BLOCK_SIZE 64 | ||
29 | |||
30 | #ifndef __GNUC_PREREQ | ||
31 | # if defined __GNUC__ && defined __GNUC_MINOR__ | ||
32 | # define __GNUC_PREREQ(maj, min) \ | ||
33 | ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) | ||
34 | # else | ||
35 | # define __GNUC_PREREQ(maj, min) 0 | ||
36 | # endif | ||
37 | #endif | ||
28 | 38 | ||
29 | #if HAVE_INTTYPES_H | 39 | #ifndef __THROW |
30 | # include <inttypes.h> | 40 | # if defined __cplusplus && __GNUC_PREREQ (2,8) |
41 | # define __THROW throw () | ||
42 | # else | ||
43 | # define __THROW | ||
44 | # endif | ||
31 | #endif | 45 | #endif |
32 | #if HAVE_STDINT_H || _LIBC | 46 | |
33 | # include <stdint.h> | 47 | #ifndef __attribute__ |
48 | # if ! __GNUC_PREREQ (2,8) || __STRICT_ANSI__ | ||
49 | # define __attribute__(x) | ||
50 | # endif | ||
34 | #endif | 51 | #endif |
35 | 52 | ||
36 | typedef uint32_t md5_uint32; | 53 | #ifndef _LIBC |
54 | # define __md5_buffer md5_buffer | ||
55 | # define __md5_finish_ctx md5_finish_ctx | ||
56 | # define __md5_init_ctx md5_init_ctx | ||
57 | # define __md5_process_block md5_process_block | ||
58 | # define __md5_process_bytes md5_process_bytes | ||
59 | # define __md5_read_ctx md5_read_ctx | ||
60 | # define __md5_stream md5_stream | ||
61 | #endif | ||
37 | 62 | ||
38 | /* Structure to save state of computation between the single steps. */ | 63 | /* Structure to save state of computation between the single steps. */ |
39 | struct md5_ctx | 64 | struct md5_ctx |
40 | { | 65 | { |
41 | md5_uint32 A; | 66 | uint32_t A; |
42 | md5_uint32 B; | 67 | uint32_t B; |
43 | md5_uint32 C; | 68 | uint32_t C; |
44 | md5_uint32 D; | 69 | uint32_t D; |
45 | 70 | ||
46 | md5_uint32 total[2]; | 71 | uint32_t total[2]; |
47 | md5_uint32 buflen; | 72 | uint32_t buflen; |
48 | char buffer[128]; | 73 | uint32_t buffer[32]; |
49 | }; | 74 | }; |
50 | 75 | ||
51 | /* | 76 | /* |
... | @@ -55,52 +80,51 @@ struct md5_ctx | ... | @@ -55,52 +80,51 @@ struct md5_ctx |
55 | 80 | ||
56 | /* Initialize structure containing state of computation. | 81 | /* Initialize structure containing state of computation. |
57 | (RFC 1321, 3.3: Step 3) */ | 82 | (RFC 1321, 3.3: Step 3) */ |
58 | extern void md5_init_ctx (struct md5_ctx *ctx); | 83 | extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW; |
59 | 84 | ||
60 | /* Starting with the result of former calls of this function (or the | 85 | /* Starting with the result of former calls of this function (or the |
61 | initialization function update the context for the next LEN bytes | 86 | initialization function update the context for the next LEN bytes |
62 | starting at BUFFER. | 87 | starting at BUFFER. |
63 | It is necessary that LEN is a multiple of 64!!! */ | 88 | It is necessary that LEN is a multiple of 64!!! */ |
64 | extern void md5_process_block (const void *buffer, size_t len, | 89 | extern void __md5_process_block (const void *buffer, size_t len, |
65 | struct md5_ctx *ctx); | 90 | struct md5_ctx *ctx) __THROW; |
66 | 91 | ||
67 | /* Starting with the result of former calls of this function (or the | 92 | /* Starting with the result of former calls of this function (or the |
68 | initialization function update the context for the next LEN bytes | 93 | initialization function update the context for the next LEN bytes |
69 | starting at BUFFER. | 94 | starting at BUFFER. |
70 | It is NOT required that LEN is a multiple of 64. */ | 95 | It is NOT required that LEN is a multiple of 64. */ |
71 | extern void md5_process_bytes (const void *buffer, size_t len, | 96 | extern void __md5_process_bytes (const void *buffer, size_t len, |
72 | struct md5_ctx *ctx); | 97 | struct md5_ctx *ctx) __THROW; |
73 | 98 | ||
74 | /* Process the remaining bytes in the buffer and put result from CTX | 99 | /* Process the remaining bytes in the buffer and put result from CTX |
75 | in first 16 bytes following RESBUF. The result is always in little | 100 | in first 16 bytes following RESBUF. The result is always in little |
76 | endian byte order, so that a byte-wise output yields to the wanted | 101 | endian byte order, so that a byte-wise output yields to the wanted |
77 | ASCII representation of the message digest. | 102 | ASCII representation of the message digest. |
78 | 103 | ||
79 | IMPORTANT: On some systems it is required that RESBUF be correctly | 104 | IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit |
80 | aligned for a 32 bits value. */ | 105 | boundary. */ |
81 | extern void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf); | 106 | extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW; |
82 | 107 | ||
83 | 108 | ||
84 | /* Put result from CTX in first 16 bytes following RESBUF. The result is | 109 | /* Put result from CTX in first 16 bytes following RESBUF. The result is |
85 | always in little endian byte order, so that a byte-wise output yields | 110 | always in little endian byte order, so that a byte-wise output yields |
86 | to the wanted ASCII representation of the message digest. | 111 | to the wanted ASCII representation of the message digest. |
87 | 112 | ||
88 | IMPORTANT: On some systems it is required that RESBUF is correctly | 113 | IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit |
89 | aligned for a 32 bits value. */ | 114 | boundary. */ |
90 | extern void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf); | 115 | extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW; |
91 | 116 | ||
92 | 117 | ||
93 | /* Compute MD5 message digest for bytes read from STREAM. The | 118 | /* Compute MD5 message digest for bytes read from STREAM. The |
94 | resulting message digest number will be written into the 16 bytes | 119 | resulting message digest number will be written into the 16 bytes |
95 | beginning at RESBLOCK. */ | 120 | beginning at RESBLOCK. */ |
96 | extern int md5_stream (FILE *stream, void *resblock); | 121 | extern int __md5_stream (FILE *stream, void *resblock) __THROW; |
97 | 122 | ||
98 | /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The | 123 | /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The |
99 | result is always in little endian byte order, so that a byte-wise | 124 | result is always in little endian byte order, so that a byte-wise |
100 | output yields to the wanted ASCII representation of the message | 125 | output yields to the wanted ASCII representation of the message |
101 | digest. */ | 126 | digest. */ |
102 | extern void *md5_buffer (const char *buffer, size_t len, void *resblock); | 127 | extern void *__md5_buffer (const char *buffer, size_t len, |
103 | 128 | void *resblock) __THROW; | |
104 | #define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) ) | ||
105 | 129 | ||
106 | #endif | 130 | #endif /* md5.h */ | ... | ... |
... | @@ -21,9 +21,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ... | @@ -21,9 +21,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | GNU General Public License for more details. | 21 | GNU General Public License for more details. |
22 | 22 | ||
23 | You should have received a copy of the GNU General Public License | 23 | You should have received a copy of the GNU General Public License |
24 | along with this program; if not, write to the Free Software | 24 | along with this program; if not, write to the Free Software Foundation, |
25 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | 25 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
26 | USA. */ | ||
27 | 26 | ||
28 | #ifdef HAVE_CONFIG_H | 27 | #ifdef HAVE_CONFIG_H |
29 | # include <config.h> | 28 | # include <config.h> | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -18,31 +18,7 @@ | ... | @@ -18,31 +18,7 @@ |
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
19 | 19 | ||
20 | #ifdef HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | #include "config.h" | 21 | # include <config.h> |
22 | #endif | ||
23 | |||
24 | #ifdef _AIX | ||
25 | #pragma alloca | ||
26 | #else | ||
27 | # ifndef allocax /* predefined by HP cc +Olibcalls */ | ||
28 | # ifdef __GNUC__ | ||
29 | # define alloca(size) __builtin_alloca (size) | ||
30 | # else | ||
31 | # if HAVE_ALLOCA_H | ||
32 | # include <alloca.h> | ||
33 | # else | ||
34 | # ifdef __hpux | ||
35 | void *alloca (); | ||
36 | # else | ||
37 | # if !defined __OS2__ && !defined WIN32 | ||
38 | char *alloca (); | ||
39 | # else | ||
40 | # include <malloc.h> /* OS/2 defines alloca in here */ | ||
41 | # endif | ||
42 | # endif | ||
43 | # endif | ||
44 | # endif | ||
45 | # endif | ||
46 | #endif | 22 | #endif |
47 | 23 | ||
48 | #ifdef _LIBC | 24 | #ifdef _LIBC |
... | @@ -70,10 +46,6 @@ | ... | @@ -70,10 +46,6 @@ |
70 | # include "../locale/localeinfo.h" | 46 | # include "../locale/localeinfo.h" |
71 | #endif | 47 | #endif |
72 | 48 | ||
73 | /* POSIX says that <sys/types.h> must be included (by the caller) before | ||
74 | <regex.h>. */ | ||
75 | #include <sys/types.h> | ||
76 | |||
77 | /* On some systems, limits.h sets RE_DUP_MAX to a lower value than | 49 | /* On some systems, limits.h sets RE_DUP_MAX to a lower value than |
78 | GNU regex allows. Include it before <regex.h>, which correctly | 50 | GNU regex allows. Include it before <regex.h>, which correctly |
79 | #undefs RE_DUP_MAX and sets it to the right value. */ | 51 | #undefs RE_DUP_MAX and sets it to the right value. */ | ... | ... |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
... | @@ -25,119 +25,10 @@ | ... | @@ -25,119 +25,10 @@ |
25 | #include "strcase.h" | 25 | #include "strcase.h" |
26 | 26 | ||
27 | #include <ctype.h> | 27 | #include <ctype.h> |
28 | #include <limits.h> | ||
28 | 29 | ||
29 | #if HAVE_MBRTOWC | 30 | #if HAVE_MBRTOWC |
30 | 31 | # include "mbuiter.h" | |
31 | #include "strnlen1.h" | ||
32 | |||
33 | /* Like mbiter.h, except it doesn't look at the entire string. */ | ||
34 | |||
35 | #include "mbchar.h" | ||
36 | |||
37 | #include <assert.h> | ||
38 | #include <stdbool.h> | ||
39 | #include <stdlib.h> | ||
40 | #include <wchar.h> | ||
41 | #include <wctype.h> | ||
42 | |||
43 | struct mbiter_multi | ||
44 | { | ||
45 | bool at_end; /* true if the end of the string has been reached */ | ||
46 | bool in_shift; /* true if next byte may not be interpreted as ASCII */ | ||
47 | mbstate_t state; /* if in_shift: current shift state */ | ||
48 | bool next_done; /* true if mbi_avail has already filled the following */ | ||
49 | struct mbchar cur; /* the current character: | ||
50 | const char *cur.ptr pointer to current character | ||
51 | The following are only valid after mbi_avail. | ||
52 | size_t cur.bytes number of bytes of current character | ||
53 | bool cur.wc_valid true if wc is a valid wide character | ||
54 | wchar_t cur.wc if wc_valid: the current character | ||
55 | */ | ||
56 | }; | ||
57 | |||
58 | static inline void | ||
59 | mbiter_multi_next (struct mbiter_multi *iter) | ||
60 | { | ||
61 | if (iter->next_done) | ||
62 | return; | ||
63 | if (iter->in_shift) | ||
64 | goto with_shift; | ||
65 | /* Handle most ASCII characters quickly, without calling mbrtowc(). */ | ||
66 | if (is_basic (*iter->cur.ptr)) | ||
67 | { | ||
68 | /* These characters are part of the basic character set. ISO C 99 | ||
69 | guarantees that their wide character code is identical to their | ||
70 | char code. */ | ||
71 | iter->cur.bytes = 1; | ||
72 | iter->cur.wc = *iter->cur.ptr; | ||
73 | iter->cur.wc_valid = true; | ||
74 | } | ||
75 | else | ||
76 | { | ||
77 | assert (mbsinit (&iter->state)); | ||
78 | iter->in_shift = true; | ||
79 | with_shift: | ||
80 | iter->cur.bytes = mbrtowc (&iter->cur.wc, iter->cur.ptr, | ||
81 | strnlen1 (iter->cur.ptr, MB_CUR_MAX), | ||
82 | &iter->state); | ||
83 | if (iter->cur.bytes == (size_t) -1) | ||
84 | { | ||
85 | /* An invalid multibyte sequence was encountered. */ | ||
86 | iter->cur.bytes = 1; | ||
87 | iter->cur.wc_valid = false; | ||
88 | /* Whether to set iter->in_shift = false and reset iter->state | ||
89 | or not is not very important; the string is bogus anyway. */ | ||
90 | } | ||
91 | else if (iter->cur.bytes == (size_t) -2) | ||
92 | { | ||
93 | /* An incomplete multibyte character at the end. */ | ||
94 | iter->cur.bytes = strlen (iter->cur.ptr) + 1; | ||
95 | iter->cur.wc_valid = false; | ||
96 | /* Whether to set iter->in_shift = false and reset iter->state | ||
97 | or not is not important; the string end is reached anyway. */ | ||
98 | } | ||
99 | else | ||
100 | { | ||
101 | if (iter->cur.bytes == 0) | ||
102 | { | ||
103 | /* A null wide character was encountered. */ | ||
104 | iter->cur.bytes = 1; | ||
105 | assert (*iter->cur.ptr == '\0'); | ||
106 | assert (iter->cur.wc == 0); | ||
107 | } | ||
108 | iter->cur.wc_valid = true; | ||
109 | |||
110 | /* When in the initial state, we can go back treating ASCII | ||
111 | characters more quickly. */ | ||
112 | if (mbsinit (&iter->state)) | ||
113 | iter->in_shift = false; | ||
114 | } | ||
115 | } | ||
116 | iter->next_done = true; | ||
117 | } | ||
118 | |||
119 | static inline void | ||
120 | mbiter_multi_reloc (struct mbiter_multi *iter, ptrdiff_t ptrdiff) | ||
121 | { | ||
122 | iter->cur.ptr += ptrdiff; | ||
123 | } | ||
124 | |||
125 | /* Iteration macros. */ | ||
126 | typedef struct mbiter_multi mbi_iterator_t; | ||
127 | #define mbi_init(iter, startptr) \ | ||
128 | ((iter).cur.ptr = (startptr), (iter).at_end = false, \ | ||
129 | (iter).in_shift = false, memset (&(iter).state, '\0', sizeof (mbstate_t)), \ | ||
130 | (iter).next_done = false) | ||
131 | #define mbi_avail(iter) \ | ||
132 | (!(iter).at_end && (mbiter_multi_next (&(iter)), true)) | ||
133 | #define mbi_advance(iter) \ | ||
134 | ((mb_isnul ((iter).cur) ? ((iter).at_end = true) : 0), \ | ||
135 | (iter).cur.ptr += (iter).cur.bytes, (iter).next_done = false) | ||
136 | |||
137 | /* Access to the current character. */ | ||
138 | #define mbi_cur(iter) (iter).cur | ||
139 | #define mbi_cur_ptr(iter) (iter).cur.ptr | ||
140 | |||
141 | #endif | 32 | #endif |
142 | 33 | ||
143 | #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) | 34 | #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) |
... | @@ -159,59 +50,26 @@ strcasecmp (const char *s1, const char *s2) | ... | @@ -159,59 +50,26 @@ strcasecmp (const char *s1, const char *s2) |
159 | #if HAVE_MBRTOWC | 50 | #if HAVE_MBRTOWC |
160 | if (MB_CUR_MAX > 1) | 51 | if (MB_CUR_MAX > 1) |
161 | { | 52 | { |
162 | mbi_iterator_t iter1; | 53 | mbui_iterator_t iter1; |
163 | mbi_iterator_t iter2; | 54 | mbui_iterator_t iter2; |
164 | 55 | ||
165 | mbi_init (iter1, s1); | 56 | mbui_init (iter1, s1); |
166 | mbi_init (iter2, s2); | 57 | mbui_init (iter2, s2); |
167 | 58 | ||
168 | while (mbi_avail (iter1) && mbi_avail (iter2)) | 59 | while (mbui_avail (iter1) && mbui_avail (iter2)) |
169 | { | 60 | { |
170 | /* Sort invalid characters after all valid ones. */ | 61 | int cmp = mb_casecmp (mbui_cur (iter1), mbui_cur (iter2)); |
171 | if (!mbi_cur (iter1).wc_valid) | 62 | |
172 | { | 63 | if (cmp != 0) |
173 | if (!mbi_cur (iter2).wc_valid) | 64 | return cmp; |
174 | { | 65 | |
175 | /* Compare two invalid characters. */ | 66 | mbui_advance (iter1); |
176 | int cmp; | 67 | mbui_advance (iter2); |
177 | |||
178 | if (mbi_cur (iter1).bytes > mbi_cur (iter2).bytes) | ||
179 | return 1; | ||
180 | if (mbi_cur (iter1).bytes < mbi_cur (iter2).bytes) | ||
181 | return -1; | ||
182 | cmp = memcmp (mbi_cur_ptr (iter1), mbi_cur_ptr (iter2), | ||
183 | mbi_cur (iter1).bytes); | ||
184 | if (cmp != 0) | ||
185 | return cmp; | ||
186 | } | ||
187 | else | ||
188 | /* mbi_cur (iter1) invalid, mbi_cur (iter2) valid. */ | ||
189 | return 1; | ||
190 | } | ||
191 | else | ||
192 | { | ||
193 | if (!mbi_cur (iter2).wc_valid) | ||
194 | /* mbi_cur (iter1) valid, mbi_cur (iter2) invalid. */ | ||
195 | return -1; | ||
196 | else | ||
197 | { | ||
198 | /* Compare two valid characters. */ | ||
199 | wchar_t c1 = towlower (mbi_cur (iter1).wc); | ||
200 | wchar_t c2 = towlower (mbi_cur (iter2).wc); | ||
201 | |||
202 | if (c1 > c2) | ||
203 | return 1; | ||
204 | if (c1 < c2) | ||
205 | return -1; | ||
206 | } | ||
207 | } | ||
208 | mbi_advance (iter1); | ||
209 | mbi_advance (iter2); | ||
210 | } | 68 | } |
211 | if (mbi_avail (iter1)) | 69 | if (mbui_avail (iter1)) |
212 | /* s2 terminated before s1. */ | 70 | /* s2 terminated before s1. */ |
213 | return 1; | 71 | return 1; |
214 | if (mbi_avail (iter2)) | 72 | if (mbui_avail (iter2)) |
215 | /* s1 terminated before s2. */ | 73 | /* s1 terminated before s2. */ |
216 | return -1; | 74 | return -1; |
217 | return 0; | 75 | return 0; |
... | @@ -236,6 +94,12 @@ strcasecmp (const char *s1, const char *s2) | ... | @@ -236,6 +94,12 @@ strcasecmp (const char *s1, const char *s2) |
236 | } | 94 | } |
237 | while (c1 == c2); | 95 | while (c1 == c2); |
238 | 96 | ||
239 | return c1 - c2; | 97 | if (UCHAR_MAX <= INT_MAX) |
98 | return c1 - c2; | ||
99 | else | ||
100 | /* On machines where 'char' and 'int' are types of the same size, the | ||
101 | difference of two 'unsigned char' values - including the sign bit - | ||
102 | doesn't fit in an 'int'. */ | ||
103 | return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); | ||
240 | } | 104 | } |
241 | } | 105 | } | ... | ... |
1 | /* strncasecmp.c -- case insensitive string comparator | 1 | /* strncasecmp.c -- case insensitive string comparator |
2 | Copyright (C) 1998, 1999 Free Software Foundation, Inc. | 2 | Copyright (C) 1998, 1999, 2005 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 |
... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
15 | along 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 | #if HAVE_CONFIG_H | 18 | #ifdef HAVE_CONFIG_H |
19 | # include <config.h> | 19 | # include <config.h> |
20 | #endif | 20 | #endif |
21 | 21 | ||
... | @@ -23,6 +23,7 @@ | ... | @@ -23,6 +23,7 @@ |
23 | #include "strcase.h" | 23 | #include "strcase.h" |
24 | 24 | ||
25 | #include <ctype.h> | 25 | #include <ctype.h> |
26 | #include <limits.h> | ||
26 | 27 | ||
27 | #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) | 28 | #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) |
28 | 29 | ||
... | @@ -54,5 +55,11 @@ strncasecmp (const char *s1, const char *s2, size_t n) | ... | @@ -54,5 +55,11 @@ strncasecmp (const char *s1, const char *s2, size_t n) |
54 | } | 55 | } |
55 | while (c1 == c2); | 56 | while (c1 == c2); |
56 | 57 | ||
57 | return c1 - c2; | 58 | if (UCHAR_MAX <= INT_MAX) |
59 | return c1 - c2; | ||
60 | else | ||
61 | /* On machines where 'char' and 'int' are types of the same size, the | ||
62 | difference of two 'unsigned char' values - including the sign bit - | ||
63 | doesn't fit in an 'int'. */ | ||
64 | return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); | ||
58 | } | 65 | } | ... | ... |
... | @@ -18,7 +18,7 @@ | ... | @@ -18,7 +18,7 @@ |
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
19 | 19 | ||
20 | #ifdef HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | # include "config.h" | 21 | # include <config.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #include <stdlib.h> | 24 | #include <stdlib.h> | ... | ... |
... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
16 | with this program; if not, write to the Free Software Foundation, | 16 | with this program; if not, write to the Free Software Foundation, |
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
18 | 18 | ||
19 | #if HAVE_CONFIG_H | 19 | #ifdef HAVE_CONFIG_H |
20 | # include <config.h> | 20 | # include <config.h> |
21 | #endif | 21 | #endif |
22 | #undef strnlen | 22 | #undef strnlen | ... | ... |
... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
17 | USA. */ | 17 | USA. */ |
18 | 18 | ||
19 | #if HAVE_CONFIG_H | 19 | #ifdef HAVE_CONFIG_H |
20 | # include <config.h> | 20 | # include <config.h> |
21 | #endif | 21 | #endif |
22 | 22 | ... | ... |
-
Please register or sign in to post a comment