stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r384034 - in /incubator/stdcxx/trunk/tests: self/0.printf.cpp src/printf.cpp
Date Tue, 07 Mar 2006 22:14:05 GMT
Author: sebor
Date: Tue Mar  7 14:14:01 2006
New Revision: 384034

URL: http://svn.apache.org/viewcvs?rev=384034&view=rev
Log:
2006-03-07  Martin Sebor  <sebor@roguewave.com>

	* printf.cpp (_rw_vasnprintf_ext): Handled width in %{s} and %{ls}.
	* snprintfa.cpp (test_string): Exercised the above.

Modified:
    incubator/stdcxx/trunk/tests/self/0.printf.cpp
    incubator/stdcxx/trunk/tests/src/printf.cpp

Modified: incubator/stdcxx/trunk/tests/self/0.printf.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/self/0.printf.cpp?rev=384034&r1=384033&r2=384034&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/self/0.printf.cpp (original)
+++ incubator/stdcxx/trunk/tests/self/0.printf.cpp Tue Mar  7 14:14:01 2006
@@ -354,6 +354,7 @@
     printf ("%s\n", "extension: \"%{#s}\": quoted character string");
 
     TEST ("%{#s}", "",     0, 0, "\"\"");
+    TEST ("%{#s}", "\0",   0, 0, "\"\"");
     TEST ("%{#s}", "\1",   0, 0, "\"\\x01\"");
     TEST ("%{#s}", "\a",   0, 0, "\"\\a\"");
     TEST ("%{#s}", "\n",   0, 0, "\"\\n\"");
@@ -366,6 +367,22 @@
     TEST ("%{#s}", "a\ac", 0, 0, "\"a\\ac\"");
     TEST ("%{#s}", "a\"c", 0, 0, "\"a\\\"c\"");
 
+    // embedded NULs
+    TEST ("%{#1s}", "\0",     0, 0, "\"\\0\"");
+    TEST ("%{#2s}", "\0",     0, 0, "\"\\0\\0\"");
+    TEST ("%{#2s}", "a\0",    0, 0, "\"a\\0\"");
+    TEST ("%{#2s}", "\0a",    0, 0, "\"\\0a\"");
+    TEST ("%{#3s}", "\0\0\0", 0, 0, "\"\\0\\0\\0\"");
+    TEST ("%{#3s}", "\0a\0",  0, 0, "\"\\0a\\0\"");
+    TEST ("%{#3s}", "\0\0a",  0, 0, "\"\\0\\0a\"");
+
+    TEST ("%{#*s}", 0, "\0\0\0v", 0, "\"\"");
+    TEST ("%{#*s}", 1, "\0\0\0w", 0, "\"\\0\"");
+    TEST ("%{#*s}", 2, "\0\0\0x", 0, "\"\\0\\0\"");
+    TEST ("%{#*s}", 3, "\0\0\0y", 0, "\"\\0\\0\\0\"");
+    TEST ("%{#*s}", 4, "\0\0\0z", 0, "\"\\0\\0\\0z\"");
+    TEST ("%{#*s}", 5, "\0\0\0z", 0, "\"\\0\\0\\0z\\0\"");
+
     //////////////////////////////////////////////////////////////////
     printf ("%s\n", "extension: \"%{#ls}\": quoted wide character string");
 
@@ -382,6 +399,22 @@
     TEST ("%{#ls}", L"a\ac",  0, 0, "\"a\\ac\"");
     TEST ("%{#ls}", L"a\"c",  0, 0, "\"a\\\"c\"");
     TEST ("%{#ls}", L"\x100", 0, 0, "\"\\x100\"");
+
+    // embedded NULs
+    TEST ("%{#1ls}", L"\0",     0, 0, "\"\\0\"");
+    TEST ("%{#2ls}", L"\0",     0, 0, "\"\\0\\0\"");
+    TEST ("%{#2ls}", L"a\0",    0, 0, "\"a\\0\"");
+    TEST ("%{#2ls}", L"\0a",    0, 0, "\"\\0a\"");
+    TEST ("%{#3ls}", L"\0\0\0", 0, 0, "\"\\0\\0\\0\"");
+    TEST ("%{#3ls}", L"\0a\0",  0, 0, "\"\\0a\\0\"");
+    TEST ("%{#3ls}", L"\0\0a",  0, 0, "\"\\0\\0a\"");
+
+    TEST ("%{#*ls}", 0, L"\0\0\0v", 0, "\"\"");
+    TEST ("%{#*ls}", 1, L"\0\0\0w", 0, "\"\\0\"");
+    TEST ("%{#*ls}", 2, L"\0\0\0x", 0, "\"\\0\\0\"");
+    TEST ("%{#*ls}", 3, L"\0\0\0y", 0, "\"\\0\\0\\0\"");
+    TEST ("%{#*ls}", 4, L"\0\0\0z", 0, "\"\\0\\0\\0z\"");
+    TEST ("%{#*ls}", 5, L"\0\0\0z", 0, "\"\\0\\0\\0z\\0\"");
 }
 
 /***********************************************************************/

Modified: incubator/stdcxx/trunk/tests/src/printf.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/printf.cpp?rev=384034&r1=384033&r2=384034&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/printf.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/printf.cpp Tue Mar  7 14:14:01 2006
@@ -3896,14 +3896,16 @@
         else if (spec.mod == spec.mod_l) {   // wchar_t*
             spec.param.ptr_ = PARAM (ptr_);
             const wchar_t* const wstr = (wchar_t*)spec.param.ptr_;
-            len = rw_fmtarray (spec, buf, wstr, _RWSTD_SIZE_MAX,
-                               A_WCHAR | A_ESC);
+            const size_t wstr_len =
+                spec.width < 0 ? _RWSTD_SIZE_MAX : size_t (spec.width);
+            len = rw_fmtarray (spec, buf, wstr, wstr_len, A_WCHAR | A_ESC);
         }
         else {   // char*
             spec.param.ptr_ = PARAM (ptr_);
             const char* const str = (char*)spec.param.ptr_;
-            len = rw_fmtarray (spec, buf, str, _RWSTD_SIZE_MAX,
-                               A_CHAR | A_ESC);
+            const size_t str_len =
+                spec.width < 0 ? _RWSTD_SIZE_MAX : size_t (spec.width);
+            len = rw_fmtarray (spec, buf, str, str_len, A_CHAR | A_ESC);
         }
         break;
 



Mime
View raw message