OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
6 #include "chrome/browser/spellchecker.h" | 6 #include "chrome/browser/spellchecker.h" |
7 #include "chrome/browser/spellchecker_common.h" | 7 #include "chrome/browser/spellchecker_common.h" |
8 #include "chrome/browser/spellchecker_platform_engine.h" | 8 #include "chrome/browser/spellchecker_platform_engine.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 return; | 540 return; |
541 | 541 |
542 int word_length = static_cast<int>(word.size()); | 542 int word_length = static_cast<int>(word.size()); |
543 if (word_length < 2 || word_length > kMaxAutoCorrectWordSize) | 543 if (word_length < 2 || word_length > kMaxAutoCorrectWordSize) |
544 return; | 544 return; |
545 | 545 |
546 wchar_t misspelled_word[kMaxAutoCorrectWordSize + 1]; | 546 wchar_t misspelled_word[kMaxAutoCorrectWordSize + 1]; |
547 const wchar_t* word_char = word.c_str(); | 547 const wchar_t* word_char = word.c_str(); |
548 for (int i = 0; i <= kMaxAutoCorrectWordSize; i++) { | 548 for (int i = 0; i <= kMaxAutoCorrectWordSize; i++) { |
549 if (i >= word_length) | 549 if (i >= word_length) |
550 misspelled_word[i] = 0; | 550 misspelled_word[i] = NULL; |
551 else | 551 else |
552 misspelled_word[i] = word_char[i]; | 552 misspelled_word[i] = word_char[i]; |
553 } | 553 } |
554 | 554 |
555 // Swap adjacent characters and spellcheck. | 555 // Swap adjacent characters and spellcheck. |
556 int misspelling_start, misspelling_len; | 556 int misspelling_start, misspelling_len; |
557 for (int i = 0; i < word_length - 1; i++) { | 557 for (int i = 0; i < word_length - 1; i++) { |
558 // Swap. | 558 // Swap. |
559 std::swap(misspelled_word[i], misspelled_word[i + 1]); | 559 std::swap(misspelled_word[i], misspelled_word[i + 1]); |
560 | 560 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 | 771 |
772 // Populate the vector of WideStrings. | 772 // Populate the vector of WideStrings. |
773 for (int i = 0; i < number_of_suggestions; i++) { | 773 for (int i = 0; i < number_of_suggestions; i++) { |
774 if (i < kMaxSuggestions) | 774 if (i < kMaxSuggestions) |
775 optional_suggestions->push_back(UTF8ToWide(suggestions[i])); | 775 optional_suggestions->push_back(UTF8ToWide(suggestions[i])); |
776 free(suggestions[i]); | 776 free(suggestions[i]); |
777 } | 777 } |
778 if (suggestions != NULL) | 778 if (suggestions != NULL) |
779 free(suggestions); | 779 free(suggestions); |
780 } | 780 } |
OLD | NEW |