Commit 94fdc609 94fdc6094f6b02c854432e8c8f658afa6dd654c7 by Sergey Poznyakoff

Updated by gnulib-sync

1 parent 3f7b793b
1 /* Safe automatic memory allocation. 1 /* Safe automatic memory allocation.
2 Copyright (C) 2003-2004 Free Software Foundation, Inc. 2 Copyright (C) 2003-2006 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2003. 3 Written by Bruno Haible <bruno@clisp.org>, 2003.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
...@@ -23,6 +23,12 @@ ...@@ -23,6 +23,12 @@
23 #include <stddef.h> 23 #include <stddef.h>
24 #include <stdlib.h> 24 #include <stdlib.h>
25 25
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31
26 /* safe_alloca(N) is equivalent to alloca(N) when it is safe to call 32 /* safe_alloca(N) is equivalent to alloca(N) when it is safe to call
27 alloca(N); otherwise it returns NULL. It either returns N bytes of 33 alloca(N); otherwise it returns NULL. It either returns N bytes of
28 memory allocated on the stack, that lasts until the function returns, 34 memory allocated on the stack, that lasts until the function returns,
...@@ -69,6 +75,11 @@ extern void freesa (void *p); ...@@ -69,6 +75,11 @@ extern void freesa (void *p);
69 If this would be useful in your application. please speak up. */ 75 If this would be useful in your application. please speak up. */
70 76
71 77
78 #ifdef __cplusplus
79 }
80 #endif
81
82
72 /* ------------------- Auxiliary, non-public definitions ------------------- */ 83 /* ------------------- Auxiliary, non-public definitions ------------------- */
73 84
74 /* Determine the alignment of a type at compile time. */ 85 /* Determine the alignment of a type at compile time. */
...@@ -81,6 +92,10 @@ extern void freesa (void *p); ...@@ -81,6 +92,10 @@ extern void freesa (void *p);
81 /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof 92 /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof
82 values. */ 93 values. */
83 # define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) 94 # define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
95 #elif defined _AIX
96 /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof
97 values. */
98 # define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
84 #else 99 #else
85 # define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) 100 # define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
86 #endif 101 #endif
......
1 /* Error handler for noninteractive utilities 1 /* Error handler for noninteractive utilities
2 Copyright (C) 1990-1998, 2000-2003, 2004 Free Software Foundation, Inc. 2 Copyright (C) 1990-1998, 2000-2005, 2006 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
34 #endif 34 #endif
35 35
36 #ifdef _LIBC 36 #ifdef _LIBC
37 # include <libintl.h>
38 # include <stdbool.h>
39 # include <stdint.h>
37 # include <wchar.h> 40 # include <wchar.h>
38 # define mbsrtowcs __mbsrtowcs 41 # define mbsrtowcs __mbsrtowcs
39 #endif 42 #endif
...@@ -59,6 +62,7 @@ unsigned int error_message_count; ...@@ -59,6 +62,7 @@ unsigned int error_message_count;
59 62
60 # define program_name program_invocation_name 63 # define program_name program_invocation_name
61 # include <errno.h> 64 # include <errno.h>
65 # include <limits.h>
62 # include <libio/libioP.h> 66 # include <libio/libioP.h>
63 67
64 /* In GNU libc we want do not want to use the common name `error' directly. 68 /* In GNU libc we want do not want to use the common name `error' directly.
...@@ -88,23 +92,19 @@ extern void __error_at_line (int status, int errnum, const char *file_name, ...@@ -88,23 +92,19 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
88 char *strerror_r (); 92 char *strerror_r ();
89 # endif 93 # endif
90 94
91 # ifndef SIZE_MAX
92 # define SIZE_MAX ((size_t) -1)
93 # endif
94
95 /* The calling program should define program_name and set it to the 95 /* The calling program should define program_name and set it to the
96 name of the executing program. */ 96 name of the executing program. */
97 extern char *program_name; 97 extern char *program_name;
98 98
99 # if HAVE_STRERROR_R || defined strerror_r 99 # if HAVE_STRERROR_R || defined strerror_r
100 # define __strerror_r strerror_r 100 # define __strerror_r strerror_r
101 # endif 101 # endif /* HAVE_STRERROR_R || defined strerror_r */
102 #endif /* not _LIBC */ 102 #endif /* not _LIBC */
103 103
104 static void 104 static void
105 print_errno_message (int errnum) 105 print_errno_message (int errnum)
106 { 106 {
107 char const *s = NULL; 107 char const *s;
108 108
109 #if defined HAVE_STRERROR_R || _LIBC 109 #if defined HAVE_STRERROR_R || _LIBC
110 char errbuf[1024]; 110 char errbuf[1024];
...@@ -113,23 +113,23 @@ print_errno_message (int errnum) ...@@ -113,23 +113,23 @@ print_errno_message (int errnum)
113 # else 113 # else
114 if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) 114 if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
115 s = errbuf; 115 s = errbuf;
116 else
117 s = 0;
116 # endif 118 # endif
119 #else
120 s = strerror (errnum);
117 #endif 121 #endif
118 122
119 #if !_LIBC 123 #if !_LIBC
120 if (! s && ! (s = strerror (errnum))) 124 if (! s)
121 s = _("Unknown system error"); 125 s = _("Unknown system error");
122 #endif 126 #endif
123 127
124 #if _LIBC 128 #if _LIBC
125 if (_IO_fwide (stderr, 0) > 0) 129 __fxprintf (NULL, ": %s", s);
126 { 130 #else
127 __fwprintf (stderr, L": %s", s);
128 return;
129 }
130 #endif
131
132 fprintf (stderr, ": %s", s); 131 fprintf (stderr, ": %s", s);
132 #endif
133 } 133 }
134 134
135 static void 135 static void
...@@ -140,26 +140,65 @@ error_tail (int status, int errnum, const char *message, va_list args) ...@@ -140,26 +140,65 @@ error_tail (int status, int errnum, const char *message, va_list args)
140 { 140 {
141 # define ALLOCA_LIMIT 2000 141 # define ALLOCA_LIMIT 2000
142 size_t len = strlen (message) + 1; 142 size_t len = strlen (message) + 1;
143 const wchar_t *wmessage = L"out of memory"; 143 wchar_t *wmessage = NULL;
144 wchar_t *wbuf = (len < ALLOCA_LIMIT 144 mbstate_t st;
145 ? alloca (len * sizeof *wbuf) 145 size_t res;
146 : len <= SIZE_MAX / sizeof *wbuf 146 const char *tmp;
147 ? malloc (len * sizeof *wbuf) 147 bool use_malloc = false;
148 : NULL); 148
149 149 while (1)
150 if (wbuf)
151 { 150 {
152 size_t res; 151 if (__libc_use_alloca (len * sizeof (wchar_t)))
153 mbstate_t st; 152 wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
154 const char *tmp = message; 153 else
154 {
155 if (!use_malloc)
156 wmessage = NULL;
157
158 wchar_t *p = (wchar_t *) realloc (wmessage,
159 len * sizeof (wchar_t));
160 if (p == NULL)
161 {
162 free (wmessage);
163 fputws_unlocked (L"out of memory\n", stderr);
164 return;
165 }
166 wmessage = p;
167 use_malloc = true;
168 }
169
155 memset (&st, '\0', sizeof (st)); 170 memset (&st, '\0', sizeof (st));
156 res = mbsrtowcs (wbuf, &tmp, len, &st); 171 tmp = message;
157 wmessage = res == (size_t) -1 ? L"???" : wbuf; 172
173 res = mbsrtowcs (wmessage, &tmp, len, &st);
174 if (res != len)
175 break;
176
177 if (__builtin_expect (len >= SIZE_MAX / 2, 0))
178 {
179 /* This really should not happen if everything is fine. */
180 res = (size_t) -1;
181 break;
182 }
183
184 len *= 2;
185 }
186
187 if (res == (size_t) -1)
188 {
189 /* The string cannot be converted. */
190 if (use_malloc)
191 {
192 free (wmessage);
193 use_malloc = false;
194 }
195 wmessage = (wchar_t *) L"???";
158 } 196 }
159 197
160 __vfwprintf (stderr, wmessage, args); 198 __vfwprintf (stderr, wmessage, args);
161 if (! (len < ALLOCA_LIMIT)) 199
162 free (wbuf); 200 if (use_malloc)
201 free (wmessage);
163 } 202 }
164 else 203 else
165 #endif 204 #endif
...@@ -170,11 +209,10 @@ error_tail (int status, int errnum, const char *message, va_list args) ...@@ -170,11 +209,10 @@ error_tail (int status, int errnum, const char *message, va_list args)
170 if (errnum) 209 if (errnum)
171 print_errno_message (errnum); 210 print_errno_message (errnum);
172 #if _LIBC 211 #if _LIBC
173 if (_IO_fwide (stderr, 0) > 0) 212 __fxprintf (NULL, "\n");
174 putwc (L'\n', stderr); 213 #else
175 else 214 putc ('\n', stderr);
176 #endif 215 #endif
177 putc ('\n', stderr);
178 fflush (stderr); 216 fflush (stderr);
179 if (status) 217 if (status)
180 exit (status); 218 exit (status);
...@@ -207,11 +245,10 @@ error (int status, int errnum, const char *message, ...) ...@@ -207,11 +245,10 @@ error (int status, int errnum, const char *message, ...)
207 else 245 else
208 { 246 {
209 #if _LIBC 247 #if _LIBC
210 if (_IO_fwide (stderr, 0) > 0) 248 __fxprintf (NULL, "%s: ", program_name);
211 __fwprintf (stderr, L"%s: ", program_name); 249 #else
212 else 250 fprintf (stderr, "%s: ", program_name);
213 #endif 251 #endif
214 fprintf (stderr, "%s: ", program_name);
215 } 252 }
216 253
217 va_start (args, message); 254 va_start (args, message);
...@@ -267,22 +304,19 @@ error_at_line (int status, int errnum, const char *file_name, ...@@ -267,22 +304,19 @@ error_at_line (int status, int errnum, const char *file_name,
267 else 304 else
268 { 305 {
269 #if _LIBC 306 #if _LIBC
270 if (_IO_fwide (stderr, 0) > 0) 307 __fxprintf (NULL, "%s:", program_name);
271 __fwprintf (stderr, L"%s: ", program_name); 308 #else
272 else 309 fprintf (stderr, "%s:", program_name);
273 #endif 310 #endif
274 fprintf (stderr, "%s:", program_name);
275 } 311 }
276 312
277 if (file_name != NULL)
278 {
279 #if _LIBC 313 #if _LIBC
280 if (_IO_fwide (stderr, 0) > 0) 314 __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ",
281 __fwprintf (stderr, L"%s:%d: ", file_name, line_number); 315 file_name, line_number);
282 else 316 #else
317 fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
318 file_name, line_number);
283 #endif 319 #endif
284 fprintf (stderr, "%s:%d: ", file_name, line_number);
285 }
286 320
287 va_start (args, message); 321 va_start (args, message);
288 error_tail (status, errnum, message, args); 322 error_tail (status, errnum, message, args);
......
1 /* Declaration for error-reporting function 1 /* Declaration for error-reporting function
2 Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc. 2 Copyright (C) 1995, 1996, 1997, 2003, 2006 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
21 21
22 #ifndef __attribute__ 22 #ifndef __attribute__
23 /* This feature is available in gcc versions 2.5 and later. */ 23 /* This feature is available in gcc versions 2.5 and later. */
24 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) 24 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
25 # define __attribute__(Spec) /* empty */ 25 # define __attribute__(Spec) /* empty */
26 # endif 26 # endif
27 /* The __-protected variants of `format' and `printf' attributes 27 /* The __-protected variants of `format' and `printf' attributes
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
21 /* Get exit() declaration. */ 21 /* Get exit() declaration. */
22 #include <stdlib.h> 22 #include <stdlib.h>
23 23
24 /* Some systems do not define EXIT_*, even with STDC_HEADERS. */ 24 /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
25 #ifndef EXIT_SUCCESS 25 #ifndef EXIT_SUCCESS
26 # define EXIT_SUCCESS 0 26 # define EXIT_SUCCESS 0
27 #endif 27 #endif
......
1 /* Failure exit status 1 /* Failure exit status
2 2
3 Copyright (C) 2002, 2003 Free Software Foundation, Inc. 3 Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
......
1 /* Determine the number of screen columns needed for a string. 1 /* Determine the number of screen columns needed for a string.
2 Copyright (C) 2000-2005 Free Software Foundation, Inc. 2 Copyright (C) 2000-2006 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
32 /* Get isprint(). */ 32 /* Get isprint(). */
33 #include <ctype.h> 33 #include <ctype.h>
34 34
35 /* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */ 35 /* Get mbstate_t, mbrtowc(), mbsinit(). */
36 #if HAVE_WCHAR_H 36 #if HAVE_WCHAR_H
37 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 37 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
38 <wchar.h>. 38 <wchar.h>.
...@@ -43,15 +43,15 @@ ...@@ -43,15 +43,15 @@
43 # include <wchar.h> 43 # include <wchar.h>
44 #endif 44 #endif
45 45
46 /* Get iswprint(), iswcntrl(). */ 46 /* Get wcwidth(). */
47 #include "wcwidth.h"
48
49 /* Get iswcntrl(). */
47 #if HAVE_WCTYPE_H 50 #if HAVE_WCTYPE_H
48 # include <wctype.h> 51 # include <wctype.h>
49 #endif 52 #endif
50 #if !defined iswprint && !HAVE_ISWPRINT
51 # define iswprint(wc) 1
52 #endif
53 #if !defined iswcntrl && !HAVE_ISWCNTRL 53 #if !defined iswcntrl && !HAVE_ISWCNTRL
54 # define iswcntrl(wc) 0 54 # define iswcntrl(wc) (((wc) & ~0x1f) == 0 || (wc) == 0x7f)
55 #endif 55 #endif
56 56
57 #ifndef mbsinit 57 #ifndef mbsinit
...@@ -60,33 +60,6 @@ ...@@ -60,33 +60,6 @@
60 # endif 60 # endif
61 #endif 61 #endif
62 62
63 #ifndef HAVE_DECL_WCWIDTH
64 "this configure-time declaration test was not run"
65 #endif
66 #if !HAVE_DECL_WCWIDTH
67 int wcwidth ();
68 #endif
69
70 #ifndef wcwidth
71 # if !HAVE_WCWIDTH
72 /* wcwidth doesn't exist, so assume all printable characters have
73 width 1. */
74 # define wcwidth(wc) ((wc) == 0 ? 0 : iswprint (wc) ? 1 : -1)
75 # endif
76 #endif
77
78 /* Get ISPRINT. */
79 #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
80 # define IN_CTYPE_DOMAIN(c) 1
81 #else
82 # define IN_CTYPE_DOMAIN(c) isascii(c)
83 #endif
84 /* Undefine to protect against the definition in wctype.h of Solaris 2.6. */
85 #undef ISPRINT
86 #define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
87 #undef ISCNTRL
88 #define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
89
90 /* Returns the number of columns needed to represent the multibyte 63 /* Returns the number of columns needed to represent the multibyte
91 character string pointed to by STRING. If a non-printable character 64 character string pointed to by STRING. If a non-printable character
92 occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned. 65 occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned.
...@@ -210,10 +183,10 @@ mbsnwidth (const char *string, size_t nbytes, int flags) ...@@ -210,10 +183,10 @@ mbsnwidth (const char *string, size_t nbytes, int flags)
210 { 183 {
211 unsigned char c = (unsigned char) *p++; 184 unsigned char c = (unsigned char) *p++;
212 185
213 if (ISPRINT (c)) 186 if (isprint (c))
214 width++; 187 width++;
215 else if (!(flags & MBSW_REJECT_UNPRINTABLE)) 188 else if (!(flags & MBSW_REJECT_UNPRINTABLE))
216 width += (ISCNTRL (c) ? 0 : 1); 189 width += (iscntrl (c) ? 0 : 1);
217 else 190 else
218 return -1; 191 return -1;
219 } 192 }
......
1 /* obstack.c - subroutines used implicitly by object stack macros 1 /* obstack.c - subroutines used implicitly by object stack macros
2 2
3 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 3 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
4 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, 4 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
5 Inc. 5 Foundation, Inc.
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
...@@ -55,13 +55,7 @@ ...@@ -55,13 +55,7 @@
55 55
56 #ifndef ELIDE_CODE 56 #ifndef ELIDE_CODE
57 57
58 58 # include <stdint.h>
59 # if HAVE_INTTYPES_H
60 # include <inttypes.h>
61 # endif
62 # if HAVE_STDINT_H || defined _LIBC
63 # include <stdint.h>
64 # endif
65 59
66 /* Determine default alignment. */ 60 /* Determine default alignment. */
67 union fooround 61 union fooround
......
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 #include <string.h> 29 #include <string.h>
30 #include <unistd.h> 30 #if _LIBC || HAVE_UNISTD_H
31 # include <unistd.h>
32 #endif
31 33
32 #if !_LIBC 34 #if !_LIBC
33 # include "allocsa.h" 35 # include "allocsa.h"
......
1 /* Formatted output to strings. 1 /* Formatted output to strings.
2 Copyright (C) 2004 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2006 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson and Paul Eggert.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
...@@ -22,13 +22,19 @@ ...@@ -22,13 +22,19 @@
22 22
23 #include "snprintf.h" 23 #include "snprintf.h"
24 24
25 #include <errno.h>
26 #include <limits.h>
25 #include <stdarg.h> 27 #include <stdarg.h>
26 #include <stdlib.h> 28 #include <stdlib.h>
27 #include <string.h> 29 #include <string.h>
28 30
29 #include "minmax.h"
30 #include "vasnprintf.h" 31 #include "vasnprintf.h"
31 32
33 /* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
34 #ifndef EOVERFLOW
35 # define EOVERFLOW E2BIG
36 #endif
37
32 /* Print formatted output to string STR. Similar to sprintf, but 38 /* Print formatted output to string STR. Similar to sprintf, but
33 additional length SIZE limit how much is written into STR. Returns 39 additional length SIZE limit how much is written into STR. Returns
34 string length of formatted string (which may be larger than SIZE). 40 string length of formatted string (which may be larger than SIZE).
...@@ -39,22 +45,34 @@ snprintf (char *str, size_t size, const char *format, ...) ...@@ -39,22 +45,34 @@ snprintf (char *str, size_t size, const char *format, ...)
39 { 45 {
40 char *output; 46 char *output;
41 size_t len; 47 size_t len;
48 size_t lenbuf = size;
42 va_list args; 49 va_list args;
43 50
44 va_start (args, format); 51 va_start (args, format);
45 len = size; 52 output = vasnprintf (str, &lenbuf, format, args);
46 output = vasnprintf (str, &len, format, args); 53 len = lenbuf;
47 va_end (args); 54 va_end (args);
48 55
49 if (!output) 56 if (!output)
50 return -1; 57 return -1;
51 58
52 if (str != NULL)
53 if (len > size - 1) /* equivalent to: (size > 0 && len >= size) */
54 str[size - 1] = '\0';
55
56 if (output != str) 59 if (output != str)
57 free (output); 60 {
61 if (size)
62 {
63 size_t pruned_len = (len < size ? len : size - 1);
64 memcpy (str, output, pruned_len);
65 str[pruned_len] = '\0';
66 }
67
68 free (output);
69 }
70
71 if (INT_MAX < len)
72 {
73 errno = EOVERFLOW;
74 return -1;
75 }
58 76
59 return len; 77 return len;
60 } 78 }
......
1 /* Formatted output to strings. 1 /* Formatted output to strings.
2 Copyright (C) 1999, 2002 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -22,10 +22,17 @@ ...@@ -22,10 +22,17 @@
22 /* Specification. */ 22 /* Specification. */
23 #include "vasprintf.h" 23 #include "vasprintf.h"
24 24
25 #include <errno.h>
26 #include <limits.h>
25 #include <stdlib.h> 27 #include <stdlib.h>
26 28
27 #include "vasnprintf.h" 29 #include "vasnprintf.h"
28 30
31 /* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
32 #ifndef EOVERFLOW
33 # define EOVERFLOW E2BIG
34 #endif
35
29 int 36 int
30 vasprintf (char **resultp, const char *format, va_list args) 37 vasprintf (char **resultp, const char *format, va_list args)
31 { 38 {
...@@ -34,9 +41,14 @@ vasprintf (char **resultp, const char *format, va_list args) ...@@ -34,9 +41,14 @@ vasprintf (char **resultp, const char *format, va_list args)
34 if (result == NULL) 41 if (result == NULL)
35 return -1; 42 return -1;
36 43
44 if (length > INT_MAX)
45 {
46 free (result);
47 errno = EOVERFLOW;
48 return -1;
49 }
50
37 *resultp = result; 51 *resultp = result;
38 /* Return the number of resulting bytes, excluding the trailing NUL. 52 /* Return the number of resulting bytes, excluding the trailing NUL. */
39 If it wouldn't fit in an 'int', vasnprintf() would have returned NULL
40 and set errno to EOVERFLOW. */
41 return length; 53 return length;
42 } 54 }
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU General Public License
15 with this program; if not, write to the Free Software Foundation, 15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 17
18 #ifndef _VASPRINTF_H 18 #ifndef _VASPRINTF_H
......
1 # argp.m4 serial 6 1 # argp.m4 serial 7
2 dnl Copyright (C) 2003-2006 Free Software Foundation, Inc. 2 dnl Copyright (C) 2003-2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
...@@ -7,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. ...@@ -7,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_ARGP], 7 AC_DEFUN([gl_ARGP],
8 [ 8 [
9 AC_REQUIRE([AC_C_INLINE]) 9 AC_REQUIRE([AC_C_INLINE])
10 AC_REQUIRE([AC_C_RESTRICT])
10 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 11 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
11 AC_REQUIRE([gl_GETOPT_SUBSTITUTE]) 12 AC_REQUIRE([gl_GETOPT_SUBSTITUTE])
12 13
...@@ -14,13 +15,13 @@ AC_DEFUN([gl_ARGP], ...@@ -14,13 +15,13 @@ AC_DEFUN([gl_ARGP],
14 [AC_DEFINE(HAVE_DECL_PROGRAM_INVOCATION_NAME, 1, 15 [AC_DEFINE(HAVE_DECL_PROGRAM_INVOCATION_NAME, 1,
15 [Define if program_invocation_name is declared])], 16 [Define if program_invocation_name is declared])],
16 [AC_DEFINE(GNULIB_PROGRAM_INVOCATION_NAME, 1, 17 [AC_DEFINE(GNULIB_PROGRAM_INVOCATION_NAME, 1,
17 [Define to 1 to add extern declaration of program_invocation_name to argp-namefrob.h])], 18 [Define to 1 to add extern declaration of program_invocation_name to argp.h])],
18 [#include <errno.h>]) 19 [#include <errno.h>])
19 AC_CHECK_DECL([program_invocation_short_name], 20 AC_CHECK_DECL([program_invocation_short_name],
20 [AC_DEFINE(HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME, 1, 21 [AC_DEFINE(HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME, 1,
21 [Define if program_invocation_short_name is declared])], 22 [Define if program_invocation_short_name is declared])],
22 [AC_DEFINE(GNULIB_PROGRAM_INVOCATION_SHORT_NAME, 1, 23 [AC_DEFINE(GNULIB_PROGRAM_INVOCATION_SHORT_NAME, 1,
23 [Define to 1 to add extern declaration of program_invocation_short_name to argp-namefrob.h])], 24 [Define to 1 to add extern declaration of program_invocation_short_name to argp.h])],
24 [#include <errno.h>]) 25 [#include <errno.h>])
25 26
26 # Check if program_invocation_name and program_invocation_short_name 27 # Check if program_invocation_name and program_invocation_short_name
......
1 #serial 8 1 #serial 9
2 2
3 dnl From Jim Meyering. 3 dnl From Jim Meyering.
4 dnl 4 dnl
5 dnl Check whether struct dirent has a member named d_type. 5 dnl Check whether struct dirent has a member named d_type.
6 dnl 6 dnl
7 7
8 # Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004 Free Software 8 # Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software
9 # Foundation, Inc. 9 # Foundation, Inc.
10 # 10 #
11 # This file is free software; the Free Software Foundation 11 # This file is free software; the Free Software Foundation
...@@ -13,26 +13,12 @@ dnl ...@@ -13,26 +13,12 @@ dnl
13 # with or without modifications, as long as this notice is preserved. 13 # with or without modifications, as long as this notice is preserved.
14 14
15 AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE], 15 AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
16 [AC_REQUIRE([AC_HEADER_DIRENT])dnl 16 [AC_CACHE_CHECK([for d_type member in directory struct],
17 AC_CACHE_CHECK([for d_type member in directory struct],
18 jm_cv_struct_dirent_d_type, 17 jm_cv_struct_dirent_d_type,
19 [AC_TRY_LINK(dnl 18 [AC_TRY_LINK(dnl
20 [ 19 [
21 #include <sys/types.h> 20 #include <sys/types.h>
22 #ifdef HAVE_DIRENT_H 21 #include <dirent.h>
23 # include <dirent.h>
24 #else /* not HAVE_DIRENT_H */
25 # define dirent direct
26 # ifdef HAVE_SYS_NDIR_H
27 # include <sys/ndir.h>
28 # endif /* HAVE_SYS_NDIR_H */
29 # ifdef HAVE_SYS_DIR_H
30 # include <sys/dir.h>
31 # endif /* HAVE_SYS_DIR_H */
32 # ifdef HAVE_NDIR_H
33 # include <ndir.h>
34 # endif /* HAVE_NDIR_H */
35 #endif /* HAVE_DIRENT_H */
36 ], 22 ],
37 [struct dirent dp; dp.d_type = 0;], 23 [struct dirent dp; dp.d_type = 0;],
38 24
......
1 # exitfail.m4 serial 5 1 # exitfail.m4 serial 6
2 dnl Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. 2 dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 AC_DEFUN([gl_EXITFAIL], 7 AC_DEFUN([gl_EXITFAIL],
8 [ 8 [
9 AC_LIBSOURCES([exitfail.c, exitfail.h])
10 AC_LIBOBJ([exitfail]) 9 AC_LIBOBJ([exitfail])
11 10
12 dnl No prerequisites of lib/exitfail.c. 11 dnl No prerequisites of lib/exitfail.c.
......
1 # Check for fnmatch. 1 # Check for fnmatch.
2 2
3 # This is a modified version of autoconf's AC_FUNC_FNMATCH. 3 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
4 # This file should be simplified after Autoconf 2.57 is required.
5
6 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software
7 # Foundation, Inc. 4 # Foundation, Inc.
8 # This file is free software; the Free Software Foundation 5 # This file is free software; the Free Software Foundation
9 # gives unlimited permission to copy and/or distribute it, 6 # gives unlimited permission to copy and/or distribute it,
10 # with or without modifications, as long as this notice is preserved. 7 # with or without modifications, as long as this notice is preserved.
11 8
9 # Autoconf defines AC_FUNC_FNMATCH, but that is obsolescent.
10 # New applications should use the macros below instead.
11
12 # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE) 12 # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
13 # ------------------------------------------------------------------------- 13 # -------------------------------------------------------------------------
14 # If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise 14 # If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
...@@ -61,10 +61,9 @@ AS_IF([test $$2 = yes], [$3], [$4]) ...@@ -61,10 +61,9 @@ AS_IF([test $$2 = yes], [$3], [$4])
61 # ------------------ 61 # ------------------
62 # Prepare the replacement of fnmatch. 62 # Prepare the replacement of fnmatch.
63 AC_DEFUN([_MU_LIBOBJ_FNMATCH], 63 AC_DEFUN([_MU_LIBOBJ_FNMATCH],
64 [AC_REQUIRE([AC_C_CONST])dnl 64 [AC_REQUIRE([AC_FUNC_ALLOCA])dnl
65 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
66 AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl 65 AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
67 AC_CHECK_DECLS([getenv]) 66 AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
68 AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy]) 67 AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy])
69 AC_CHECK_HEADERS([wchar.h wctype.h]) 68 AC_CHECK_HEADERS([wchar.h wctype.h])
70 MU_LIBOBJ([fnmatch]) 69 MU_LIBOBJ([fnmatch])
......
1 # getdelim.m4 serial 1 1 # getdelim.m4 serial 2
2 2
3 dnl Copyright (C) 2005 Free Software dnl Foundation, Inc. 3 dnl Copyright (C) 2005, 2006 Free Software dnl Foundation, Inc.
4 dnl 4 dnl
5 dnl This file is free software; the Free Software Foundation 5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it, 6 dnl gives unlimited permission to copy and/or distribute it,
...@@ -10,7 +10,6 @@ AC_PREREQ(2.52) ...@@ -10,7 +10,6 @@ AC_PREREQ(2.52)
10 10
11 AC_DEFUN([gl_FUNC_GETDELIM], 11 AC_DEFUN([gl_FUNC_GETDELIM],
12 [ 12 [
13 MU_LIBSOURCES([getdelim.c, getdelim.h])
14 13
15 dnl Persuade glibc <stdio.h> to declare getdelim(). 14 dnl Persuade glibc <stdio.h> to declare getdelim().
16 AC_REQUIRE([AC_GNU_SOURCE]) 15 AC_REQUIRE([AC_GNU_SOURCE])
......
1 # getline.m4 serial 13 1 # getline.m4 serial 15
2 2
3 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 Free Software 3 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 Free Software
4 dnl Foundation, Inc. 4 dnl Foundation, Inc.
5 dnl 5 dnl
6 dnl This file is free software; the Free Software Foundation 6 dnl This file is free software; the Free Software Foundation
...@@ -15,8 +15,6 @@ dnl have a function by that name in -linet that doesn't have anything ...@@ -15,8 +15,6 @@ dnl have a function by that name in -linet that doesn't have anything
15 dnl to do with the function we need. 15 dnl to do with the function we need.
16 AC_DEFUN([gl_FUNC_GETLINE], 16 AC_DEFUN([gl_FUNC_GETLINE],
17 [ 17 [
18 MU_LIBSOURCES([getline.c, getline.h])
19
20 dnl Persuade glibc <stdio.h> to declare getline(). 18 dnl Persuade glibc <stdio.h> to declare getline().
21 AC_REQUIRE([AC_GNU_SOURCE]) 19 AC_REQUIRE([AC_GNU_SOURCE])
22 20
...@@ -47,7 +45,18 @@ AC_DEFUN([gl_FUNC_GETLINE], ...@@ -47,7 +45,18 @@ AC_DEFUN([gl_FUNC_GETLINE],
47 } 45 }
48 ], am_cv_func_working_getline=yes dnl The library version works. 46 ], am_cv_func_working_getline=yes dnl The library version works.
49 , am_cv_func_working_getline=no dnl The library version does NOT work. 47 , am_cv_func_working_getline=no dnl The library version does NOT work.
50 , am_cv_func_working_getline=no dnl We're cross compiling. 48 , dnl We're cross compiling. Assume it works on glibc2 systems.
49 [AC_EGREP_CPP([Lucky GNU user],
50 [
51 #include <features.h>
52 #ifdef __GNU_LIBRARY__
53 #if (__GLIBC__ >= 2)
54 Lucky GNU user
55 #endif
56 #endif
57 ],
58 [am_cv_func_working_getline=yes],
59 [am_cv_func_working_getline=no])]
51 )]) 60 )])
52 fi 61 fi
53 62
......
1 #serial 2 1 #serial 3
2 2
3 # Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3 # Copyright (C) 2005, 2006 Free Software Foundation, Inc.
4 # 4 #
...@@ -14,7 +14,6 @@ dnl ...@@ -14,7 +14,6 @@ dnl
14 AC_DEFUN([gl_GETLOGIN_R_SUBSTITUTE], 14 AC_DEFUN([gl_GETLOGIN_R_SUBSTITUTE],
15 [ 15 [
16 gl_PREREQ_GETLOGIN_R 16 gl_PREREQ_GETLOGIN_R
17 MU_LIBSOURCE([getlogin_r.h])
18 MU_LIBOBJ([getlogin_r]) 17 MU_LIBOBJ([getlogin_r])
19 ]) 18 ])
20 19
......
1 # getopt.m4 serial 12 1 # getopt.m4 serial 13
2 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 2 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 # The getopt module assume you want GNU getopt, with getopt_long etc, 7 # The getopt module assume you want GNU getopt, with getopt_long etc,
8 # rather than vanilla POSIX getopt. This means your your code should 8 # rather than vanilla POSIX getopt. This means your code should
9 # always include <getopt.h> for the getopt prototypes. 9 # always include <getopt.h> for the getopt prototypes.
10 10
11 AC_DEFUN([gl_GETOPT_SUBSTITUTE], 11 AC_DEFUN([gl_GETOPT_SUBSTITUTE],
......
1 # getpass.m4 serial 7 1 # getpass.m4 serial 9
2 dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc. 2 dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
...@@ -7,8 +7,6 @@ dnl with or without modifications, as long as this notice is preserved. ...@@ -7,8 +7,6 @@ dnl with or without modifications, as long as this notice is preserved.
7 # Provide a getpass() function if the system doesn't have it. 7 # Provide a getpass() function if the system doesn't have it.
8 AC_DEFUN([gl_FUNC_GETPASS], 8 AC_DEFUN([gl_FUNC_GETPASS],
9 [ 9 [
10 AC_LIBSOURCES([getpass.c, getpass.h])
11
12 AC_REPLACE_FUNCS(getpass) 10 AC_REPLACE_FUNCS(getpass)
13 AC_CHECK_DECLS_ONCE(getpass) 11 AC_CHECK_DECLS_ONCE(getpass)
14 if test $ac_cv_func_getpass = no; then 12 if test $ac_cv_func_getpass = no; then
...@@ -20,8 +18,6 @@ AC_DEFUN([gl_FUNC_GETPASS], ...@@ -20,8 +18,6 @@ AC_DEFUN([gl_FUNC_GETPASS],
20 # arbitrary length (not just 8 bytes as on HP-UX). 18 # arbitrary length (not just 8 bytes as on HP-UX).
21 AC_DEFUN([gl_FUNC_GETPASS_GNU], 19 AC_DEFUN([gl_FUNC_GETPASS_GNU],
22 [ 20 [
23 AC_LIBSOURCES([getpass.c, getpass.h])
24
25 AC_CHECK_DECLS_ONCE(getpass) 21 AC_CHECK_DECLS_ONCE(getpass)
26 dnl TODO: Detect when GNU getpass() is already found in glibc. 22 dnl TODO: Detect when GNU getpass() is already found in glibc.
27 AC_LIBOBJ(getpass) 23 AC_LIBOBJ(getpass)
...@@ -42,4 +38,5 @@ AC_DEFUN([gl_PREREQ_GETPASS], [ ...@@ -42,4 +38,5 @@ AC_DEFUN([gl_PREREQ_GETPASS], [
42 AC_CHECK_DECLS_ONCE([fputs_unlocked]) 38 AC_CHECK_DECLS_ONCE([fputs_unlocked])
43 AC_CHECK_DECLS_ONCE([funlockfile]) 39 AC_CHECK_DECLS_ONCE([funlockfile])
44 AC_CHECK_DECLS_ONCE([putc_unlocked]) 40 AC_CHECK_DECLS_ONCE([putc_unlocked])
41 :
45 ]) 42 ])
......
1 # glob.m4 serial 3 1 # glob.m4 serial 7
2 dnl Copyright (C) 2005 Free Software Foundation, Inc. 2 dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 # The glob module assumes you want GNU glob, with glob_pattern_p etc, 7 # The glob module assumes you want GNU glob, with glob_pattern_p etc,
8 # rather than vanilla POSIX glob. This means your your code should 8 # rather than vanilla POSIX glob. This means your code should
9 # always include <glob.h> for the glob prototypes. 9 # always include <glob.h> for the glob prototypes.
10 10
11 AC_DEFUN([gl_GLOB_SUBSTITUTE], 11 AC_DEFUN([gl_GLOB_SUBSTITUTE],
...@@ -13,7 +13,6 @@ AC_DEFUN([gl_GLOB_SUBSTITUTE], ...@@ -13,7 +13,6 @@ AC_DEFUN([gl_GLOB_SUBSTITUTE],
13 gl_PREREQ_GLOB 13 gl_PREREQ_GLOB
14 14
15 GLOB_H=glob.h 15 GLOB_H=glob.h
16 MU_LIBSOURCES([glob.c, glob_.h, glob-libc.h])
17 MU_LIBOBJ([glob]) 16 MU_LIBOBJ([glob])
18 AC_SUBST([GLOB_H]) 17 AC_SUBST([GLOB_H])
19 ]) 18 ])
...@@ -73,8 +72,8 @@ if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) return 1;]]), ...@@ -73,8 +72,8 @@ if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) return 1;]]),
73 # Prerequisites of lib/glob.*. 72 # Prerequisites of lib/glob.*.
74 AC_DEFUN([gl_PREREQ_GLOB], 73 AC_DEFUN([gl_PREREQ_GLOB],
75 [ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])dnl 74 [ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])dnl
75 AC_REQUIRE([AC_C_RESTRICT])dnl
76 AC_REQUIRE([AC_GNU_SOURCE])dnl 76 AC_REQUIRE([AC_GNU_SOURCE])dnl
77 AC_REQUIRE([AC_HEADER_DIRENT])dnl
78 AC_CHECK_HEADERS_ONCE([sys/cdefs.h unistd.h])dnl 77 AC_CHECK_HEADERS_ONCE([sys/cdefs.h unistd.h])dnl
79 AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r])dnl 78 AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r])dnl
80 :]) 79 :])
......
1 # intmax_t.m4 serial 4 1 # intmax_t.m4 serial 5
2 dnl Copyright (C) 1997-2004 Free Software Foundation, Inc. 2 dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
...@@ -46,7 +46,7 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T], ...@@ -46,7 +46,7 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T],
46 #if HAVE_INTTYPES_H_WITH_UINTMAX 46 #if HAVE_INTTYPES_H_WITH_UINTMAX
47 #include <inttypes.h> 47 #include <inttypes.h>
48 #endif 48 #endif
49 ], [intmax_t x = -1;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)]) 49 ], [intmax_t x = -1; return !x;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)])
50 if test $gt_cv_c_intmax_t = yes; then 50 if test $gt_cv_c_intmax_t = yes; then
51 AC_DEFINE(HAVE_INTMAX_T, 1, 51 AC_DEFINE(HAVE_INTMAX_T, 1,
52 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.]) 52 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
......
1 #serial 5 1 #serial 6
2 dnl Copyright (C) 2004, 2005 Free Software Foundation, Inc. 2 dnl Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 AC_DEFUN([gl_INTTOSTR], 7 AC_DEFUN([gl_INTTOSTR],
8 [ 8 [
9 MU_LIBSOURCES([inttostr.c, inttostr.h, intprops.h])
10
11 dnl We don't technically need to list the following .c files, since their
12 dnl functions are named in the MU_LIBOBJ calls, but this is an unusual
13 dnl module and it seems a little clearer to do so.
14 MU_LIBSOURCES([imaxtostr.c, offtostr.c, umaxtostr.c])
15
16 MU_LIBOBJ([imaxtostr]) 9 MU_LIBOBJ([imaxtostr])
17 MU_LIBOBJ([offtostr]) 10 MU_LIBOBJ([offtostr])
18 MU_LIBOBJ([umaxtostr]) 11 MU_LIBOBJ([umaxtostr])
...@@ -25,8 +18,6 @@ AC_DEFUN([gl_INTTOSTR], ...@@ -25,8 +18,6 @@ AC_DEFUN([gl_INTTOSTR],
25 18
26 # Prerequisites of lib/inttostr.h. 19 # Prerequisites of lib/inttostr.h.
27 AC_DEFUN([gl_PREREQ_INTTOSTR], [ 20 AC_DEFUN([gl_PREREQ_INTTOSTR], [
28 AC_REQUIRE([gl_AC_TYPE_INTMAX_T])
29 AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])
30 AC_REQUIRE([AC_TYPE_OFF_T]) 21 AC_REQUIRE([AC_TYPE_OFF_T])
31 : 22 :
32 ]) 23 ])
......
1 # inttypes_h.m4 serial 6 1 # inttypes_h.m4 serial 7
2 dnl Copyright (C) 1997-2004 Free Software Foundation, Inc. 2 dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
...@@ -15,7 +15,7 @@ AC_DEFUN([gl_AC_HEADER_INTTYPES_H], ...@@ -15,7 +15,7 @@ AC_DEFUN([gl_AC_HEADER_INTTYPES_H],
15 [AC_TRY_COMPILE( 15 [AC_TRY_COMPILE(
16 [#include <sys/types.h> 16 [#include <sys/types.h>
17 #include <inttypes.h>], 17 #include <inttypes.h>],
18 [uintmax_t i = (uintmax_t) -1;], 18 [uintmax_t i = (uintmax_t) -1; return !i;],
19 gl_cv_header_inttypes_h=yes, 19 gl_cv_header_inttypes_h=yes,
20 gl_cv_header_inttypes_h=no)]) 20 gl_cv_header_inttypes_h=no)])
21 if test $gl_cv_header_inttypes_h = yes; then 21 if test $gl_cv_header_inttypes_h = yes; then
......
1 # longlong.m4 serial 5 1 # longlong.m4 serial 7
2 dnl Copyright (C) 1999-2004 Free Software Foundation, Inc. 2 dnl Copyright (C) 1999-2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 dnl From Paul Eggert. 7 dnl From Paul Eggert.
8 8
9 # Define HAVE_LONG_LONG if 'long long' works. 9 # Define HAVE_LONG_LONG_INT if 'long long int' works.
10 # This fixes a bug in Autoconf 2.60, but can be removed once we
11 # assume 2.61 everywhere.
10 12
13 AC_DEFUN([AC_TYPE_LONG_LONG_INT],
14 [
15 AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
16 [AC_LINK_IFELSE(
17 [AC_LANG_PROGRAM(
18 [[long long int ll = 9223372036854775807ll;
19 long long int nll = -9223372036854775807LL;
20 typedef int a[((-9223372036854775807LL < 0
21 && 0 < 9223372036854775807ll)
22 ? 1 : -1)];
23 int i = 63;]],
24 [[long long int llmax = 9223372036854775807ll;
25 return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
26 | (llmax / ll) | (llmax % ll));]])],
27 [ac_cv_type_long_long_int=yes],
28 [ac_cv_type_long_long_int=no])])
29 if test $ac_cv_type_long_long_int = yes; then
30 AC_DEFINE([HAVE_LONG_LONG_INT], 1,
31 [Define to 1 if the system has the type `long long int'.])
32 fi
33 ])
34
35 # This macro is obsolescent and should go away soon.
11 AC_DEFUN([gl_AC_TYPE_LONG_LONG], 36 AC_DEFUN([gl_AC_TYPE_LONG_LONG],
12 [ 37 [
13 AC_CACHE_CHECK([for long long], ac_cv_type_long_long, 38 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
14 [AC_TRY_LINK([long long ll = 1LL; int i = 63;], 39 ac_cv_type_long_long=$ac_cv_type_long_long_int
15 [long long llmax = (long long) -1;
16 return ll << i | ll >> i | llmax / ll | llmax % ll;],
17 ac_cv_type_long_long=yes,
18 ac_cv_type_long_long=no)])
19 if test $ac_cv_type_long_long = yes; then 40 if test $ac_cv_type_long_long = yes; then
20 AC_DEFINE(HAVE_LONG_LONG, 1, 41 AC_DEFINE(HAVE_LONG_LONG, 1,
21 [Define if you have the 'long long' type.]) 42 [Define if you have the 'long long' type.])
......
1 # mbchar.m4 serial 2 1 # mbchar.m4 serial 4
2 dnl Copyright (C) 2005 Free Software Foundation, Inc. 2 dnl Copyright (C) 2005-2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
...@@ -10,11 +10,14 @@ dnl From Bruno Haible. ...@@ -10,11 +10,14 @@ dnl From Bruno Haible.
10 AC_DEFUN([gl_MBCHAR], 10 AC_DEFUN([gl_MBCHAR],
11 [ 11 [
12 AC_REQUIRE([AC_GNU_SOURCE]) 12 AC_REQUIRE([AC_GNU_SOURCE])
13 dnl The following line is that so the user can test 13 dnl The following line is that so the user can test HAVE_WCHAR_H
14 dnl HAVE_WCHAR_H && HAVE_WCTYPE_H before #include "mbchar.h". 14 dnl before #include "mbchar.h".
15 AC_CHECK_HEADERS_ONCE(wchar.h wctype.h) 15 AC_CHECK_HEADERS_ONCE([wchar.h])
16 dnl Compile mbchar.c only if HAVE_WCHAR_H && HAVE_WCTYPE_H. 16 dnl Compile mbchar.c only if HAVE_WCHAR_H.
17 if test $ac_cv_header_wchar_h = yes && test $ac_cv_header_wctype_h = yes; then 17 if test $ac_cv_header_wchar_h = yes; then
18 MU_LIBOBJ([mbchar]) 18 MU_LIBOBJ([mbchar])
19 dnl Prerequisites of mbchar.h and mbchar.c.
20 AC_CHECK_HEADERS_ONCE([wctype.h])
21 AC_CHECK_FUNCS([iswcntrl])
19 fi 22 fi
20 ]) 23 ])
......
1 # mbswidth.m4 serial 11 1 # mbswidth.m4 serial 12
2 dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc. 2 dnl Copyright (C) 2000-2002, 2004, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
...@@ -9,33 +9,11 @@ dnl From Bruno Haible. ...@@ -9,33 +9,11 @@ dnl From Bruno Haible.
9 9
10 AC_DEFUN([gl_MBSWIDTH], 10 AC_DEFUN([gl_MBSWIDTH],
11 [ 11 [
12 AC_CHECK_HEADERS_ONCE(wchar.h wctype.h) 12 AC_CHECK_HEADERS_ONCE([wchar.h wctype.h])
13 AC_CHECK_FUNCS_ONCE(isascii iswprint mbsinit) 13 AC_CHECK_FUNCS_ONCE([isascii mbsinit])
14 AC_CHECK_FUNCS(iswcntrl wcwidth) 14 AC_CHECK_FUNCS([iswcntrl])
15 gl_FUNC_MBRTOWC 15 gl_FUNC_MBRTOWC
16 16
17 AC_CACHE_CHECK([whether wcwidth is declared], ac_cv_have_decl_wcwidth,
18 [AC_TRY_COMPILE([
19 /* AIX 3.2.5 declares wcwidth in <string.h>. */
20 #if HAVE_STRING_H
21 # include <string.h>
22 #endif
23 #if HAVE_WCHAR_H
24 # include <wchar.h>
25 #endif
26 ], [
27 #ifndef wcwidth
28 char *p = (char *) wcwidth;
29 #endif
30 ], ac_cv_have_decl_wcwidth=yes, ac_cv_have_decl_wcwidth=no)])
31 if test $ac_cv_have_decl_wcwidth = yes; then
32 ac_val=1
33 else
34 ac_val=0
35 fi
36 AC_DEFINE_UNQUOTED(HAVE_DECL_WCWIDTH, $ac_val,
37 [Define to 1 if you have the declaration of wcwidth(), and to 0 otherwise.])
38
39 dnl UnixWare 7.1.1 <wchar.h> has a declaration of a function mbswidth() 17 dnl UnixWare 7.1.1 <wchar.h> has a declaration of a function mbswidth()
40 dnl that clashes with ours. 18 dnl that clashes with ours.
41 AC_CACHE_CHECK([whether mbswidth is declared in <wchar.h>], 19 AC_CACHE_CHECK([whether mbswidth is declared in <wchar.h>],
......
1 # md5.m4 serial 8 1 # md5.m4 serial 9
2 dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 2 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 AC_DEFUN([gl_MD5], 7 AC_DEFUN([gl_MD5],
8 [ 8 [
9 MU_LIBSOURCES([md5.c, md5.h])
10 MU_LIBOBJ([md5]) 9 MU_LIBOBJ([md5])
11 10
12 dnl Prerequisites of lib/md5.c. 11 dnl Prerequisites of lib/md5.c.
......
1 # mempcpy.m4 serial 3 1 # mempcpy.m4 serial 4
2 dnl Copyright (C) 2003, 2004 Free Software Foundation, Inc. 2 dnl Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 AC_DEFUN([gl_FUNC_MEMPCPY], 7 AC_DEFUN([gl_FUNC_MEMPCPY],
8 [ 8 [
9 MU_LIBSOURCES([mempcpy.c, mempcpy.h])
10 9
11 dnl Persuade glibc <string.h> to declare mempcpy(). 10 dnl Persuade glibc <string.h> to declare mempcpy().
12 AC_REQUIRE([AC_GNU_SOURCE]) 11 AC_REQUIRE([AC_GNU_SOURCE])
......
1 # onceonly_2_57.m4 serial 3 1 # onceonly_2_57.m4 serial 4
2 dnl Copyright (C) 2002-2003, 2005 Free Software Foundation, Inc. 2 dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc.
3 dnl This file is free software, distributed under the terms of the GNU 3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License. As a special exception to the GNU General 4 dnl General Public License. As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program 5 dnl Public License, this file may be distributed as part of a program
...@@ -7,10 +7,10 @@ dnl that contains a configuration script generated by Autoconf, under ...@@ -7,10 +7,10 @@ dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program. 7 dnl the same distribution terms as the rest of that program.
8 8
9 dnl This file defines some "once only" variants of standard autoconf macros. 9 dnl This file defines some "once only" variants of standard autoconf macros.
10 dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS 10 dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS
11 dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS 11 dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS
12 dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS 12 dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS
13 dnl AC_REQUIRE([AC_HEADER_STDC]) like AC_HEADER_STDC 13 dnl AC_REQUIRE([AC_FUNC_STRCOLL]) like AC_FUNC_STRCOLL
14 dnl The advantage is that the check for each of the headers/functions/decls 14 dnl The advantage is that the check for each of the headers/functions/decls
15 dnl will be put only once into the 'configure' file. It keeps the size of 15 dnl will be put only once into the 'configure' file. It keeps the size of
16 dnl the 'configure' file down, and avoids redundant output when 'configure' 16 dnl the 'configure' file down, and avoids redundant output when 'configure'
......
1 #serial 36 1 #serial 39
2 2
3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
4 # 2006 Free Software Foundation, Inc. 4 # 2006 Free Software Foundation, Inc.
...@@ -14,10 +14,6 @@ AC_PREREQ([2.50]) ...@@ -14,10 +14,6 @@ AC_PREREQ([2.50])
14 14
15 AC_DEFUN([gl_REGEX], 15 AC_DEFUN([gl_REGEX],
16 [ 16 [
17 MU_LIBSOURCES(
18 [regcomp.c, regex.c, regex.h,
19 regex_internal.c, regex_internal.h, regexec.c])
20
21 AC_ARG_WITH([included-regex], 17 AC_ARG_WITH([included-regex],
22 [AC_HELP_STRING([--without-included-regex], 18 [AC_HELP_STRING([--without-included-regex],
23 [don't compile regex; this is the default on 19 [don't compile regex; this is the default on
...@@ -28,7 +24,7 @@ AC_DEFUN([gl_REGEX], ...@@ -28,7 +24,7 @@ AC_DEFUN([gl_REGEX],
28 yes|no) ac_use_included_regex=$with_included_regex 24 yes|no) ac_use_included_regex=$with_included_regex
29 ;; 25 ;;
30 '') 26 '')
31 # If the system regex support is good enough that it passes the the 27 # If the system regex support is good enough that it passes the
32 # following run test, then default to *not* using the included regex.c. 28 # following run test, then default to *not* using the included regex.c.
33 # If cross compiling, assume the test would fail and use the included 29 # If cross compiling, assume the test would fail and use the included
34 # regex.c. The first failing regular expression is from `Spencer ere 30 # regex.c. The first failing regular expression is from `Spencer ere
...@@ -163,8 +159,9 @@ AC_DEFUN([gl_REGEX], ...@@ -163,8 +159,9 @@ AC_DEFUN([gl_REGEX],
163 AC_DEFUN([gl_PREREQ_REGEX], 159 AC_DEFUN([gl_PREREQ_REGEX],
164 [ 160 [
165 AC_REQUIRE([AC_GNU_SOURCE]) 161 AC_REQUIRE([AC_GNU_SOURCE])
166 AC_REQUIRE([gl_C_RESTRICT]) 162 AC_REQUIRE([AC_C_RESTRICT])
167 AC_REQUIRE([AM_LANGINFO_CODESET]) 163 AC_REQUIRE([AM_LANGINFO_CODESET])
168 AC_CHECK_HEADERS_ONCE([locale.h wchar.h wctype.h]) 164 AC_CHECK_HEADERS_ONCE([locale.h wchar.h wctype.h])
169 AC_CHECK_FUNCS_ONCE([isblank mbrtowc mempcpy wcrtomb wcscoll]) 165 AC_CHECK_FUNCS_ONCE([mbrtowc mempcpy wcrtomb wcscoll])
166 AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
170 ]) 167 ])
......
1 # sha1.m4 serial 6 1 # sha1.m4 serial 7
2 dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 2 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 AC_DEFUN([gl_SHA1], 7 AC_DEFUN([gl_SHA1],
8 [ 8 [
9 MU_LIBSOURCES([sha1.c, sha1.h])
10 MU_LIBOBJ([sha1]) 9 MU_LIBOBJ([sha1])
11 10
12 dnl Prerequisites of lib/sha1.c. 11 dnl Prerequisites of lib/sha1.c.
......
1 #serial 2 1 #serial 3
2 2
3 # Copyright (C) 2005 Free Software Foundation, Inc. 3 # Copyright (C) 2005, 2006 Free Software Foundation, Inc.
4 # 4 #
5 # This file is free software; the Free Software Foundation 5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it, 6 # gives unlimited permission to copy and/or distribute it,
...@@ -8,7 +8,5 @@ ...@@ -8,7 +8,5 @@
8 8
9 AC_DEFUN([gl_STAT_MACROS], 9 AC_DEFUN([gl_STAT_MACROS],
10 [ 10 [
11 MU_LIBSOURCES([stat-macros.h])
12
13 AC_REQUIRE([AC_HEADER_STAT]) 11 AC_REQUIRE([AC_HEADER_STAT])
14 ]) 12 ])
......
1 # stdint.m4 serial 10 1 # stdint.m4 serial 18
2 dnl Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc. 2 dnl Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 dnl From Bruno Haible. 7 dnl From Paul Eggert and Bruno Haible.
8 dnl Test whether <stdint.h> is supported or must be substituted. 8 dnl Test whether <stdint.h> is supported or must be substituted.
9 9
10 AC_DEFUN([gl_STDINT_H], 10 AC_DEFUN([gl_STDINT_H],
11 [ 11 [
12 AC_PREREQ(2.59)dnl
13
14 dnl Check for long long int.
15 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
16 if test $ac_cv_type_long_long_int = yes; then
17 HAVE_LONG_LONG_INT=1
18 else
19 HAVE_LONG_LONG_INT=0
20 fi
21 AC_SUBST([HAVE_LONG_LONG_INT])
22
12 dnl Check for <wchar.h>. 23 dnl Check for <wchar.h>.
13 AC_CHECK_HEADERS_ONCE([wchar.h]) 24 AC_CHECK_HEADERS_ONCE([wchar.h])
14 if test $ac_cv_header_wchar_h = yes; then 25 if test $ac_cv_header_wchar_h = yes; then
...@@ -18,582 +29,186 @@ AC_DEFUN([gl_STDINT_H], ...@@ -18,582 +29,186 @@ AC_DEFUN([gl_STDINT_H],
18 fi 29 fi
19 AC_SUBST([HAVE_WCHAR_H]) 30 AC_SUBST([HAVE_WCHAR_H])
20 31
21 dnl Check for <stdint.h> that doesn't clash with <sys/types.h>. 32 dnl Check for <inttypes.h>.
22 gl_HEADER_STDINT_H 33 dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h.
23 if test $gl_cv_header_stdint_h = yes; then 34 if test $ac_cv_header_inttypes_h = yes; then
24 ac_cv_header_stdint_h=yes; dnl Hack for gl_FULL_HEADER_PATH.
25 gl_FULL_HEADER_PATH([stdint.h])
26 FULL_PATH_STDINT_H='<'$gl_cv_full_path_stdint_h'>'
27 AC_SUBST([FULL_PATH_STDINT_H])
28 HAVE_STDINT_H=1
29 else
30 HAVE_STDINT_H=0
31 fi
32 AC_SUBST([HAVE_STDINT_H])
33
34 dnl Check for <inttypes.h> that doesn't clash with <sys/types.h>.
35 gl_HEADER_INTTYPES_H
36 if test $gl_cv_header_inttypes_h = yes; then
37 ac_cv_header_inttypes_h=yes; dnl Hack for gl_FULL_HEADER_PATH.
38 gl_FULL_HEADER_PATH([inttypes.h])
39 FULL_PATH_INTTYPES_H='<'$gl_cv_full_path_inttypes_h'>'
40 AC_SUBST([FULL_PATH_INTTYPES_H])
41 HAVE_INTTYPES_H=1 35 HAVE_INTTYPES_H=1
42 else 36 else
43 HAVE_INTTYPES_H=0 37 HAVE_INTTYPES_H=0
44 fi 38 fi
45 AC_SUBST([HAVE_INTTYPES_H]) 39 AC_SUBST([HAVE_INTTYPES_H])
46 40
47 dnl Check for <sys/inttypes.h>. 41 dnl Check for <sys/types.h>.
48 AC_CHECK_HEADERS([sys/inttypes.h]) 42 dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h.
49 if test $ac_cv_header_sys_inttypes_h = yes; then 43 if test $ac_cv_header_sys_types_h = yes; then
50 HAVE_SYS_INTTYPES_H=1 44 HAVE_SYS_TYPES_H=1
51 else 45 else
52 HAVE_SYS_INTTYPES_H=0 46 HAVE_SYS_TYPES_H=0
53 fi 47 fi
54 AC_SUBST([HAVE_SYS_INTTYPES_H]) 48 AC_SUBST([HAVE_SYS_TYPES_H])
55 49
56 dnl Check for <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5). 50 dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_stdint_h.
57 AC_CHECK_HEADERS([sys/bitypes.h]) 51 if test $ac_cv_header_stdint_h = yes; then
58 if test $ac_cv_header_sys_bitypes_h = yes; then 52 gl_ABSOLUTE_HEADER([stdint.h])
59 HAVE_SYS_BITYPES_H=1 53 ABSOLUTE_STDINT_H=\"$gl_cv_absolute_stdint_h\"
60 else 54 HAVE_STDINT_H=1
61 HAVE_SYS_BITYPES_H=0
62 fi
63 AC_SUBST([HAVE_SYS_BITYPES_H])
64
65 dnl Is long == int64_t ?
66 AC_CACHE_CHECK([whether 'long' is 64 bit wide], gl_cv_long_bitsize_64, [
67 AC_TRY_COMPILE([
68 #define POW63 ((((((long) 1 << 15) << 15) << 15) << 15) << 3)
69 #define POW64 ((((((long) 1 << 15) << 15) << 15) << 15) << 4)
70 typedef int array [2 * (POW63 != 0 && POW64 == 0) - 1];
71 ], , gl_cv_long_bitsize_64=yes, gl_cv_long_bitsize_64=no)])
72 if test $gl_cv_long_bitsize_64 = yes; then
73 HAVE_LONG_64BIT=1
74 else
75 HAVE_LONG_64BIT=0
76 fi
77 AC_SUBST(HAVE_LONG_64BIT)
78
79 dnl Is long long == int64_t ?
80 AC_CACHE_CHECK([whether 'long long' is 64 bit wide], gl_cv_longlong_bitsize_64, [
81 AC_TRY_COMPILE([
82 #define POW63 ((((((long long) 1 << 15) << 15) << 15) << 15) << 3)
83 #define POW64 ((((((long long) 1 << 15) << 15) << 15) << 15) << 4)
84 typedef int array [2 * (POW63 != 0 && POW64 == 0) - 1];
85 ], , gl_cv_longlong_bitsize_64=yes, gl_cv_longlong_bitsize_64=no)])
86 if test $gl_cv_longlong_bitsize_64 = yes; then
87 HAVE_LONG_LONG_64BIT=1
88 else 55 else
89 HAVE_LONG_LONG_64BIT=0 56 ABSOLUTE_STDINT_H=\"no/such/file/stdint.h\"
57 HAVE_STDINT_H=0
90 fi 58 fi
91 AC_SUBST(HAVE_LONG_LONG_64BIT) 59 AC_SUBST([ABSOLUTE_STDINT_H])
60 AC_SUBST([HAVE_STDINT_H])
92 61
93 dnl Here we use FULL_PATH_INTTYPES_H and FULL_PATH_STDINT_H, not just 62 dnl Now see whether we need a substitute <stdint.h>. Use
94 dnl <inttypes.h> and <stdint.h>, so that it also works during a 63 dnl ABSOLUTE_STDINT_H, not <stdint.h>, so that it also works during
95 dnl "config.status --recheck" if an inttypes.h or stdint.h have been 64 dnl a "config.status --recheck" if a stdint.h has been
96 dnl created in the build directory. 65 dnl created in the build directory.
97 other_includes=' 66 if test $ac_cv_header_stdint_h = yes; then
98 /* Get those types that are already defined in other system include files. */ 67 AC_CACHE_CHECK([whether stdint.h conforms to C99],
99 #if defined(__FreeBSD__) && (__FreeBSD__ >= 3) && (__FreeBSD__ <= 4) 68 [gl_cv_header_working_stdint_h],
100 # include <sys/inttypes.h> 69 [gl_cv_header_working_stdint_h=no
70 AC_COMPILE_IFELSE([
71 AC_LANG_PROGRAM([[
72 #include <stddef.h>
73 #define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
74 #define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */
75 #include ABSOLUTE_STDINT_H
76 #ifdef INT8_MAX
77 int8_t a1 = INT8_MAX;
78 int8_t a1min = INT8_MIN;
101 #endif 79 #endif
102 #if defined(__OpenBSD__) || defined(__bsdi__) || defined(__sgi) 80 #ifdef INT16_MAX
103 # include <sys/types.h> 81 int16_t a2 = INT16_MAX;
104 # if HAVE_INTTYPES_H 82 int16_t a2min = INT16_MIN;
105 # include FULL_PATH_INTTYPES_H
106 # endif
107 #endif 83 #endif
108 #if defined(__linux__) && HAVE_SYS_BITYPES_H 84 #ifdef INT32_MAX
109 # include <sys/bitypes.h> 85 int32_t a3 = INT32_MAX;
86 int32_t a3min = INT32_MIN;
110 #endif 87 #endif
111 #if defined(__sun) && HAVE_SYS_INTTYPES_H 88 #ifdef INT64_MAX
112 # include <sys/inttypes.h> 89 int64_t a4 = INT64_MAX;
90 int64_t a4min = INT64_MIN;
113 #endif 91 #endif
114 #if (defined(__hpux) || defined(_AIX)) && HAVE_INTTYPES_H 92 #ifdef UINT8_MAX
115 # include FULL_PATH_INTTYPES_H 93 uint8_t b1 = UINT8_MAX;
94 #else
95 typedef int b1[(unsigned char) -1 != 255 ? 1 : -1];
116 #endif 96 #endif
117 #if HAVE_STDINT_H && !(defined(__sgi) && HAVE_INTTYPES_H && !defined(__c99)) 97 #ifdef UINT16_MAX
118 # include FULL_PATH_STDINT_H 98 uint16_t b2 = UINT16_MAX;
119 #endif 99 #endif
120 ' 100 #ifdef UINT32_MAX
121 gl_STDINT_CHECK_TYPES( 101 uint32_t b3 = UINT32_MAX;
122 [int8_t int16_t int32_t int64_t \
123 uint8_t uint16_t uint32_t uint64_t \
124 int_least8_t int_least16_t int_least32_t int_least64_t \
125 uint_least8_t uint_least16_t uint_least32_t uint_least64_t \
126 int_fast8_t int_fast16_t int_fast32_t int_fast64_t \
127 uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t \
128 intptr_t uintptr_t \
129 intmax_t uintmax_t],
130 [$other_includes],
131 [gl_cv_type_], [], [])
132
133 dnl Now see if we need a substitute <stdint.h>.
134 gl_cv_header_working_stdint_h=no
135 if test $gl_cv_header_stdint_h = yes; then
136 gl_STDINT_CHECK_TYPES(
137 [int64_t uint64_t \
138 int_least64_t uint_least64_t \
139 int_fast64_t uint_fast64_t],
140 [#include <stdint.h>],
141 [gl_cv_stdint_], [_IN_STDINT_H], [in <stdint.h>])
142 AC_COMPILE_IFELSE([
143 AC_LANG_PROGRAM([
144 #define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
145 #include <stdint.h>
146 int8_t a1 = INT8_C (17);
147 int16_t a2 = INT16_C (17);
148 int32_t a3 = INT32_C (17);
149 #if HAVE_INT64_T_IN_STDINT_H
150 int64_t a4 = INT64_C (17);
151 #endif 102 #endif
152 uint8_t b1 = UINT8_C (17); 103 #ifdef UINT64_MAX
153 uint16_t b2 = UINT16_C (17); 104 uint64_t b4 = UINT64_MAX;
154 uint32_t b3 = UINT32_C (17);
155 #if HAVE_UINT64_T_IN_STDINT_H
156 uint64_t b4 = UINT64_C (17);
157 #endif 105 #endif
158 int_least8_t c1 = 17; 106 int_least8_t c1 = INT8_C (0x7f);
159 int_least16_t c2 = 17; 107 int_least8_t c1max = INT_LEAST8_MAX;
160 int_least32_t c3 = 17; 108 int_least8_t c1min = INT_LEAST8_MIN;
161 #if HAVE_INT_LEAST64_T_IN_STDINT_H 109 int_least16_t c2 = INT16_C (0x7fff);
162 int_least64_t c4 = 17; 110 int_least16_t c2max = INT_LEAST16_MAX;
111 int_least16_t c2min = INT_LEAST16_MIN;
112 int_least32_t c3 = INT32_C (0x7fffffff);
113 int_least32_t c3max = INT_LEAST32_MAX;
114 int_least32_t c3min = INT_LEAST32_MIN;
115 int_least64_t c4 = INT64_C (0x7fffffffffffffff);
116 int_least64_t c4max = INT_LEAST64_MAX;
117 int_least64_t c4min = INT_LEAST64_MIN;
118 uint_least8_t d1 = UINT8_C (0xff);
119 uint_least8_t d1max = UINT_LEAST8_MAX;
120 uint_least16_t d2 = UINT16_C (0xffff);
121 uint_least16_t d2max = UINT_LEAST16_MAX;
122 uint_least32_t d3 = UINT32_C (0xffffffff);
123 uint_least32_t d3max = UINT_LEAST32_MAX;
124 uint_least64_t d4 = UINT64_C (0xffffffffffffffff);
125 uint_least64_t d4max = UINT_LEAST64_MAX;
126 int_fast8_t e1 = INT_FAST8_MAX;
127 int_fast8_t e1min = INT_FAST8_MIN;
128 int_fast16_t e2 = INT_FAST16_MAX;
129 int_fast16_t e2min = INT_FAST16_MIN;
130 int_fast32_t e3 = INT_FAST32_MAX;
131 int_fast32_t e3min = INT_FAST32_MIN;
132 int_fast64_t e4 = INT_FAST64_MAX;
133 int_fast64_t e4min = INT_FAST64_MIN;
134 uint_fast8_t f1 = UINT_FAST8_MAX;
135 uint_fast16_t f2 = UINT_FAST16_MAX;
136 uint_fast32_t f3 = UINT_FAST32_MAX;
137 uint_fast64_t f4 = UINT_FAST64_MAX;
138 #ifdef INTPTR_MAX
139 intptr_t g = INTPTR_MAX;
140 intptr_t gmin = INTPTR_MIN;
163 #endif 141 #endif
164 uint_least8_t d1 = 17; 142 #ifdef UINTPTR_MAX
165 uint_least16_t d2 = 17; 143 uintptr_t h = UINTPTR_MAX;
166 uint_least32_t d3 = 17;
167 #if HAVE_UINT_LEAST64_T_IN_STDINT_H
168 uint_least64_t d4 = 17;
169 #endif 144 #endif
170 int_fast8_t e1 = 17; 145 intmax_t i = INTMAX_MAX;
171 int_fast16_t e2 = 17; 146 uintmax_t j = UINTMAX_MAX;
172 int_fast32_t e3 = 17; 147 struct s {
173 #if HAVE_INT_FAST64_T_IN_STDINT_H 148 int check_PTRDIFF: PTRDIFF_MIN < 0 && 0 < PTRDIFF_MAX ? 1 : -1;
174 int_fast64_t e4 = 17; 149 int check_SIG_ATOMIC: SIG_ATOMIC_MIN <= 0 && 0 < SIG_ATOMIC_MAX ? 1 : -1;
150 int check_SIZE: 0 < SIZE_MAX ? 1 : -1;
151 int check_WCHAR: WCHAR_MIN <= 0 && 0 < WCHAR_MAX ? 1 : -1;
152 int check_WINT: WINT_MIN <= 0 && 0 < WINT_MAX ? 1 : -1;
153
154 /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */
155 int check_UINT8_C:
156 (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1;
157 int check_UINT16_C:
158 (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1;
159
160 /* Detect bugs in OpenBSD 3.9 stdint.h. */
161 #ifdef UINT8_MAX
162 int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1;
175 #endif 163 #endif
176 uint_fast8_t f1 = 17; 164 #ifdef UINT16_MAX
177 uint_fast16_t f2 = 17; 165 int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1;
178 uint_fast32_t f3 = 17;
179 #if HAVE_UINT_FAST64_T_IN_STDINT_H
180 uint_fast64_t f4 = 17;
181 #endif 166 #endif
182 intptr_t g = 17; 167 #ifdef UINT32_MAX
183 uintptr_t h = 17; 168 int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1;
184 intmax_t i = INTMAX_C (17);
185 uintmax_t j = UINTMAX_C (17);
186 ])],
187 [gl_cv_header_working_stdint_h=yes])
188 fi
189 if test $gl_cv_header_working_stdint_h = yes; then
190 dnl Use the existing <stdint.h>, adding missing macro definitions.
191 suff64=
192 suffu64=
193 if test $HAVE_LONG_64BIT = 1; then
194 suff64=L
195 suffu64=UL
196 else
197 if test $HAVE_LONG_LONG_64BIT = 1; then
198 suff64=LL
199 suffu64=ULL
200 else
201 AC_EGREP_CPP([msvc compiler], [
202 #ifdef _MSC_VER
203 msvc compiler
204 #endif 169 #endif
205 ], [ 170 #ifdef UINT64_MAX
206 suff64=i64 171 int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1;
207 suffu64=ui64 172 #endif
208 ]) 173 int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1;
209 fi 174 int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1;
210 fi 175 int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1;
211 dnl Here we assume a standard architecture where the hardware integer 176 int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1;
212 dnl types have 8, 16, 32, optionally 64 bits. 177 int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1;
213 gl_STDINT_MISSING_BOUND([INT8_MIN], [-128], 178 int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1;
214 [Define if <stdint.h> doesn't define it.]) 179 int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1;
215 gl_STDINT_MISSING_BOUND([INT8_MAX], [127], 180 int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1;
216 [Define if <stdint.h> doesn't define it.]) 181 int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1;
217 gl_STDINT_MISSING_BOUND([UINT8_MAX], [255], 182 int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1;
218 [Define if <stdint.h> doesn't define it.]) 183 int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1;
219 gl_STDINT_MISSING_BOUND([INT16_MIN], [-32768], 184 };
220 [Define if <stdint.h> doesn't define it.]) 185 ]])],
221 gl_STDINT_MISSING_BOUND([INT16_MAX], [32767], 186 [gl_cv_header_working_stdint_h=yes])])
222 [Define if <stdint.h> doesn't define it.]) 187 fi
223 gl_STDINT_MISSING_BOUND([UINT16_MAX], [65535], 188 if test "$gl_cv_header_working_stdint_h" != yes; then
224 [Define if <stdint.h> doesn't define it.])
225 gl_STDINT_MISSING_BOUND([INT32_MIN], [(~INT32_MAX)],
226 [Define if <stdint.h> doesn't define it.])
227 gl_STDINT_MISSING_BOUND([INT32_MAX], [2147483647],
228 [Define if <stdint.h> doesn't define it.])
229 gl_STDINT_MISSING_BOUND([UINT32_MAX], [4294967295U],
230 [Define if <stdint.h> doesn't define it.])
231 if test $gl_cv_stdint_int64_t = yes; then
232 gl_STDINT_MISSING_BOUND([INT64_MIN], [(~INT64_MAX)],
233 [Define if <stdint.h> doesn't define it but has the int64_t type.])
234 gl_STDINT_MISSING_BOUND([INT64_MAX], [9223372036854775807${suff64}],
235 [Define if <stdint.h> doesn't define it but has the int64_t type.])
236 fi
237 if test $gl_cv_stdint_uint64_t = yes; then
238 gl_STDINT_MISSING_BOUND([UINT64_MAX], [18446744073709551615${suffu64}],
239 [Define if <stdint.h> doesn't define it but has the uint64_t type.])
240 fi
241 dnl Here we assume a standard architecture where the hardware integer
242 dnl types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
243 dnl are the same as the corresponding N_t types.
244 gl_STDINT_MISSING_BOUND([INT_LEAST8_MIN], [INT8_MIN],
245 [Define if <stdint.h> doesn't define it.])
246 gl_STDINT_MISSING_BOUND([INT_LEAST8_MAX], [INT8_MAX],
247 [Define if <stdint.h> doesn't define it.])
248 gl_STDINT_MISSING_BOUND([UINT_LEAST8_MAX], [UINT8_MAX],
249 [Define if <stdint.h> doesn't define it.])
250 gl_STDINT_MISSING_BOUND([INT_LEAST16_MIN], [INT16_MIN],
251 [Define if <stdint.h> doesn't define it.])
252 gl_STDINT_MISSING_BOUND([INT_LEAST16_MAX], [INT16_MAX],
253 [Define if <stdint.h> doesn't define it.])
254 gl_STDINT_MISSING_BOUND([UINT_LEAST16_MAX], [UINT16_MAX],
255 [Define if <stdint.h> doesn't define it.])
256 gl_STDINT_MISSING_BOUND([INT_LEAST32_MIN], [INT32_MIN],
257 [Define if <stdint.h> doesn't define it.])
258 gl_STDINT_MISSING_BOUND([INT_LEAST32_MAX], [INT32_MAX],
259 [Define if <stdint.h> doesn't define it.])
260 gl_STDINT_MISSING_BOUND([UINT_LEAST32_MAX], [UINT32_MAX],
261 [Define if <stdint.h> doesn't define it.])
262 if test $gl_cv_stdint_int_least64_t = yes; then
263 gl_STDINT_MISSING_BOUND([INT_LEAST64_MIN], [INT64_MIN],
264 [Define if <stdint.h> doesn't define it but has the int_least64_t type.])
265 gl_STDINT_MISSING_BOUND([INT_LEAST64_MAX], [INT64_MAX],
266 [Define if <stdint.h> doesn't define it but has the int_least64_t type.])
267 fi
268 if test $gl_cv_stdint_uint_least64_t = yes; then
269 gl_STDINT_MISSING_BOUND([UINT_LEAST64_MAX], [UINT64_MAX],
270 [Define if <stdint.h> doesn't define it but has the uint_least64_t type.])
271 fi
272 dnl Here we assume a standard architecture where the hardware integer
273 dnl types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
274 dnl are taken from the same list of types.
275 gl_STDINT_MISSING_BOUNDS([INT_FAST8_MIN INT_FAST8_MAX UINT_FAST8_MAX \
276 INT_FAST16_MIN INT_FAST16_MAX UINT_FAST16_MAX \
277 INT_FAST32_MIN INT_FAST32_MAX UINT_FAST32_MAX])
278 if test $gl_cv_stdint_uint_fast64_t = yes; then
279 gl_STDINT_MISSING_BOUNDS([INT_FAST64_MIN INT_FAST64_MAX])
280 fi
281 if test $gl_cv_stdint_uint_fast64_t = yes; then
282 gl_STDINT_MISSING_BOUNDS([UINT_FAST64_MAX])
283 fi
284 gl_STDINT_MISSING_BOUNDS([INTPTR_MIN INTPTR_MAX UINTPTR_MAX \
285 INTMAX_MIN INTMAX_MAX UINTMAX_MAX])
286 gl_STDINT_MISSING_BOUNDS([PTRDIFF_MIN PTRDIFF_MAX], [#include <stddef.h>])
287 gl_SIZE_MAX
288 gl_STDINT_MISSING_BOUNDS2([SIG_ATOMIC_MIN SIG_ATOMIC_MAX],
289 [#include <signal.h>])
290 dnl Don't bother defining WCHAR_MIN and WCHAR_MAX, since they should
291 dnl already be defined in <stddef.h> or <wchar.h>.
292 dnl For wint_t we need <wchar.h>.
293 dnl Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included
294 dnl before <wchar.h>.
295 dnl BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
296 dnl <wchar.h>.
297 gl_STDINT_MISSING_BOUNDS2([WINT_MIN WINT_MAX], [
298 #include <stdio.h>
299 #include <time.h>
300 #include <wchar.h>
301 ])
302 STDINT_H=''
303 else
304
305 gl_STDINT_BITSIZEOF(
306 [int8_t int16_t int32_t int64_t \
307 uint8_t uint16_t uint32_t uint64_t \
308 int_least8_t int_least16_t int_least32_t int_least64_t \
309 uint_least8_t uint_least16_t uint_least32_t uint_least64_t \
310 int_fast8_t int_fast16_t int_fast32_t int_fast64_t \
311 uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t \
312 intptr_t uintptr_t \
313 intmax_t uintmax_t],
314 [$other_includes])
315
316 gl_cv_type_unsigned_int=yes
317 gl_cv_type_long=yes
318 gl_cv_type_unsigned_long=yes
319 gl_STDINT_BITSIZEOF([unsigned_int long unsigned_long],
320 [typedef unsigned int unsigned_int;
321 typedef unsigned long unsigned_long;])
322
323 AC_CHECK_TYPES([ptrdiff_t])
324 gl_cv_type_ptrdiff_t=$ac_cv_type_ptrdiff_t
325 AC_REQUIRE([AC_TYPE_SIZE_T])
326 gl_cv_type_size_t=yes
327 gl_STDINT_BITSIZEOF([ptrdiff_t size_t], [#include <stddef.h>])
328 gl_CHECK_TYPE_SAME([ptrdiff_t], [long], [#include <stddef.h>])
329 gl_CHECK_TYPE_SAME([size_t], [unsigned long], [#include <stddef.h>])
330
331 AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
332 gl_cv_type_sig_atomic_t=$ac_cv_type_sig_atomic_t
333 gl_STDINT_BITSIZEOF([sig_atomic_t], [#include <signal.h>])
334 gl_CHECK_TYPES_SIGNED([sig_atomic_t], [#include <signal.h>])
335 if test $HAVE_SIGNED_SIG_ATOMIC_T = 1; then
336 gl_CHECK_TYPE_SAME([sig_atomic_t], [long], [#include <signal.h>])
337 else
338 gl_CHECK_TYPE_SAME([sig_atomic_t], [unsigned long], [#include <signal.h>])
339 fi
340 189
341 AC_REQUIRE([gt_TYPE_WCHAR_T]) 190 dnl Check for <sys/inttypes.h>, and for
342 gl_cv_type_wchar_t=$gt_cv_c_wchar_t 191 dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
343 gl_STDINT_BITSIZEOF([wchar_t], [#include <stddef.h>]) 192 AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
344 gl_CHECK_TYPES_SIGNED([wchar_t], [#include <stddef.h>]) 193 if test $ac_cv_header_sys_inttypes_h = yes; then
345 if test $HAVE_SIGNED_WCHAR_T = 1; then 194 HAVE_SYS_INTTYPES_H=1
346 gl_CHECK_TYPE_SAME([wchar_t], [long], [#include <stddef.h>])
347 else 195 else
348 gl_CHECK_TYPE_SAME([wchar_t], [unsigned long], [#include <stddef.h>]) 196 HAVE_SYS_INTTYPES_H=0
349 fi 197 fi
350 198 AC_SUBST([HAVE_SYS_INTTYPES_H])
351 dnl For wint_t we need <wchar.h>. 199 if test $ac_cv_header_sys_bitypes_h = yes; then
352 dnl Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included 200 HAVE_SYS_BITYPES_H=1
353 dnl before <wchar.h>.
354 dnl BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
355 dnl <wchar.h>.
356 AC_CHECK_TYPES([wint_t], , , [#include <stdio.h>
357 #include <time.h>
358 #include <wchar.h>
359 ])
360 gl_cv_type_wint_t=$ac_cv_type_wint_t
361 gl_STDINT_BITSIZEOF([wint_t], [#include <stdio.h>
362 #include <time.h>
363 #include <wchar.h>
364 ])
365 gl_CHECK_TYPES_SIGNED([wint_t], [#include <stdio.h>
366 #include <time.h>
367 #include <wchar.h>
368 ])
369 if test $HAVE_SIGNED_WINT_T = 1; then
370 gl_CHECK_TYPE_SAME([wint_t], [long], [#include <stdio.h>
371 #include <time.h>
372 #include <wchar.h>
373 ])
374 else 201 else
375 gl_CHECK_TYPE_SAME([wint_t], [unsigned long], [#include <stdio.h> 202 HAVE_SYS_BITYPES_H=0
376 #include <time.h>
377 #include <wchar.h>
378 ])
379 fi 203 fi
204 AC_SUBST([HAVE_SYS_BITYPES_H])
380 205
381 STDINT_H='stdint.h' 206 gl_STDINT_TYPE_PROPERTIES
207 STDINT_H=stdint.h
382 fi 208 fi
383 AC_SUBST(STDINT_H) 209 AC_SUBST(STDINT_H)
384 ]) 210 ])
385 211
386 dnl Set gl_cv_header_stdint_h to yes and define HAVE_STDINT_H if
387 dnl <stdint.h> exists and doesn't clash with <sys/types.h>.
388 AC_DEFUN([gl_HEADER_STDINT_H],
389 [
390 dnl Check for <stdint.h> that doesn't clash with <sys/types.h>.
391 AC_CACHE_CHECK([for stdint.h], gl_cv_header_stdint_h, [
392 AC_TRY_COMPILE([
393 #include <sys/types.h>
394 #include <stdint.h>],
395 [], gl_cv_header_stdint_h=yes, gl_cv_header_stdint_h=no)
396 ])
397 if test $gl_cv_header_stdint_h = yes; then
398 AC_DEFINE_UNQUOTED(HAVE_STDINT_H, 1,
399 [Define if <stdint.h> exists and doesn't clash with <sys/types.h>.])
400 fi
401 ])
402
403 dnl Set gl_cv_header_inttypes_h to yes and define HAVE_INTTYPES_H if
404 dnl <inttypes.h> exists and doesn't clash with <sys/types.h>.
405 AC_DEFUN([gl_HEADER_INTTYPES_H],
406 [
407 dnl Check for <inttypes.h> that doesn't clash with <sys/types.h>.
408 dnl On IRIX 5.3, <inttypes.h> conflicts with <sys/types.h>.
409 AC_CACHE_CHECK([for inttypes.h], gl_cv_header_inttypes_h, [
410 AC_TRY_COMPILE([
411 #include <sys/types.h>
412 #include <inttypes.h>],
413 [], gl_cv_header_inttypes_h=yes, gl_cv_header_inttypes_h=no)
414 ])
415 if test $gl_cv_header_inttypes_h = yes; then
416 AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
417 [Define if <inttypes.h> exists and doesn't clash with <sys/types.h>.])
418 fi
419 ])
420
421 dnl gl_STDINT_CHECK_TYPES(TYPES, INCLUDES, CACHE_VAR_PREFIX, MACRO_SUFFIX, DESCRIPTION_SUFFIX)
422 dnl Check each of the given types, whether they are defined in the given
423 dnl include files.
424 AC_DEFUN([gl_STDINT_CHECK_TYPES],
425 [
426 dnl Use a shell loop, to avoid bloating configure, and
427 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
428 dnl config.h.in,
429 dnl - extra AC_SUBST calls, so that the right substitutions are made.
430 AC_FOREACH([gltype], [$1],
431 [AH_TEMPLATE([HAVE_]translit(gltype,[abcdefghijklmnopqrstuvwxyz],[ABCDEFGHIJKLMNOPQRSTUVWXYZ])[$4],
432 [Define to 1 if the type ']gltype[' is already defined$5.])])
433 for gltype in $1 ; do
434 AC_MSG_CHECKING([for $gltype])
435 AC_COMPILE_IFELSE([
436 AC_LANG_PROGRAM([$2
437 /* Test if the type exists. */
438 $gltype x = 17;
439 ])],
440 result=yes, result=no)
441 eval $3${gltype}=\$result
442 AC_MSG_RESULT($result)
443 GLTYPE=`echo "$gltype" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
444 if test $result = yes; then
445 AC_DEFINE_UNQUOTED([HAVE_${GLTYPE}$4], 1)
446 eval HAVE_${GLTYPE}$4=1
447 else
448 eval HAVE_${GLTYPE}$4=0
449 fi
450 done
451 AC_FOREACH([gltype], [$1],
452 [AC_SUBST([HAVE_]translit(gltype,[abcdefghijklmnopqrstuvwxyz],[ABCDEFGHIJKLMNOPQRSTUVWXYZ])[$4])])
453 ])
454
455 dnl gl_STDINT_MISSING_BOUND(TYPE_BOUND, DEFAULT, DESCRIPTION)
456 dnl assumes an otherwise complete <stdint.h> and defines TYPE_BOUND if
457 dnl <stdint.h> doesn't define it.
458 AC_DEFUN([gl_STDINT_MISSING_BOUND],
459 [
460 AC_CACHE_CHECK([for $1], [gl_cv_stdint_$1],
461 [AC_EGREP_CPP([found it], [#include <stdint.h>
462 #ifdef $1
463 found it
464 #endif
465 ], [gl_cv_stdint_$1=yes], [gl_cv_stdint_$1="$2"])])
466 if test "$gl_cv_stdint_$1" != yes; then
467 AC_DEFINE_UNQUOTED([$1], [$2], [$3])
468 fi
469 ])
470
471 dnl gl_STDINT_MISSING_BOUNDS(BOUNDS, INCLUDES)
472 dnl assumes an otherwise complete <stdint.h> and defines each element of BOUNDS
473 dnl if <stdint.h> doesn't define it.
474 dnl Use this for types whose signedness is determined by the first letter
475 dnl ('u' or not).
476 AC_DEFUN([gl_STDINT_MISSING_BOUNDS],
477 [
478 dnl Use a shell loop, to avoid bloating configure, and
479 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
480 dnl config.h.in.
481 AC_FOREACH([bound], [$1],
482 [AH_TEMPLATE(bound, [Define if <stdint.h> doesn't define it.])])
483 changequote(,)dnl
484 sed_unsigned='s,^\(U*\).*,\1,'
485 sed_limitkind='s,^.*\(_[^_]*\)$,\1,'
486 changequote([,])dnl
487 for bound in $1; do
488 type=`echo $bound | sed -e 's,_MAX,_t,' -e 's,_MIN,_t,' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
489 unsigned=`echo $bound | sed -e "$sed_unsigned" | tr U u`
490 width=`echo $bound | sed -e 's,^U*INT,,' -e 's,_MIN,,' -e 's,_MAX,,'`
491 limitkind=`echo $bound | sed -e "$sed_limitkind"`
492 AC_CACHE_CHECK([for $bound], [gl_cv_stdint_$bound],
493 [AC_EGREP_CPP([found it], [#include <stdint.h>
494 #ifdef $bound
495 found it
496 #endif
497 ], [eval gl_cv_stdint_$bound=yes],
498 [result=
499 case $width in
500 *8) widthlist="8 16 32 64" ;;
501 *16) widthlist="16 32 64" ;;
502 *32 | PTR | MAX | PTRDIFF) widthlist="32 64" ;;
503 *64) widthlist="64" ;;
504 esac
505 for w in $widthlist; do
506 if test -z "$result"; then
507 AC_COMPILE_IFELSE([[$2
508 #include <stdint.h>
509 int verify[2 * (sizeof ($type) == sizeof (${unsigned}int${w}_t)) - 1];
510 ]], [result=`echo "$unsigned" | tr u U`INT${w}${limitkind}])
511 else
512 break
513 fi
514 done
515 if test -z "$result"; then
516 result=no
517 fi
518 eval gl_cv_stdint_$bound=\$result
519 ])])
520 eval result=\$gl_cv_stdint_$bound
521 if test "$result" != yes && test "$result" != no; then
522 AC_DEFINE_UNQUOTED([$bound], [$result],
523 [Define if <stdint.h> doesn't define it.])
524 fi
525 done
526 ])
527
528 dnl gl_STDINT_MISSING_BOUNDS2(BOUNDS, INCLUDES)
529 dnl assumes an otherwise complete <stdint.h> and defines each element of BOUNDS
530 dnl if <stdint.h> doesn't define it.
531 dnl Use this for types whose signedness is a priori unknown.
532 AC_DEFUN([gl_STDINT_MISSING_BOUNDS2],
533 [
534 dnl Use a shell loop, to avoid bloating configure, and
535 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
536 dnl config.h.in.
537 AC_FOREACH([bound], [$1],
538 [AH_TEMPLATE(bound, [Define if <stdint.h> doesn't define it.])])
539 changequote(,)dnl
540 sed_limitkind='s,^.*\(_[^_]*\)$,\1,'
541 changequote([,])dnl
542 for bound in $1; do
543 type=`echo $bound | sed -e 's,_MAX,_t,' -e 's,_MIN,_t,' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
544 limitkind=`echo $bound | sed -e "$sed_limitkind"`
545 AC_CACHE_CHECK([for $bound], [gl_cv_stdint_$bound],
546 [AC_EGREP_CPP([found it], [#include <stdint.h>
547 #ifdef $bound
548 found it
549 #endif
550 ], [eval gl_cv_stdint_$bound=yes],
551 [result=
552 AC_COMPILE_IFELSE([[$2
553 int verify[2 * (($type) -1 >= ($type) 0) - 1];
554 ]],
555 [eval gl_cv_${type}_signed=no],
556 [eval gl_cv_${type}_signed=yes])
557 if eval test \$gl_cv_${type}_signed = yes; then
558 for w in 8 16 32 64; do
559 if test -z "$result"; then
560 AC_COMPILE_IFELSE([[$2
561 #include <stdint.h>
562 int verify[2 * (sizeof ($type) == sizeof (int${w}_t)) - 1];
563 ]], [result=INT${w}${limitkind}])
564 else
565 break
566 fi
567 done
568 else
569 if test ${limitkind} = _MIN; then
570 result=0
571 else
572 for w in 8 16 32 64; do
573 if test -z "$result"; then
574 AC_COMPILE_IFELSE([[$2
575 #include <stdint.h>
576 int verify[2 * (sizeof ($type) == sizeof (uint${w}_t)) - 1];
577 ]], [result=UINT${w}${limitkind}])
578 else
579 break
580 fi
581 done
582 fi
583 fi
584 if test -z "$result"; then
585 result=no
586 fi
587 eval gl_cv_stdint_$bound=\$result
588 ])])
589 eval result=\$gl_cv_stdint_$bound
590 if test "$result" != yes && test "$result" != no; then
591 AC_DEFINE_UNQUOTED([$bound], [$result],
592 [Define if <stdint.h> doesn't define it.])
593 fi
594 done
595 ])
596
597 dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES) 212 dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
598 dnl Determine the size of each of the given types in bits. 213 dnl Determine the size of each of the given types in bits.
599 AC_DEFUN([gl_STDINT_BITSIZEOF], 214 AC_DEFUN([gl_STDINT_BITSIZEOF],
...@@ -606,18 +221,26 @@ AC_DEFUN([gl_STDINT_BITSIZEOF], ...@@ -606,18 +221,26 @@ AC_DEFUN([gl_STDINT_BITSIZEOF],
606 [AH_TEMPLATE([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), 221 [AH_TEMPLATE([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
607 [Define to the number of bits in type ']gltype['.])]) 222 [Define to the number of bits in type ']gltype['.])])
608 for gltype in $1 ; do 223 for gltype in $1 ; do
609 if eval test \$gl_cv_type_${gltype} = yes; then 224 AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}],
610 AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}], 225 [_AC_COMPUTE_INT([sizeof ($gltype) * CHAR_BIT], result,
611 [_AC_COMPUTE_INT([sizeof ($gltype) * CHAR_BIT], result, 226 [$2
612 [$2 227 #include <limits.h>], [result=unknown])
613 #include <limits.h>], result=unknown) 228 eval gl_cv_bitsizeof_${gltype}=\$result
614 eval gl_cv_bitsizeof_${gltype}=\$result 229 ])
615 ]) 230 eval result=\$gl_cv_bitsizeof_${gltype}
616 eval result=\$gl_cv_bitsizeof_${gltype} 231 if test $result = unknown; then
617 GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` 232 dnl Use a nonempty default, because some compilers, such as IRIX 5 cc,
618 AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result]) 233 dnl do a syntax check even on unused #if conditions and give an error
619 eval BITSIZEOF_${GLTYPE}=\$result 234 dnl on valid C code like this:
235 dnl #if 0
236 dnl # if > 32
237 dnl # endif
238 dnl #endif
239 result=0
620 fi 240 fi
241 GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
242 AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result])
243 eval BITSIZEOF_${GLTYPE}=\$result
621 done 244 done
622 AC_FOREACH([gltype], [$1], 245 AC_FOREACH([gltype], [$1],
623 [AC_SUBST([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) 246 [AC_SUBST([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
...@@ -638,9 +261,8 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED], ...@@ -638,9 +261,8 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED],
638 for gltype in $1 ; do 261 for gltype in $1 ; do
639 AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed], 262 AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed],
640 [AC_COMPILE_IFELSE( 263 [AC_COMPILE_IFELSE(
641 [AC_LANG_PROGRAM([[$2 264 [AC_LANG_PROGRAM([$2[
642 int verify[2 * (($1) -1 < ($1) 0) - 1]; 265 int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];]])],
643 ]])],
644 result=yes, result=no) 266 result=yes, result=no)
645 eval gl_cv_type_${gltype}_signed=\$result 267 eval gl_cv_type_${gltype}_signed=\$result
646 ]) 268 ])
...@@ -657,14 +279,83 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED], ...@@ -657,14 +279,83 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED],
657 [AC_SUBST([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) 279 [AC_SUBST([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
658 ]) 280 ])
659 281
660 dnl gl_CHECK_TYPE_SAME(TYPE, KNOWNTYPE, INCLUDES) 282 dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES)
661 dnl Determines whether two types are the same. 283 dnl Determine the suffix to use for integer constants of the given types.
662 AC_DEFUN([gl_CHECK_TYPE_SAME], 284 dnl Define t_SUFFIX for each such type.
285 AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
286 [
287 dnl Use a shell loop, to avoid bloating configure, and
288 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
289 dnl config.h.in,
290 dnl - extra AC_SUBST calls, so that the right substitutions are made.
291 AC_FOREACH([gltype], [$1],
292 [AH_TEMPLATE(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX],
293 [Define to l, ll, u, ul, ull, etc., as suitable for
294 constants of type ']gltype['.])])
295 for gltype in $1 ; do
296 AC_CACHE_CHECK([for $gltype integer literal suffix],
297 [gl_cv_type_${gltype}_suffix],
298 [eval gl_cv_type_${gltype}_suffix=no
299 eval result=\$gl_cv_type_${gltype}_signed
300 if test "$result" = yes; then
301 glsufu=
302 else
303 glsufu=u
304 fi
305 for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
306 case $glsuf in
307 '') gltype1='int';;
308 l) gltype1='long int';;
309 ll) gltype1='long long int';;
310 i64) gltype1='__int64';;
311 u) gltype1='unsigned int';;
312 ul) gltype1='unsigned long int';;
313 ull) gltype1='unsigned long long int';;
314 ui64)gltype1='unsigned __int64';;
315 esac
316 AC_COMPILE_IFELSE(
317 [AC_LANG_PROGRAM([$2
318 extern $gltype foo;
319 extern $gltype1 foo;])],
320 [eval gl_cv_type_${gltype}_suffix=\$glsuf])
321 eval result=\$gl_cv_type_${gltype}_suffix
322 test "$result" != no && break
323 done])
324 GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
325 eval result=\$gl_cv_type_${gltype}_suffix
326 test "$result" = no && result=
327 eval ${GLTYPE}_SUFFIX=\$result
328 AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], $result)
329 done
330 AC_FOREACH([gltype], [$1],
331 [AC_SUBST(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])])
332 ])
333
334 dnl gl_STDINT_INCLUDES
335 AC_DEFUN([gl_STDINT_INCLUDES],
336 [[
337 #include <stddef.h>
338 #include <signal.h>
339 #if HAVE_WCHAR_H
340 /* BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
341 <wchar.h>. */
342 # include <stdio.h>
343 # include <time.h>
344 # include <wchar.h>
345 #endif
346 ]])
347
348 dnl gl_STDINT_TYPE_PROPERTIES
349 dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t
350 dnl of interest to stdint_.h.
351 AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
663 [ 352 [
664 AC_TRY_COMPILE([$3 353 gl_STDINT_BITSIZEOF([ptrdiff_t sig_atomic_t size_t wchar_t wint_t],
665 extern $1 foo; 354 [gl_STDINT_INCLUDES])
666 extern $2 foo;], [], 355 gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t],
667 [SAME_TYPE_]AS_TR_CPP([$1])[_]AS_TR_CPP([$2])[=1], 356 [gl_STDINT_INCLUDES])
668 [SAME_TYPE_]AS_TR_CPP([$1])[_]AS_TR_CPP([$2])[=0]) 357 gl_cv_type_ptrdiff_t_signed=yes
669 AC_SUBST([SAME_TYPE_]AS_TR_CPP([$1])[_]AS_TR_CPP([$2])) 358 gl_cv_type_size_t_signed=no
359 gl_INTEGER_TYPE_SUFFIX([ptrdiff_t sig_atomic_t size_t wchar_t wint_t],
360 [gl_STDINT_INCLUDES])
670 ]) 361 ])
......
1 # stdint_h.m4 serial 5 1 # stdint_h.m4 serial 6
2 dnl Copyright (C) 1997-2004 Free Software Foundation, Inc. 2 dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
...@@ -15,7 +15,7 @@ AC_DEFUN([gl_AC_HEADER_STDINT_H], ...@@ -15,7 +15,7 @@ AC_DEFUN([gl_AC_HEADER_STDINT_H],
15 [AC_TRY_COMPILE( 15 [AC_TRY_COMPILE(
16 [#include <sys/types.h> 16 [#include <sys/types.h>
17 #include <stdint.h>], 17 #include <stdint.h>],
18 [uintmax_t i = (uintmax_t) -1;], 18 [uintmax_t i = (uintmax_t) -1; return !i;],
19 gl_cv_header_stdint_h=yes, 19 gl_cv_header_stdint_h=yes,
20 gl_cv_header_stdint_h=no)]) 20 gl_cv_header_stdint_h=no)])
21 if test $gl_cv_header_stdint_h = yes; then 21 if test $gl_cv_header_stdint_h = yes; then
......
1 # strdup.m4 serial 6 1 # strdup.m4 serial 7
2 dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 2 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 AC_DEFUN([gl_FUNC_STRDUP], 7 AC_DEFUN([gl_FUNC_STRDUP],
8 [ 8 [
9 MU_LIBSOURCES([strdup.c, strdup.h])
10
11 MU_REPLACE_FUNCS(strdup) 9 MU_REPLACE_FUNCS(strdup)
12 AC_CHECK_DECLS_ONCE(strdup) 10 AC_CHECK_DECLS_ONCE(strdup)
13 gl_PREREQ_STRDUP 11 gl_PREREQ_STRDUP
......
1 # strndup.m4 serial 6 1 # strndup.m4 serial 8
2 dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc. 2 dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
...@@ -6,8 +6,6 @@ dnl with or without modifications, as long as this notice is preserved. ...@@ -6,8 +6,6 @@ dnl with or without modifications, as long as this notice is preserved.
6 6
7 AC_DEFUN([gl_FUNC_STRNDUP], 7 AC_DEFUN([gl_FUNC_STRNDUP],
8 [ 8 [
9 MU_LIBSOURCES([strndup.c, strndup.h])
10
11 dnl Persuade glibc <string.h> to declare strndup(). 9 dnl Persuade glibc <string.h> to declare strndup().
12 AC_REQUIRE([AC_GNU_SOURCE]) 10 AC_REQUIRE([AC_GNU_SOURCE])
13 11
...@@ -27,13 +25,15 @@ AC_DEFUN([gl_FUNC_STRNDUP], ...@@ -27,13 +25,15 @@ AC_DEFUN([gl_FUNC_STRNDUP],
27 return s[13] != '\0';]])], 25 return s[13] != '\0';]])],
28 [gl_cv_func_strndup=yes], 26 [gl_cv_func_strndup=yes],
29 [gl_cv_func_strndup=no], 27 [gl_cv_func_strndup=no],
30 [AC_EGREP_CPP([too risky], [ 28 [AC_CHECK_FUNC([strndup],
29 [AC_EGREP_CPP([too risky], [
31 #ifdef _AIX 30 #ifdef _AIX
32 too risky 31 too risky
33 #endif 32 #endif
34 ], 33 ],
35 [gl_cv_func_strndup=no], 34 [gl_cv_func_strndup=no],
36 [gl_cv_func_strndup=yes])])]) 35 [gl_cv_func_strndup=yes])],
36 [gl_cv_func_strndup=no])])])
37 if test $gl_cv_func_strndup = yes; then 37 if test $gl_cv_func_strndup = yes; then
38 AC_DEFINE([HAVE_STRNDUP], 1, 38 AC_DEFINE([HAVE_STRNDUP], 1,
39 [Define if you have the strndup() function and it works.]) 39 [Define if you have the strndup() function and it works.])
......
1 # strnlen.m4 serial 5 1 # strnlen.m4 serial 6
2 dnl Copyright (C) 2002-2003, 2005 Free Software Foundation, Inc. 2 dnl Copyright (C) 2002-2003, 2005, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 AC_DEFUN([gl_FUNC_STRNLEN], 7 AC_DEFUN([gl_FUNC_STRNLEN],
8 [ 8 [
9 MU_LIBSOURCES([strnlen.c, strnlen.h])
10
11 dnl Persuade glibc <string.h> to declare strnlen(). 9 dnl Persuade glibc <string.h> to declare strnlen().
12 AC_REQUIRE([AC_GNU_SOURCE]) 10 AC_REQUIRE([AC_GNU_SOURCE])
13 11
......
1 # strtok_r.m4 serial 2 1 # strtok_r.m4 serial 3
2 dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. 2 dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
...@@ -13,5 +13,5 @@ AC_DEFUN([gl_FUNC_STRTOK_R], ...@@ -13,5 +13,5 @@ AC_DEFUN([gl_FUNC_STRTOK_R],
13 13
14 # Prerequisites of lib/strtok_r.h and lib/strtok_r.c. 14 # Prerequisites of lib/strtok_r.h and lib/strtok_r.c.
15 AC_DEFUN([gl_PREREQ_STRTOK_R], [ 15 AC_DEFUN([gl_PREREQ_STRTOK_R], [
16 AC_REQUIRE([gl_C_RESTRICT]) 16 AC_REQUIRE([AC_C_RESTRICT])
17 ]) 17 ])
......
1 # xalloc.m4 serial 12 1 # xalloc.m4 serial 13
2 dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 2 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 AC_DEFUN([gl_XALLOC], 7 AC_DEFUN([gl_XALLOC],
8 [ 8 [
9 AC_LIBSOURCES([xmalloc.c, xalloc.h])
10 AC_LIBOBJ([xmalloc]) 9 AC_LIBOBJ([xmalloc])
11 10
12 gl_PREREQ_XALLOC 11 gl_PREREQ_XALLOC
......
...@@ -1475,46 +1475,51 @@ argp_doc (const struct argp *argp, const struct argp_state *state, ...@@ -1475,46 +1475,51 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
1475 { 1475 {
1476 const char *text; 1476 const char *text;
1477 const char *inp_text; 1477 const char *inp_text;
1478 size_t inp_text_len = 0;
1479 const char *trans_text;
1478 void *input = 0; 1480 void *input = 0;
1479 int anything = 0; 1481 int anything = 0;
1480 size_t inp_text_limit = 0;
1481 const char *doc = dgettext (argp->argp_domain, argp->doc);
1482 const struct argp_child *child = argp->children; 1482 const struct argp_child *child = argp->children;
1483 1483
1484 if (doc) 1484 if (argp->doc)
1485 { 1485 {
1486 char *vt = strchr (doc, '\v'); 1486 char *vt = strchr (argp->doc, '\v');
1487 inp_text = post ? (vt ? vt + 1 : 0) : doc; 1487 if (vt)
1488 inp_text_limit = (!post && vt) ? (vt - doc) : 0; 1488 {
1489 if (post)
1490 inp_text = vt + 1;
1491 else
1492 {
1493 inp_text_len = vt - argp->doc;
1494 inp_text = __strndup (argp->doc, inp_text_len);
1495 }
1496 }
1497 else
1498 inp_text = post ? 0 : argp->doc;
1499 trans_text = dgettext (argp->argp_domain, inp_text);
1489 } 1500 }
1490 else 1501 else
1491 inp_text = 0; 1502 trans_text = inp_text = 0;
1492 1503
1493 if (argp->help_filter) 1504 if (argp->help_filter)
1494 /* We have to filter the doc strings. */ 1505 /* We have to filter the doc strings. */
1495 { 1506 {
1496 if (inp_text_limit)
1497 /* Copy INP_TEXT so that it's nul-terminated. */
1498 inp_text = __strndup (inp_text, inp_text_limit);
1499 input = __argp_input (argp, state); 1507 input = __argp_input (argp, state);
1500 text = 1508 text =
1501 (*argp->help_filter) (post 1509 (*argp->help_filter) (post
1502 ? ARGP_KEY_HELP_POST_DOC 1510 ? ARGP_KEY_HELP_POST_DOC
1503 : ARGP_KEY_HELP_PRE_DOC, 1511 : ARGP_KEY_HELP_PRE_DOC,
1504 inp_text, input); 1512 trans_text, input);
1505 } 1513 }
1506 else 1514 else
1507 text = (const char *) inp_text; 1515 text = (const char *) trans_text;
1508 1516
1509 if (text) 1517 if (text)
1510 { 1518 {
1511 if (pre_blank) 1519 if (pre_blank)
1512 __argp_fmtstream_putc (stream, '\n'); 1520 __argp_fmtstream_putc (stream, '\n');
1513 1521
1514 if (text == inp_text && inp_text_limit) 1522 __argp_fmtstream_puts (stream, text);
1515 __argp_fmtstream_write (stream, inp_text, inp_text_limit);
1516 else
1517 __argp_fmtstream_puts (stream, text);
1518 1523
1519 if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream)) 1524 if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream))
1520 __argp_fmtstream_putc (stream, '\n'); 1525 __argp_fmtstream_putc (stream, '\n');
...@@ -1522,9 +1527,10 @@ argp_doc (const struct argp *argp, const struct argp_state *state, ...@@ -1522,9 +1527,10 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
1522 anything = 1; 1527 anything = 1;
1523 } 1528 }
1524 1529
1525 if (text && text != inp_text) 1530 if (text && text != trans_text)
1526 free ((char *) text); /* Free TEXT returned from the help filter. */ 1531 free ((char *) text); /* Free TEXT returned from the help filter. */
1527 if (inp_text && inp_text_limit && argp->help_filter) 1532
1533 if (inp_text && inp_text_len)
1528 free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */ 1534 free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */
1529 1535
1530 if (post && argp->help_filter) 1536 if (post && argp->help_filter)
......
...@@ -141,20 +141,6 @@ ...@@ -141,20 +141,6 @@
141 # define putchar_unlocked(x) putchar (x) 141 # define putchar_unlocked(x) putchar (x)
142 # endif 142 # endif
143 143
144 /* GNULIB makes sure both program_invocation_name and
145 program_invocation_short_name are available */
146 #ifdef GNULIB_PROGRAM_INVOCATION_NAME
147 extern char *program_invocation_name;
148 # undef HAVE_DECL_PROGRAM_INVOCATION_NAME
149 # define HAVE_DECL_PROGRAM_INVOCATION_NAME 1
150 #endif
151
152 #ifdef GNULIB_PROGRAM_INVOCATION_SHORT_NAME
153 extern char *program_invocation_short_name;
154 # undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
155 # define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 1
156 #endif
157
158 #endif /* !_LIBC */ 144 #endif /* !_LIBC */
159 145
160 #ifndef __set_errno 146 #ifndef __set_errno
......
...@@ -877,6 +877,20 @@ __argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags, ...@@ -877,6 +877,20 @@ __argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
877 to be parsed (which in some cases isn't actually an error). */ 877 to be parsed (which in some cases isn't actually an error). */
878 int arg_ebadkey = 0; 878 int arg_ebadkey = 0;
879 879
880 #ifndef _LIBC
881 if (!(flags & ARGP_PARSE_ARGV0))
882 {
883 #ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
884 if (!program_invocation_name)
885 program_invocation_name = argv[0];
886 #endif
887 #ifdef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
888 if (!program_invocation_short_name)
889 program_invocation_short_name = __argp_base_name (argv[0]);
890 #endif
891 }
892 #endif
893
880 if (! (flags & ARGP_NO_HELP)) 894 if (! (flags & ARGP_NO_HELP))
881 /* Add our own options. */ 895 /* Add our own options. */
882 { 896 {
......
1 /* Default definition for ARGP_PROGRAM_VERSION. 1 /* Default definition for ARGP_PROGRAM_VERSION.
2 Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. 2 Copyright (C) 1996, 1997, 1999, 2006 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Written by Miles Bader <miles@gnu.ai.mit.edu>. 4 Written by Miles Bader <miles@gnu.ai.mit.edu>.
5 5
...@@ -19,6 +19,6 @@ ...@@ -19,6 +19,6 @@
19 19
20 /* If set by the user program to a non-zero value, then a default option 20 /* If set by the user program to a non-zero value, then a default option
21 --version is added (unless the ARGP_NO_HELP flag is used), which will 21 --version is added (unless the ARGP_NO_HELP flag is used), which will
22 print this this string followed by a newline and exit (unless the 22 print this string followed by a newline and exit (unless the
23 ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */ 23 ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
24 const char *argp_program_version; 24 const char *argp_program_version;
......
...@@ -94,7 +94,10 @@ struct argp_option ...@@ -94,7 +94,10 @@ struct argp_option
94 /* The doc string for this option. If both NAME and KEY are 0, This string 94 /* The doc string for this option. If both NAME and KEY are 0, This string
95 will be printed outdented from the normal option column, making it 95 will be printed outdented from the normal option column, making it
96 useful as a group header (it will be the first thing printed in its 96 useful as a group header (it will be the first thing printed in its
97 group); in this usage, it's conventional to end the string with a `:'. */ 97 group); in this usage, it's conventional to end the string with a `:'.
98
99 Write the initial value as N_("TEXT") if you want xgettext to collect
100 it into a POT file. */
98 const char *doc; 101 const char *doc;
99 102
100 /* The group this option is in. In a long help message, options are sorted 103 /* The group this option is in. In a long help message, options are sorted
...@@ -243,7 +246,9 @@ struct argp ...@@ -243,7 +246,9 @@ struct argp
243 246
244 /* If non-NULL, a string containing extra text to be printed before and 247 /* If non-NULL, a string containing extra text to be printed before and
245 after the options in a long help message (separated by a vertical tab 248 after the options in a long help message (separated by a vertical tab
246 `\v' character). */ 249 `\v' character).
250 Write the initial value as N_("BEFORE-TEXT") "\v" N_("AFTER-TEXT") if
251 you want xgettext to collect the two pieces of text into a POT file. */
247 const char *doc; 252 const char *doc;
248 253
249 /* A vector of argp_children structures, terminated by a member with a 0 254 /* A vector of argp_children structures, terminated by a member with a 0
...@@ -418,6 +423,20 @@ extern error_t __argp_parse (const struct argp *__restrict __argp, ...@@ -418,6 +423,20 @@ extern error_t __argp_parse (const struct argp *__restrict __argp,
418 423
419 /* Global variables. */ 424 /* Global variables. */
420 425
426 /* GNULIB makes sure both program_invocation_name and
427 program_invocation_short_name are available */
428 #ifdef GNULIB_PROGRAM_INVOCATION_NAME
429 extern char *program_invocation_name;
430 # undef HAVE_DECL_PROGRAM_INVOCATION_NAME
431 # define HAVE_DECL_PROGRAM_INVOCATION_NAME 1
432 #endif
433
434 #ifdef GNULIB_PROGRAM_INVOCATION_SHORT_NAME
435 extern char *program_invocation_short_name;
436 # undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
437 # define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 1
438 #endif
439
421 /* If defined or set by the user program to a non-zero value, then a default 440 /* If defined or set by the user program to a non-zero value, then a default
422 option --version is added (unless the ARGP_NO_HELP flag is used), which 441 option --version is added (unless the ARGP_NO_HELP flag is used), which
423 will print this string followed by a newline and exit (unless the 442 will print this string followed by a newline and exit (unless the
......
...@@ -86,34 +86,10 @@ extern int fnmatch (const char *pattern, const char *string, int flags); ...@@ -86,34 +86,10 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
86 #if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU 86 #if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU
87 87
88 88
89 # if defined STDC_HEADERS || !defined isascii 89 # if ! (defined isblank || HAVE_DECL_ISBLANK)
90 # define ISASCII(c) 1 90 # define isblank(c) ((c) == ' ' || (c) == '\t')
91 # else
92 # define ISASCII(c) isascii(c)
93 # endif
94
95 # ifdef isblank
96 # define ISBLANK(c) (ISASCII (c) && isblank (c))
97 # else
98 # define ISBLANK(c) ((c) == ' ' || (c) == '\t')
99 # endif
100 # ifdef isgraph
101 # define ISGRAPH(c) (ISASCII (c) && isgraph (c))
102 # else
103 # define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
104 # endif 91 # endif
105 92
106 # define ISPRINT(c) (ISASCII (c) && isprint (c))
107 # define ISDIGIT(c) (ISASCII (c) && isdigit (c))
108 # define ISALNUM(c) (ISASCII (c) && isalnum (c))
109 # define ISALPHA(c) (ISASCII (c) && isalpha (c))
110 # define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
111 # define ISLOWER(c) (ISASCII (c) && islower (c))
112 # define ISPUNCT(c) (ISASCII (c) && ispunct (c))
113 # define ISSPACE(c) (ISASCII (c) && isspace (c))
114 # define ISUPPER(c) (ISASCII (c) && isupper (c))
115 # define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
116
117 # define STREQ(s1, s2) ((strcmp (s1, s2) == 0)) 93 # define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
118 94
119 # if defined _LIBC || WIDE_CHAR_SUPPORT 95 # if defined _LIBC || WIDE_CHAR_SUPPORT
...@@ -169,11 +145,7 @@ static int posixly_correct; ...@@ -169,11 +145,7 @@ static int posixly_correct;
169 # endif 145 # endif
170 146
171 /* Note that this evaluates C many times. */ 147 /* Note that this evaluates C many times. */
172 # ifdef _LIBC 148 # define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
173 # define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
174 # else
175 # define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
176 # endif
177 # define CHAR char 149 # define CHAR char
178 # define UCHAR unsigned char 150 # define UCHAR unsigned char
179 # define INT int 151 # define INT int
......
...@@ -288,18 +288,18 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, ...@@ -288,18 +288,18 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
288 goto matched; 288 goto matched;
289 # endif 289 # endif
290 #else 290 #else
291 if ((STREQ (str, L_("alnum")) && ISALNUM ((UCHAR) *n)) 291 if ((STREQ (str, L_("alnum")) && isalnum ((UCHAR) *n))
292 || (STREQ (str, L_("alpha")) && ISALPHA ((UCHAR) *n)) 292 || (STREQ (str, L_("alpha")) && isalpha ((UCHAR) *n))
293 || (STREQ (str, L_("blank")) && ISBLANK ((UCHAR) *n)) 293 || (STREQ (str, L_("blank")) && isblank ((UCHAR) *n))
294 || (STREQ (str, L_("cntrl")) && ISCNTRL ((UCHAR) *n)) 294 || (STREQ (str, L_("cntrl")) && iscntrl ((UCHAR) *n))
295 || (STREQ (str, L_("digit")) && ISDIGIT ((UCHAR) *n)) 295 || (STREQ (str, L_("digit")) && isdigit ((UCHAR) *n))
296 || (STREQ (str, L_("graph")) && ISGRAPH ((UCHAR) *n)) 296 || (STREQ (str, L_("graph")) && isgraph ((UCHAR) *n))
297 || (STREQ (str, L_("lower")) && ISLOWER ((UCHAR) *n)) 297 || (STREQ (str, L_("lower")) && islower ((UCHAR) *n))
298 || (STREQ (str, L_("print")) && ISPRINT ((UCHAR) *n)) 298 || (STREQ (str, L_("print")) && isprint ((UCHAR) *n))
299 || (STREQ (str, L_("punct")) && ISPUNCT ((UCHAR) *n)) 299 || (STREQ (str, L_("punct")) && ispunct ((UCHAR) *n))
300 || (STREQ (str, L_("space")) && ISSPACE ((UCHAR) *n)) 300 || (STREQ (str, L_("space")) && isspace ((UCHAR) *n))
301 || (STREQ (str, L_("upper")) && ISUPPER ((UCHAR) *n)) 301 || (STREQ (str, L_("upper")) && isupper ((UCHAR) *n))
302 || (STREQ (str, L_("xdigit")) && ISXDIGIT ((UCHAR) *n))) 302 || (STREQ (str, L_("xdigit")) && isxdigit ((UCHAR) *n)))
303 goto matched; 303 goto matched;
304 #endif 304 #endif
305 c = *p++; 305 c = *p++;
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
31 #include <string.h> 31 #include <string.h>
32 #include <unistd.h> 32 #include <unistd.h>
33 33
34 #ifdef VMS 34 #ifdef __VMS
35 # include <unixlib.h> 35 # include <unixlib.h>
36 #endif 36 #endif
37 37
......
1 /* Convenience header for conditional use of GNU <libintl.h>. 1 /* Convenience header for conditional use of GNU <libintl.h>.
2 Copyright (C) 1995-1998, 2000-2002, 2004 Free Software Foundation, Inc. 2 Copyright (C) 1995-1998, 2000-2002, 2004-2006 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -75,4 +75,168 @@ ...@@ -75,4 +75,168 @@
75 initializer for static 'char[]' or 'const char[]' variables. */ 75 initializer for static 'char[]' or 'const char[]' variables. */
76 #define gettext_noop(String) String 76 #define gettext_noop(String) String
77 77
78 /* The separator between msgctxt and msgid in a .mo file. */
79 #define GETTEXT_CONTEXT_GLUE "\004"
80
81 /* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
82 MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
83 short and rarely need to change.
84 The letter 'p' stands for 'particular' or 'special'. */
85 #define pgettext(Msgctxt, Msgid) \
86 pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
87 #define dpgettext(Domainname, Msgctxt, Msgid) \
88 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
89 #define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
90 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
91 #define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
92 npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
93 #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
94 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
95 #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
96 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
97
98 #ifdef __GNUC__
99 __inline
100 #else
101 #ifdef __cplusplus
102 inline
103 #endif
104 #endif
105 static const char *
106 pgettext_aux (const char *domain,
107 const char *msg_ctxt_id, const char *msgid,
108 int category)
109 {
110 const char *translation = dcgettext (domain, msg_ctxt_id, category);
111 if (translation == msg_ctxt_id)
112 return msgid;
113 else
114 return translation;
115 }
116
117 #ifdef __GNUC__
118 __inline
119 #else
120 #ifdef __cplusplus
121 inline
122 #endif
123 #endif
124 static const char *
125 npgettext_aux (const char *domain,
126 const char *msg_ctxt_id, const char *msgid,
127 const char *msgid_plural, unsigned long int n,
128 int category)
129 {
130 const char *translation =
131 dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
132 if (translation == msg_ctxt_id || translation == msgid_plural)
133 return (n == 1 ? msgid : msgid_plural);
134 else
135 return translation;
136 }
137
138 /* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
139 can be arbitrary expressions. But for string literals these macros are
140 less efficient than those above. */
141
142 #include <string.h>
143
144 #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
145 (__GNUC__ >= 3 || defined __cplusplus)
146
147 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
148 #include <stdlib.h>
149 #endif
150
151 #define pgettext_expr(Msgctxt, Msgid) \
152 dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
153 #define dpgettext_expr(Domainname, Msgctxt, Msgid) \
154 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
155
156 #ifdef __GNUC__
157 __inline
158 #else
159 #ifdef __cplusplus
160 inline
161 #endif
162 #endif
163 static const char *
164 dcpgettext_expr (const char *domain,
165 const char *msgctxt, const char *msgid,
166 int category)
167 {
168 size_t msgctxt_len = strlen (msgctxt) + 1;
169 size_t msgid_len = strlen (msgid) + 1;
170 const char *translation;
171 #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
172 char msg_ctxt_id[msgctxt_len + msgid_len];
173 #else
174 char buf[1024];
175 char *msg_ctxt_id =
176 (msgctxt_len + msgid_len <= sizeof (buf)
177 ? buf
178 : (char *) malloc (msgctxt_len + msgid_len));
179 if (msg_ctxt_id != NULL)
180 #endif
181 {
182 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
183 msg_ctxt_id[msgctxt_len - 1] = '\004';
184 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
185 translation = dcgettext (domain, msg_ctxt_id, category);
186 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
187 if (msg_ctxt_id != buf)
188 free (msg_ctxt_id);
189 #endif
190 if (translation != msg_ctxt_id)
191 return translation;
192 }
193 return msgid;
194 }
195
196 #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
197 dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
198 #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
199 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
200
201 #ifdef __GNUC__
202 __inline
203 #else
204 #ifdef __cplusplus
205 inline
206 #endif
207 #endif
208 static const char *
209 dcnpgettext_expr (const char *domain,
210 const char *msgctxt, const char *msgid,
211 const char *msgid_plural, unsigned long int n,
212 int category)
213 {
214 size_t msgctxt_len = strlen (msgctxt) + 1;
215 size_t msgid_len = strlen (msgid) + 1;
216 const char *translation;
217 #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
218 char msg_ctxt_id[msgctxt_len + msgid_len];
219 #else
220 char buf[1024];
221 char *msg_ctxt_id =
222 (msgctxt_len + msgid_len <= sizeof (buf)
223 ? buf
224 : (char *) malloc (msgctxt_len + msgid_len));
225 if (msg_ctxt_id != NULL)
226 #endif
227 {
228 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
229 msg_ctxt_id[msgctxt_len - 1] = '\004';
230 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
231 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
232 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
233 if (msg_ctxt_id != buf)
234 free (msg_ctxt_id);
235 #endif
236 if (!(translation == msg_ctxt_id || translation == msgid_plural))
237 return translation;
238 }
239 return (n == 1 ? msgid : msgid_plural);
240 }
241
78 #endif /* _LIBGETTEXT_H */ 242 #endif /* _LIBGETTEXT_H */
......
...@@ -47,31 +47,12 @@ ...@@ -47,31 +47,12 @@
47 # define __set_errno(val) errno = (val) 47 # define __set_errno(val) errno = (val)
48 #endif 48 #endif
49 49
50 #if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__ 50 #include <dirent.h>
51 # include <dirent.h>
52 # define NAMLEN(dirent) strlen((dirent)->d_name)
53 #else
54 # define dirent direct
55 # define NAMLEN(dirent) (dirent)->d_namlen
56 # ifdef HAVE_SYS_NDIR_H
57 # include <sys/ndir.h>
58 # endif
59 # ifdef HAVE_SYS_DIR_H
60 # include <sys/dir.h>
61 # endif
62 # ifdef HAVE_NDIR_H
63 # include <ndir.h>
64 # endif
65 # ifdef HAVE_VMSDIR_H
66 # include "vmsdir.h"
67 # endif /* HAVE_VMSDIR_H */
68 #endif
69 51
70 52
71 /* In GNU systems, <dirent.h> defines this macro for us. */ 53 /* In GNU systems, <dirent.h> defines this macro for us. */
72 #ifdef _D_NAMLEN 54 #ifndef _D_EXACT_NAMLEN
73 # undef NAMLEN 55 # define _D_EXACT_NAMLEN(dirent) strlen ((dirent)->d_name)
74 # define NAMLEN(d) _D_NAMLEN(d)
75 #endif 56 #endif
76 57
77 /* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available 58 /* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available
...@@ -97,13 +78,6 @@ ...@@ -97,13 +78,6 @@
97 78
98 /* If the system has the `struct dirent64' type we use it internally. */ 79 /* If the system has the `struct dirent64' type we use it internally. */
99 #if defined _LIBC && !defined COMPILE_GLOB64 80 #if defined _LIBC && !defined COMPILE_GLOB64
100 # if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
101 # define CONVERT_D_NAMLEN(d64, d32)
102 # else
103 # define CONVERT_D_NAMLEN(d64, d32) \
104 (d64)->d_namlen = (d32)->d_namlen;
105 # endif
106
107 # if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__ 81 # if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
108 # define CONVERT_D_INO(d64, d32) 82 # define CONVERT_D_INO(d64, d32)
109 # else 83 # else
...@@ -119,8 +93,7 @@ ...@@ -119,8 +93,7 @@
119 # endif 93 # endif
120 94
121 # define CONVERT_DIRENT_DIRENT64(d64, d32) \ 95 # define CONVERT_DIRENT_DIRENT64(d64, d32) \
122 memcpy ((d64)->d_name, (d32)->d_name, NAMLEN (d32) + 1); \ 96 memcpy ((d64)->d_name, (d32)->d_name, _D_EXACT_NAMLEN (d32) + 1); \
123 CONVERT_D_NAMLEN (d64, d32) \
124 CONVERT_D_INO (d64, d32) \ 97 CONVERT_D_INO (d64, d32) \
125 CONVERT_D_TYPE (d64, d32) 98 CONVERT_D_TYPE (d64, d32)
126 #endif 99 #endif
...@@ -511,7 +484,6 @@ glob (pattern, flags, errfunc, pglob) ...@@ -511,7 +484,6 @@ glob (pattern, flags, errfunc, pglob)
511 484
512 oldcount = pglob->gl_pathc + pglob->gl_offs; 485 oldcount = pglob->gl_pathc + pglob->gl_offs;
513 486
514 #ifndef VMS
515 if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~') 487 if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~')
516 { 488 {
517 if (dirname[1] == '\0' || dirname[1] == '/') 489 if (dirname[1] == '\0' || dirname[1] == '/')
...@@ -679,7 +651,6 @@ glob (pattern, flags, errfunc, pglob) ...@@ -679,7 +651,6 @@ glob (pattern, flags, errfunc, pglob)
679 } 651 }
680 # endif /* Not Amiga && not WINDOWS32. */ 652 # endif /* Not Amiga && not WINDOWS32. */
681 } 653 }
682 #endif /* Not VMS. */
683 654
684 /* Now test whether we looked for "~" or "~NAME". In this case we 655 /* Now test whether we looked for "~" or "~NAME". In this case we
685 can give the answer now. */ 656 can give the answer now. */
...@@ -1132,7 +1103,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, ...@@ -1132,7 +1103,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
1132 { 1103 {
1133 int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) 1104 int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)
1134 | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) 1105 | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
1135 #if defined _AMIGA || defined VMS 1106 #if defined _AMIGA || defined __VMS
1136 | FNM_CASEFOLD 1107 | FNM_CASEFOLD
1137 #endif 1108 #endif
1138 ); 1109 );
...@@ -1205,7 +1176,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, ...@@ -1205,7 +1176,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
1205 struct globlink *new = 1176 struct globlink *new =
1206 __alloca (sizeof (struct globlink)); 1177 __alloca (sizeof (struct globlink));
1207 char *p; 1178 char *p;
1208 len = NAMLEN (d); 1179 len = _D_EXACT_NAMLEN (d);
1209 new->name = 1180 new->name =
1210 malloc (len + 1 + ((flags & GLOB_MARK) && isdir)); 1181 malloc (len + 1 + ((flags & GLOB_MARK) && isdir));
1211 if (new->name == NULL) 1182 if (new->name == NULL)
......
...@@ -46,10 +46,6 @@ ...@@ -46,10 +46,6 @@
46 #endif 46 #endif
47 47
48 48
49 #ifndef HAVE_DIRENT_H
50 # define dirent direct
51 #endif
52
53 #define glob rpl_glob 49 #define glob rpl_glob
54 #define globfree rpl_globfree 50 #define globfree rpl_globfree
55 #define glob_pattern_p rpl_glob_pattern_p 51 #define glob_pattern_p rpl_glob_pattern_p
......
1 /* inttostr.h -- convert integers to printable strings 1 /* inttostr.h -- convert integers to printable strings
2 2
3 Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software
4 Foundation, Inc.
4 5
5 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
...@@ -18,13 +19,7 @@ ...@@ -18,13 +19,7 @@
18 19
19 /* Written by Paul Eggert */ 20 /* Written by Paul Eggert */
20 21
21 #if HAVE_INTTYPES_H 22 #include <stdint.h>
22 # include <inttypes.h>
23 #endif
24 #if HAVE_STDINT_H
25 # include <stdint.h>
26 #endif
27
28 #include <sys/types.h> 23 #include <sys/types.h>
29 24
30 #include "intprops.h" 25 #include "intprops.h"
......
1 /* Multibyte character data type. 1 /* Multibyte character data type.
2 Copyright (C) 2001, 2005 Free Software Foundation, Inc. 2 Copyright (C) 2001, 2005-2006 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -156,7 +156,133 @@ ...@@ -156,7 +156,133 @@
156 #include <time.h> 156 #include <time.h>
157 #include <wchar.h> 157 #include <wchar.h>
158 158
159 #include <wctype.h> 159 /* BeOS 5 has the functions but no <wctype.h>. */
160 #if HAVE_WCTYPE_H
161 # include <wctype.h>
162 #endif
163 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
164 Assume all 12 functions are implemented the same way, or not at all. */
165 #if !defined iswalnum && !HAVE_ISWCNTRL
166 static inline int
167 iswalnum (wint_t wc)
168 {
169 return (wc >= 0 && wc < 128
170 ? (wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')
171 : 0);
172 }
173 # define iswalnum iswalnum
174 #endif
175 #if !defined iswalpha && !HAVE_ISWCNTRL
176 static inline int
177 iswalpha (wint_t wc)
178 {
179 return (wc >= 0 && wc < 128
180 ? (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'
181 : 0);
182 }
183 # define iswalpha iswalpha
184 #endif
185 #if !defined iswblank && !HAVE_ISWCNTRL
186 static inline int
187 iswblank (wint_t wc)
188 {
189 return (wc >= 0 && wc < 128
190 ? wc == ' ' || wc == '\t'
191 : 0);
192 }
193 # define iswblank iswblank
194 #endif
195 #if !defined iswcntrl && !HAVE_ISWCNTRL
196 static inline int
197 iswcntrl (wint_t wc)
198 {
199 return (wc >= 0 && wc < 128
200 ? (wc & ~0x1f) == 0 || wc == 0x7f
201 : 0);
202 }
203 # define iswcntrl iswcntrl
204 #endif
205 #if !defined iswdigit && !HAVE_ISWCNTRL
206 static inline int
207 iswdigit (wint_t wc)
208 {
209 return (wc >= '0' && wc <= '9');
210 }
211 # define iswdigit iswdigit
212 #endif
213 #if !defined iswgraph && !HAVE_ISWCNTRL
214 static inline int
215 iswgraph (wint_t wc)
216 {
217 return (wc >= 0 && wc < 128
218 ? wc >= '!' && wc <= '~'
219 : 1);
220 }
221 # define iswgraph iswgraph
222 #endif
223 #if !defined iswlower && !HAVE_ISWCNTRL
224 static inline int
225 iswlower (wint_t wc)
226 {
227 return (wc >= 0 && wc < 128
228 ? wc >= 'a' && wc <= 'z'
229 : 0);
230 }
231 # define iswlower iswlower
232 #endif
233 #if !defined iswprint && !HAVE_ISWCNTRL
234 static inline int
235 iswprint (wint_t wc)
236 {
237 return (wc >= 0 && wc < 128
238 ? wc >= ' ' && wc <= '~'
239 : 1);
240 }
241 # define iswprint iswprint
242 #endif
243 #if !defined iswpunct && !HAVE_ISWCNTRL
244 static inline int
245 iswpunct (wint_t wc)
246 {
247 return (wc >= 0 && wc < 128
248 ? wc >= '!' && wc <= '~'
249 && !((wc >= '0' && wc <= '9')
250 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))
251 : 1);
252 }
253 # define iswpunct iswpunct
254 #endif
255 #if !defined iswspace && !HAVE_ISWCNTRL
256 static inline int
257 iswspace (wint_t wc)
258 {
259 return (wc >= 0 && wc < 128
260 ? wc == ' ' || wc == '\t'
261 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'
262 : 0);
263 }
264 # define iswspace iswspace
265 #endif
266 #if !defined iswupper && !HAVE_ISWCNTRL
267 static inline int
268 iswupper (wint_t wc)
269 {
270 return (wc >= 0 && wc < 128
271 ? wc >= 'A' && wc <= 'Z'
272 : 0);
273 }
274 # define iswupper iswupper
275 #endif
276 #if !defined iswxdigit && !HAVE_ISWCNTRL
277 static inline int
278 iswxdigit (wint_t wc)
279 {
280 return (wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F');
281 }
282 # define iswxdigit iswxdigit
283 #endif
284
285 #include "wcwidth.h"
160 286
161 #define MBCHAR_BUF_SIZE 24 287 #define MBCHAR_BUF_SIZE 24
162 288
......
1 /* Decomposed printf argument list. 1 /* Decomposed printf argument list.
2 Copyright (C) 1999, 2002-2003, 2006 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002-2003, 2005-2006 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -79,7 +79,13 @@ printf_fetchargs (va_list args, arguments *a) ...@@ -79,7 +79,13 @@ printf_fetchargs (va_list args, arguments *a)
79 break; 79 break;
80 #ifdef HAVE_WINT_T 80 #ifdef HAVE_WINT_T
81 case TYPE_WIDE_CHAR: 81 case TYPE_WIDE_CHAR:
82 ap->a.a_wide_char = va_arg (args, wint_t); 82 /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
83 default argument promotions", this is not the case in mingw32,
84 where wint_t is 'unsigned short'. */
85 ap->a.a_wide_char =
86 (sizeof (wint_t) < sizeof (int)
87 ? va_arg (args, int)
88 : va_arg (args, wint_t));
83 break; 89 break;
84 #endif 90 #endif
85 case TYPE_STRING: 91 case TYPE_STRING:
......
...@@ -37,12 +37,6 @@ extern "C" { ...@@ -37,12 +37,6 @@ extern "C" {
37 # define __USE_GNU_REGEX 1 37 # define __USE_GNU_REGEX 1
38 #endif 38 #endif
39 39
40 #ifdef __VMS
41 /* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
42 should be there. */
43 # include <stddef.h>
44 #endif
45
46 #ifdef _REGEX_LARGE_OFFSETS 40 #ifdef _REGEX_LARGE_OFFSETS
47 41
48 /* Use types and values that are wide enough to represent signed and 42 /* Use types and values that are wide enough to represent signed and
...@@ -641,9 +635,10 @@ extern int re_exec (const char *); ...@@ -641,9 +635,10 @@ extern int re_exec (const char *);
641 # endif 635 # endif
642 # endif 636 # endif
643 #endif 637 #endif
644 /* gcc 3.1 and up support the [restrict] syntax, but g++ doesn't. */ 638 /* gcc 3.1 and up support the [restrict] syntax. */
645 #ifndef __restrict_arr 639 #ifndef __restrict_arr
646 # if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) && !defined __cplusplus 640 # if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \
641 && !defined __GNUG__
647 # define __restrict_arr __restrict 642 # define __restrict_arr __restrict
648 # else 643 # else
649 # define __restrict_arr 644 # define __restrict_arr
......
...@@ -488,27 +488,34 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc) ...@@ -488,27 +488,34 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
488 mbstate_t prev_st; 488 mbstate_t prev_st;
489 Idx rawbuf_idx; 489 Idx rawbuf_idx;
490 size_t mbclen; 490 size_t mbclen;
491 wchar_t wc = 0; 491 wint_t wc = WEOF;
492 492
493 /* Skip the characters which are not necessary to check. */ 493 /* Skip the characters which are not necessary to check. */
494 for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len; 494 for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len;
495 rawbuf_idx < new_raw_idx;) 495 rawbuf_idx < new_raw_idx;)
496 { 496 {
497 wchar_t wc2;
497 Idx remain_len; 498 Idx remain_len;
498 remain_len = pstr->len - rawbuf_idx; 499 remain_len = pstr->len - rawbuf_idx;
499 prev_st = pstr->cur_state; 500 prev_st = pstr->cur_state;
500 mbclen = mbrtowc (&wc, (const char *) pstr->raw_mbs + rawbuf_idx, 501 mbclen = mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
501 remain_len, &pstr->cur_state); 502 remain_len, &pstr->cur_state);
502 if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0)) 503 if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
503 { 504 {
504 /* We treat these cases as a singlebyte character. */ 505 /* We treat these cases as a single byte character. */
506 if (mbclen == 0 || remain_len == 0)
507 wc = L'\0';
508 else
509 wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx);
505 mbclen = 1; 510 mbclen = 1;
506 pstr->cur_state = prev_st; 511 pstr->cur_state = prev_st;
507 } 512 }
513 else
514 wc = wc2;
508 /* Then proceed the next character. */ 515 /* Then proceed the next character. */
509 rawbuf_idx += mbclen; 516 rawbuf_idx += mbclen;
510 } 517 }
511 *last_wc = (wint_t) wc; 518 *last_wc = wc;
512 return rawbuf_idx; 519 return rawbuf_idx;
513 } 520 }
514 #endif /* RE_ENABLE_I18N */ 521 #endif /* RE_ENABLE_I18N */
...@@ -627,7 +634,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) ...@@ -627,7 +634,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
627 } 634 }
628 #endif 635 #endif
629 pstr->valid_len = 0; 636 pstr->valid_len = 0;
630 pstr->valid_raw_len = 0;
631 #ifdef RE_ENABLE_I18N 637 #ifdef RE_ENABLE_I18N
632 if (pstr->mb_cur_max > 1) 638 if (pstr->mb_cur_max > 1)
633 { 639 {
...@@ -690,6 +696,16 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) ...@@ -690,6 +696,16 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
690 696
691 if (wc == WEOF) 697 if (wc == WEOF)
692 pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx; 698 pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx;
699 if (wc == WEOF)
700 pstr->tip_context
701 = re_string_context_at (pstr, pstr->valid_raw_len - 1, eflags);
702 else
703 pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0)
704 && IS_WIDE_WORD_CHAR (wc))
705 ? CONTEXT_WORD
706 : ((IS_WIDE_NEWLINE (wc)
707 && pstr->newline_anchor)
708 ? CONTEXT_NEWLINE : 0));
693 if (BE (pstr->valid_len, 0)) 709 if (BE (pstr->valid_len, 0))
694 { 710 {
695 for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx) 711 for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
...@@ -698,17 +714,12 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) ...@@ -698,17 +714,12 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
698 memset (pstr->mbs, -1, pstr->valid_len); 714 memset (pstr->mbs, -1, pstr->valid_len);
699 } 715 }
700 pstr->valid_raw_len = pstr->valid_len; 716 pstr->valid_raw_len = pstr->valid_len;
701 pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0)
702 && IS_WIDE_WORD_CHAR (wc))
703 ? CONTEXT_WORD
704 : ((IS_WIDE_NEWLINE (wc)
705 && pstr->newline_anchor)
706 ? CONTEXT_NEWLINE : 0));
707 } 717 }
708 else 718 else
709 #endif /* RE_ENABLE_I18N */ 719 #endif /* RE_ENABLE_I18N */
710 { 720 {
711 int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1]; 721 int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
722 pstr->valid_raw_len = 0;
712 if (pstr->trans) 723 if (pstr->trans)
713 c = pstr->trans[c]; 724 c = pstr->trans[c];
714 pstr->tip_context = (bitset_contain (pstr->word_char, c) 725 pstr->tip_context = (bitset_contain (pstr->word_char, c)
......
...@@ -43,20 +43,17 @@ ...@@ -43,20 +43,17 @@
43 #if defined HAVE_WCTYPE_H || defined _LIBC 43 #if defined HAVE_WCTYPE_H || defined _LIBC
44 # include <wctype.h> 44 # include <wctype.h>
45 #endif /* HAVE_WCTYPE_H || _LIBC */ 45 #endif /* HAVE_WCTYPE_H || _LIBC */
46 #if defined HAVE_STDINT_H || defined _LIBC 46 #include <stdint.h>
47 # include <stdint.h>
48 #endif /* HAVE_STDINT_H || _LIBC */
49 #if defined _LIBC 47 #if defined _LIBC
50 # include <bits/libc-lock.h> 48 # include <bits/libc-lock.h>
51 #else 49 #else
52 # define __libc_lock_define(CLASS,NAME)
53 # define __libc_lock_init(NAME) do { } while (0) 50 # define __libc_lock_init(NAME) do { } while (0)
54 # define __libc_lock_lock(NAME) do { } while (0) 51 # define __libc_lock_lock(NAME) do { } while (0)
55 # define __libc_lock_unlock(NAME) do { } while (0) 52 # define __libc_lock_unlock(NAME) do { } while (0)
56 #endif 53 #endif
57 54
58 /* In case that the system doesn't have isblank(). */ 55 /* In case that the system doesn't have isblank(). */
59 #if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank 56 #if !defined _LIBC && !HAVE_DECL_ISBLANK && !defined isblank
60 # define isblank(ch) ((ch) == ' ' || (ch) == '\t') 57 # define isblank(ch) ((ch) == ' ' || (ch) == '\t')
61 #endif 58 #endif
62 59
...@@ -711,7 +708,9 @@ struct re_dfa_t ...@@ -711,7 +708,9 @@ struct re_dfa_t
711 #ifdef DEBUG 708 #ifdef DEBUG
712 char* re_str; 709 char* re_str;
713 #endif 710 #endif
711 #ifdef _LIBC
714 __libc_lock_define (, lock) 712 __libc_lock_define (, lock)
713 #endif
715 }; 714 };
716 715
717 #define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set)) 716 #define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
......
1 /* stat-related macros 1 /* stat-related macros
2 2
3 Copyright (C) 1993, 1994, 2001, 2002, 2004 Free Software Foundation, Inc. 3 Copyright (C) 1993, 1994, 2001, 2002, 2004, 2006 Free Software
4 Foundation, Inc.
4 5
5 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
...@@ -33,7 +34,6 @@ ...@@ -33,7 +34,6 @@
33 # undef S_ISBLK 34 # undef S_ISBLK
34 # undef S_ISCHR 35 # undef S_ISCHR
35 # undef S_ISDIR 36 # undef S_ISDIR
36 # undef S_ISDOOR
37 # undef S_ISFIFO 37 # undef S_ISFIFO
38 # undef S_ISLNK 38 # undef S_ISLNK
39 # undef S_ISNAM 39 # undef S_ISNAM
...@@ -70,11 +70,7 @@ ...@@ -70,11 +70,7 @@
70 # endif 70 # endif
71 71
72 # ifndef S_ISDOOR /* Solaris 2.5 and up */ 72 # ifndef S_ISDOOR /* Solaris 2.5 and up */
73 # ifdef S_IFDOOR 73 # define S_ISDOOR(m) 0
74 # define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
75 # else
76 # define S_ISDOOR(m) 0
77 # endif
78 # endif 74 # endif
79 75
80 # ifndef S_ISFIFO 76 # ifndef S_ISFIFO
...@@ -119,6 +115,10 @@ ...@@ -119,6 +115,10 @@
119 # endif 115 # endif
120 # endif 116 # endif
121 117
118 # ifndef S_ISPORT /* Solaris 10 and up */
119 # define S_ISPORT(m) 0
120 # endif
121
122 # ifndef S_ISREG 122 # ifndef S_ISREG
123 # ifdef S_IFREG 123 # ifdef S_IFREG
124 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 124 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
161 # endif 161 # endif
162 # endif 162 # endif
163 163
164 /* contiguous */ 164 /* high performance ("contiguous data") */
165 # ifndef S_ISCTG 165 # ifndef S_ISCTG
166 # define S_ISCTG(p) 0 166 # define S_ISCTG(p) 0
167 # endif 167 # endif
...@@ -176,6 +176,11 @@ ...@@ -176,6 +176,11 @@
176 # define S_ISOFL(p) 0 176 # define S_ISOFL(p) 0
177 # endif 177 # endif
178 178
179 /* 4.4BSD whiteout */
180 # ifndef S_ISWHT
181 # define S_ISWHT(m) 0
182 # endif
183
179 /* If any of the following are undefined, 184 /* If any of the following are undefined,
180 define them to their de facto standard values. */ 185 define them to their de facto standard values. */
181 # if !S_ISUID 186 # if !S_ISUID
......
1 /* Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc. 1 /* Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc.
2 Written by Bruno Haible, Sam Steingold, Peter Burwood. 2 Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
3 This file is part of gnulib. 3 This file is part of gnulib.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
...@@ -16,165 +16,155 @@ ...@@ -16,165 +16,155 @@
16 along with this program; if not, write to the Free Software Foundation, 16 along 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 #ifndef _STDINT_H 19 #ifndef _GL_STDINT_H
20 #define _STDINT_H 20 #define _GL_STDINT_H
21 21
22 /* 22 /*
23 * ISO C 99 <stdint.h> for platforms that lack it. 23 * ISO C 99 <stdint.h> for platforms that lack it.
24 * <http://www.opengroup.org/susv3xbd/stdint.h.html> 24 * <http://www.opengroup.org/susv3xbd/stdint.h.html>
25 */ 25 */
26 26
27 /* Get wchar_t, WCHAR_MIN, WCHAR_MAX. */ 27 /* Get those types that are already defined in other system include
28 #include <stddef.h> 28 files, so that we can "#define int8_t signed char" below without
29 /* BSD/OS 4.2 defines WCHAR_MIN, WCHAR_MAX in <wchar.h>, not <stddef.h>. */ 29 worrying about a later system include file containing a "typedef
30 #if !(defined(WCHAR_MIN) && defined(WCHAR_MAX)) && @HAVE_WCHAR_H@ 30 signed char int8_t;" that will get messed up by our macro. Our
31 # include <wchar.h> 31 macros should all be consistent with the system versions, except
32 for the "fast" types and macros, which we recommend against using
33 in public interfaces due to compiler differences. */
34
35 #if @HAVE_STDINT_H@
36 # if defined __sgi && ! defined __c99
37 /* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users
38 with "This header file is to be used only for c99 mode compilations"
39 diagnostics. */
40 # define __STDINT_H__
41 # endif
42 /* Other systems may have an incomplete or buggy <stdint.h>.
43 Include it before <inttypes.h>, since any "#include <stdint.h>"
44 in <inttypes.h> would reinclude us, skipping our contents because
45 _GL_STDINT_H is defined. */
46 # include @ABSOLUTE_STDINT_H@
47 #endif
48
49 /* <sys/types.h> defines some of the stdint.h types as well, on glibc,
50 IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
51 MacOS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
52 relies on the system <stdint.h> definitions, so include
53 <sys/types.h> after @ABSOLUTE_STDINT_H@. */
54 #if @HAVE_SYS_TYPES_H@
55 # include <sys/types.h>
32 #endif 56 #endif
33 57
34 /* Get LONG_MIN, LONG_MAX, ULONG_MAX. */ 58 /* Get LONG_MIN, LONG_MAX, ULONG_MAX. */
35 #include <limits.h> 59 #include <limits.h>
36 60
37 /* Get those types that are already defined in other system include files. */ 61 #if @HAVE_INTTYPES_H@
38 #if defined(__FreeBSD__) && (__FreeBSD__ >= 3) && (__FreeBSD__ <= 4) 62 /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
39 # include <sys/inttypes.h>
40 #endif
41 #if defined(__OpenBSD__) || defined(__bsdi__) || defined(__sgi)
42 /* In OpenBSD 3.8, <sys/types.h> includes <machine/types.h>, which defines
43 int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. 63 int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
44 <inttypes.h> includes <machine/types.h> and also defines intptr_t and 64 <inttypes.h> also defines intptr_t and uintptr_t. */
45 uintptr_t. */ 65 # define _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H
46 /* BSD/OS 4.2 is similar, but doesn't have <inttypes.h> */ 66 # include <inttypes.h>
47 /* IRIX 6.5 has <inttypes.h>, and <sys/types.h> defines some of these 67 # undef _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H
48 types as well. */ 68 #elif @HAVE_SYS_INTTYPES_H@
49 # include <sys/types.h> 69 /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
50 # if @HAVE_INTTYPES_H@ 70 the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */
51 # include @FULL_PATH_INTTYPES_H@ 71 # include <sys/inttypes.h>
52 # endif
53 #endif 72 #endif
54 #if defined(__linux__) && @HAVE_SYS_BITYPES_H@ 73
74 #if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__
55 /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines 75 /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
56 int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is 76 int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
57 included by <sys/types.h>. */ 77 included by <sys/types.h>. */
58 # include <sys/bitypes.h> 78 # include <sys/bitypes.h>
59 #endif 79 #endif
60 #if defined(__sun) && @HAVE_SYS_INTTYPES_H@ 80
61 /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and 81 #if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
62 the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. 82
63 But note that <sys/int_types.h> contains only the type definitions! */ 83 /* Get WCHAR_MIN, WCHAR_MAX. */
64 # include <sys/inttypes.h> 84 # if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
65 #endif 85 /* BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
66 #if (defined(__hpux) || defined(_AIX)) && @HAVE_INTTYPES_H@ 86 <wchar.h>. */
67 /* HP-UX 10 <inttypes.h> has nearly everything, except UINT_LEAST8_MAX, 87 # include <stdio.h>
68 UINT_FAST8_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */ 88 # include <time.h>
69 /* AIX 4 <inttypes.h> has nearly everything, except INTPTR_MIN, INTPTR_MAX, 89 # include <wchar.h>
70 UINTPTR_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */
71 # include @FULL_PATH_INTTYPES_H@
72 #endif
73 #if @HAVE_STDINT_H@
74 /* Other systems may have an incomplete <stdint.h>. */
75 /* On some versions of IRIX, the SGI C compiler comes with an <stdint.h>,
76 but
77 - in c99 mode, <inttypes.h> includes <stdint.h>,
78 - in c89 mode, <stdint.h> spews warnings and defines nothing.
79 <inttypes.h> defines only a subset of the types and macros that
80 <stdint.h> would define in c99 mode.
81 So we rely only on <inttypes.h> (included above). It means that in
82 c89 mode, we shadow the contents of warning-spewing <stdint.h>. */
83 # if !(defined(__sgi) && @HAVE_INTTYPES_H@ && !defined(__c99))
84 # include @FULL_PATH_STDINT_H@
85 # endif 90 # endif
91
86 #endif 92 #endif
87 93
94 /* Minimum and maximum values for a integer type under the usual assumption.
95 Return an unspecified value if BITS == 0, adding a check to pacify
96 picky compilers. */
97
98 #define _STDINT_MIN(signed, bits, zero) \
99 ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero))
100
101 #define _STDINT_MAX(signed, bits, zero) \
102 ((signed) \
103 ? ~ _STDINT_MIN (signed, bits, zero) \
104 : ((((zero) + 1) << ((bits) ? (bits) - 1 : 0)) - 1) * 2 + 1)
105
88 /* 7.18.1.1. Exact-width integer types */ 106 /* 7.18.1.1. Exact-width integer types */
89 107
90 /* Here we assume a standard architecture where the hardware integer 108 /* Here we assume a standard architecture where the hardware integer
91 types have 8, 16, 32, optionally 64 bits. */ 109 types have 8, 16, 32, optionally 64 bits. */
92 110
93 #if !@HAVE_INT8_T@ 111 #undef int8_t
94 typedef signed char int8_t; 112 #undef uint8_t
95 #endif 113 #define int8_t signed char
96 #if !@HAVE_UINT8_T@ 114 #define uint8_t unsigned char
97 typedef unsigned char uint8_t;
98 # define _UINT8_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
99 #endif
100 115
101 #if !@HAVE_INT16_T@ 116 #undef int16_t
102 typedef short int16_t; 117 #undef uint16_t
103 #endif 118 #define int16_t short int
104 #if !@HAVE_UINT16_T@ 119 #define uint16_t unsigned short int
105 typedef unsigned short uint16_t;
106 #endif
107 120
108 #if !@HAVE_INT32_T@ 121 #undef int32_t
109 typedef int int32_t; 122 #undef uint32_t
110 #endif 123 #define int32_t int
111 #if !@HAVE_UINT32_T@ 124 #define uint32_t unsigned int
112 typedef unsigned int uint32_t;
113 # define _UINT32_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
114 #endif
115 125
116 #if @HAVE_INT64_T@ 126 #undef int64_t
117 # define _STDINT_H_HAVE_INT64 1 127 #undef uint64_t
118 #else 128 #if LONG_MAX >> 31 >> 31 == 1
119 # if @HAVE_LONG_64BIT@ 129 # define int64_t long int
120 typedef long int64_t; 130 # define uint64_t unsigned long int
121 # define _STDINT_H_HAVE_INT64 1 131 #elif defined _MSC_VER
122 # elif @HAVE_LONG_LONG_64BIT@ 132 # define int64_t __int64
123 typedef long long int64_t; 133 # define uint64_t unsigned __int64
124 # define _STDINT_H_HAVE_INT64 1 134 #elif @HAVE_LONG_LONG_INT@
125 # elif defined _MSC_VER 135 # define int64_t long long int
126 typedef __int64 int64_t; 136 # define uint64_t unsigned long long int
127 # define _STDINT_H_HAVE_INT64 1
128 # endif
129 #endif
130 #if @HAVE_UINT64_T@
131 # define _STDINT_H_HAVE_UINT64 1
132 #else
133 # if @HAVE_LONG_64BIT@
134 typedef unsigned long uint64_t;
135 # define _STDINT_H_HAVE_UINT64 1
136 # elif @HAVE_LONG_LONG_64BIT@
137 typedef unsigned long long uint64_t;
138 # define _UINT64_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
139 # define _STDINT_H_HAVE_UINT64 1
140 # elif defined _MSC_VER
141 typedef unsigned __int64 uint64_t;
142 # define _STDINT_H_HAVE_UINT64 1
143 # endif
144 #endif 137 #endif
145 138
139 /* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
140 #define _UINT8_T
141 #define _UINT32_T
142 #define _UINT64_T
143
144
146 /* 7.18.1.2. Minimum-width integer types */ 145 /* 7.18.1.2. Minimum-width integer types */
147 146
148 /* Here we assume a standard architecture where the hardware integer 147 /* Here we assume a standard architecture where the hardware integer
149 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types 148 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
150 are the same as the corresponding N_t types. */ 149 are the same as the corresponding N_t types. */
151 150
152 #if !@HAVE_INT_LEAST8_T@ 151 #undef int_least8_t
153 typedef int8_t int_least8_t; 152 #undef uint_least8_t
154 #endif 153 #undef int_least16_t
155 #if !@HAVE_UINT_LEAST8_T@ 154 #undef uint_least16_t
156 typedef uint8_t uint_least8_t; 155 #undef int_least32_t
157 #endif 156 #undef uint_least32_t
158 157 #undef int_least64_t
159 #if !@HAVE_INT_LEAST16_T@ 158 #undef uint_least64_t
160 typedef int16_t int_least16_t; 159 #define int_least8_t int8_t
161 #endif 160 #define uint_least8_t uint8_t
162 #if !@HAVE_UINT_LEAST16_T@ 161 #define int_least16_t int16_t
163 typedef uint16_t uint_least16_t; 162 #define uint_least16_t uint16_t
164 #endif 163 #define int_least32_t int32_t
165 164 #define uint_least32_t uint32_t
166 #if !@HAVE_INT_LEAST32_T@ 165 #ifdef int64_t
167 typedef int32_t int_least32_t; 166 # define int_least64_t int64_t
168 #endif 167 # define uint_least64_t uint64_t
169 #if !@HAVE_UINT_LEAST32_T@
170 typedef uint32_t uint_least32_t;
171 #endif
172
173 #if !@HAVE_INT_LEAST64_T@ && _STDINT_H_HAVE_INT64
174 typedef int64_t int_least64_t;
175 #endif
176 #if !@HAVE_UINT_LEAST64_T@ && _STDINT_H_HAVE_UINT64
177 typedef uint64_t uint_least64_t;
178 #endif 168 #endif
179 169
180 /* 7.18.1.3. Fastest minimum-width integer types */ 170 /* 7.18.1.3. Fastest minimum-width integer types */
...@@ -184,240 +174,90 @@ typedef uint64_t uint_least64_t; ...@@ -184,240 +174,90 @@ typedef uint64_t uint_least64_t;
184 174
185 /* Here we assume a standard architecture where the hardware integer 175 /* Here we assume a standard architecture where the hardware integer
186 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types 176 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
187 are taken from the same list of types. */ 177 are taken from the same list of types. Assume that 'long int'
188 178 is fast enough for all narrower integers. */
189 /* On alpha processors, int32_t variables are slower than int64_t variables, 179
190 due to the necessary zap instructions. */ 180 #undef int_fast8_t
191 #if defined __alpha 181 #undef uint_fast8_t
192 # define _STDINT_H_INT64_FASTER_THAN_INT32 1 182 #undef int_fast16_t
193 #endif 183 #undef uint_fast16_t
194 184 #undef int_fast32_t
195 #if !@HAVE_INT_FAST8_T@ 185 #undef uint_fast32_t
196 # if _STDINT_H_INT64_FASTER_THAN_INT32 186 #undef int_fast64_t
197 typedef int64_t int_fast8_t; 187 #undef uint_fast64_t
198 # else 188 #define int_fast8_t long int
199 typedef int32_t int_fast8_t; 189 #define uint_fast8_t unsigned int_fast8_t
200 # endif 190 #define int_fast16_t long int
201 #endif 191 #define uint_fast16_t unsigned int_fast16_t
202 #if !@HAVE_UINT_FAST8_T@ 192 #define int_fast32_t long int
203 # if _STDINT_H_INT64_FASTER_THAN_INT32 193 #define uint_fast32_t unsigned int_fast32_t
204 typedef uint64_t uint_fast8_t; 194 #ifdef int64_t
205 # else 195 # define int_fast64_t int64_t
206 typedef uint32_t uint_fast8_t; 196 # define uint_fast64_t uint64_t
207 # endif
208 #endif
209
210 #if !@HAVE_INT_FAST16_T@
211 # if _STDINT_H_INT64_FASTER_THAN_INT32
212 typedef int64_t int_fast16_t;
213 # else
214 typedef int32_t int_fast16_t;
215 # endif
216 #endif
217 #if !@HAVE_UINT_FAST16_T@
218 # if _STDINT_H_INT64_FASTER_THAN_INT32
219 typedef uint64_t uint_fast16_t;
220 # else
221 typedef uint32_t uint_fast16_t;
222 # endif
223 #endif
224
225 #if !@HAVE_INT_FAST32_T@
226 # if _STDINT_H_INT64_FASTER_THAN_INT32
227 typedef int64_t int_fast32_t;
228 # else
229 typedef int32_t int_fast32_t;
230 # endif
231 #endif
232 #if !@HAVE_UINT_FAST32_T@
233 # if _STDINT_H_INT64_FASTER_THAN_INT32
234 typedef uint64_t uint_fast32_t;
235 # else
236 typedef uint32_t uint_fast32_t;
237 # endif
238 #endif
239
240 #if !@HAVE_INT_FAST64_T@ && _STDINT_H_HAVE_INT64
241 typedef int64_t int_fast64_t;
242 #endif
243 #if !@HAVE_UINT_FAST64_T@ && _STDINT_H_HAVE_UINT64
244 typedef uint64_t uint_fast64_t;
245 #endif 197 #endif
246 198
247 /* 7.18.1.4. Integer types capable of holding object pointers */ 199 /* 7.18.1.4. Integer types capable of holding object pointers */
248 200
249 /* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long), 201 #undef intptr_t
250 but this doesn't matter here. */ 202 #undef uintptr_t
251 #if !@HAVE_INTPTR_T@ 203 #define intptr_t long int
252 typedef long intptr_t; 204 #define uintptr_t unsigned long int
253 #endif
254 #if !@HAVE_UINTPTR_T@
255 typedef unsigned long uintptr_t;
256 #endif
257 205
258 /* 7.18.1.5. Greatest-width integer types */ 206 /* 7.18.1.5. Greatest-width integer types */
259 207
260 /* Note: These types are compiler dependent. It may be unwise to use them in 208 /* Note: These types are compiler dependent. It may be unwise to use them in
261 public header files. */ 209 public header files. */
262 210
263 #if !@HAVE_INTMAX_T@ 211 #undef intmax_t
264 # ifdef _STDINT_H_HAVE_INT64 212 #undef uintmax_t
265 typedef int64_t intmax_t; 213 #if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
266 # else 214 # define intmax_t long long int
267 typedef int32_t intmax_t; 215 # define uintmax_t unsigned long long int
268 # endif 216 #elif defined int64_t
269 #endif 217 # define intmax_t int64_t
270 #if !@HAVE_UINTMAX_T@ 218 # define uintmax_t uint64_t
271 # ifdef _STDINT_H_HAVE_UINT64 219 #else
272 typedef uint64_t uintmax_t; 220 # define intmax_t long int
273 # else 221 # define uintmax_t unsigned long int
274 typedef uint32_t uintmax_t;
275 # endif
276 #endif 222 #endif
277 223
278 /* 7.18.2. Limits of specified-width integer types */ 224 /* 7.18.2. Limits of specified-width integer types */
279 225
280 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) 226 #if ! defined __cplusplus || defined __STDC_LIMIT_MACROS
281 227
282 /* 7.18.2.1. Limits of exact-width integer types */ 228 /* 7.18.2.1. Limits of exact-width integer types */
283 229
284 /* Here we assume a standard architecture where the hardware integer 230 /* Here we assume a standard architecture where the hardware integer
285 types have 8, 16, 32, optionally 64 bits. */ 231 types have 8, 16, 32, optionally 64 bits. */
286 232
287 #if @HAVE_INT8_T@ 233 #undef INT8_MIN
288 # ifndef INT8_MIN 234 #undef INT8_MAX
289 # define INT8_MIN (-1 << (@BITSIZEOF_INT8_T@ - 1)) 235 #undef UINT8_MAX
290 # endif 236 #define INT8_MIN (~ INT8_MAX)
291 #else 237 #define INT8_MAX 127
292 # define INT8_MIN -128 238 #define UINT8_MAX 255
293 #endif 239
294 #if @HAVE_INT8_T@ 240 #undef INT16_MIN
295 # ifndef INT8_MAX 241 #undef INT16_MAX
296 # define INT8_MAX (~ (-1 << (@BITSIZEOF_INT8_T@ - 1))) 242 #undef UINT16_MAX
297 # endif 243 #define INT16_MIN (~ INT16_MAX)
298 #else 244 #define INT16_MAX 32767
299 # define INT8_MAX 127 245 #define UINT16_MAX 65535
300 #endif 246
301 #if @HAVE_UINT8_T@ 247 #undef INT32_MIN
302 # ifndef UINT8_MAX 248 #undef INT32_MAX
303 # if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@ 249 #undef UINT32_MAX
304 # define UINT8_MAX (((1 << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1) 250 #define INT32_MIN (~ INT32_MAX)
305 # else 251 #define INT32_MAX 2147483647
306 # define UINT8_MAX (((1U << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1) 252 #define UINT32_MAX 4294967295U
307 # endif 253
308 # endif 254 #undef INT64_MIN
309 #else 255 #undef INT64_MAX
310 # define UINT8_MAX 255 256 #undef UINT64_MAX
311 #endif 257 #ifdef int64_t
312 258 # define INT64_MIN (~ INT64_MAX)
313 #if @HAVE_INT16_T@ 259 # define INT64_MAX INTMAX_C (9223372036854775807)
314 # ifndef INT16_MIN 260 # define UINT64_MAX UINTMAX_C (18446744073709551615)
315 # define INT16_MIN (-1 << (@BITSIZEOF_INT16_T@ - 1))
316 # endif
317 #else
318 # define INT16_MIN -32768
319 #endif
320 #if @HAVE_INT16_T@
321 # ifndef INT16_MAX
322 # define INT16_MAX (~ (-1 << (@BITSIZEOF_INT16_T@ - 1)))
323 # endif
324 #else
325 # define INT16_MAX 32767
326 #endif
327 #if @HAVE_UINT16_T@
328 # ifndef UINT16_MAX
329 # if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
330 # define UINT16_MAX (((1 << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
331 # else
332 # define UINT16_MAX (((1U << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
333 # endif
334 # endif
335 #else
336 # define UINT16_MAX 65535
337 #endif
338
339 #if @HAVE_INT32_T@
340 # ifndef INT32_MIN
341 # define INT32_MIN (-1 << (@BITSIZEOF_INT32_T@ - 1))
342 # endif
343 #else
344 # define INT32_MIN (~INT32_MAX)
345 #endif
346 #if @HAVE_INT32_T@
347 # ifndef INT32_MAX
348 # define INT32_MAX (~ (-1 << (@BITSIZEOF_INT32_T@ - 1)))
349 # endif
350 #else
351 # define INT32_MAX 2147483647
352 #endif
353 #if @HAVE_UINT32_T@
354 # ifndef UINT32_MAX
355 # if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
356 # define UINT32_MAX (((1 << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
357 # else
358 # define UINT32_MAX (((1U << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
359 # endif
360 # endif
361 #else
362 # define UINT32_MAX 4294967295U
363 #endif
364
365 #if @HAVE_INT64_T@
366 # ifndef INT64_MIN
367 # if @HAVE_LONG_64BIT@
368 # define INT64_MIN (-1L << (@BITSIZEOF_INT64_T@ - 1))
369 # elif @HAVE_LONG_LONG_64BIT@
370 # define INT64_MIN (-1LL << (@BITSIZEOF_INT64_T@ - 1))
371 # elif defined _MSC_VER
372 # define INT64_MIN (-1i64 << (@BITSIZEOF_INT64_T@ - 1))
373 # endif
374 # endif
375 #else
376 # ifdef _STDINT_H_HAVE_INT64
377 # define INT64_MIN (~INT64_MAX)
378 # endif
379 #endif
380 #if @HAVE_INT64_T@
381 # ifndef INT64_MAX
382 # if @HAVE_LONG_64BIT@
383 # define INT64_MAX (~ (-1L << (@BITSIZEOF_INT64_T@ - 1)))
384 # elif @HAVE_LONG_LONG_64BIT@
385 # define INT64_MAX (~ (-1LL << (@BITSIZEOF_INT64_T@ - 1)))
386 # elif defined _MSC_VER
387 # define INT64_MAX (~ (-1i64 << (@BITSIZEOF_INT64_T@ - 1)))
388 # endif
389 # endif
390 #else
391 # ifdef _STDINT_H_HAVE_INT64
392 # if @HAVE_LONG_64BIT@
393 # define INT64_MAX 9223372036854775807L
394 # elif @HAVE_LONG_LONG_64BIT@
395 # define INT64_MAX 9223372036854775807LL
396 # elif defined _MSC_VER
397 # define INT64_MAX 9223372036854775807i64
398 # endif
399 # endif
400 #endif
401 #if @HAVE_UINT64_T@
402 # ifndef UINT64_MAX
403 # if @HAVE_LONG_64BIT@
404 # define UINT64_MAX (((1UL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
405 # elif @HAVE_LONG_LONG_64BIT@
406 # define UINT64_MAX (((1ULL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
407 # elif defined _MSC_VER
408 # define UINT64_MAX (((1ui64 << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
409 # endif
410 # endif
411 #else
412 # ifdef _STDINT_H_HAVE_UINT64
413 # if @HAVE_LONG_64BIT@
414 # define UINT64_MAX 18446744073709551615UL
415 # elif @HAVE_LONG_LONG_64BIT@
416 # define UINT64_MAX 18446744073709551615ULL
417 # elif defined _MSC_VER
418 # define UINT64_MAX 18446744073709551615ui64
419 # endif
420 # endif
421 #endif 261 #endif
422 262
423 /* 7.18.2.2. Limits of minimum-width integer types */ 263 /* 7.18.2.2. Limits of minimum-width integer types */
...@@ -426,128 +266,34 @@ typedef uint32_t uintmax_t; ...@@ -426,128 +266,34 @@ typedef uint32_t uintmax_t;
426 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types 266 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
427 are the same as the corresponding N_t types. */ 267 are the same as the corresponding N_t types. */
428 268
429 #if @HAVE_INT_LEAST8_T@ 269 #undef INT_LEAST8_MIN
430 # ifndef INT_LEAST8_MIN 270 #undef INT_LEAST8_MAX
431 # define INT_LEAST8_MIN (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1)) 271 #undef UINT_LEAST8_MAX
432 # endif 272 #define INT_LEAST8_MIN INT8_MIN
433 #else 273 #define INT_LEAST8_MAX INT8_MAX
434 # define INT_LEAST8_MIN INT8_MIN 274 #define UINT_LEAST8_MAX UINT8_MAX
435 #endif 275
436 #if @HAVE_INT_LEAST8_T@ 276 #undef INT_LEAST16_MIN
437 # ifndef INT_LEAST8_MAX 277 #undef INT_LEAST16_MAX
438 # define INT_LEAST8_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1))) 278 #undef UINT_LEAST16_MAX
439 # endif 279 #define INT_LEAST16_MIN INT16_MIN
440 #else 280 #define INT_LEAST16_MAX INT16_MAX
441 # define INT_LEAST8_MAX INT8_MAX 281 #define UINT_LEAST16_MAX UINT16_MAX
442 #endif 282
443 #if @HAVE_UINT_LEAST8_T@ 283 #undef INT_LEAST32_MIN
444 # ifndef UINT_LEAST8_MAX 284 #undef INT_LEAST32_MAX
445 # if @BITSIZEOF_UINT_LEAST8_T@ < @BITSIZEOF_UNSIGNED_INT@ 285 #undef UINT_LEAST32_MAX
446 # define UINT_LEAST8_MAX (((1 << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1) 286 #define INT_LEAST32_MIN INT32_MIN
447 # else 287 #define INT_LEAST32_MAX INT32_MAX
448 # define UINT_LEAST8_MAX (((1U << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1) 288 #define UINT_LEAST32_MAX UINT32_MAX
449 # endif 289
450 # endif 290 #undef INT_LEAST64_MIN
451 #else 291 #undef INT_LEAST64_MAX
452 # define UINT_LEAST8_MAX UINT8_MAX 292 #undef UINT_LEAST64_MAX
453 #endif 293 #ifdef int64_t
454 294 # define INT_LEAST64_MIN INT64_MIN
455 #if @HAVE_INT_LEAST16_T@ 295 # define INT_LEAST64_MAX INT64_MAX
456 # ifndef INT_LEAST16_MIN 296 # define UINT_LEAST64_MAX UINT64_MAX
457 # define INT_LEAST16_MIN (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1))
458 # endif
459 #else
460 # define INT_LEAST16_MIN INT16_MIN
461 #endif
462 #if @HAVE_INT_LEAST16_T@
463 # ifndef INT_LEAST16_MAX
464 # define INT_LEAST16_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1)))
465 # endif
466 #else
467 # define INT_LEAST16_MAX INT16_MAX
468 #endif
469 #if @HAVE_UINT_LEAST16_T@
470 # ifndef UINT_LEAST16_MAX
471 # if @BITSIZEOF_UINT_LEAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
472 # define UINT_LEAST16_MAX (((1 << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
473 # else
474 # define UINT_LEAST16_MAX (((1U << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
475 # endif
476 # endif
477 #else
478 # define UINT_LEAST16_MAX UINT16_MAX
479 #endif
480
481 #if @HAVE_INT_LEAST32_T@
482 # ifndef INT_LEAST32_MIN
483 # define INT_LEAST32_MIN (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1))
484 # endif
485 #else
486 # define INT_LEAST32_MIN INT32_MIN
487 #endif
488 #if @HAVE_INT_LEAST32_T@
489 # ifndef INT_LEAST32_MAX
490 # define INT_LEAST32_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1)))
491 # endif
492 #else
493 # define INT_LEAST32_MAX INT32_MAX
494 #endif
495 #if @HAVE_UINT_LEAST32_T@
496 # ifndef UINT_LEAST32_MAX
497 # if @BITSIZEOF_UINT_LEAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
498 # define UINT_LEAST32_MAX (((1 << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
499 # else
500 # define UINT_LEAST32_MAX (((1U << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
501 # endif
502 # endif
503 #else
504 # define UINT_LEAST32_MAX UINT32_MAX
505 #endif
506
507 #if @HAVE_INT_LEAST64_T@
508 # ifndef INT_LEAST64_MIN
509 # if @HAVE_LONG_64BIT@
510 # define INT_LEAST64_MIN (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1))
511 # elif @HAVE_LONG_LONG_64BIT@
512 # define INT_LEAST64_MIN (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1))
513 # elif defined _MSC_VER
514 # define INT_LEAST64_MIN (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1))
515 # endif
516 # endif
517 #else
518 # ifdef _STDINT_H_HAVE_INT64
519 # define INT_LEAST64_MIN INT64_MIN
520 # endif
521 #endif
522 #if @HAVE_INT_LEAST64_T@
523 # ifndef INT_LEAST64_MAX
524 # if @HAVE_LONG_64BIT@
525 # define INT_LEAST64_MAX (~ (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
526 # elif @HAVE_LONG_LONG_64BIT@
527 # define INT_LEAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
528 # elif defined _MSC_VER
529 # define INT_LEAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
530 # endif
531 # endif
532 #else
533 # ifdef _STDINT_H_HAVE_INT64
534 # define INT_LEAST64_MAX INT64_MAX
535 # endif
536 #endif
537 #if @HAVE_UINT_LEAST64_T@
538 # ifndef UINT_LEAST64_MAX
539 # if @HAVE_LONG_64BIT@
540 # define UINT_LEAST64_MAX (((1UL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
541 # elif @HAVE_LONG_LONG_64BIT@
542 # define UINT_LEAST64_MAX (((1ULL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
543 # elif defined _MSC_VER
544 # define UINT_LEAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
545 # endif
546 # endif
547 #else
548 # ifdef _STDINT_H_HAVE_UINT64
549 # define UINT_LEAST64_MAX UINT64_MAX
550 # endif
551 #endif 297 #endif
552 298
553 /* 7.18.2.3. Limits of fastest minimum-width integer types */ 299 /* 7.18.2.3. Limits of fastest minimum-width integer types */
...@@ -556,464 +302,155 @@ typedef uint32_t uintmax_t; ...@@ -556,464 +302,155 @@ typedef uint32_t uintmax_t;
556 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types 302 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
557 are taken from the same list of types. */ 303 are taken from the same list of types. */
558 304
559 #if @HAVE_INT_FAST8_T@ 305 #undef INT_FAST8_MIN
560 # ifndef INT_FAST8_MIN 306 #undef INT_FAST8_MAX
561 # define INT_FAST8_MIN (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1)) 307 #undef UINT_FAST8_MAX
562 # endif 308 #define INT_FAST8_MIN LONG_MIN
563 #else 309 #define INT_FAST8_MAX LONG_MAX
564 # if _STDINT_H_INT64_FASTER_THAN_INT32 310 #define UINT_FAST8_MAX ULONG_MAX
565 # define INT_FAST8_MIN INT64_MIN 311
566 # else 312 #undef INT_FAST16_MIN
567 # define INT_FAST8_MIN INT32_MIN 313 #undef INT_FAST16_MAX
568 # endif 314 #undef UINT_FAST16_MAX
569 #endif 315 #define INT_FAST16_MIN LONG_MIN
570 #if @HAVE_INT_FAST8_T@ 316 #define INT_FAST16_MAX LONG_MAX
571 # ifndef INT_FAST8_MAX 317 #define UINT_FAST16_MAX ULONG_MAX
572 # define INT_FAST8_MAX (~ (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1))) 318
573 # endif 319 #undef INT_FAST32_MIN
574 #else 320 #undef INT_FAST32_MAX
575 # if _STDINT_H_INT64_FASTER_THAN_INT32 321 #undef UINT_FAST32_MAX
576 # define INT_FAST8_MAX INT64_MAX 322 #define INT_FAST32_MIN LONG_MIN
577 # else 323 #define INT_FAST32_MAX LONG_MAX
578 # define INT_FAST8_MAX INT32_MAX 324 #define UINT_FAST32_MAX ULONG_MAX
579 # endif 325
580 #endif 326 #undef INT_FAST64_MIN
581 #if @HAVE_UINT_FAST8_T@ 327 #undef INT_FAST64_MAX
582 # ifndef UINT_FAST8_MAX 328 #undef UINT_FAST64_MAX
583 # if @BITSIZEOF_UINT_FAST8_T@ < @BITSIZEOF_UNSIGNED_INT@ 329 #ifdef int64_t
584 # define UINT_FAST8_MAX (((1 << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1) 330 # define INT_FAST64_MIN INT64_MIN
585 # else 331 # define INT_FAST64_MAX INT64_MAX
586 # define UINT_FAST8_MAX (((1UL << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1) 332 # define UINT_FAST64_MAX UINT64_MAX
587 # endif
588 # endif
589 #else
590 # if _STDINT_H_INT64_FASTER_THAN_INT32
591 # define UINT_FAST8_MAX UINT64_MAX
592 # else
593 # define UINT_FAST8_MAX UINT32_MAX
594 # endif
595 #endif
596
597 #if @HAVE_INT_FAST16_T@
598 # ifndef INT_FAST16_MIN
599 # define INT_FAST16_MIN (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1))
600 # endif
601 #else
602 # if _STDINT_H_INT64_FASTER_THAN_INT32
603 # define INT_FAST16_MIN INT64_MIN
604 # else
605 # define INT_FAST16_MIN INT32_MIN
606 # endif
607 #endif
608 #if @HAVE_INT_FAST16_T@
609 # ifndef INT_FAST16_MAX
610 # define INT_FAST16_MAX (~ (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1)))
611 # endif
612 #else
613 # if _STDINT_H_INT64_FASTER_THAN_INT32
614 # define INT_FAST16_MAX INT64_MAX
615 # else
616 # define INT_FAST16_MAX INT32_MAX
617 # endif
618 #endif
619 #if @HAVE_UINT_FAST16_T@
620 # ifndef UINT_FAST16_MAX
621 # if @BITSIZEOF_UINT_FAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
622 # define UINT_FAST16_MAX (((1 << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
623 # else
624 # define UINT_FAST16_MAX (((1UL << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
625 # endif
626 # endif
627 #else
628 # if _STDINT_H_INT64_FASTER_THAN_INT32
629 # define UINT_FAST16_MAX UINT64_MAX
630 # else
631 # define UINT_FAST16_MAX UINT32_MAX
632 # endif
633 #endif
634
635 #if @HAVE_INT_FAST32_T@
636 # ifndef INT_FAST32_MIN
637 # define INT_FAST32_MIN (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1))
638 # endif
639 #else
640 # if _STDINT_H_INT64_FASTER_THAN_INT32
641 # define INT_FAST32_MIN INT64_MIN
642 # else
643 # define INT_FAST32_MIN INT32_MIN
644 # endif
645 #endif
646 #if @HAVE_INT_FAST32_T@
647 # ifndef INT_FAST32_MAX
648 # define INT_FAST32_MAX (~ (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1)))
649 # endif
650 #else
651 # if _STDINT_H_INT64_FASTER_THAN_INT32
652 # define INT_FAST32_MAX INT64_MAX
653 # else
654 # define INT_FAST32_MAX INT32_MAX
655 # endif
656 #endif
657 #if @HAVE_UINT_FAST32_T@
658 # ifndef UINT_FAST32_MAX
659 # if @BITSIZEOF_UINT_FAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
660 # define UINT_FAST32_MAX (((1 << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
661 # else
662 # define UINT_FAST32_MAX (((1UL << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
663 # endif
664 # endif
665 #else
666 # if _STDINT_H_INT64_FASTER_THAN_INT32
667 # define UINT_FAST32_MAX UINT64_MAX
668 # else
669 # define UINT_FAST32_MAX UINT32_MAX
670 # endif
671 #endif
672
673 #if @HAVE_INT_FAST64_T@
674 # ifndef INT_FAST64_MIN
675 # if @HAVE_LONG_64BIT@
676 # define INT_FAST64_MIN (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1))
677 # elif @HAVE_LONG_LONG_64BIT@
678 # define INT_FAST64_MIN (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1))
679 # elif defined _MSC_VER
680 # define INT_FAST64_MIN (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1))
681 # endif
682 # endif
683 #else
684 # ifdef _STDINT_H_HAVE_INT64
685 # define INT_FAST64_MIN INT64_MIN
686 # endif
687 #endif
688 #if @HAVE_INT_FAST64_T@
689 # ifndef INT_FAST64_MAX
690 # if @HAVE_LONG_64BIT@
691 # define INT_FAST64_MAX (~ (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1)))
692 # elif @HAVE_LONG_LONG_64BIT@
693 # define INT_FAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1)))
694 # elif defined _MSC_VER
695 # define INT_FAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1)))
696 # endif
697 # endif
698 #else
699 # ifdef _STDINT_H_HAVE_INT64
700 # define INT_FAST64_MAX INT64_MAX
701 # endif
702 #endif
703 #if @HAVE_UINT_FAST64_T@
704 # ifndef UINT_FAST64_MAX
705 # if @HAVE_LONG_64BIT@
706 # define UINT_FAST64_MAX (((1UL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
707 # elif @HAVE_LONG_LONG_64BIT@
708 # define UINT_FAST64_MAX (((1ULL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
709 # elif defined _MSC_VER
710 # define UINT_FAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
711 # endif
712 # endif
713 #else
714 # ifdef _STDINT_H_HAVE_UINT64
715 # define UINT_FAST64_MAX UINT64_MAX
716 # endif
717 #endif 333 #endif
718 334
719 /* 7.18.2.4. Limits of integer types capable of holding object pointers */ 335 /* 7.18.2.4. Limits of integer types capable of holding object pointers */
720 336
721 #if @HAVE_INTPTR_T@ 337 #undef INTPTR_MIN
722 # ifndef INTPTR_MIN 338 #undef INTPTR_MAX
723 # if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@ 339 #undef UINTPTR_MAX
724 # define INTPTR_MIN (-1LL << (@BITSIZEOF_INTPTR_T@ - 1)) 340 #define INTPTR_MIN LONG_MIN
725 # else 341 #define INTPTR_MAX LONG_MAX
726 # define INTPTR_MIN (-1L << (@BITSIZEOF_INTPTR_T@ - 1)) 342 #define UINTPTR_MAX ULONG_MAX
727 # endif
728 # endif
729 #else
730 # define INTPTR_MIN LONG_MIN
731 #endif
732 #if @HAVE_INTPTR_T@
733 # ifndef INTPTR_MAX
734 # if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
735 # define INTPTR_MAX (~ (-1LL << (@BITSIZEOF_INTPTR_T@ - 1)))
736 # else
737 # define INTPTR_MAX (~ (-1L << (@BITSIZEOF_INTPTR_T@ - 1)))
738 # endif
739 # endif
740 #else
741 # define INTPTR_MAX LONG_MAX
742 #endif
743 #if @HAVE_UINTPTR_T@
744 # ifndef UINTPTR_MAX
745 # if @BITSIZEOF_UINTPTR_T@ > @BITSIZEOF_UNSIGNED_LONG@
746 # define UINTPTR_MAX (((1ULL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
747 # else
748 # define UINTPTR_MAX (((1UL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
749 # endif
750 # endif
751 #else
752 # define UINTPTR_MAX ULONG_MAX
753 #endif
754 343
755 /* 7.18.2.5. Limits of greatest-width integer types */ 344 /* 7.18.2.5. Limits of greatest-width integer types */
756 345
757 #if @HAVE_INTMAX_T@ 346 #undef INTMAX_MIN
758 # ifndef INTMAX_MIN 347 #undef INTMAX_MAX
759 # if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@ 348 #undef UINTMAX_MAX
760 # define INTMAX_MIN (-1LL << (@BITSIZEOF_INTMAX_T@ - 1)) 349 #define INTMAX_MIN (~ INTMAX_MAX)
761 # else 350 #ifdef INT64_MAX
762 # define INTMAX_MIN (-1L << (@BITSIZEOF_INTMAX_T@ - 1)) 351 # define INTMAX_MAX INT64_MAX
763 # endif 352 # define UINTMAX_MAX UINT64_MAX
764 # endif
765 #else
766 # ifdef _STDINT_H_HAVE_INT64
767 # define INTMAX_MIN INT64_MIN
768 # else
769 # define INTMAX_MIN INT32_MIN
770 # endif
771 #endif
772 #if @HAVE_INTMAX_T@
773 # ifndef INTMAX_MAX
774 # if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
775 # define INTMAX_MAX (~ (-1LL << (@BITSIZEOF_INTMAX_T@ - 1)))
776 # else
777 # define INTMAX_MAX (~ (-1L << (@BITSIZEOF_INTMAX_T@ - 1)))
778 # endif
779 # endif
780 #else
781 # ifdef _STDINT_H_HAVE_INT64
782 # define INTMAX_MAX INT64_MAX
783 # else
784 # define INTMAX_MAX INT32_MAX
785 # endif
786 #endif
787 #if @HAVE_UINTMAX_T@
788 # ifndef UINTMAX_MAX
789 # if @BITSIZEOF_UINTMAX_T@ > @BITSIZEOF_UNSIGNED_LONG@
790 # define UINTMAX_MAX (((1ULL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
791 # else
792 # define UINTMAX_MAX (((1UL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
793 # endif
794 # endif
795 #else 353 #else
796 # ifdef _STDINT_H_HAVE_INT64 354 # define INTMAX_MAX INT32_MAX
797 # define UINTMAX_MAX UINT64_MAX 355 # define UINTMAX_MAX UINT32_MAX
798 # else
799 # define UINTMAX_MAX UINT32_MAX
800 # endif
801 #endif 356 #endif
802 357
803 /* 7.18.3. Limits of other integer types */ 358 /* 7.18.3. Limits of other integer types */
804 359
805 /* ptrdiff_t limits */ 360 /* ptrdiff_t limits */
806 #ifndef PTRDIFF_MIN 361 #undef PTRDIFF_MIN
807 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@ 362 #undef PTRDIFF_MAX
808 # define PTRDIFF_MIN (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1)) 363 #define PTRDIFF_MIN \
809 # else 364 _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
810 # define PTRDIFF_MIN (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1)) 365 #define PTRDIFF_MAX \
811 # endif 366 _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
812 #endif
813 #ifndef PTRDIFF_MAX
814 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
815 # define PTRDIFF_MAX (~ (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1)))
816 # else
817 # define PTRDIFF_MAX (~ (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1)))
818 # endif
819 #endif
820 367
821 /* sig_atomic_t limits */ 368 /* sig_atomic_t limits */
822 #ifndef SIG_ATOMIC_MIN 369 #undef SIG_ATOMIC_MIN
823 # if @HAVE_SIGNED_SIG_ATOMIC_T@ 370 #undef SIG_ATOMIC_MAX
824 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@ 371 #define SIG_ATOMIC_MIN \
825 # define SIG_ATOMIC_MIN (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) 372 _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
826 # else 373 0@SIG_ATOMIC_T_SUFFIX@)
827 # define SIG_ATOMIC_MIN (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) 374 #define SIG_ATOMIC_MAX \
828 # endif 375 _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
829 # else 376 0@SIG_ATOMIC_T_SUFFIX@)
830 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@ 377
831 # define SIG_ATOMIC_MIN 0UL
832 # elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
833 # define SIG_ATOMIC_MIN 0U
834 # else
835 # define SIG_ATOMIC_MIN 0
836 # endif
837 # endif
838 #endif
839 #ifndef SIG_ATOMIC_MAX
840 # if @HAVE_SIGNED_SIG_ATOMIC_T@
841 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@
842 # define SIG_ATOMIC_MAX (~ (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
843 # else
844 # define SIG_ATOMIC_MAX (~ (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
845 # endif
846 # else
847 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@
848 # define SIG_ATOMIC_MAX (((1UL << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
849 # elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
850 # define SIG_ATOMIC_MAX (((1U << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
851 # else
852 # define SIG_ATOMIC_MAX (((1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
853 # endif
854 # endif
855 #endif
856 378
857 /* size_t limit */ 379 /* size_t limit */
858 #ifndef SIZE_MAX /* SIZE_MAX may also be defined in config.h. */ 380 #undef SIZE_MAX
859 # if @BITSIZEOF_SIZE_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIZE_T_UNSIGNED_LONG@ 381 #define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
860 # define SIZE_MAX (((1UL << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
861 # else
862 # define SIZE_MAX (((1U << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
863 # endif
864 #endif
865 382
866 /* wchar_t limits may already be defined in <stddef.h>. */ 383 /* wchar_t limits */
867 #ifndef WCHAR_MIN 384 #undef WCHAR_MIN
868 # if @HAVE_SIGNED_WCHAR_T@ 385 #undef WCHAR_MAX
869 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@ 386 #define WCHAR_MIN \
870 # define WCHAR_MIN (-1L << (@BITSIZEOF_WCHAR_T@ - 1)) 387 _STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
871 # else 388 #define WCHAR_MAX \
872 # define WCHAR_MIN (-1 << (@BITSIZEOF_WCHAR_T@ - 1)) 389 _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
873 # endif
874 # else
875 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
876 # define WCHAR_MIN 0UL
877 # elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
878 # define WCHAR_MIN 0U
879 # else
880 # define WCHAR_MIN 0
881 # endif
882 # endif
883 #endif
884 #ifndef WCHAR_MAX
885 # if @HAVE_SIGNED_WCHAR_T@
886 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
887 # define WCHAR_MAX (~ (-1L << (@BITSIZEOF_WCHAR_T@ - 1)))
888 # else
889 # define WCHAR_MAX (~ (-1 << (@BITSIZEOF_WCHAR_T@ - 1)))
890 # endif
891 # else
892 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
893 # define WCHAR_MAX (((1UL << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
894 # elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
895 # define WCHAR_MAX (((1U << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
896 # else
897 # define WCHAR_MAX (((1 << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
898 # endif
899 # endif
900 #endif
901 390
902 /* wint_t limits */ 391 /* wint_t limits */
903 #ifndef WINT_MIN 392 #undef WINT_MIN
904 # if @HAVE_SIGNED_WINT_T@ 393 #undef WINT_MAX
905 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@ 394 #define WINT_MIN \
906 # define WINT_MIN (-1L << (@BITSIZEOF_WINT_T@ - 1)) 395 _STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
907 # else 396 #define WINT_MAX \
908 # define WINT_MIN (-1 << (@BITSIZEOF_WINT_T@ - 1)) 397 _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
909 # endif
910 # else
911 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
912 # define WINT_MIN 0UL
913 # elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
914 # define WINT_MIN 0U
915 # else
916 # define WINT_MIN 0
917 # endif
918 # endif
919 #endif
920 #ifndef WINT_MAX
921 # if @HAVE_SIGNED_WINT_T@
922 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
923 # define WINT_MAX (~ (-1L << (@BITSIZEOF_WINT_T@ - 1)))
924 # else
925 # define WINT_MAX (~ (-1 << (@BITSIZEOF_WINT_T@ - 1)))
926 # endif
927 # else
928 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
929 # define WINT_MAX (((1UL << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
930 # elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
931 # define WINT_MAX (((1U << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
932 # else
933 # define WINT_MAX (((1 << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
934 # endif
935 # endif
936 #endif
937 398
938 #endif 399 #endif /* !defined __cplusplus || defined __STDC_LIMIT_MACROS */
939 400
940 /* 7.18.4. Macros for integer constants */ 401 /* 7.18.4. Macros for integer constants */
941 402
942 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) 403 #if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
943 404
944 /* 7.18.4.1. Macros for minimum-width integer constants */ 405 /* 7.18.4.1. Macros for minimum-width integer constants */
945 /* According to ISO C 99 Technical Corrigendum 1 */ 406 /* According to ISO C 99 Technical Corrigendum 1 */
946 407
408 /* Here we assume a standard architecture where the hardware integer
409 types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */
410
947 #undef INT8_C 411 #undef INT8_C
948 #undef UINT8_C 412 #undef UINT8_C
949 #define INT8_C(x) x 413 #define INT8_C(x) x
950 #if @HAVE_UINT8_T@ 414 #define UINT8_C(x) x
951 # if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@
952 # define UINT8_C(x) x
953 # else
954 # define UINT8_C(x) x##U
955 # endif
956 #else
957 # define UINT8_C(x) x
958 #endif
959 415
960 #undef INT16_C 416 #undef INT16_C
961 #undef UINT16_C 417 #undef UINT16_C
962 #define INT16_C(x) x 418 #define INT16_C(x) x
963 #if @HAVE_UINT16_T@ 419 #define UINT16_C(x) x
964 # if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
965 # define UINT16_C(x) x
966 # else
967 # define UINT16_C(x) x##U
968 # endif
969 #else
970 # define UINT16_C(x) x
971 #endif
972 420
973 #undef INT32_C 421 #undef INT32_C
974 #undef UINT32_C 422 #undef UINT32_C
975 #define INT32_C(x) x 423 #define INT32_C(x) x
976 #if @HAVE_UINT32_T@ 424 #define UINT32_C(x) x ## U
977 # if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
978 # define UINT32_C(x) x
979 # else
980 # define UINT32_C(x) x##U
981 # endif
982 #else
983 # define UINT32_C(x) x
984 #endif
985 425
986 #undef INT64_C 426 #undef INT64_C
987 #undef UINT64_C 427 #undef UINT64_C
988 #if @HAVE_LONG_64BIT@ 428 #if LONG_MAX >> 31 >> 31 == 1
989 # define INT64_C(x) x##L 429 # define INT64_C(x) x##L
990 # define UINT64_C(x) x##UL 430 # define UINT64_C(x) x##UL
991 #elif @HAVE_LONG_LONG_64BIT@ 431 #elif defined _MSC_VER
992 # define INT64_C(x) x##LL
993 # define UINT64_C(x) x##ULL
994 #elif defined(_MSC_VER)
995 # define INT64_C(x) x##i64 432 # define INT64_C(x) x##i64
996 # define UINT64_C(x) x##ui64 433 # define UINT64_C(x) x##ui64
434 #elif @HAVE_LONG_LONG_INT@
435 # define INT64_C(x) x##LL
436 # define UINT64_C(x) x##ULL
997 #endif 437 #endif
998 438
999 /* 7.18.4.2. Macros for greatest-width integer constants */ 439 /* 7.18.4.2. Macros for greatest-width integer constants */
1000 440
1001 #undef INTMAX_C 441 #undef INTMAX_C
1002 #undef UINTMAX_C 442 #undef UINTMAX_C
1003 #if @HAVE_LONG_64BIT@ 443 #if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
1004 # define INTMAX_C(x) x##L 444 # define INTMAX_C(x) x##LL
1005 # define UINTMAX_C(x) x##UL 445 # define UINTMAX_C(x) x##ULL
1006 #elif @HAVE_LONG_LONG_64BIT@ 446 #elif defined int64_t
1007 # define INTMAX_C(x) x##LL 447 # define INTMAX_C(x) INT64_C(x)
1008 # define UINTMAX_C(x) x##ULL 448 # define UINTMAX_C(x) UINT64_C(x)
1009 #elif defined(_MSC_VER)
1010 # define INTMAX_C(x) x##i64
1011 # define UINTMAX_C(x) x##ui64
1012 #else 449 #else
1013 # define INTMAX_C(x) x 450 # define INTMAX_C(x) x##L
1014 # define UINTMAX_C(x) x##U 451 # define UINTMAX_C(x) x##UL
1015 #endif 452 #endif
1016 453
1017 #endif 454 #endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */
1018 455
1019 #endif /* _STDINT_H */ 456 #endif /* _GL_STDINT_H */
......
1 /* Find the length of STRING + 1, but scan at most MAXLEN bytes. 1 /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
2 Copyright (C) 2005 Free Software Foundation, Inc. 2 Copyright (C) 2005 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify it 4 This program is free software; you can redistribute it and/or modify
5 under the terms of the GNU Library General Public License as published 5 it under the terms of the GNU General Public License as published by
6 by the Free Software Foundation; either version 2, or (at your option) 6 the Free Software Foundation; either version 2, or (at your option)
7 any later version. 7 any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 Library General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public 14 You should have received a copy of the GNU General Public License
15 License along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software Foundation,
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 USA. */
18 17
19 #ifdef HAVE_CONFIG_H 18 #ifdef HAVE_CONFIG_H
20 # include <config.h> 19 # include <config.h>
......
1 /* Find the length of STRING + 1, but scan at most MAXLEN bytes. 1 /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
2 Copyright (C) 2005 Free Software Foundation, Inc. 2 Copyright (C) 2005 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify it 4 This program is free software; you can redistribute it and/or modify
5 under the terms of the GNU Library General Public License as published 5 it under the terms of the GNU General Public License as published by
6 by the Free Software Foundation; either version 2, or (at your option) 6 the Free Software Foundation; either version 2, or (at your option)
7 any later version. 7 any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 Library General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public 14 You should have received a copy of the GNU General Public License
15 License along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software Foundation,
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 USA. */
18 17
19 #ifndef _STRNLEN1_H 18 #ifndef _STRNLEN1_H
20 #define _STRNLEN1_H 19 #define _STRNLEN1_H
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
40 #include <stdlib.h> /* abort(), malloc(), realloc(), free() */ 40 #include <stdlib.h> /* abort(), malloc(), realloc(), free() */
41 #include <string.h> /* memcpy(), strlen() */ 41 #include <string.h> /* memcpy(), strlen() */
42 #include <errno.h> /* errno */ 42 #include <errno.h> /* errno */
43 #include <limits.h> /* CHAR_BIT, INT_MAX */ 43 #include <limits.h> /* CHAR_BIT */
44 #include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */ 44 #include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
45 #if WIDE_CHAR_VERSION 45 #if WIDE_CHAR_VERSION
46 # include "wprintf-parse.h" 46 # include "wprintf-parse.h"
...@@ -51,11 +51,6 @@ ...@@ -51,11 +51,6 @@
51 /* Checked size_t computations. */ 51 /* Checked size_t computations. */
52 #include "xsize.h" 52 #include "xsize.h"
53 53
54 /* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
55 #ifndef EOVERFLOW
56 # define EOVERFLOW E2BIG
57 #endif
58
59 #ifdef HAVE_WCHAR_T 54 #ifdef HAVE_WCHAR_T
60 # ifdef HAVE_WCSLEN 55 # ifdef HAVE_WCSLEN
61 # define local_wcslen wcslen 56 # define local_wcslen wcslen
...@@ -869,19 +864,12 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar ...@@ -869,19 +864,12 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
869 free (buf_malloced); 864 free (buf_malloced);
870 CLEANUP (); 865 CLEANUP ();
871 *lengthp = length; 866 *lengthp = length;
872 if (length > INT_MAX) 867 /* Note that we can produce a big string of a length > INT_MAX. POSIX
873 goto length_overflow; 868 says that snprintf() fails with errno = EOVERFLOW in this case, but
869 that's only because snprintf() returns an 'int'. This function does
870 not have this limitation. */
874 return result; 871 return result;
875 872
876 length_overflow:
877 /* We could produce such a big string, but its length doesn't fit into
878 an 'int'. POSIX says that snprintf() fails with errno = EOVERFLOW in
879 this case. */
880 if (result != resultbuf)
881 free (result);
882 errno = EOVERFLOW;
883 return NULL;
884
885 out_of_memory: 873 out_of_memory:
886 if (!(result == resultbuf || result == NULL)) 874 if (!(result == resultbuf || result == NULL))
887 free (result); 875 free (result);
......
1 /* Formatted output to strings. 1 /* Formatted output to strings.
2 Copyright (C) 2004 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2006 Free Software Foundation, Inc.
3 Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>. 3 Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
23 /* Specification. */ 23 /* Specification. */
24 #include "vsnprintf.h" 24 #include "vsnprintf.h"
25 25
26 #include <errno.h>
27 #include <limits.h>
26 #include <stdarg.h> 28 #include <stdarg.h>
27 #include <stdio.h> 29 #include <stdio.h>
28 #include <stdlib.h> 30 #include <stdlib.h>
...@@ -30,6 +32,11 @@ ...@@ -30,6 +32,11 @@
30 32
31 #include "vasnprintf.h" 33 #include "vasnprintf.h"
32 34
35 /* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
36 #ifndef EOVERFLOW
37 # define EOVERFLOW E2BIG
38 #endif
39
33 /* Print formatted output to string STR. Similar to vsprintf, but 40 /* Print formatted output to string STR. Similar to vsprintf, but
34 additional length SIZE limit how much is written into STR. Returns 41 additional length SIZE limit how much is written into STR. Returns
35 string length of formatted string (which may be larger than SIZE). 42 string length of formatted string (which may be larger than SIZE).
...@@ -40,19 +47,31 @@ vsnprintf (char *str, size_t size, const char *format, va_list args) ...@@ -40,19 +47,31 @@ vsnprintf (char *str, size_t size, const char *format, va_list args)
40 { 47 {
41 char *output; 48 char *output;
42 size_t len; 49 size_t len;
50 size_t lenbuf = size;
43 51
44 len = size; 52 output = vasnprintf (str, &lenbuf, format, args);
45 output = vasnprintf (str, &len, format, args); 53 len = lenbuf;
46 54
47 if (!output) 55 if (!output)
48 return -1; 56 return -1;
49 57
50 if (str != NULL)
51 if (len > size - 1) /* equivalent to: (size > 0 && len >= size) */
52 str[size - 1] = '\0';
53
54 if (output != str) 58 if (output != str)
55 free (output); 59 {
60 if (size)
61 {
62 size_t pruned_len = (len < size ? len : size - 1);
63 memcpy (str, output, pruned_len);
64 str[pruned_len] = '\0';
65 }
66
67 free (output);
68 }
69
70 if (len > INT_MAX)
71 {
72 errno = EOVERFLOW;
73 return -1;
74 }
56 75
57 return len; 76 return len;
58 } 77 }
......