[PATCH] 2.3 %qu vs. %llu on *BSD
John Capo
jc at irbs.com
Fri Sep 17 21:30:20 EDT 2004
FreeBSD 4.X printf() and friends support the %llu format. scanf()
and friends do not. I suspect this is true of most BSD-4.4 derived
systems. I don't know what ANSI says about this issue.
One way to fix it is attached. My autoconf foo is lacking so I
just jammed a #define into configure.in where O_DSYNC is defined
for BSD systems. I doubt this will work in all cases.
John Capo
-------------- next part --------------
Index: imap/quota.h
===================================================================
RCS file: /cvs/src/cyrus/imap/quota.h,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 quota.h
--- imap/quota.h 9 Aug 2004 18:51:21 -0000 1.1.2.3
+++ imap/quota.h 18 Sep 2004 00:36:46 -0000
@@ -60,7 +60,12 @@
typedef long long int quota_t;
#define UQUOTA_T_FMT "%llu"
#define QUOTA_T_FMT "%lld"
-#define QUOTA_REPORT_FMT "%8llu"
+# ifdef HAVE_QUAD_SCAN_FMT
+# define UQUOTA_T_SCAN_FMT "%qu"
+# else
+# define UQUOTA_T_SCAN_FMT "%llu"
+# endif
+#define QUOTA_REPORT_FMT "%8lu"
#else
typedef unsigned long uquota_t;
typedef long quota_t;
Index: imap/quota_db.c
===================================================================
RCS file: /cvs/src/cyrus/imap/quota_db.c,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 quota_db.c
--- imap/quota_db.c 9 Aug 2004 18:51:21 -0000 1.1.2.3
+++ imap/quota_db.c 18 Sep 2004 00:36:46 -0000
@@ -89,7 +89,7 @@
switch (r) {
case CYRUSDB_OK:
- sscanf(data, UQUOTA_T_FMT " %d", "a->used, "a->limit);
+ sscanf(data, UQUOTA_T_SCAN_FMT " %d", "a->used, "a->limit);
break;
case CYRUSDB_AGAIN:
Index: imap/quota.c
===================================================================
RCS file: /cvs/src/cyrus/imap/quota.c,v
retrieving revision 1.48.2.7
diff -u -r1.48.2.7 quota.c
--- imap/quota.c 9 Aug 2004 18:51:20 -0000 1.48.2.7
+++ imap/quota.c 18 Sep 2004 00:36:46 -0000
@@ -251,7 +251,7 @@
}
memset("a[quota_num], 0, sizeof(struct quotaentry));
quota[quota_num].quota.root = xstrndup(key, keylen);
- sscanf(data, UQUOTA_T_FMT " %d",
+ sscanf(data, UQUOTA_T_SCAN_FMT " %d",
"a[quota_num].quota.used, "a[quota_num].quota.limit);
quota_num++;
Index: configure.in
===================================================================
RCS file: /cvs/src/cyrus/configure.in,v
retrieving revision 1.268.2.15
diff -u -r1.268.2.15 configure.in
--- configure.in 13 Sep 2004 19:59:19 -0000 1.268.2.15
+++ configure.in 18 Sep 2004 01:14:04 -0000
@@ -1079,6 +1079,7 @@
# define O_DSYNC O_SYNC /* POSIX */
# else
# define O_DSYNC O_FSYNC /* BSD */
+# define HAVE_QUAD_SCAN_FMT
# endif
#endif
More information about the Info-cyrus
mailing list