Changeset 15526 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jul 19, 2006, 10:32:15 AM (19 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r15524 r15526 1 2006-07-19 Anders Carlsson <[email protected]> 2 3 Reviewed by Darin. 4 5 <rdar://problem/4620655> REGRESSION(10.4.7-10.5): preview button for a blogger.com post doesn't work 6 7 * kjs/nodes2string.cpp: 8 (StringNode::streamTo): 9 Return the escaped string. 10 11 (RegExpNode::streamTo): 12 Use the correct syntax. 13 14 * kjs/function.cpp: 15 (KJS::escapeStringForPrettyPrinting): 16 * kjs/function.h: 17 Add escape function which escapes a string for pretty-printing so it can be parsed again. 18 19 * wtf/unicode/icu/UnicodeIcu.h: 20 (WTF::Unicode::isPrintableChar): 21 New function. 22 1 23 === Safari-521.19 === 2 24 -
trunk/JavaScriptCore/kjs/function.cpp
r15026 r15526 919 919 } 920 920 921 UString escapeStringForPrettyPrinting(const UString& s) 922 { 923 UString escapedString; 924 925 for (int i = 0; i < s.size(); i++) { 926 unsigned short c = s.data()[i].unicode(); 927 928 switch (c) { 929 case '\"': 930 escapedString += "\\\""; 931 break; 932 case '\n': 933 escapedString += "\\n"; 934 break; 935 case '\r': 936 escapedString += "\\r"; 937 break; 938 case '\t': 939 escapedString += "\\t"; 940 break; 941 case '\\': 942 escapedString += "\\\\"; 943 break; 944 default: 945 if (c < 128 && WTF::Unicode::isPrintableChar(c)) 946 escapedString.append(c); 947 else { 948 char hexValue[7]; 949 950 snprintf(hexValue, 7, "\\u%04x", c); 951 escapedString += hexValue; 952 } 953 } 954 } 955 956 return escapedString; 957 } 958 959 921 960 } // namespace -
trunk/JavaScriptCore/kjs/function.h
r14256 r15526 162 162 }; 163 163 164 164 UString escapeStringForPrettyPrinting(const UString& s); 165 165 166 166 } // namespace -
trunk/JavaScriptCore/kjs/nodes2string.cpp
r14502 r15526 23 23 #include "config.h" 24 24 #include "nodes.h" 25 #include "function.h" 25 26 26 27 namespace KJS { … … 117 118 void StringNode::streamTo(SourceStream &s) const 118 119 { 119 s << '"' << value << '"'; 120 } 121 122 void RegExpNode::streamTo(SourceStream &s) const { s << pattern; } 120 s << '"' << escapeStringForPrettyPrinting(value) << '"'; 121 } 122 123 void RegExpNode::streamTo(SourceStream &s) const 124 { 125 s << "/" << pattern << "/" << flags; 126 } 123 127 124 128 void ThisNode::streamTo(SourceStream &s) const { s << "this"; } -
trunk/JavaScriptCore/wtf/unicode/icu/UnicodeIcu.h
r14256 r15526 83 83 } 84 84 85 inline bool isPrintableChar(int32_t c) 86 { 87 return u_isprint(c); 88 } 89 85 90 inline CharCategory category(int32_t c) 86 91 {
Note:
See TracChangeset
for help on using the changeset viewer.