LWG 2019 - isblank not supported by std::locale
Jonathan Wakely
jwakely.gcc@gmail.com
Sun Apr 3 18:05:00 GMT 2011
Attached is a work-in-progress patch to add support for the "blank"
character class to std::locale by adding ctype_base::blank for each OS
(making it equal to space when I couldn't find out if that OS supports
C99's blank class) and compiling ctype_members.cc with -std=gnu++0x so
that ctype_base::blank is defined.
I won't have a chance to write proper tests for this for two or three
weeks, so thought I'd post this now for anyone to comment on or play
with.
(This makes regex_traits::lookup_classname easier to implement, which
was what caused me to notice and report the LWG issue.)
-------------- next part --------------
Index: include/bits/locale_facets.h
===================================================================
--- include/bits/locale_facets.h (revision 171888)
+++ include/bits/locale_facets.h (working copy)
@@ -2590,6 +2590,14 @@ _GLIBCXX_END_NAMESPACE_LDBL
isgraph(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ /// Convenience interface to ctype.is(ctype_base::blank, __c).
+ template<typename _CharT>
+ inline bool
+ isblank(_CharT __c, const locale& __loc)
+ { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::blank, __c); }
+#endif
+
/// Convenience interface to ctype.toupper(__c).
template<typename _CharT>
inline _CharT
Index: include/bits/localefwd.h
===================================================================
--- include/bits/localefwd.h (revision 171888)
+++ include/bits/localefwd.h (working copy)
@@ -109,6 +109,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool
isgraph(_CharT, const locale&);
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename _CharT>
+ bool
+ isblank(_CharT, const locale&);
+#endif
+
template<typename _CharT>
_CharT
toupper(_CharT, const locale&);
Index: config/os/newlib/ctype_base.h
===================================================================
--- config/os/newlib/ctype_base.h (revision 171888)
+++ config/os/newlib/ctype_base.h (working copy)
@@ -54,6 +54,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _C;
static const mask punct = _P;
static const mask alnum = _U | _L | _N;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _B;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/aix/ctype_base.h
===================================================================
--- config/os/aix/ctype_base.h (revision 171888)
+++ config/os/aix/ctype_base.h (working copy)
@@ -52,6 +52,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _ISCNTRL;
static const mask punct = _ISPUNCT;
static const mask alnum = _ISALPHA | _ISDIGIT;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _ISBLANK;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/vxworks/ctype_base.h
===================================================================
--- config/os/vxworks/ctype_base.h (revision 171888)
+++ config/os/vxworks/ctype_base.h (working copy)
@@ -53,6 +53,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _C_CONTROL;
static const mask punct = _C_PUNCT;
static const mask alnum = _C_UPPER | _C_LOWER | _C_NUMBER;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _C_WHITE_SPACE;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/hpux/ctype_base.h
===================================================================
--- config/os/hpux/ctype_base.h (revision 171888)
+++ config/os/hpux/ctype_base.h (working copy)
@@ -52,6 +52,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _ISCNTRL;
static const mask punct = _ISPUNCT;
static const mask alnum = _ISALPHA | _ISDIGIT;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _ISBLANK;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/gnu-linux/ctype_base.h
===================================================================
--- config/os/gnu-linux/ctype_base.h (revision 171888)
+++ config/os/gnu-linux/ctype_base.h (working copy)
@@ -58,6 +58,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _IScntrl;
static const mask punct = _ISpunct;
static const mask alnum = _ISalpha | _ISdigit;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _ISblank;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/mingw32/ctype_base.h
===================================================================
--- config/os/mingw32/ctype_base.h (revision 171888)
+++ config/os/mingw32/ctype_base.h (working copy)
@@ -58,6 +58,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = 1 << 8;
static const mask punct = 1 << 9;
static const mask alnum = (1 << 2) | (1 << 3); // alpha|digit
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = 1 << 5; // space
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/tpf/ctype_base.h
===================================================================
--- config/os/tpf/ctype_base.h (revision 171888)
+++ config/os/tpf/ctype_base.h (working copy)
@@ -52,6 +52,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _IScntrl;
static const mask punct = _ISpunct;
static const mask alnum = _ISalpha | _ISdigit;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _ISblank;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/uclibc/ctype_base.h
===================================================================
--- config/os/uclibc/ctype_base.h (revision 171888)
+++ config/os/uclibc/ctype_base.h (working copy)
@@ -60,6 +60,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _IScntrl;
static const mask punct = _ISpunct;
static const mask alnum = _ISalpha | _ISdigit;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _ISblank;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/bionic/ctype_base.h
===================================================================
--- config/os/bionic/ctype_base.h (revision 171888)
+++ config/os/bionic/ctype_base.h (working copy)
@@ -54,6 +54,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _C;
static const mask punct = _P;
static const mask alnum = _U | _L | _N;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _B;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/djgpp/ctype_base.h
===================================================================
--- config/os/djgpp/ctype_base.h (revision 171888)
+++ config/os/djgpp/ctype_base.h (working copy)
@@ -51,6 +51,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask xdigit = __dj_ISXDIGIT; // Hexadecimal numeric
static const mask alnum = __dj_ISALPHA | __dj_ISDIGIT; // Alphanumeric
static const mask graph = __dj_ISALPHA | __dj_ISDIGIT | __dj_ISPUNCT; // Graphical
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = space;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/qnx/qnx6.1/ctype_base.h
===================================================================
--- config/os/qnx/qnx6.1/ctype_base.h (revision 171888)
+++ config/os/qnx/qnx6.1/ctype_base.h (working copy)
@@ -57,6 +57,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _BB;
static const mask punct = _PU;
static const mask alnum = _DI | _LO | _UP | _XA;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = space;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/bsd/netbsd/ctype_base.h
===================================================================
--- config/os/bsd/netbsd/ctype_base.h (revision 171888)
+++ config/os/bsd/netbsd/ctype_base.h (working copy)
@@ -59,6 +59,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _C;
static const mask punct = _P;
static const mask alnum = _U | _L | _N;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _B;
+#endif
#else
static const mask upper = _CTYPE_U;
static const mask lower = _CTYPE_L;
@@ -71,6 +74,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _CTYPE_C;
static const mask punct = _CTYPE_P;
static const mask alnum = _CTYPE_U | _CTYPE_L | _CTYPE_N;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _CTYPE_B;
+#endif
#endif
};
Index: config/os/bsd/darwin/ctype_base.h
===================================================================
--- config/os/bsd/darwin/ctype_base.h (revision 171888)
+++ config/os/bsd/darwin/ctype_base.h (working copy)
@@ -54,6 +54,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _CTYPE_C;
static const mask punct = _CTYPE_P;
static const mask alnum = _CTYPE_A | _CTYPE_D;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _CTYPE_B;
+#endif
#else
// Older versions, including Free BSD 3.4, use this style of define.
static const mask upper = _U;
@@ -67,6 +70,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _C;
static const mask punct = _P;
static const mask alnum = _A | _D;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _B;
+#endif
#endif
};
Index: config/os/bsd/freebsd/ctype_base.h
===================================================================
--- config/os/bsd/freebsd/ctype_base.h (revision 171888)
+++ config/os/bsd/freebsd/ctype_base.h (working copy)
@@ -56,6 +56,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _CTYPE_C;
static const mask punct = _CTYPE_P;
static const mask alnum = _CTYPE_A | _CTYPE_D;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _CTYPE_B;
+#endif
#else
// Older versions, including Free BSD 3.4, use this style of define.
static const mask upper = _U;
@@ -69,6 +72,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _C;
static const mask punct = _P;
static const mask alnum = _A | _D;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _B;
+#endif
#endif
};
Index: config/os/irix/irix6.5/ctype_base.h
===================================================================
--- config/os/irix/irix6.5/ctype_base.h (revision 171888)
+++ config/os/irix/irix6.5/ctype_base.h (working copy)
@@ -58,6 +58,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _IScntrl;
static const mask punct = _ISpunct;
static const mask alnum = _ISalpha | _ISdigit;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _ISblank;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/generic/ctype_base.h
===================================================================
--- config/os/generic/ctype_base.h (revision 171888)
+++ config/os/generic/ctype_base.h (working copy)
@@ -53,6 +53,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = 1 << 8;
static const mask punct = 1 << 9;
static const mask alnum = (1 << 2) | (1 << 3); // alpha|digit
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = space;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/os/generic/ctype_inline.h
===================================================================
--- config/os/generic/ctype_inline.h (revision 171888)
+++ config/os/generic/ctype_inline.h (working copy)
@@ -97,6 +97,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
case graph:
__testis = isgraph(__c);
break;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ case blank:
+ __testis = isblank(__c);
+ break;
+#endif
default:
__testis = false;
break;
Index: config/os/solaris/solaris2.7/ctype_base.h
===================================================================
--- config/os/solaris/solaris2.7/ctype_base.h (revision 171888)
+++ config/os/solaris/solaris2.7/ctype_base.h (working copy)
@@ -54,6 +54,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _ISCNTRL;
static const mask punct = _ISPUNCT;
static const mask alnum = _ISALPHA | _ISDIGIT;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ static const mask blank = _ISBLANK;
+#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
Index: config/locale/generic/ctype_members.cc
===================================================================
--- config/locale/generic/ctype_members.cc (revision 171888)
+++ config/locale/generic/ctype_members.cc (working copy)
@@ -93,6 +93,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
case graph:
__ret = wctype("graph");
break;
+ case blank:
+ __ret = wctype("blank");
+ break;
default:
__ret = __wmask_type();
}
Index: config/locale/gnu/ctype_members.cc
===================================================================
--- config/locale/gnu/ctype_members.cc (revision 171888)
+++ config/locale/gnu/ctype_members.cc (working copy)
@@ -95,6 +95,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
case graph:
__ret = __wctype_l("graph", _M_c_locale_ctype);
break;
+ case blank:
+ __ret = __wctype_l("blank", _M_c_locale_ctype);
+ break;
default:
__ret = __wmask_type();
}
Index: src/Makefile.am
===================================================================
--- src/Makefile.am (revision 171888)
+++ src/Makefile.am (working copy)
@@ -393,6 +393,11 @@ placeholders.lo: placeholders.cc
placeholders.o: placeholders.cc
$(CXXCOMPILE) -std=gnu++0x -c $<
+ctype_members.lo: ctype_members.cc
+ $(LTCXXCOMPILE) -std=gnu++0x -c $<
+ctype_members.o: ctype_members.cc
+ $(CXXCOMPILE) -std=gnu++0x -c $<
+
if GLIBCXX_LDBL_COMPAT
# Use special rules for compatibility-ldbl.cc compilation, as we need to
# pass -mlong-double-64.
More information about the Libstdc++
mailing list