dovecot-1.1: Added more fallbacks if strtoll() or strtoull() isn...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jun 13 00:36:29 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/f7989d01fa3c
changeset: 7647:f7989d01fa3c
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jun 12 23:31:51 2008 +0300
description:
Added more fallbacks if strtoll() or strtoull() isn't implemented
(e.g. HP-UX).

diffstat:

3 files changed, 27 insertions(+), 5 deletions(-)
configure.in     |    8 ++++----
src/lib/compat.c |   20 +++++++++++++++++++-
src/lib/compat.h |    4 ++++

diffs (80 lines):

diff -r bbae551fd110 -r f7989d01fa3c configure.in
--- a/configure.in	Thu Jun 12 23:16:46 2008 +0300
+++ b/configure.in	Thu Jun 12 23:31:51 2008 +0300
@@ -15,7 +15,7 @@ AC_PROG_LIBTOOL
 AC_PROG_LIBTOOL
 AM_ICONV
 
-AC_CHECK_HEADERS(strings.h stdint.h unistd.h dirent.h malloc.h \
+AC_CHECK_HEADERS(strings.h stdint.h unistd.h dirent.h malloc.h inttypes.h \
   sys/uio.h sys/sysmacros.h sys/resource.h sys/select.h libgen.h \
   sys/quota.h sys/fs/ufs_quota.h ufs/ufs/quota.h jfs/quota.h \
   mntent.h sys/mnttab.h sys/event.h sys/time.h sys/mkdev.h linux/dqblk_xfs.h \
@@ -429,9 +429,9 @@ AC_CHECK_FUNCS(fcntl flock lockf inet_at
 AC_CHECK_FUNCS(fcntl flock lockf inet_aton sigaction getpagesize madvise \
                strcasecmp stricmp vsyslog writev pread \
 	       setrlimit setproctitle seteuid setreuid setegid setresgid \
-	       strtoull strtouq setpriority quotactl getmntent kqueue kevent \
-	       backtrace_symbols walkcontext dirfd clearenv \
-	       malloc_usable_size)
+	       strtoull strtoll strtoumax strtoimax strtouq strtoq \
+	       setpriority quotactl getmntent kqueue kevent backtrace_symbols \
+	       walkcontext dirfd clearenv malloc_usable_size)
 
 dnl * I/O loop function
 have_ioloop=no
diff -r bbae551fd110 -r f7989d01fa3c src/lib/compat.c
--- a/src/lib/compat.c	Thu Jun 12 23:16:46 2008 +0300
+++ b/src/lib/compat.c	Thu Jun 12 23:31:51 2008 +0300
@@ -17,6 +17,9 @@
 #include <ctype.h>
 #include <unistd.h>
 #include <syslog.h>
+#ifdef HAVE_INTTYPES_H
+#  include <inttypes.h> /* for strtoimax() and strtoumax() */
+#endif
 
 #ifndef INADDR_NONE
 #  define INADDR_NONE INADDR_BROADCAST
@@ -201,7 +204,9 @@ char *my_basename(char *path)
 #ifndef HAVE_STRTOULL
 unsigned long long int my_strtoull(const char *nptr, char **endptr, int base)
 {
-#ifdef HAVE_STRTOUQ
+#ifdef HAVE_STRTOUMAX
+	return strtoumax(nptr, endptr, base);
+#elif defined(HAVE_STRTOUQ)
 	return strtouq(nptr, endptr, base);
 #else
 	unsigned long ret = 0;
@@ -220,3 +225,16 @@ unsigned long long int my_strtoull(const
 #endif
 }
 #endif
+
+#ifndef HAVE_STRTOLL
+unsigned long long int my_strtoll(const char *nptr, char **endptr, int base)
+{
+#ifdef HAVE_STRTOIMAX 
+	return strtoimax(nptr, endptr, base);
+#elif defined (HAVE_STRTOQ)
+	return strtoq(nptr, endptr, base);
+#else
+	i_panic("strtoll() not implemented");
+#endif
+}
+#endif
diff -r bbae551fd110 -r f7989d01fa3c src/lib/compat.h
--- a/src/lib/compat.h	Thu Jun 12 23:16:46 2008 +0300
+++ b/src/lib/compat.h	Thu Jun 12 23:31:51 2008 +0300
@@ -187,6 +187,10 @@ char *my_basename(char *path);
 #ifndef HAVE_STRTOULL
 #  define strtoull my_strtoull
 unsigned long long int my_strtoull(const char *nptr, char **endptr, int base);
+#endif
+#ifndef HAVE_STRTOLL
+#  define strtoll my_strtoll
+unsigned long long int my_strtoll(const char *nptr, char **endptr, int base);
 #endif
 
 /* ctype.h isn't safe with signed chars,


More information about the dovecot-cvs mailing list