summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@webkeks.org>2011-06-30 22:50:40 +0200
committerJonathan Schleifer <js@webkeks.org>2011-06-30 22:50:40 +0200
commit40baf42024d5a903a758b3b7ec903348afa6fd06 (patch)
treea7d2a174eaa321f70e6974e78337e33c28e2243f
parent3f5f1f604fd43bff1cb86075b1f0271769d5dffc (diff)
of_asprintf: Work around Win32 breaking C99 standard length modifiers.
-rw-r--r--src/of_asprintf.m24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/of_asprintf.m b/src/of_asprintf.m
index dc788044..58b49894 100644
--- a/src/of_asprintf.m
+++ b/src/of_asprintf.m
@@ -169,8 +169,13 @@ state_format_length_modifier(struct context *ctx)
break;
case 'l': /* and also ll */
if (ctx->fmt_len > ctx->i + 1 && ctx->fmt[ctx->i + 1] == 'l') {
+#ifndef _WIN32
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 2))
return false;
+#else
+ if (!append_subfmt(ctx, "I64", 3))
+ return false;
+#endif
ctx->i++;
ctx->len_mod = LENGTH_MODIFIER_LL;
@@ -183,8 +188,13 @@ state_format_length_modifier(struct context *ctx)
break;
case 'j':
+#ifndef _WIN32
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
return false;
+#else
+ if (!append_subfmt(ctx, "I64", 3))
+ return false;
+#endif
ctx->len_mod = LENGTH_MODIFIER_J;
@@ -210,6 +220,20 @@ state_format_length_modifier(struct context *ctx)
ctx->len_mod = LENGTH_MODIFIER_CAPITAL_L;
break;
+#ifdef _WIN32
+ case 'I': /* win32 strangeness (I64 instead of ll or j) */
+ if (ctx->fmt_len > ctx->i + 2 && ctx->fmt[ctx->i + 1] == '6' &&
+ ctx->fmt[ctx->i + 2] == '4') {
+ if (!append_subfmt(ctx, ctx->fmt + ctx->i, 3))
+ return false;
+
+ ctx->i += 2;
+ ctx->len_mod = LENGTH_MODIFIER_LL;
+ } else
+ ctx->i--;
+
+ break;
+#endif
default:
ctx->i--;