Commit 14d03c97 14d03c97f261729a270e953763dbfb1a880146c4 by Sergey Poznyakoff

Update

1 parent 7cc0cdd7
1 2006-04-19 Sergey Poznyakoff <gray@gnu.org.ua> 1 2006-04-19 Sergey Poznyakoff <gray@gnu.org.ua>
2 2
3 * NEWS: Update 3 * NEWS: Update
4 * gnulib.modules (muaux): Remove xstrtol
5 * libproto/pop/mbox.c (parse_answer0,parse_answer1): Use strtoul
6 instead of strtoumax. This is a temporary change.
7 * m4/gnulib.m4: Remove gl_XSTRTOL.
8 * m4/xstrtol.m4: Removed
9 * lib/xstrtol.h: Removed
10 * lib/xstrtol.c: Removed
11 * lib/xstrtoul.c: Removed
12
13 * NEWS: Update
4 * README: Document --with-berkeley-db option 14 * README: Document --with-berkeley-db option
5 * configure.ac (--with-berkeley-db): New option 15 * configure.ac (--with-berkeley-db): New option
6 (--with-db2): Deprecated. Remove from the help list. 16 (--with-db2): Deprecated. Remove from the help list.
......
...@@ -9,7 +9,7 @@ Version 0.6.94: ...@@ -9,7 +9,7 @@ Version 0.6.94:
9 * Add support for Berkeley DB 3.x and 4.x 9 * Add support for Berkeley DB 3.x and 4.x
10 10
11 * Bugfixes: 11 * Bugfixes:
12 ** Fix handling of file name containing whitespace characters in imap4 server 12 ** Fix handling of file names containing whitespace characters in imap4 server
13 and library. 13 and library.
14 ** frm: Fix coredump on empty From headers 14 ** frm: Fix coredump on empty From headers
15 15
...@@ -82,7 +82,7 @@ Add support for localname and localdomain mtstailor variables. ...@@ -82,7 +82,7 @@ Add support for localname and localdomain mtstailor variables.
82 82
83 New mtstailor variable x-mailer controls whether to add the 'X-Mailer' 83 New mtstailor variable x-mailer controls whether to add the 'X-Mailer'
84 header to the message being sent, if it does not contain one. The 84 header to the message being sent, if it does not contain one. The
85 the value 'yes' means to add the default X-Mailer string, the value 85 value 'yes' means to add the default X-Mailer string, the value
86 'no' means to ignore it. Any other value is taken as the X-Mailer 86 'no' means to ignore it. Any other value is taken as the X-Mailer
87 identifier to be added to the message. 87 identifier to be added to the message.
88 88
...@@ -111,7 +111,7 @@ Version 0.6.91: ...@@ -111,7 +111,7 @@ Version 0.6.91:
111 111
112 * imap4d: Implemented SASL authentication using LOGIN and PLAIN mechanisms. 112 * imap4d: Implemented SASL authentication using LOGIN and PLAIN mechanisms.
113 113
114 * Plaintext passwords for SASL authentication types may be kept in SQL 114 * Plaintext passwords for SASL authentication types can be kept in SQL
115 database. When used with LOGIN or PLAIN, the passwords may be 115 database. When used with LOGIN or PLAIN, the passwords may be
116 encrypted using MySQL password() function. New option 116 encrypted using MySQL password() function. New option
117 --sql-password-type specifies what kind of password is returned by 117 --sql-password-type specifies what kind of password is returned by
......
...@@ -270,11 +270,11 @@ case "${withval}" in ...@@ -270,11 +270,11 @@ case "${withval}" in
270 esac]) 270 esac])
271 271
272 ## Support --with-db2 for backward compatibility 272 ## Support --with-db2 for backward compatibility
273 if test ${with_db2+set} = set; then 273 if test "${with_db2+set}" = set; then
274 case "${with_db2}" in 274 case "${with_db2}" in
275 yes) use_dbm=BDB2 ;; 275 yes) use_dbm=BDB2 ;;
276 no) use_dbm=no ;; 276 no) use_dbm=no ;;
277 *) AC_MSG_ERROR(bad value ${withval} for --with-db2) ;; 277 *) AC_MSG_ERROR(bad value ${with_db2} for --with-db2) ;;
278 esac 278 esac
279 fi 279 fi
280 280
......
1 /* A more useful interface to strtol.
2
3 Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004, 2005
4 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20 /* Written by Jim Meyering. */
21
22 #ifdef HAVE_CONFIG_H
23 # include <config.h>
24 #endif
25
26 #include "xstrtol.h"
27
28 #ifndef __strtol
29 # define __strtol strtol
30 # define __strtol_t long int
31 # define __xstrtol xstrtol
32 # define STRTOL_T_MINIMUM LONG_MIN
33 # define STRTOL_T_MAXIMUM LONG_MAX
34 #endif
35
36 /* Some pre-ANSI implementations (e.g. SunOS 4)
37 need stderr defined if assertion checking is enabled. */
38 #include <stdio.h>
39
40 #include <assert.h>
41 #include <ctype.h>
42 #include <errno.h>
43 #include <limits.h>
44 #include <stdlib.h>
45 #include <string.h>
46
47 #include "intprops.h"
48
49 #ifndef STRTOL_T_MINIMUM
50 # define STRTOL_T_MINIMUM TYPE_MINIMUM (__strtol_t)
51 # define STRTOL_T_MAXIMUM TYPE_MAXIMUM (__strtol_t)
52 #endif
53
54 #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
55 # define IN_CTYPE_DOMAIN(c) 1
56 #else
57 # define IN_CTYPE_DOMAIN(c) isascii(c)
58 #endif
59
60 #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
61
62 #if !HAVE_DECL_STRTOIMAX && !defined strtoimax
63 intmax_t strtoimax ();
64 #endif
65
66 #if !HAVE_DECL_STRTOUMAX && !defined strtoumax
67 uintmax_t strtoumax ();
68 #endif
69
70 static strtol_error
71 bkm_scale (__strtol_t *x, int scale_factor)
72 {
73 if (TYPE_SIGNED (__strtol_t) && *x < STRTOL_T_MINIMUM / scale_factor)
74 {
75 *x = STRTOL_T_MINIMUM;
76 return LONGINT_OVERFLOW;
77 }
78 if (STRTOL_T_MAXIMUM / scale_factor < *x)
79 {
80 *x = STRTOL_T_MAXIMUM;
81 return LONGINT_OVERFLOW;
82 }
83 *x *= scale_factor;
84 return LONGINT_OK;
85 }
86
87 static strtol_error
88 bkm_scale_by_power (__strtol_t *x, int base, int power)
89 {
90 strtol_error err = LONGINT_OK;
91 while (power--)
92 err |= bkm_scale (x, base);
93 return err;
94 }
95
96 /* FIXME: comment. */
97
98 strtol_error
99 __xstrtol (const char *s, char **ptr, int strtol_base,
100 __strtol_t *val, const char *valid_suffixes)
101 {
102 char *t_ptr;
103 char **p;
104 __strtol_t tmp;
105 strtol_error err = LONGINT_OK;
106
107 assert (0 <= strtol_base && strtol_base <= 36);
108
109 p = (ptr ? ptr : &t_ptr);
110
111 if (! TYPE_SIGNED (__strtol_t))
112 {
113 const char *q = s;
114 unsigned char ch = *q;
115 while (ISSPACE (ch))
116 ch = *++q;
117 if (ch == '-')
118 return LONGINT_INVALID;
119 }
120
121 errno = 0;
122 tmp = __strtol (s, p, strtol_base);
123
124 if (*p == s)
125 {
126 /* If there is no number but there is a valid suffix, assume the
127 number is 1. The string is invalid otherwise. */
128 if (valid_suffixes && **p && strchr (valid_suffixes, **p))
129 tmp = 1;
130 else
131 return LONGINT_INVALID;
132 }
133 else if (errno != 0)
134 {
135 if (errno != ERANGE)
136 return LONGINT_INVALID;
137 err = LONGINT_OVERFLOW;
138 }
139
140 /* Let valid_suffixes == NULL mean `allow any suffix'. */
141 /* FIXME: update all callers except the ones that allow suffixes
142 after the number, changing last parameter NULL to `""'. */
143 if (!valid_suffixes)
144 {
145 *val = tmp;
146 return err;
147 }
148
149 if (**p != '\0')
150 {
151 int base = 1024;
152 int suffixes = 1;
153 strtol_error overflow;
154
155 if (!strchr (valid_suffixes, **p))
156 {
157 *val = tmp;
158 return err | LONGINT_INVALID_SUFFIX_CHAR;
159 }
160
161 if (strchr (valid_suffixes, '0'))
162 {
163 /* The ``valid suffix'' '0' is a special flag meaning that
164 an optional second suffix is allowed, which can change
165 the base. A suffix "B" (e.g. "100MB") stands for a power
166 of 1000, whereas a suffix "iB" (e.g. "100MiB") stands for
167 a power of 1024. If no suffix (e.g. "100M"), assume
168 power-of-1024. */
169
170 switch (p[0][1])
171 {
172 case 'i':
173 if (p[0][2] == 'B')
174 suffixes += 2;
175 break;
176
177 case 'B':
178 case 'D': /* 'D' is obsolescent */
179 base = 1000;
180 suffixes++;
181 break;
182 }
183 }
184
185 switch (**p)
186 {
187 case 'b':
188 overflow = bkm_scale (&tmp, 512);
189 break;
190
191 case 'B':
192 overflow = bkm_scale (&tmp, 1024);
193 break;
194
195 case 'c':
196 overflow = 0;
197 break;
198
199 case 'E': /* exa or exbi */
200 overflow = bkm_scale_by_power (&tmp, base, 6);
201 break;
202
203 case 'G': /* giga or gibi */
204 case 'g': /* 'g' is undocumented; for compatibility only */
205 overflow = bkm_scale_by_power (&tmp, base, 3);
206 break;
207
208 case 'k': /* kilo */
209 case 'K': /* kibi */
210 overflow = bkm_scale_by_power (&tmp, base, 1);
211 break;
212
213 case 'M': /* mega or mebi */
214 case 'm': /* 'm' is undocumented; for compatibility only */
215 overflow = bkm_scale_by_power (&tmp, base, 2);
216 break;
217
218 case 'P': /* peta or pebi */
219 overflow = bkm_scale_by_power (&tmp, base, 5);
220 break;
221
222 case 'T': /* tera or tebi */
223 case 't': /* 't' is undocumented; for compatibility only */
224 overflow = bkm_scale_by_power (&tmp, base, 4);
225 break;
226
227 case 'w':
228 overflow = bkm_scale (&tmp, 2);
229 break;
230
231 case 'Y': /* yotta or 2**80 */
232 overflow = bkm_scale_by_power (&tmp, base, 8);
233 break;
234
235 case 'Z': /* zetta or 2**70 */
236 overflow = bkm_scale_by_power (&tmp, base, 7);
237 break;
238
239 default:
240 *val = tmp;
241 return err | LONGINT_INVALID_SUFFIX_CHAR;
242 }
243
244 err |= overflow;
245 *p += suffixes;
246 if (**p)
247 err |= LONGINT_INVALID_SUFFIX_CHAR;
248 }
249
250 *val = tmp;
251 return err;
252 }
253
254 #ifdef TESTING_XSTRTO
255
256 # include <stdio.h>
257 # include "error.h"
258
259 char *program_name;
260
261 int
262 main (int argc, char **argv)
263 {
264 strtol_error s_err;
265 int i;
266
267 program_name = argv[0];
268 for (i=1; i<argc; i++)
269 {
270 char *p;
271 __strtol_t val;
272
273 s_err = __xstrtol (argv[i], &p, 0, &val, "bckmw");
274 if (s_err == LONGINT_OK)
275 {
276 printf ("%s->%lu (%s)\n", argv[i], val, p);
277 }
278 else
279 {
280 STRTOL_FATAL_ERROR (argv[i], "arg", s_err);
281 }
282 }
283 exit (0);
284 }
285
286 #endif /* TESTING_XSTRTO */
1 /* A more useful interface to strtol.
2
3 Copyright (C) 1995, 1996, 1998, 1999, 2001, 2002, 2003, 2004 Free
4 Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20 #ifndef XSTRTOL_H_
21 # define XSTRTOL_H_ 1
22
23 # include "exitfail.h"
24
25 # if HAVE_INTTYPES_H
26 # include <inttypes.h>
27 # endif
28 # if HAVE_STDINT_H
29 # include <stdint.h>
30 # endif
31
32 # ifndef _STRTOL_ERROR
33 enum strtol_error
34 {
35 LONGINT_OK = 0,
36
37 /* These two values can be ORed together, to indicate that both
38 errors occurred. */
39 LONGINT_OVERFLOW = 1,
40 LONGINT_INVALID_SUFFIX_CHAR = 2,
41
42 LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW = (LONGINT_INVALID_SUFFIX_CHAR
43 | LONGINT_OVERFLOW),
44 LONGINT_INVALID = 4
45 };
46 typedef enum strtol_error strtol_error;
47 # endif
48
49 # define _DECLARE_XSTRTOL(name, type) \
50 strtol_error name (const char *, char **, int, type *, const char *);
51 _DECLARE_XSTRTOL (xstrtol, long int)
52 _DECLARE_XSTRTOL (xstrtoul, unsigned long int)
53 _DECLARE_XSTRTOL (xstrtoimax, intmax_t)
54 _DECLARE_XSTRTOL (xstrtoumax, uintmax_t)
55
56 # define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \
57 do \
58 { \
59 switch ((Err)) \
60 { \
61 default: \
62 abort (); \
63 \
64 case LONGINT_INVALID: \
65 error ((Exit_code), 0, "invalid %s `%s'", \
66 (Argument_type_string), (Str)); \
67 break; \
68 \
69 case LONGINT_INVALID_SUFFIX_CHAR: \
70 case LONGINT_INVALID_SUFFIX_CHAR | LONGINT_OVERFLOW: \
71 error ((Exit_code), 0, "invalid character following %s in `%s'", \
72 (Argument_type_string), (Str)); \
73 break; \
74 \
75 case LONGINT_OVERFLOW: \
76 error ((Exit_code), 0, "%s `%s' too large", \
77 (Argument_type_string), (Str)); \
78 break; \
79 } \
80 } \
81 while (0)
82
83 # define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err) \
84 _STRTOL_ERROR (exit_failure, Str, Argument_type_string, Err)
85
86 # define STRTOL_FAIL_WARN(Str, Argument_type_string, Err) \
87 _STRTOL_ERROR (0, Str, Argument_type_string, Err)
88
89 #endif /* not XSTRTOL_H_ */
1 #define __strtol strtoul
2 #define __strtol_t unsigned long int
3 #define __xstrtol xstrtoul
4 #define STRTOL_T_MINIMUM 0
5 #define STRTOL_T_MAXIMUM ULONG_MAX
6 #include "xstrtol.c"
1 #serial 7
2 dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_XSTRTOL],
8 [
9 AC_LIBSOURCES([xstrtol.c, xstrtol.h, xstrtoul.c, intprops.h])
10 AC_LIBOBJ([xstrtol])
11 AC_LIBOBJ([xstrtoul])
12
13 AC_REQUIRE([gl_PREREQ_XSTRTOL])
14 AC_REQUIRE([gl_PREREQ_XSTRTOUL])
15 ])
16
17 # Prerequisites of lib/xstrtol.h.
18 AC_DEFUN([gl_PREREQ_XSTRTOL_H],
19 [
20 AC_REQUIRE([gl_AC_TYPE_INTMAX_T])
21 AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])
22 ])
23
24 # Prerequisites of lib/xstrtol.c.
25 AC_DEFUN([gl_PREREQ_XSTRTOL],
26 [
27 AC_REQUIRE([gl_PREREQ_XSTRTOL_H])
28 AC_REQUIRE([AC_HEADER_STDC])
29 AC_CHECK_FUNCS_ONCE(isascii)
30 AC_CHECK_DECLS([strtoimax, strtoumax])
31 ])
32
33 # Prerequisites of lib/xstrtoul.c.
34 AC_DEFUN([gl_PREREQ_XSTRTOUL],
35 [
36 AC_REQUIRE([gl_PREREQ_XSTRTOL])
37 ])