Changeset 132292 in webkit


Ignore:
Timestamp:
Oct 23, 2012 7:16:57 PM (11 years ago)
Author:
tkent@chromium.org
Message:

Move appendAsLDMLLiteral in LocaleWin.cpp to a common place
https://bugs.webkit.org/show_bug.cgi?id=100129

Reviewed by Kentaro Hara.

We're going to use appendAsLDMLLiteral in other code, and it is
related to DateTimeFormat class. So we move it to DateTimeFormat
class as quoteAndAppendLiteral.

No new tests because of no behavior change.

  • platform/text/DateTimeFormat.cpp:

(WebCore::DateTimeFormat::quoteAndAppendLiteral):
Moved from LocaleWin.cpp

  • platform/text/DateTimeFormat.h:

Declare StringBuilder by wtf/Forward.h. It also declares String.
(DateTimeFormat): Declare quoteAndAppendLiteral.

  • platform/text/LocaleWin.cpp:

(WebCore): Move appendLDMLLiteral to DateTimeFormat.
(WebCore::convertWindowsDateFormatToLDML):
Follow the moving.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r132291 r132292  
     12012-10-23  Kent Tamura  <tkent@chromium.org>
     2
     3        Move appendAsLDMLLiteral in LocaleWin.cpp to a common place
     4        https://bugs.webkit.org/show_bug.cgi?id=100129
     5
     6        Reviewed by Kentaro Hara.
     7
     8        We're going to use appendAsLDMLLiteral in other code, and it is
     9        related to DateTimeFormat class.  So we move it to DateTimeFormat
     10        class as quoteAndAppendLiteral.
     11
     12        No new tests because of no behavior change.
     13
     14        * platform/text/DateTimeFormat.cpp:
     15        (WebCore::DateTimeFormat::quoteAndAppendLiteral):
     16        Moved from LocaleWin.cpp
     17        * platform/text/DateTimeFormat.h:
     18        Declare StringBuilder by wtf/Forward.h. It also declares String.
     19        (DateTimeFormat): Declare quoteAndAppendLiteral.
     20        * platform/text/LocaleWin.cpp:
     21        (WebCore): Move appendLDMLLiteral to DateTimeFormat.
     22        (WebCore::convertWindowsDateFormatToLDML):
     23        Follow the moving.
     24
    1252012-10-23  Kent Tamura  <tkent@chromium.org>
    226
  • trunk/Source/WebCore/platform/text/DateTimeFormat.cpp

    r130116 r132292  
    242242}
    243243
     244void DateTimeFormat::quoteAndAppendLiteral(const String& literal, StringBuilder& buffer)
     245{
     246    if (literal.length() <= 0)
     247        return;
     248   
     249    if (literal.find('\'') == notFound) {
     250        buffer.append("'");
     251        buffer.append(literal);
     252        buffer.append("'");
     253        return;
     254    }
     255
     256    for (unsigned i = 0; i < literal.length(); ++i) {
     257        if (literal[i] == '\'')
     258            buffer.append("''");
     259        else {
     260            String escaped = literal.substring(i);
     261            escaped.replace(ASCIILiteral("'"), ASCIILiteral("''"));
     262            buffer.append("'");
     263            buffer.append(escaped);
     264            buffer.append("'");
     265            return;
     266        }
     267    }
     268}
     269
    244270} // namespace WebCore
    245271
  • trunk/Source/WebCore/platform/text/DateTimeFormat.h

    r130116 r132292  
    2828
    2929#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
    30 #include <wtf/text/WTFString.h>
     30#include <wtf/Forward.h>
    3131
    3232namespace WebCore {
     
    104104    // Returns true if succeeded, false if failed.
    105105    static bool parse(const String&, TokenHandler&);
     106    static void quoteAndAppendLiteral(const String&, StringBuilder&);
    106107};
    107108
  • trunk/Source/WebCore/platform/text/LocaleWin.cpp

    r132170 r132292  
    580580
    581581#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
    582 static void appendAsLDMLLiteral(const String& literal, StringBuilder& buffer)
    583 {
    584     if (literal.length() <= 0)
    585         return;
    586    
    587     if (literal.find('\'') == notFound) {
    588         buffer.append("'");
    589         buffer.append(literal);
    590         buffer.append("'");
    591         return;
    592     }
    593 
    594     for (unsigned i = 0; i < literal.length(); ++i) {
    595         if (literal[i] == '\'')
    596             buffer.append("''");
    597         else {
    598             String escaped = literal.substring(i);
    599             escaped.replace(ASCIILiteral("'"), ASCIILiteral("''"));
    600             buffer.append("'");
    601             buffer.append(escaped);
    602             buffer.append("'");
    603             return;
    604         }
    605     }
    606 }
    607 
    608582static String convertWindowsDateFormatToLDML(const Vector<DateFormatToken>& tokens)
    609583{
     
    612586        switch (tokens[i].type) {
    613587        case DateFormatToken::Literal:
    614             appendAsLDMLLiteral(tokens[i].data, buffer);
     588            DateTimeFormat::quoteAndAppendLiteral(tokens[i].data, buffer);
    615589            break;
    616590
Note: See TracChangeset for help on using the changeset viewer.