[dovecot-cvs] dovecot/src/lib compat.c, 1.20, 1.21 compat.h, 1.26,
1.27
cras at dovecot.org
cras at dovecot.org
Mon Dec 20 06:39:52 EET 2004
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv22699/src/lib
Modified Files:
compat.c compat.h
Log Message:
If strtoull() isn't supported, fallback to strtouq(). If that's not found
either, use our own implementation.
Index: compat.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/compat.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- compat.c 8 Nov 2004 02:45:59 -0000 1.20
+++ compat.c 20 Dec 2004 04:39:50 -0000 1.21
@@ -11,6 +11,7 @@
#include "lib.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <syslog.h>
@@ -184,3 +185,26 @@
return p == NULL ? path : p + 1;
}
#endif
+
+#ifndef HAVE_STRTOULL
+unsigned long long int my_strtoull(const char *nptr, char **endptr, int base)
+{
+#ifdef HAVE_STRTOUQ
+ return strtouq(nptr, endptr, base);
+#else
+ unsigned long ret = 0;
+
+ /* we support only base-10 in our fallback implementation.. */
+ i_assert(base == 10);
+
+ for (; *nptr != '\0'; nptr++) {
+ if (*nptr < '0' || *nptr > '9')
+ break;
+ ret = ret * 10 + (*nptr - '0');
+ }
+ if (endptr != NULL)
+ *endptr = (char *)nptr;
+ return ret;
+#endif
+}
+#endif
Index: compat.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/compat.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- compat.h 8 Nov 2004 02:45:59 -0000 1.26
+++ compat.h 20 Dec 2004 04:39:50 -0000 1.27
@@ -118,6 +118,11 @@
char *my_basename(char *path);
#endif
+#ifndef HAVE_STRTOULL
+# define strtoull my_strtoull
+unsigned long long int my_strtoull(const char *nptr, char **endptr, int base);
+#endif
+
/* ctype.h isn't safe with signed chars,
use our own instead if really needed */
#define i_toupper(x) ((char) toupper((int) (unsigned char) (x)))
More information about the dovecot-cvs
mailing list