Updated by gnulib-sync
Showing
52 changed files
with
455 additions
and
508 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 | ||
160 | if (_IO_fwide (out, 0) > 0) | ||
161 | __fwprintf (out, L"%s", prompt); | ||
162 | else | ||
163 | #endif | ||
164 | fputs_unlocked (prompt, out); | 127 | 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 | ||
197 | if (_IO_fwide (out, 0) > 0) | ||
198 | putwc_unlocked (L'\n', out); | ||
199 | else | ||
200 | #endif | ||
201 | putc_unlocked ('\n', out); | 155 | 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 | ||
440 | # endif | ||
441 | fprintf (stderr, "%s\n", _("memory exhausted")); | 435 | fprintf (stderr, "%s\n", _("memory exhausted")); |
436 | # endif | ||
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,32 +10,35 @@ | ... | @@ -10,32 +10,35 @@ |
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, |
19 | [Define if you want regoff_t to be at least as wide POSIX requires.]) | ||
17 | 20 | ||
18 | dnl Usage: gl_INCLUDED_REGEX([lib/regex.c]) | ||
19 | dnl | ||
20 | AC_DEFUN([gl_INCLUDED_REGEX], | ||
21 | [ | ||
22 | MU_LIBSOURCES( | 21 | MU_LIBSOURCES( |
23 | [regcomp.c, regex.c, regex.h, | 22 | [regcomp.c, regex.c, regex.h, |
24 | regex_internal.c, regex_internal.h, regexec.c]) | 23 | regex_internal.c, regex_internal.h, regexec.c]) |
25 | 24 | ||
26 | dnl Even packages that don't use regex.c can use this macro. | 25 | AC_ARG_WITH([included-regex], |
27 | dnl Of course, for them it doesn't do anything. | 26 | [AC_HELP_STRING([--without-included-regex], |
28 | 27 | [don't compile regex; this is the default on | |
29 | # Assume we'll default to using the included regex.c. | 28 | systems with recent-enough versions of the GNU C |
30 | ac_use_included_regex=yes | 29 | Library (use with caution on other systems)])]) |
31 | 30 | ||
32 | # However, if the system regex support is good enough that it passes the | 31 | case $with_included_regex in |
33 | # the following run test, then default to *not* using the included regex.c. | 32 | yes|no) ac_use_included_regex=$with_included_regex |
33 | ;; | ||
34 | '') | ||
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 |
... | @@ -43,7 +46,10 @@ AC_DEFUN([gl_INCLUDED_REGEX], | ... | @@ -43,7 +46,10 @@ AC_DEFUN([gl_INCLUDED_REGEX], |
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_, |
50 | rather than the traditional GNU spelling with leading RE_, | ||
51 | so that we reject older libc implementations. */ | ||
52 | re_set_syntax (REG_SYNTAX_POSIX_EGREP); | ||
47 | memset (®ex, 0, sizeof (regex)); | 53 | memset (®ex, 0, sizeof (regex)); |
48 | s = re_compile_pattern ("a[:@:>@:]b\n", 9, ®ex); | 54 | s = re_compile_pattern ("a[:@:>@:]b\n", 9, ®ex); |
49 | /* This should fail with _Invalid character class name_ error. */ | 55 | /* This should fail with _Invalid character class name_ error. */ |
... | @@ -79,9 +85,10 @@ AC_DEFUN([gl_INCLUDED_REGEX], | ... | @@ -79,9 +85,10 @@ AC_DEFUN([gl_INCLUDED_REGEX], |
79 | exit (1); | 85 | exit (1); |
80 | 86 | ||
81 | /* The version of regex.c in older versions of gnulib | 87 | /* The version of regex.c in older versions of gnulib |
82 | * ignored RE_ICASE. Detect that problem too. */ | 88 | ignored REG_IGNORE_CASE (which was then called RE_ICASE). |
89 | Detect that problem too. */ | ||
83 | memset (®ex, 0, sizeof (regex)); | 90 | memset (®ex, 0, sizeof (regex)); |
84 | re_set_syntax(RE_SYNTAX_EMACS|RE_ICASE); | 91 | re_set_syntax (REG_SYNTAX_EMACS | REG_IGNORE_CASE); |
85 | s = re_compile_pattern ("x", 1, ®ex); | 92 | s = re_compile_pattern ("x", 1, ®ex); |
86 | if (s) | 93 | if (s) |
87 | exit (1); | 94 | exit (1); |
... | @@ -94,37 +101,64 @@ AC_DEFUN([gl_INCLUDED_REGEX], | ... | @@ -94,37 +101,64 @@ AC_DEFUN([gl_INCLUDED_REGEX], |
94 | if (! REG_STARTEND) | 101 | if (! REG_STARTEND) |
95 | exit (1); | 102 | exit (1); |
96 | 103 | ||
104 | /* Reject hosts whose regoff_t values are too narrow. | ||
105 | These include glibc 2.3.5 on hosts with 64-bit off_t | ||
106 | and 32-bit int, and Solaris 10 on hosts with 32-bit int | ||
107 | and _FILE_OFFSET_BITS=64. */ | ||
108 | if (sizeof (regoff_t) < sizeof (off_t)) | ||
109 | exit (1); | ||
110 | |||
97 | exit (0);]])], | 111 | exit (0);]])], |
98 | [gl_cv_func_working_re_compile_pattern=yes], | 112 | [gl_cv_func_re_compile_pattern_broken=no], |
99 | [gl_cv_func_working_re_compile_pattern=no], | 113 | [gl_cv_func_re_compile_pattern_broken=yes], |
100 | dnl When crosscompiling, assume it is broken. | 114 | dnl When crosscompiling, assume it is broken. |
101 | [gl_cv_func_working_re_compile_pattern=no])]) | 115 | [gl_cv_func_re_compile_pattern_broken=yes])]) |
102 | if test $gl_cv_func_working_re_compile_pattern = yes; then | 116 | ac_use_included_regex=$gl_cv_func_re_compile_pattern_broken |
103 | ac_use_included_regex=no | 117 | ;; |
104 | fi | 118 | *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex]) |
105 | 119 | ;; | |
106 | test -n "$1" || AC_MSG_ERROR([missing argument]) | 120 | esac |
107 | m4_syscmd([test -f '$1']) | 121 | |
108 | ifelse(m4_sysval, 0, | 122 | if test $ac_use_included_regex = yes; then |
109 | [ | 123 | AC_DEFINE([re_syntax_options], [rpl_re_syntax_options], |
110 | AC_ARG_WITH([included-regex], | 124 | [Define to rpl_re_syntax_options if the replacement should be used.]) |
111 | [ --without-included-regex don't compile regex; this is the default on | 125 | AC_DEFINE([re_set_syntax], [rpl_re_set_syntax], |
112 | systems with recent-enough versions of the GNU C | 126 | [Define to rpl_re_set_syntax if the replacement should be used.]) |
113 | Library (use with caution on other systems)], | 127 | AC_DEFINE([re_compile_pattern], [rpl_re_compile_pattern], |
114 | [gl_with_regex=$withval], | 128 | [Define to rpl_re_compile_pattern if the replacement should be used.]) |
115 | [gl_with_regex=$ac_use_included_regex]) | 129 | AC_DEFINE([re_compile_fastmap], [rpl_re_compile_fastmap], |
116 | if test "X$gl_with_regex" = Xyes; then | 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.]) | ||
117 | MU_LIBOBJ([regex]) | 153 | MU_LIBOBJ([regex]) |
118 | gl_PREREQ_REGEX | 154 | gl_PREREQ_REGEX |
119 | fi | 155 | fi |
120 | ], | 156 | ]) |
121 | ) | ||
122 | ] | ||
123 | ) | ||
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 | ]) | ... | ... |
... | @@ -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 <sysexits.h> | 24 | #include <sysexits.h> | ... | ... |
... | @@ -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> | ... | ... |
... | @@ -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 | #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" | ... | ... |
... | @@ -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 | #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) |
84 | { | ||
85 | result = -1; | ||
79 | break; | 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 | ||
38 | # include <unistd.h> | 37 | # 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 | ? ((mbc2).wc_valid \ | ||
186 | ? (int) (mbc1).wc - (int) (mbc2).wc \ | 187 | ? (int) (mbc1).wc - (int) (mbc2).wc \ |
188 | : -1) \ | ||
189 | : ((mbc2).wc_valid \ | ||
190 | ? 1 \ | ||
187 | : (mbc1).bytes == (mbc2).bytes \ | 191 | : (mbc1).bytes == (mbc2).bytes \ |
188 | ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ | 192 | ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ |
189 | : (mbc1).bytes < (mbc2).bytes \ | 193 | : (mbc1).bytes < (mbc2).bytes \ |
190 | ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ | 194 | ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ |
191 | : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).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 \ |
198 | ? ((mbc2).wc_valid \ | ||
194 | ? (int) towlower ((mbc1).wc) - (int) towlower ((mbc2).wc) \ | 199 | ? (int) towlower ((mbc1).wc) - (int) towlower ((mbc2).wc) \ |
200 | : -1) \ | ||
201 | : ((mbc2).wc_valid \ | ||
202 | ? 1 \ | ||
195 | : (mbc1).bytes == (mbc2).bytes \ | 203 | : (mbc1).bytes == (mbc2).bytes \ |
196 | ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ | 204 | ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ |
197 | : (mbc1).bytes < (mbc2).bytes \ | 205 | : (mbc1).bytes < (mbc2).bytes \ |
198 | ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ | 206 | ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ |
199 | : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).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 \ | ... | ... |
1 | /* md5.c - Functions to compute MD5 message digest of files or memory blocks | 1 | /* Functions to compute MD5 message digest of files or memory blocks. |
2 | according to the definition of MD5 in RFC 1321 from April 1992. | 2 | according to the definition of MD5 in RFC 1321 from April 1992. |
3 | Copyright (C) 1995, 1996, 2001, 2003, 2004 Free Software Foundation, Inc. | 3 | Copyright (C) 1995,1996,1997,1999,2000,2001,2005 |
4 | NOTE: The canonical source of this file is maintained with the GNU C | 4 | Free Software Foundation, Inc. |
5 | Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. | 5 | This file is part of the GNU C Library. |
6 | 6 | ||
7 | 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 |
8 | 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 |
... | @@ -27,7 +27,9 @@ | ... | @@ -27,7 +27,9 @@ |
27 | #include "md5.h" | 27 | #include "md5.h" |
28 | 28 | ||
29 | #include <stddef.h> | 29 | #include <stddef.h> |
30 | #include <stdlib.h> | ||
30 | #include <string.h> | 31 | #include <string.h> |
32 | #include <sys/types.h> | ||
31 | 33 | ||
32 | #if USE_UNLOCKED_IO | 34 | #if USE_UNLOCKED_IO |
33 | # include "unlocked-io.h" | 35 | # include "unlocked-io.h" |
... | @@ -57,10 +59,8 @@ | ... | @@ -57,10 +59,8 @@ |
57 | #endif | 59 | #endif |
58 | 60 | ||
59 | #define BLOCKSIZE 4096 | 61 | #define BLOCKSIZE 4096 |
60 | /* Ensure that BLOCKSIZE is a multiple of 64. */ | ||
61 | #if BLOCKSIZE % 64 != 0 | 62 | #if BLOCKSIZE % 64 != 0 |
62 | /* FIXME-someday (soon?): use #error instead of this kludge. */ | 63 | # error "invalid BLOCKSIZE" |
63 | "invalid BLOCKSIZE" | ||
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | /* This array contains the bytes used to pad the buffer to the next | 66 | /* This array contains the bytes used to pad the buffer to the next |
... | @@ -90,10 +90,10 @@ md5_init_ctx (struct md5_ctx *ctx) | ... | @@ -90,10 +90,10 @@ md5_init_ctx (struct md5_ctx *ctx) |
90 | void * | 90 | void * |
91 | md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) | 91 | md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) |
92 | { | 92 | { |
93 | ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A); | 93 | ((uint32_t *) resbuf)[0] = SWAP (ctx->A); |
94 | ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B); | 94 | ((uint32_t *) resbuf)[1] = SWAP (ctx->B); |
95 | ((md5_uint32 *) resbuf)[2] = SWAP (ctx->C); | 95 | ((uint32_t *) resbuf)[2] = SWAP (ctx->C); |
96 | ((md5_uint32 *) resbuf)[3] = SWAP (ctx->D); | 96 | ((uint32_t *) resbuf)[3] = SWAP (ctx->D); |
97 | 97 | ||
98 | return resbuf; | 98 | return resbuf; |
99 | } | 99 | } |
... | @@ -107,24 +107,22 @@ void * | ... | @@ -107,24 +107,22 @@ void * |
107 | md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) | 107 | md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) |
108 | { | 108 | { |
109 | /* Take yet unprocessed bytes into account. */ | 109 | /* Take yet unprocessed bytes into account. */ |
110 | md5_uint32 bytes = ctx->buflen; | 110 | uint32_t bytes = ctx->buflen; |
111 | size_t pad; | 111 | size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4; |
112 | 112 | ||
113 | /* Now count remaining bytes. */ | 113 | /* Now count remaining bytes. */ |
114 | ctx->total[0] += bytes; | 114 | ctx->total[0] += bytes; |
115 | if (ctx->total[0] < bytes) | 115 | if (ctx->total[0] < bytes) |
116 | ++ctx->total[1]; | 116 | ++ctx->total[1]; |
117 | 117 | ||
118 | pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes; | ||
119 | memcpy (&ctx->buffer[bytes], fillbuf, pad); | ||
120 | |||
121 | /* Put the 64-bit file length in *bits* at the end of the buffer. */ | 118 | /* Put the 64-bit file length in *bits* at the end of the buffer. */ |
122 | *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3); | 119 | ctx->buffer[size - 2] = SWAP (ctx->total[0] << 3); |
123 | *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) | | 120 | ctx->buffer[size - 1] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); |
124 | (ctx->total[0] >> 29)); | 121 | |
122 | memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); | ||
125 | 123 | ||
126 | /* Process last bytes. */ | 124 | /* Process last bytes. */ |
127 | md5_process_block (ctx->buffer, bytes + pad + 8, ctx); | 125 | md5_process_block (ctx->buffer, size * 4, ctx); |
128 | 126 | ||
129 | return md5_read_ctx (ctx, resbuf); | 127 | return md5_read_ctx (ctx, resbuf); |
130 | } | 128 | } |
... | @@ -184,7 +182,7 @@ md5_stream (FILE *stream, void *resblock) | ... | @@ -184,7 +182,7 @@ md5_stream (FILE *stream, void *resblock) |
184 | md5_process_block (buffer, BLOCKSIZE, &ctx); | 182 | md5_process_block (buffer, BLOCKSIZE, &ctx); |
185 | } | 183 | } |
186 | 184 | ||
187 | process_partial_block:; | 185 | process_partial_block: |
188 | 186 | ||
189 | /* Process any remaining bytes. */ | 187 | /* Process any remaining bytes. */ |
190 | if (sum > 0) | 188 | if (sum > 0) |
... | @@ -225,7 +223,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) | ... | @@ -225,7 +223,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) |
225 | size_t left_over = ctx->buflen; | 223 | size_t left_over = ctx->buflen; |
226 | size_t add = 128 - left_over > len ? len : 128 - left_over; | 224 | size_t add = 128 - left_over > len ? len : 128 - left_over; |
227 | 225 | ||
228 | memcpy (&ctx->buffer[left_over], buffer, add); | 226 | memcpy (&((char *) ctx->buffer)[left_over], buffer, add); |
229 | ctx->buflen += add; | 227 | ctx->buflen += add; |
230 | 228 | ||
231 | if (ctx->buflen > 64) | 229 | if (ctx->buflen > 64) |
... | @@ -234,7 +232,8 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) | ... | @@ -234,7 +232,8 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) |
234 | 232 | ||
235 | ctx->buflen &= 63; | 233 | ctx->buflen &= 63; |
236 | /* The regions in the following copy operation cannot overlap. */ | 234 | /* The regions in the following copy operation cannot overlap. */ |
237 | memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], | 235 | memcpy (ctx->buffer, |
236 | &((char *) ctx->buffer)[(left_over + add) & ~63], | ||
238 | ctx->buflen); | 237 | ctx->buflen); |
239 | } | 238 | } |
240 | 239 | ||
... | @@ -246,8 +245,14 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) | ... | @@ -246,8 +245,14 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) |
246 | if (len >= 64) | 245 | if (len >= 64) |
247 | { | 246 | { |
248 | #if !_STRING_ARCH_unaligned | 247 | #if !_STRING_ARCH_unaligned |
248 | /* To check alignment gcc has an appropriate operator. Other | ||
249 | compilers don't. */ | ||
250 | # if __GNUC__ >= 2 | ||
251 | # define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint32_t) != 0) | ||
252 | # else | ||
249 | # define alignof(type) offsetof (struct { char c; type x; }, x) | 253 | # define alignof(type) offsetof (struct { char c; type x; }, x) |
250 | # define UNALIGNED_P(p) (((size_t) p) % alignof (md5_uint32) != 0) | 254 | # define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) |
255 | # endif | ||
251 | if (UNALIGNED_P (buffer)) | 256 | if (UNALIGNED_P (buffer)) |
252 | while (len > 64) | 257 | while (len > 64) |
253 | { | 258 | { |
... | @@ -269,13 +274,13 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) | ... | @@ -269,13 +274,13 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) |
269 | { | 274 | { |
270 | size_t left_over = ctx->buflen; | 275 | size_t left_over = ctx->buflen; |
271 | 276 | ||
272 | memcpy (&ctx->buffer[left_over], buffer, len); | 277 | memcpy (&((char *) ctx->buffer)[left_over], buffer, len); |
273 | left_over += len; | 278 | left_over += len; |
274 | if (left_over >= 64) | 279 | if (left_over >= 64) |
275 | { | 280 | { |
276 | md5_process_block (ctx->buffer, 64, ctx); | 281 | md5_process_block (ctx->buffer, 64, ctx); |
277 | left_over -= 64; | 282 | left_over -= 64; |
278 | memcpy (ctx->buffer, &ctx->buffer[64], left_over); | 283 | memcpy (ctx->buffer, &ctx->buffer[16], left_over); |
279 | } | 284 | } |
280 | ctx->buflen = left_over; | 285 | ctx->buflen = left_over; |
281 | } | 286 | } |
... | @@ -297,14 +302,14 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) | ... | @@ -297,14 +302,14 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) |
297 | void | 302 | void |
298 | md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) | 303 | md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) |
299 | { | 304 | { |
300 | md5_uint32 correct_words[16]; | 305 | uint32_t correct_words[16]; |
301 | const md5_uint32 *words = buffer; | 306 | const uint32_t *words = buffer; |
302 | size_t nwords = len / sizeof (md5_uint32); | 307 | size_t nwords = len / sizeof (uint32_t); |
303 | const md5_uint32 *endp = words + nwords; | 308 | const uint32_t *endp = words + nwords; |
304 | md5_uint32 A = ctx->A; | 309 | uint32_t A = ctx->A; |
305 | md5_uint32 B = ctx->B; | 310 | uint32_t B = ctx->B; |
306 | md5_uint32 C = ctx->C; | 311 | uint32_t C = ctx->C; |
307 | md5_uint32 D = ctx->D; | 312 | uint32_t D = ctx->D; |
308 | 313 | ||
309 | /* First increment the byte count. RFC 1321 specifies the possible | 314 | /* First increment the byte count. RFC 1321 specifies the possible |
310 | length of the file up to 2^64 bits. Here we only compute the | 315 | length of the file up to 2^64 bits. Here we only compute the |
... | @@ -317,11 +322,11 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) | ... | @@ -317,11 +322,11 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) |
317 | the loop. */ | 322 | the loop. */ |
318 | while (words < endp) | 323 | while (words < endp) |
319 | { | 324 | { |
320 | md5_uint32 *cwp = correct_words; | 325 | uint32_t *cwp = correct_words; |
321 | md5_uint32 A_save = A; | 326 | uint32_t A_save = A; |
322 | md5_uint32 B_save = B; | 327 | uint32_t B_save = B; |
323 | md5_uint32 C_save = C; | 328 | uint32_t C_save = C; |
324 | md5_uint32 D_save = D; | 329 | uint32_t D_save = D; |
325 | 330 | ||
326 | /* First round: using the given function, the context and a constant | 331 | /* First round: using the given function, the context and a constant |
327 | the next context is computed. Because the algorithms processing | 332 | the next context is computed. Because the algorithms processing |
... | @@ -335,15 +340,22 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) | ... | @@ -335,15 +340,22 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) |
335 | { \ | 340 | { \ |
336 | a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \ | 341 | a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \ |
337 | ++words; \ | 342 | ++words; \ |
338 | a = rol (a, s); \ | 343 | CYCLIC (a, s); \ |
339 | a += b; \ | 344 | a += b; \ |
340 | } \ | 345 | } \ |
341 | while (0) | 346 | while (0) |
342 | 347 | ||
348 | /* It is unfortunate that C does not provide an operator for | ||
349 | cyclic rotation. Hope the C compiler is smart enough. */ | ||
350 | #define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s))) | ||
351 | |||
343 | /* Before we start, one word to the strange constants. | 352 | /* Before we start, one word to the strange constants. |
344 | They are defined in RFC 1321 as | 353 | They are defined in RFC 1321 as |
345 | 354 | ||
346 | T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64, or | 355 | T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 |
356 | |||
357 | Here is an equivalent invocation using Perl: | ||
358 | |||
347 | perl -e 'foreach(1..64){printf "0x%08x\n", int (4294967296 * abs (sin $_))}' | 359 | perl -e 'foreach(1..64){printf "0x%08x\n", int (4294967296 * abs (sin $_))}' |
348 | */ | 360 | */ |
349 | 361 | ||
... | @@ -373,7 +385,7 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) | ... | @@ -373,7 +385,7 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) |
373 | do \ | 385 | do \ |
374 | { \ | 386 | { \ |
375 | a += f (b, c, d) + correct_words[k] + T; \ | 387 | a += f (b, c, d) + correct_words[k] + T; \ |
376 | a = rol (a, s); \ | 388 | CYCLIC (a, s); \ |
377 | a += b; \ | 389 | a += b; \ |
378 | } \ | 390 | } \ |
379 | while (0) | 391 | while (0) | ... | ... |
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 | { | ||
170 | /* Sort invalid characters after all valid ones. */ | ||
171 | if (!mbi_cur (iter1).wc_valid) | ||
172 | { | 60 | { |
173 | if (!mbi_cur (iter2).wc_valid) | 61 | int cmp = mb_casecmp (mbui_cur (iter1), mbui_cur (iter2)); |
174 | { | ||
175 | /* Compare two invalid characters. */ | ||
176 | int cmp; | ||
177 | 62 | ||
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) | 63 | if (cmp != 0) |
185 | return cmp; | 64 | 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 | 65 | ||
202 | if (c1 > c2) | 66 | mbui_advance (iter1); |
203 | return 1; | 67 | mbui_advance (iter2); |
204 | if (c1 < c2) | ||
205 | return -1; | ||
206 | } | ||
207 | } | 68 | } |
208 | mbi_advance (iter1); | 69 | if (mbui_avail (iter1)) |
209 | mbi_advance (iter2); | ||
210 | } | ||
211 | if (mbi_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 | ||
97 | if (UCHAR_MAX <= INT_MAX) | ||
239 | return c1 - c2; | 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 | ||
58 | if (UCHAR_MAX <= INT_MAX) | ||
57 | return c1 - c2; | 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