From 3f314aee5476605d2aec5f42911d23b7726e2ecd Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 14 Aug 2008 12:11:25 +0200 Subject: [PATCH] =?UTF-8?q?Bug=20438688=20=E2=80=93=20String=20formatter?= =?UTF-8?q?=20fails=20to=20format=20the=20same=20argument=20twice.=20r=3Db?= =?UTF-8?q?smedberg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xpcom/glue/nsTextFormatter.cpp | 2 +- xpcom/tests/TestTextFormatter.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/xpcom/glue/nsTextFormatter.cpp b/xpcom/glue/nsTextFormatter.cpp index 0e1aa94b41d8..923b1c40fed2 100644 --- a/xpcom/glue/nsTextFormatter.cpp +++ b/xpcom/glue/nsTextFormatter.cpp @@ -920,7 +920,7 @@ static int dosprintf(SprintfState *ss, const PRUnichar *fmt, va_list ap) return -1; } - ap = nas[i-1].ap; + VARARGS_ASSIGN(ap, nas[i-1].ap); dolPt = fmt; c = *fmt++; } diff --git a/xpcom/tests/TestTextFormatter.cpp b/xpcom/tests/TestTextFormatter.cpp index 1d29be7402f6..2477be7facb6 100644 --- a/xpcom/tests/TestTextFormatter.cpp +++ b/xpcom/tests/TestTextFormatter.cpp @@ -44,7 +44,7 @@ int main() { int test_ok = true; - nsAutoString fmt(NS_LITERAL_STRING("%3$s %4$S %1$d %2$d")); + nsAutoString fmt(NS_LITERAL_STRING("%3$s %4$S %1$d %2$d %2$d %3$s")); char utf8[] = "Hello"; PRUnichar ucs2[]={'W', 'o', 'r', 'l', 'd', 0x4e00, 0xAc00, 0xFF45, 0x0103, 0x00}; int d=3; @@ -59,7 +59,9 @@ int main() const PRUnichar expected[] = {0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x4E00, 0xAC00, 0xFF45, 0x0103, 0x20, 0x33, - 0x20, 0x33, 0x33, 0x33}; + 0x20, 0x33, 0x33, 0x33, 0x20, 0x33, + 0x33, 0x33, 0x20, 0x48, 0x65, 0x6C, + 0x6C, 0x6F}; for(PRUint32 i=0;i