OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 ASSERT_NOT_REACHED(); | 238 ASSERT_NOT_REACHED(); |
239 return false; | 239 return false; |
240 } | 240 } |
241 | 241 |
242 static bool isASCIIAlphabetOrQuote(UChar ch) | 242 static bool isASCIIAlphabetOrQuote(UChar ch) |
243 { | 243 { |
244 return isASCIIAlpha(ch) || ch == '\''; | 244 return isASCIIAlpha(ch) || ch == '\''; |
245 } | 245 } |
246 | 246 |
247 void DateTimeFormat::quoteAndAppendLiteral(const String& literal, StringBuilder&
buffer) | 247 void DateTimeFormat::quoteAndappend(const String& literal, StringBuilder& buffer
) |
248 { | 248 { |
249 if (literal.length() <= 0) | 249 if (literal.length() <= 0) |
250 return; | 250 return; |
251 | 251 |
252 if (literal.find(isASCIIAlphabetOrQuote) == kNotFound) { | 252 if (literal.find(isASCIIAlphabetOrQuote) == kNotFound) { |
253 buffer.append(literal); | 253 buffer.append(literal); |
254 return; | 254 return; |
255 } | 255 } |
256 | 256 |
257 if (literal.find('\'') == kNotFound) { | 257 if (literal.find('\'') == kNotFound) { |
258 buffer.append('\''); | 258 buffer.append('\''); |
259 buffer.append(literal); | 259 buffer.append(literal); |
260 buffer.append('\''); | 260 buffer.append('\''); |
261 return; | 261 return; |
262 } | 262 } |
263 | 263 |
264 for (unsigned i = 0; i < literal.length(); ++i) { | 264 for (unsigned i = 0; i < literal.length(); ++i) { |
265 if (literal[i] == '\'') { | 265 if (literal[i] == '\'') { |
266 buffer.appendLiteral("''"); | 266 buffer.append("''"); |
267 } else { | 267 } else { |
268 String escaped = literal.substring(i); | 268 String escaped = literal.substring(i); |
269 escaped.replace("'", "''"); | 269 escaped.replace("'", "''"); |
270 buffer.append('\''); | 270 buffer.append('\''); |
271 buffer.append(escaped); | 271 buffer.append(escaped); |
272 buffer.append('\''); | 272 buffer.append('\''); |
273 return; | 273 return; |
274 } | 274 } |
275 } | 275 } |
276 } | 276 } |
277 | 277 |
278 } // namespace blink | 278 } // namespace blink |
OLD | NEW |