OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Create a state machine for validating UTF-8. The algorithm in brief: | 5 // Create a state machine for validating UTF-8. The algorithm in brief: |
6 // 1. Convert the complete unicode range of code points, except for the | 6 // 1. Convert the complete unicode range of code points, except for the |
7 // surrogate code points, to an ordered array of sequences of bytes in | 7 // surrogate code points, to an ordered array of sequences of bytes in |
8 // UTF-8. | 8 // UTF-8. |
9 // 2. Convert individual bytes to ranges, starting from the right of each byte | 9 // 2. Convert individual bytes to ranges, starting from the right of each byte |
10 // sequence. For each range, ensure the bytes on the left and the ranges | 10 // sequence. For each range, ensure the bytes on the left and the ranges |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include <stdlib.h> | 30 #include <stdlib.h> |
31 #include <string.h> | 31 #include <string.h> |
32 | 32 |
33 #include <algorithm> | 33 #include <algorithm> |
34 #include <map> | 34 #include <map> |
35 #include <string> | 35 #include <string> |
36 #include <vector> | 36 #include <vector> |
37 | 37 |
38 #include "base/basictypes.h" | 38 #include "base/basictypes.h" |
39 #include "base/command_line.h" | 39 #include "base/command_line.h" |
40 #include "base/file_util.h" | |
41 #include "base/files/file_path.h" | 40 #include "base/files/file_path.h" |
| 41 #include "base/files/file_util.h" |
42 #include "base/logging.h" | 42 #include "base/logging.h" |
43 #include "base/numerics/safe_conversions.h" | 43 #include "base/numerics/safe_conversions.h" |
44 #include "base/strings/stringprintf.h" | 44 #include "base/strings/stringprintf.h" |
45 #include "third_party/icu/source/common/unicode/utf8.h" | 45 #include "third_party/icu/source/common/unicode/utf8.h" |
46 | 46 |
47 namespace { | 47 namespace { |
48 | 48 |
49 const char kHelpText[] = | 49 const char kHelpText[] = |
50 "Usage: build_utf8_validator_tables [ --help ] [ --output=<file> ]\n"; | 50 "Usage: build_utf8_validator_tables [ --help ] [ --output=<file> ]\n"; |
51 | 51 |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 PrintStates(states, output); | 457 PrintStates(states, output); |
458 | 458 |
459 if (!filename.empty()) { | 459 if (!filename.empty()) { |
460 if (!base::CloseFile(output)) | 460 if (!base::CloseFile(output)) |
461 PLOG(FATAL) << "Couldn't finish writing '" << filename.AsUTF8Unsafe() | 461 PLOG(FATAL) << "Couldn't finish writing '" << filename.AsUTF8Unsafe() |
462 << "'"; | 462 << "'"; |
463 } | 463 } |
464 | 464 |
465 return EXIT_SUCCESS; | 465 return EXIT_SUCCESS; |
466 } | 466 } |
OLD | NEW |