[Patch] libc++: Add a default rune table
Ed Schouten
ed at 80386.nl
Wed Dec 10 03:55:01 PST 2014
Hi there,
In an attempt to get libc++ working in a new POSIX-like environment
(to be released to the public early/mid next year), I noticed that
libc++ unconditionally requires that the environment provides a
character class table for ASCII. Though most operating systems provide
such a table (or use such a table internally), there is no standards
requirement that such a table is provided.
The classic_table() function currently prints a message and aborts
when compiled on such a system, whereas it could easily fall back to
an integrated table. Attached is a patch that adds such a table.
URL: http://80386.nl/pub/20141210-libcxx-runetable.txt
Best regards,
--
Ed Schouten <ed at 80386.nl>
-------------- next part --------------
Index: src/locale.cpp
===================================================================
--- src/locale.cpp (revision 223766)
+++ src/locale.cpp (working copy)
@@ -1038,12 +1056,77 @@
#elif defined(__ANDROID__)
return reinterpret_cast<const unsigned char*>(_ctype_) + 1;
#else
- // Platform not supported: abort so the person doing the port knows what to
- // fix
-# warning ctype<char>::classic_table() is not implemented
- printf("ctype<char>::classic_table() is not implemented\n");
- abort();
- return NULL;
+ // Operating system does not use or provide a rune table. Return a
+ // built-in copy.
+ static const ctype<char>::mask builtin_table[] = {
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl | space | blank,
+ cntrl | space, cntrl | space,
+ cntrl | space, cntrl | space,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ cntrl, cntrl,
+ space | blank | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ digit | print | xdigit, digit | print | xdigit,
+ digit | print | xdigit, digit | print | xdigit,
+ digit | print | xdigit, digit | print | xdigit,
+ digit | print | xdigit, digit | print | xdigit,
+ digit | print | xdigit, digit | print | xdigit,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, upper | xdigit | print | alpha,
+ upper | xdigit | print | alpha, upper | xdigit | print | alpha,
+ upper | xdigit | print | alpha, upper | xdigit | print | alpha,
+ upper | xdigit | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, upper | print | alpha,
+ upper | print | alpha, punct | print,
+ punct | print, punct | print,
+ punct | print, punct | print,
+ punct | print, lower | xdigit | print | alpha,
+ lower | xdigit | print | alpha, lower | xdigit | print | alpha,
+ lower | xdigit | print | alpha, lower | xdigit | print | alpha,
+ lower | xdigit | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, lower | print | alpha,
+ lower | print | alpha, punct | print,
+ punct | print, punct | print,
+ punct | print, cntrl,
+ };
+ static_assert(sizeof(builtin_table) / sizeof(builtin_table[0]) == 128,
+ "Incorrect table size");
+ return builtin_table;
#endif
}
More information about the cfe-commits
mailing list