| 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/string_util.h" | 11 #include "base/string_util.h" |
| 11 #include "chrome/tools/convert_dict/aff_reader.h" | 12 #include "chrome/tools/convert_dict/aff_reader.h" |
| 12 #include "chrome/tools/convert_dict/hunspell_reader.h" | 13 #include "chrome/tools/convert_dict/hunspell_reader.h" |
| 13 | 14 |
| 14 namespace convert_dict { | 15 namespace convert_dict { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // Maps each unique word to the unique affix group IDs associated with it. | 19 // Maps each unique word to the unique affix group IDs associated with it. |
| 19 typedef std::map<std::string, std::set<int> > WordSet; | 20 typedef std::map<std::string, std::set<int> > WordSet; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 38 output->push_back(word); | 39 output->push_back(word); |
| 39 | 40 |
| 40 // Everything (if anything) after the slash is the second. | 41 // Everything (if anything) after the slash is the second. |
| 41 if (slash_index < line.size() - 1) | 42 if (slash_index < line.size() - 1) |
| 42 output->push_back(line.substr(slash_index + 1)); | 43 output->push_back(line.substr(slash_index + 1)); |
| 43 } | 44 } |
| 44 | 45 |
| 45 } // namespace | 46 } // namespace |
| 46 | 47 |
| 47 DicReader::DicReader(const std::string& filename) { | 48 DicReader::DicReader(const std::string& filename) { |
| 48 fopen_s(&file_, filename.c_str(), "r"); | 49 file_ = file_util::OpenFile(filename, "r"); |
| 49 } | 50 } |
| 50 | 51 |
| 51 DicReader::~DicReader() { | 52 DicReader::~DicReader() { |
| 52 if (file_) | 53 if (file_) |
| 53 fclose(file_); | 54 file_util::CloseFile(file_); |
| 54 } | 55 } |
| 55 | 56 |
| 56 bool DicReader::Read(AffReader* aff_reader) { | 57 bool DicReader::Read(AffReader* aff_reader) { |
| 57 if (!file_) | 58 if (!file_) |
| 58 return false; | 59 return false; |
| 59 | 60 |
| 60 bool got_count = false; | 61 bool got_count = false; |
| 61 int line_number = 0; | 62 int line_number = 0; |
| 62 | 63 |
| 63 WordSet word_set; | 64 WordSet word_set; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 words_.push_back(std::make_pair(word->first, affixes)); | 133 words_.push_back(std::make_pair(word->first, affixes)); |
| 133 } | 134 } |
| 134 | 135 |
| 135 // Double-check that the words are sorted. | 136 // Double-check that the words are sorted. |
| 136 std::sort(words_.begin(), words_.end()); | 137 std::sort(words_.begin(), words_.end()); |
| 137 return true; | 138 return true; |
| 138 } | 139 } |
| 139 | 140 |
| 140 } // namespace convert_dict | 141 } // namespace convert_dict |
| 141 | 142 |
| OLD | NEW |