Author: [EMAIL PROTECTED]
Date: Tue Nov 18 00:47:15 2008
New Revision: 782
Modified:
branches/experimental/regexp2000/src/ast.cc
branches/experimental/regexp2000/src/string-stream.cc
branches/experimental/regexp2000/test/cctest/test-regexp.cc
Log:
Format "%k" now prints either a printable ASCII character or a \x.. or
\u.... format value.
Modified: branches/experimental/regexp2000/src/ast.cc
==============================================================================
--- branches/experimental/regexp2000/src/ast.cc (original)
+++ branches/experimental/regexp2000/src/ast.cc Tue Nov 18 00:47:15 2008
@@ -254,21 +254,11 @@
return NULL;
}
-static void AddChar(StringStream* stream, uc16 character) {
- if (character < 32 || (character >= 128 && character < 256)) {
- stream->Add("\\x%02x", character);
- } else if (character >= 256) {
- stream->Add("\\u%04x", character);
- } else {
- stream->Add("%c", character);
- }
-}
void RegExpUnparser::VisitCharacterRange(CharacterRange that) {
- AddChar(stream(), that.from());
+ stream()->Add("%k", that.from());
if (!that.IsSingleton()) {
- stream()->Add("-");
- AddChar(stream(), that.to());
+ stream()->Add("-%k", that.to());
}
}
@@ -317,7 +307,7 @@
stream()->Add("'");
Vector<const uc16> chardata = that->data();
for (int i = 0; i < chardata.length(); i++) {
- AddChar(stream(), chardata[i]);
+ stream()->Add("%k", chardata[i]);
}
stream()->Add("'");
return NULL;
Modified: branches/experimental/regexp2000/src/string-stream.cc
==============================================================================
--- branches/experimental/regexp2000/src/string-stream.cc (original)
+++ branches/experimental/regexp2000/src/string-stream.cc Tue Nov 18
00:47:15 2008
@@ -143,10 +143,12 @@
case 'k': {
ASSERT_EQ(FmtElm::INT, current.type_);
int value = current.data_.u_int_;
- if (0x20 <= value && value <= 0xFF) {
+ if (0x20 <= value && value <= 0x7F) {
Put(value);
+ } else if (value <= 0xff) {
+ Add("\\x%02x", value);
} else {
- Add("\\x%X", value);
+ Add("\\u%04x", value);
}
break;
}
Modified: branches/experimental/regexp2000/test/cctest/test-regexp.cc
==============================================================================
--- branches/experimental/regexp2000/test/cctest/test-regexp.cc (original)
+++ branches/experimental/regexp2000/test/cctest/test-regexp.cc Tue Nov 18
00:47:15 2008
@@ -734,7 +734,7 @@
for (uc32 c = 128; c < (1 << 21); c++) {
// These exceptions are caused by a known bug in the implementation.
if (c != 0x026B && c != 0x027D)
- CHECK(canonicalize(c) >= 128);
+ CHECK_GE(canonicalize(c), 128);
}
unibrow::Mapping<unibrow::ToUppercase> to_upper;
for (uc32 c = 0; c < (1 << 21); c++) {
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---