Changeset 62155 in webkit
- Timestamp:
- Jun 29, 2010 6:16:21 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r62154 r62155 1 2010-06-29 Kinuko Yasuda <kinuko@chromium.org> 2 3 Reviewed by Jian Li. 4 5 Fix http/tests/local/blob/send-data-blob.html on Windows 6 https://bugs.webkit.org/show_bug.cgi?id=41228 7 8 Fix the cgi code to make it work with cygwin perl. 9 Also fix test expectations for Windows. 10 11 * http/tests/resources/post-and-verify-hybrid.cgi: 12 * platform/chromium/test_expectations.txt: 13 * platform/win/fast/js/global-constructors-expected.txt: 14 1 15 2010-06-29 James Robinson <jamesr@chromium.org> 2 16 -
trunk/LayoutTests/http/tests/resources/post-and-verify-hybrid.cgi
r61650 r62155 1 1 #!/usr/bin/perl -w 2 3 use Config; 2 4 3 5 print "Content-type: text/plain\n\n"; … … 71 73 72 74 if ($values{'convert_newlines'}) { 73 $nativeEnding = ($ ^O =~ /MSWin/) ? "\r\n" : "\n";75 $nativeEnding = ($Config{osname} =~ /(MSWin|cygwin)/) ? "\r\n" : "\n"; 74 76 $postData =~ s/$nativeEnding/[NL]/g; 75 77 } -
trunk/LayoutTests/platform/chromium/test_expectations.txt
r62154 r62155 2877 2877 BUG_HCLAM : fast/js/script-line-number.html = TEXT 2878 2878 2879 // Added by r616502880 BUG47259 WIN : http/tests/local/blob/send-data-blob.html = TEXT2881 2882 2879 // LayoutTestController::isPageBoxVisible, pageAreaRectInPixels, and preferredPageSizeInPixels are not implemented yet for Chromium. 2883 2880 BUGWK37538 : printing/page-format-data.html = TEXT -
trunk/LayoutTests/platform/win/fast/js/global-constructors-expected.txt
r61531 r62155 8 8 PASS BeforeLoadEvent.toString() is '[object BeforeLoadEventConstructor]' 9 9 PASS Blob.toString() is '[object BlobConstructor]' 10 PASS BlobBuilder.toString() is '[object BlobBuilderConstructor]' 10 11 PASS CDATASection.toString() is '[object CDATASectionConstructor]' 11 12 PASS CSSCharsetRule.toString() is '[object CSSCharsetRuleConstructor]' -
trunk/WebCore/ChangeLog
r62153 r62155 1 2010-06-29 Kinuko Yasuda <kinuko@chromium.org> 2 3 Reviewed by Jian Li. 4 5 Fix http/tests/local/blob/send-data-blob.html on Windows 6 https://bugs.webkit.org/show_bug.cgi?id=41228 7 8 Fix a regression bug in the line-conversion code. 9 Rewrite the line-conversion function with simpler functions to 10 make it less error prone. 11 12 No new tests as this is for bug fixes. 13 14 * platform/BlobItem.cpp: 15 (WebCore::StringBlobItem::convertToCString): 16 1 17 2010-06-29 Dumitru Daniliuc <dumi@chromium.org> 2 18 -
trunk/WebCore/platform/BlobItem.cpp
r61349 r62155 34 34 #include "FileSystem.h" 35 35 #include "UUID.h" 36 #include <wtf/Assertions.h> 36 37 37 38 namespace WebCore { … … 125 126 } 126 127 128 // Normalize all line-endings to CRLF. 129 static CString convertToCRLF(const CString& from) 130 { 131 unsigned newLen = 0; 132 const char* p = from.data(); 133 while (char c = *p++) { 134 if (c == '\r') { 135 // Safe to look ahead because of trailing '\0'. 136 if (*p != '\n') { 137 // Turn CR into CRLF. 138 newLen += 2; 139 } 140 } else if (c == '\n') { 141 // Turn LF into CRLF. 142 newLen += 2; 143 } else { 144 // Leave other characters alone. 145 newLen += 1; 146 } 147 } 148 if (newLen == from.length()) 149 return from; 150 151 // Make a copy of the string. 152 p = from.data(); 153 char* q; 154 CString result = CString::newUninitialized(newLen, q); 155 while (char c = *p++) { 156 if (c == '\r') { 157 // Safe to look ahead because of trailing '\0'. 158 if (*p != '\n') { 159 // Turn CR into CRLF. 160 *q++ = '\r'; 161 *q++ = '\n'; 162 } 163 } else if (c == '\n') { 164 // Turn LF into CRLF. 165 *q++ = '\r'; 166 *q++ = '\n'; 167 } else { 168 // Leave other characters alone. 169 *q++ = c; 170 } 171 } 172 return result; 173 } 174 175 // Normalize all line-endings to CR or LF. 176 static CString convertToCROrLF(const CString& from, bool toCR) 177 { 178 unsigned newLen = 0; 179 bool needFix = false; 180 const char* p = from.data(); 181 char fromEndingChar = toCR ? '\n' : '\r'; 182 char toEndingChar = toCR ? '\r' : '\n'; 183 while (char c = *p++) { 184 if (c == '\r' && *p == '\n') { 185 // Turn CRLF into CR or LF. 186 p++; 187 needFix = true; 188 } else if (c == fromEndingChar) { 189 // Turn CR/LF into LF/CR. 190 needFix = true; 191 } 192 newLen += 1; 193 } 194 if (!needFix) 195 return from; 196 197 // Make a copy of the string. 198 p = from.data(); 199 char* q; 200 CString result = CString::newUninitialized(newLen, q); 201 while (char c = *p++) { 202 if (c == '\r' && *p == '\n') { 203 // Turn CRLF or CR into CR or LF. 204 p++; 205 *q++ = toEndingChar; 206 } else if (c == fromEndingChar) { 207 // Turn CR/LF into LF/CR. 208 *q++ = toEndingChar; 209 } else { 210 // Leave other characters alone. 211 *q++ = c; 212 } 213 } 214 return result; 215 } 216 127 217 CString StringBlobItem::convertToCString(const String& text, LineEnding ending, TextEncoding encoding) 128 218 { 129 219 CString from = encoding.encode(text.characters(), text.length(), EntitiesForUnencodables); 130 CString result = from;131 132 if (ending == EndingTransparent)133 return result;134 220 135 221 if (ending == EndingNative) { … … 141 227 } 142 228 143 const char* endingChars = (ending == EndingCRLF) ? "\r\n" : ((ending == EndingCR) ? "\r" : "\n"); 144 145 int endingLength = (ending == EndingCRLF) ? 2 : 1; 146 int needFix = 0; 147 148 // Calculate the final length. 149 int calculatedLength = from.length(); 150 const char* p = from.data(); 151 while (char c = *p++) { 152 if (c == '\r') { 153 // Safe to look ahead because of trailing '\0'. 154 if (*p == '\n' && ending != EndingCRLF) { 155 p++; 156 calculatedLength += (endingLength - 2); 157 ++needFix; 158 } else if (ending != EndingCR) { 159 calculatedLength += (endingLength - 1); 160 ++needFix; 161 } 162 } else if (c == '\n' && ending != EndingLF) { 163 calculatedLength += (endingLength - 1); 164 ++needFix; 165 } 166 } 167 168 if (!needFix) 169 return result; 170 171 // Convert the endings and create a data buffer. 172 p = from.data(); 173 char* q; 174 result = CString::newUninitialized(calculatedLength, q); 175 while (char c = *p++) { 176 if (c == '\r') { 177 if (*p == '\n' && ending != EndingCRLF) { 178 p++; 179 memcpy(q, endingChars, endingLength); 180 q += endingLength; 181 } else if (*p != '\n' && ending != EndingCR) { 182 memcpy(q, endingChars, endingLength); 183 q += endingLength; 184 } 185 } else if (c == '\n' && ending != EndingLF) { 186 memcpy(q, endingChars, endingLength); 187 q += endingLength; 188 } else { 189 // Leave other characters alone. 190 *q++ = c; 191 } 192 } 193 return result; 229 switch (ending) { 230 case EndingTransparent: 231 return from; 232 case EndingCRLF: 233 return convertToCRLF(from); 234 case EndingCR: 235 return convertToCROrLF(from, true); 236 case EndingLF: 237 return convertToCROrLF(from, false); 238 default: 239 ASSERT_NOT_REACHED(); 240 } 241 242 ASSERT_NOT_REACHED(); 243 return from; 194 244 } 195 245
Note: See TracChangeset
for help on using the changeset viewer.