| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 field_counter = 1; | 172 field_counter = 1; |
| 173 state = kStateSymbol; | 173 state = kStateSymbol; |
| 174 break; | 174 break; |
| 175 | 175 |
| 176 case kStateQuote: | 176 case kStateQuote: |
| 177 literal_buffer.Append(ch); | 177 literal_buffer.Append(ch); |
| 178 state = ch == '\'' ? kStateLiteral : kStateInQuote; | 178 state = ch == '\'' ? kStateLiteral : kStateInQuote; |
| 179 break; | 179 break; |
| 180 | 180 |
| 181 case kStateSymbol: { | 181 case kStateSymbol: { |
| 182 ASSERT(field_type != kFieldTypeInvalid); | 182 DCHECK_NE(field_type, kFieldTypeInvalid); |
| 183 ASSERT(field_type != kFieldTypeLiteral); | 183 DCHECK_NE(field_type, kFieldTypeLiteral); |
| 184 ASSERT(literal_buffer.IsEmpty()); | 184 DCHECK(literal_buffer.IsEmpty()); |
| 185 | 185 |
| 186 FieldType field_type2 = MapCharacterToFieldType(ch); | 186 FieldType field_type2 = MapCharacterToFieldType(ch); |
| 187 if (field_type2 == kFieldTypeInvalid) | 187 if (field_type2 == kFieldTypeInvalid) |
| 188 return false; | 188 return false; |
| 189 | 189 |
| 190 if (field_type == field_type2) { | 190 if (field_type == field_type2) { |
| 191 ++field_counter; | 191 ++field_counter; |
| 192 break; | 192 break; |
| 193 } | 193 } |
| 194 | 194 |
| 195 token_handler.VisitField(field_type, field_counter); | 195 token_handler.VisitField(field_type, field_counter); |
| 196 | 196 |
| 197 if (field_type2 == kFieldTypeLiteral) { | 197 if (field_type2 == kFieldTypeLiteral) { |
| 198 if (ch == '\'') { | 198 if (ch == '\'') { |
| 199 state = kStateQuote; | 199 state = kStateQuote; |
| 200 } else { | 200 } else { |
| 201 literal_buffer.Append(ch); | 201 literal_buffer.Append(ch); |
| 202 state = kStateLiteral; | 202 state = kStateLiteral; |
| 203 } | 203 } |
| 204 break; | 204 break; |
| 205 } | 205 } |
| 206 | 206 |
| 207 field_counter = 1; | 207 field_counter = 1; |
| 208 field_type = field_type2; | 208 field_type = field_type2; |
| 209 break; | 209 break; |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 ASSERT(field_type != kFieldTypeInvalid); | 214 DCHECK_NE(field_type, kFieldTypeInvalid); |
| 215 | 215 |
| 216 switch (state) { | 216 switch (state) { |
| 217 case kStateLiteral: | 217 case kStateLiteral: |
| 218 case kStateInQuoteQuote: | 218 case kStateInQuoteQuote: |
| 219 if (literal_buffer.length()) | 219 if (literal_buffer.length()) |
| 220 token_handler.VisitLiteral(literal_buffer.ToString()); | 220 token_handler.VisitLiteral(literal_buffer.ToString()); |
| 221 return true; | 221 return true; |
| 222 | 222 |
| 223 case kStateQuote: | 223 case kStateQuote: |
| 224 case kStateInQuote: | 224 case kStateInQuote: |
| 225 if (literal_buffer.length()) | 225 if (literal_buffer.length()) |
| 226 token_handler.VisitLiteral(literal_buffer.ToString()); | 226 token_handler.VisitLiteral(literal_buffer.ToString()); |
| 227 return false; | 227 return false; |
| 228 | 228 |
| 229 case kStateSymbol: | 229 case kStateSymbol: |
| 230 ASSERT(field_type != kFieldTypeLiteral); | 230 DCHECK_NE(field_type, kFieldTypeLiteral); |
| 231 ASSERT(!literal_buffer.length()); | 231 DCHECK(!literal_buffer.length()); |
| 232 token_handler.VisitField(field_type, field_counter); | 232 token_handler.VisitField(field_type, field_counter); |
| 233 return true; | 233 return true; |
| 234 } | 234 } |
| 235 | 235 |
| 236 ASSERT_NOT_REACHED(); | 236 NOTREACHED(); |
| 237 return false; | 237 return false; |
| 238 } | 238 } |
| 239 | 239 |
| 240 static bool IsASCIIAlphabetOrQuote(UChar ch) { | 240 static bool IsASCIIAlphabetOrQuote(UChar ch) { |
| 241 return IsASCIIAlpha(ch) || ch == '\''; | 241 return IsASCIIAlpha(ch) || ch == '\''; |
| 242 } | 242 } |
| 243 | 243 |
| 244 void DateTimeFormat::QuoteAndappend(const String& literal, | 244 void DateTimeFormat::QuoteAndappend(const String& literal, |
| 245 StringBuilder& buffer) { | 245 StringBuilder& buffer) { |
| 246 if (literal.length() <= 0) | 246 if (literal.length() <= 0) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 266 escaped.Replace("'", "''"); | 266 escaped.Replace("'", "''"); |
| 267 buffer.Append('\''); | 267 buffer.Append('\''); |
| 268 buffer.Append(escaped); | 268 buffer.Append(escaped); |
| 269 buffer.Append('\''); | 269 buffer.Append('\''); |
| 270 return; | 270 return; |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace blink | 275 } // namespace blink |
| OLD | NEW |