You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2006/07/06 03:32:18 UTC

svn commit: r419404 - in /incubator/stdcxx/trunk/tests: self/0.printf.cpp src/fmt_bits.cpp src/fmt_defs.h src/printf.cpp

Author: sebor
Date: Wed Jul  5 18:32:18 2006
New Revision: 419404

URL: http://svn.apache.org/viewvc?rev=419404&view=rev
Log:
2006-07-05  Martin Sebor  <se...@roguewave.com>

	* fmt_defs.h (_rw_fmtmask): Renamed to _rw_fmtcharmask and added
	a new function with the same name to format ctype_base::mask values.
	* fmt_bits.cpp (_rw_fmtmask): Same.
	* src/printf.cpp (_rw_vasnprintf_ext): Handled the new %{C} and
	%{LC} directives to format the ctype mask of a character argument
	and a ctype_base::mask value, respectively.
	* test/printf.cpp (test_ctype_mask): Exercised the %{LC} directive.
	(main): Called test_ctype_mask.

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

Modified: incubator/stdcxx/trunk/tests/self/0.printf.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/self/0.printf.cpp?rev=419404&r1=419403&r2=419404&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/self/0.printf.cpp (original)
+++ incubator/stdcxx/trunk/tests/self/0.printf.cpp Wed Jul  5 18:32:18 2006
@@ -770,6 +770,57 @@
 
 /***********************************************************************/
 
+static void
+test_ctype_mask ()
+{
+    //////////////////////////////////////////////////////////////////
+    printf ("%s\n", "extension: \"%{LC}\": std::ctype_base::mask");
+
+    const int Alpha  = std::ctype_base::alpha;
+    const int Alnum  = std::ctype_base::alnum;
+    const int Cntrl  = std::ctype_base::cntrl;
+    const int Digit  = std::ctype_base::digit;
+    const int Graph  = std::ctype_base::graph;
+    const int Lower  = std::ctype_base::lower;
+    const int Print  = std::ctype_base::print;
+    const int Punct  = std::ctype_base::punct;
+    const int Space  = std::ctype_base::space;
+    const int Xdigit = std::ctype_base::xdigit;
+
+    TEST ("[%{LC}]", Alpha,  0, 0, "[alpha]");
+    TEST ("[%{LC}]", Alnum,  0, 0, "[alnum]");
+    TEST ("[%{LC}]", Cntrl,  0, 0, "[cntrl]");
+    TEST ("[%{LC}]", Digit,  0, 0, "[digit]");
+    TEST ("[%{LC}]", Graph,  0, 0, "[graph]");
+    TEST ("[%{LC}]", Lower,  0, 0, "[lower]");
+    TEST ("[%{LC}]", Print,  0, 0, "[print]");
+    TEST ("[%{LC}]", Punct,  0, 0, "[punct]");
+    TEST ("[%{LC}]", Space,  0, 0, "[space]");
+    TEST ("[%{LC}]", Xdigit, 0, 0, "[xdigit]");
+
+    TEST ("[%{#LC}]", Alpha,  0, 0, "[std::ctype_base::alpha]");
+    TEST ("[%{#LC}]", Alnum,  0, 0, "[std::ctype_base::alnum]");
+    TEST ("[%{#LC}]", Cntrl,  0, 0, "[std::ctype_base::cntrl]");
+    TEST ("[%{#LC}]", Digit,  0, 0, "[std::ctype_base::digit]");
+    TEST ("[%{#LC}]", Graph,  0, 0, "[std::ctype_base::graph]");
+    TEST ("[%{#LC}]", Lower,  0, 0, "[std::ctype_base::lower]");
+    TEST ("[%{#LC}]", Print,  0, 0, "[std::ctype_base::print]");
+    TEST ("[%{#LC}]", Punct,  0, 0, "[std::ctype_base::punct]");
+    TEST ("[%{#LC}]", Space,  0, 0, "[std::ctype_base::space]");
+    TEST ("[%{#LC}]", Xdigit, 0, 0, "[std::ctype_base::xdigit]");
+
+    TEST ("[%{LC}]", Alpha | Cntrl, 0, 0, "[alpha | cntrl]");
+    TEST ("[%{LC}]", Cntrl | Digit, 0, 0, "[cntrl | digit]");
+    TEST ("[%{LC}]", Digit | Graph, 0, 0, "[digit | graph]");
+    TEST ("[%{LC}]", Graph | Lower, 0, 0, "[graph | lower]");
+    TEST ("[%{LC}]", Lower | Print, 0, 0, "[lower | print]");
+    TEST ("[%{LC}]", Print | Punct, 0, 0, "[print | punct]");
+    TEST ("[%{LC}]", Punct | Space, 0, 0, "[punct | space]");
+}
+
+/***********************************************************************/
+
+
 static const char*
 mkbitset (const char *str)
 {
@@ -2675,6 +2726,8 @@
     test_basic_string ();
 
     test_ios_bitmasks ();
+
+    test_ctype_mask ();
 
     test_bitset ();
 

Modified: incubator/stdcxx/trunk/tests/src/fmt_bits.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/fmt_bits.cpp?rev=419404&r1=419403&r2=419404&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/fmt_bits.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/fmt_bits.cpp Wed Jul  5 18:32:18 2006
@@ -1004,7 +1004,31 @@
 /********************************************************************/
 
 /* extern */ int
-_rw_fmtmask (const FmtSpec &spec, Buffer &buf, int c)
+_rw_fmtmask (const FmtSpec &spec, Buffer &buf, int bits)
+{
+    static const Bitnames names [] = {
+        BITNAME (std::ctype_base, alnum),
+        BITNAME (std::ctype_base, alpha),
+        BITNAME (std::ctype_base, cntrl),
+        BITNAME (std::ctype_base, digit),
+        BITNAME (std::ctype_base, graph),
+        BITNAME (std::ctype_base, lower),
+        BITNAME (std::ctype_base, print),
+        BITNAME (std::ctype_base, punct),
+        BITNAME (std::ctype_base, space),
+        BITNAME (std::ctype_base, upper),
+        BITNAME (std::ctype_base, xdigit)
+    };
+
+    static const size_t count = sizeof names / sizeof *names;
+
+    return _rw_bmpfmt (spec, buf, names, count, bits);
+}
+
+/********************************************************************/
+
+/* extern */ int
+_rw_fmtcharmask (const FmtSpec &spec, Buffer &buf, int c)
 {
     enum {
         bit_alnum  = 1,

Modified: incubator/stdcxx/trunk/tests/src/fmt_defs.h
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/fmt_defs.h?rev=419404&r1=419403&r2=419404&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/fmt_defs.h (original)
+++ incubator/stdcxx/trunk/tests/src/fmt_defs.h Wed Jul  5 18:32:18 2006
@@ -190,9 +190,13 @@
 extern int
 _rw_fmtlc (const FmtSpec&, Buffer&, int);
 
-// format a character mask (alpha|alnum|...|xdigit)
+// format ctype_base::mask
 extern int
 _rw_fmtmask (const FmtSpec&, Buffer&, int);
+
+// format a character mask (alpha|alnum|...|xdigit)
+extern int
+_rw_fmtcharmask (const FmtSpec&, Buffer&, int);
 
 // format ios_base::iostate
 extern int

Modified: incubator/stdcxx/trunk/tests/src/printf.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/printf.cpp?rev=419404&r1=419403&r2=419404&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/printf.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/printf.cpp Wed Jul  5 18:32:18 2006
@@ -2580,6 +2580,19 @@
         }
         break;
 
+    case 'C':   // %{C}, %{LC}
+        if (spec.mod == spec.mod_L) {
+            // ctype_base::mask value
+            spec.param.int_ = PARAM (int_);
+            len = _rw_fmtmask (spec, buf, spec.param.int_);
+        }
+        else {
+            // ctype_base::mask of a character
+            spec.param.int_ = PARAM (int_);
+            len = _rw_fmtcharmask (spec, buf, spec.param.int_);
+        }
+        break;
+
     case 'e':   // %{e}, %{Ae}
         if (spec.mod == spec.mod_ext_A) {   // array of floating point values
             spec.param.ptr_ = PARAM (ptr_);