[vlc-devel] commit: Win64: properly work around %z modifiers (Pierre Ynard )
git version control
git at videolan.org
Tue Mar 10 17:06:55 CET 2009
vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Mon Mar 9 12:18:14 2009 +0100| [0cca872b95aff09b9c12d0b871fd4a56d422a6d1] | committer: Rémi Denis-Courmont
Win64: properly work around %z modifiers
size_t are 64-bit long on Win64, adapt the wrapper for it
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0cca872b95aff09b9c12d0b871fd4a56d422a6d1
---
include/vlc_fixups.h | 35 +++++++++++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index f685806..e6906e9 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -42,9 +42,40 @@ static inline char *strdup (const char *str)
/* Windows' printf doesn't support %z modifiers, thus we need to rewrite
* the format string in a wrapper. */
# include <string.h>
+# include <stdlib.h>
static inline char *vlc_fix_format_string (const char *format)
{
- char *fmt, *f;
+ char *fmt;
+# ifdef WIN64
+ const char *src = format, *tmp;
+ char *dst;
+ size_t n = 0;
+ while ((tmp = strstr (src, "%z")) != NULL)
+ {
+ n++;
+ src = tmp + 2;
+ }
+ if (n == 0)
+ return NULL;
+
+ fmt = (char*)malloc (strlen (format) + n + 1);
+ if (fmt == NULL)
+ return NULL;
+
+ src = format;
+ dst = fmt;
+ while ((tmp = strstr (src, "%z")) != NULL)
+ {
+ size_t d = tmp - src;
+ memcpy (dst, src, d);
+ dst += d;
+ memcpy (dst, "%ll", 3);
+ dst += 3;
+ src = tmp + 2;
+ }
+ strcpy (dst, src);
+# else
+ char *f;
if (strstr (format, "%z") == NULL)
return NULL;
@@ -56,10 +87,10 @@ static inline char *vlc_fix_format_string (const char *format)
{
f[1] = 'l';
}
+# endif
return fmt;
}
-# include <stdlib.h>
# include <stdio.h>
# include <stdarg.h>
More information about the vlc-devel
mailing list