| OLD | NEW |
| 1 // Copyright 2008 Google Inc. All Rights Reserved. | 1 // Copyright 2008 Google Inc. All Rights Reserved. |
| 2 | 2 |
| 3 #include "third_party/hunspell/google/bdict_writer.h" | 3 #include "third_party/hunspell/google/bdict_writer.h" |
| 4 | 4 |
| 5 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "third_party/hunspell/google/bdict.h" | 7 #include "third_party/hunspell/google/bdict.h" |
| 8 | 8 |
| 9 namespace hunspell { | 9 namespace hunspell { |
| 10 | 10 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 457 |
| 458 // Fill the header last, now that we have the data. | 458 // Fill the header last, now that we have the data. |
| 459 hunspell::BDict::Header* header = | 459 hunspell::BDict::Header* header = |
| 460 reinterpret_cast<hunspell::BDict::Header*>(&ret[0]); | 460 reinterpret_cast<hunspell::BDict::Header*>(&ret[0]); |
| 461 header->signature = hunspell::BDict::SIGNATURE; | 461 header->signature = hunspell::BDict::SIGNATURE; |
| 462 header->major_version = hunspell::BDict::MAJOR_VERSION; | 462 header->major_version = hunspell::BDict::MAJOR_VERSION; |
| 463 header->minor_version = hunspell::BDict::MINOR_VERSION; | 463 header->minor_version = hunspell::BDict::MINOR_VERSION; |
| 464 header->aff_offset = static_cast<uint32>(aff_offset); | 464 header->aff_offset = static_cast<uint32>(aff_offset); |
| 465 header->dic_offset = static_cast<uint32>(dic_offset); | 465 header->dic_offset = static_cast<uint32>(dic_offset); |
| 466 | 466 |
| 467 // Write the MD5 digest of the affix information and the dictionary words at |
| 468 // the end of the BDic header. |
| 469 if (header->major_version >= 2) |
| 470 MD5Sum(&ret[aff_offset], ret.size() - aff_offset, &header->digest); |
| 471 |
| 467 return ret; | 472 return ret; |
| 468 } | 473 } |
| 469 | 474 |
| 470 void BDictWriter::SerializeAff(std::string* output) const { | 475 void BDictWriter::SerializeAff(std::string* output) const { |
| 471 // Reserve enough room for the header. | 476 // Reserve enough room for the header. |
| 472 size_t header_offset = output->size(); | 477 size_t header_offset = output->size(); |
| 473 output->resize(output->size() + sizeof(hunspell::BDict::AffHeader)); | 478 output->resize(output->size() + sizeof(hunspell::BDict::AffHeader)); |
| 474 | 479 |
| 475 // Write the comment. | 480 // Write the comment. |
| 476 output->push_back('\n'); | 481 output->push_back('\n'); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 495 // Add the header now that we know the offsets. | 500 // Add the header now that we know the offsets. |
| 496 hunspell::BDict::AffHeader* header = | 501 hunspell::BDict::AffHeader* header = |
| 497 reinterpret_cast<hunspell::BDict::AffHeader*>(&(*output)[header_offset]); | 502 reinterpret_cast<hunspell::BDict::AffHeader*>(&(*output)[header_offset]); |
| 498 header->affix_group_offset = static_cast<uint32>(affix_group_offset); | 503 header->affix_group_offset = static_cast<uint32>(affix_group_offset); |
| 499 header->affix_rule_offset = static_cast<uint32>(affix_rule_offset); | 504 header->affix_rule_offset = static_cast<uint32>(affix_rule_offset); |
| 500 header->rep_offset = static_cast<uint32>(rep_offset); | 505 header->rep_offset = static_cast<uint32>(rep_offset); |
| 501 header->other_offset = static_cast<uint32>(other_offset); | 506 header->other_offset = static_cast<uint32>(other_offset); |
| 502 } | 507 } |
| 503 | 508 |
| 504 } // namespace hunspell | 509 } // namespace hunspell |
| OLD | NEW |