OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "chrome/tools/convert_dict/dic_reader.h" | 5 #include "chrome/tools/convert_dict/dic_reader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 if (file_has_word_count_in_the_first_line) { | 65 if (file_has_word_count_in_the_first_line) { |
66 // Skip the first nonempty line, this is the line count. We don't bother | 66 // Skip the first nonempty line, this is the line count. We don't bother |
67 // with it and just read all the lines. | 67 // with it and just read all the lines. |
68 file_has_word_count_in_the_first_line = false; | 68 file_has_word_count_in_the_first_line = false; |
69 continue; | 69 continue; |
70 } | 70 } |
71 | 71 |
72 std::vector<std::string> split; | 72 std::vector<std::string> split; |
73 SplitDicLine(line, &split); | 73 SplitDicLine(line, &split); |
74 if (split.size() == 0 || split.size() > 2) { | 74 if (split.empty() || split.size() > 2) { |
75 printf("Line %d has extra slashes in the %s file\n", line_number, | 75 printf("Line %d has extra slashes in the %s file\n", line_number, |
76 file_type); | 76 file_type); |
77 return false; | 77 return false; |
78 } | 78 } |
79 | 79 |
80 // The first part is the word, the second (optional) part is the affix. We | 80 // The first part is the word, the second (optional) part is the affix. We |
81 // always use UTF-8 as the encoding to simplify life. | 81 // always use UTF-8 as the encoding to simplify life. |
82 std::string utf8word; | 82 std::string utf8word; |
83 std::string encoding_string(encoding); | 83 std::string encoding_string(encoding); |
84 if (encoding_string == "UTF-8") { | 84 if (encoding_string == "UTF-8") { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 std::sort(affixes.begin(), affixes.end()); | 181 std::sort(affixes.begin(), affixes.end()); |
182 words_.push_back(std::make_pair(word->first, affixes)); | 182 words_.push_back(std::make_pair(word->first, affixes)); |
183 } | 183 } |
184 | 184 |
185 // Double-check that the words are sorted. | 185 // Double-check that the words are sorted. |
186 std::sort(words_.begin(), words_.end()); | 186 std::sort(words_.begin(), words_.end()); |
187 return true; | 187 return true; |
188 } | 188 } |
189 | 189 |
190 } // namespace convert_dict | 190 } // namespace convert_dict |
OLD | NEW |