| 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 // This tool converts Hunspell .aff/.dic pairs to a combined binary dictionary | 5 // This tool converts Hunspell .aff/.dic pairs to a combined binary dictionary |
| 6 // format (.bdic). This format is more compact, and can be more efficiently | 6 // format (.bdic). This format is more compact, and can be more efficiently |
| 7 // read by the client application. | 7 // read by the client application. |
| 8 // | 8 // |
| 9 // We do this conversion manually before publishing dictionary files. It is not | 9 // We do this conversion manually before publishing dictionary files. It is not |
| 10 // part of any build process. | 10 // part of any build process. |
| 11 // | 11 // |
| 12 // See PrintHelp() below for usage. | 12 // See PrintHelp() below for usage. |
| 13 | 13 |
| 14 #include <stdio.h> | 14 #include <stdio.h> |
| 15 | 15 |
| 16 #include "base/icu_util.h" | 16 #include "base/icu_util.h" |
| 17 #include "base/process_util.h" |
| 17 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 18 #include "chrome/third_party/hunspell/google/bdict_reader.h" | 19 #include "chrome/third_party/hunspell/google/bdict_reader.h" |
| 19 #include "chrome/third_party/hunspell/google/bdict_writer.h" | 20 #include "chrome/third_party/hunspell/google/bdict_writer.h" |
| 20 #include "chrome/tools/convert_dict/aff_reader.h" | 21 #include "chrome/tools/convert_dict/aff_reader.h" |
| 21 #include "chrome/tools/convert_dict/dic_reader.h" | 22 #include "chrome/tools/convert_dict/dic_reader.h" |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Compares the given word list with the serialized trie to make sure they | 26 // Compares the given word list with the serialized trie to make sure they |
| 26 // are the same. | 27 // are the same. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 int PrintHelp() { | 63 int PrintHelp() { |
| 63 printf("Usage: convert_dict <dicfile base name>\n\n"); | 64 printf("Usage: convert_dict <dicfile base name>\n\n"); |
| 64 printf("Example:\n convert_dict en-US\nwill read en-US.dic / en-US.aff and\n"
); | 65 printf("Example:\n convert_dict en-US\nwill read en-US.dic / en-US.aff and\n"
); |
| 65 printf("generate en-US.bdic\n\n"); | 66 printf("generate en-US.bdic\n\n"); |
| 66 return 1; | 67 return 1; |
| 67 } | 68 } |
| 68 | 69 |
| 69 } // namespace | 70 } // namespace |
| 70 | 71 |
| 71 int main(int argc, char* argv[]) { | 72 int main(int argc, char* argv[]) { |
| 73 process_util::EnableTerminationOnHeapCorruption(); |
| 72 if (argc != 2) | 74 if (argc != 2) |
| 73 return PrintHelp(); | 75 return PrintHelp(); |
| 74 | 76 |
| 75 icu_util::Initialize(); | 77 icu_util::Initialize(); |
| 76 | 78 |
| 77 std::string file_base = argv[1]; | 79 std::string file_base = argv[1]; |
| 78 | 80 |
| 79 std::string aff_name = file_base + ".aff"; | 81 std::string aff_name = file_base + ".aff"; |
| 80 printf("Reading %s ...\n", aff_name.c_str()); | 82 printf("Reading %s ...\n", aff_name.c_str()); |
| 81 convert_dict::AffReader aff_reader(aff_name.c_str()); | 83 convert_dict::AffReader aff_reader(aff_name.c_str()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 if (!out_file) { | 118 if (!out_file) { |
| 117 printf("ERROR writing file\n"); | 119 printf("ERROR writing file\n"); |
| 118 return 1; | 120 return 1; |
| 119 } | 121 } |
| 120 fwrite(&serialized[0], 1, serialized.size(), out_file); | 122 fwrite(&serialized[0], 1, serialized.size(), out_file); |
| 121 fclose(out_file); | 123 fclose(out_file); |
| 122 | 124 |
| 123 return 0; | 125 return 0; |
| 124 } | 126 } |
| 125 | 127 |
| OLD | NEW |