<<< Date Index >>>     <<< Thread Index >>>

Re: sscanf (x, "%u", &(uint64_t))



On Sun, Mar 20, 2005 at 02:43:45PM +0100, Thomas Glanzmann wrote:
> > I misread the documenation. UIDVALIDITY is 32bit not 64bit. I will send
> > a patch shortly.
> 
> here is the patch. Some people should test it before it is reported
> upstream. For me it works.

Thank you.

I have only 32bit machines, so, uint32_t is unsigned int.
Now there is no problem for _me_.

But, wouldn't some environment need this attached patch?
I'm afraid "%u" is not for uint32_t on some systems.

-- 
tamo
Index: m4/types.m4
===================================================================
RCS file: /home/roessler/cvs/mutt/m4/types.m4,v
retrieving revision 1.1
diff -u -r1.1 types.m4
--- m4/types.m4 31 Jan 2005 02:40:14 -0000      1.1
+++ m4/types.m4 21 Mar 2005 00:54:49 -0000
@@ -19,17 +19,35 @@
   [#ifndef HAVE_C99_INTTYPES
 #  if SIZEOF_SHORT == 4
 typedef unsigned short uint32_t;
+#    ifndef SCNu32
+#      define SCNu32 "hu"
+#    endif
 #  elif SIZEOF_INT == 4
 typedef unsigned int uint32_t;
+#    ifndef SCNu32
+#      define SCNu32 "u"
+#    endif
 #  elif SIZEOF_LONG == 4
 typedef unsigned long uint32_t;
+#    ifndef SCNu32
+#      define SCNu32 "lu"
+#    endif
 #  endif
 #  if SIZEOF_INT == 8
 typedef unsigned int uint64_t;
+#    ifndef SCNu64
+#      define SCNu64 "u"
+#    endif
 #  elif SIZEOF_LONG == 8
 typedef unsigned long uint64_t;
+#    ifndef SCNu64
+#      define SCNu64 "lu"
+#    endif
 #  elif SIZEOF_LONG_LONG == 8
 typedef unsigned long long uint64_t;
+#    ifndef SCNu64
+#      define SCNu64 "llu"
+#    endif
 #  endif
 #endif
   ])
Index: imap/imap.c
===================================================================
RCS file: /home/roessler/cvs/mutt/imap/imap.c,v
retrieving revision 3.21
diff -u -r3.21 imap.c
--- imap/imap.c 17 Feb 2005 03:33:00 -0000      3.21
+++ imap/imap.c 21 Mar 2005 00:59:47 -0000
@@ -635,7 +635,8 @@
       dprint(2, (debugfile, "Getting mailbox UIDVALIDITY\n"));
       pc += 3;
       pc = imap_next_word(pc);
-      sscanf(pc, "%u", &(idata->uid_validity));
+      if (sscanf (pc, "%" SCNu32, &(idata->uid_validity)) != 1)
+       goto fail;
     }
 #endif
     else