| 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 fieldCounter = 1; | 172 fieldCounter = 1; |
| 173 state = StateSymbol; | 173 state = StateSymbol; |
| 174 break; | 174 break; |
| 175 | 175 |
| 176 case StateQuote: | 176 case StateQuote: |
| 177 literalBuffer.append(ch); | 177 literalBuffer.append(ch); |
| 178 state = ch == '\'' ? StateLiteral : StateInQuote; | 178 state = ch == '\'' ? StateLiteral : StateInQuote; |
| 179 break; | 179 break; |
| 180 | 180 |
| 181 case StateSymbol: { | 181 case StateSymbol: { |
| 182 ASSERT(fieldType != FieldTypeInvalid); | 182 DCHECK_NE(fieldType, FieldTypeInvalid); |
| 183 ASSERT(fieldType != FieldTypeLiteral); | 183 DCHECK_NE(fieldType, FieldTypeLiteral); |
| 184 ASSERT(literalBuffer.isEmpty()); | 184 DCHECK(literalBuffer.isEmpty()); |
| 185 | 185 |
| 186 FieldType fieldType2 = mapCharacterToFieldType(ch); | 186 FieldType fieldType2 = mapCharacterToFieldType(ch); |
| 187 if (fieldType2 == FieldTypeInvalid) | 187 if (fieldType2 == FieldTypeInvalid) |
| 188 return false; | 188 return false; |
| 189 | 189 |
| 190 if (fieldType == fieldType2) { | 190 if (fieldType == fieldType2) { |
| 191 ++fieldCounter; | 191 ++fieldCounter; |
| 192 break; | 192 break; |
| 193 } | 193 } |
| 194 | 194 |
| 195 tokenHandler.visitField(fieldType, fieldCounter); | 195 tokenHandler.visitField(fieldType, fieldCounter); |
| 196 | 196 |
| 197 if (fieldType2 == FieldTypeLiteral) { | 197 if (fieldType2 == FieldTypeLiteral) { |
| 198 if (ch == '\'') { | 198 if (ch == '\'') { |
| 199 state = StateQuote; | 199 state = StateQuote; |
| 200 } else { | 200 } else { |
| 201 literalBuffer.append(ch); | 201 literalBuffer.append(ch); |
| 202 state = StateLiteral; | 202 state = StateLiteral; |
| 203 } | 203 } |
| 204 break; | 204 break; |
| 205 } | 205 } |
| 206 | 206 |
| 207 fieldCounter = 1; | 207 fieldCounter = 1; |
| 208 fieldType = fieldType2; | 208 fieldType = fieldType2; |
| 209 break; | 209 break; |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 ASSERT(fieldType != FieldTypeInvalid); | 214 DCHECK_NE(fieldType, FieldTypeInvalid); |
| 215 | 215 |
| 216 switch (state) { | 216 switch (state) { |
| 217 case StateLiteral: | 217 case StateLiteral: |
| 218 case StateInQuoteQuote: | 218 case StateInQuoteQuote: |
| 219 if (literalBuffer.length()) | 219 if (literalBuffer.length()) |
| 220 tokenHandler.visitLiteral(literalBuffer.toString()); | 220 tokenHandler.visitLiteral(literalBuffer.toString()); |
| 221 return true; | 221 return true; |
| 222 | 222 |
| 223 case StateQuote: | 223 case StateQuote: |
| 224 case StateInQuote: | 224 case StateInQuote: |
| 225 if (literalBuffer.length()) | 225 if (literalBuffer.length()) |
| 226 tokenHandler.visitLiteral(literalBuffer.toString()); | 226 tokenHandler.visitLiteral(literalBuffer.toString()); |
| 227 return false; | 227 return false; |
| 228 | 228 |
| 229 case StateSymbol: | 229 case StateSymbol: |
| 230 ASSERT(fieldType != FieldTypeLiteral); | 230 DCHECK_NE(fieldType, FieldTypeLiteral); |
| 231 ASSERT(!literalBuffer.length()); | 231 DCHECK(!literalBuffer.length()); |
| 232 tokenHandler.visitField(fieldType, fieldCounter); | 232 tokenHandler.visitField(fieldType, fieldCounter); |
| 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 |