Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: chrome/tools/convert_dict/hunspell_reader.cc

Issue 165297: Replaces some TrimWhitespace with TrimWhitespaceASCII or TrimWhitespaceUTF8.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: hunspell fix Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/selenium/selenium_test.cc ('k') | webkit/activex_shim/activex_shared.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/hunspell_reader.h" 5 #include "chrome/tools/convert_dict/hunspell_reader.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 8
9 namespace convert_dict { 9 namespace convert_dict {
10 10
11 // This silly 64K buffer is just copied from Hunspell's way of parsing. 11 // This silly 64K buffer is just copied from Hunspell's way of parsing.
12 const int kLineBufferLen = 65535; 12 const int kLineBufferLen = 65535;
13 char line_buffer[kLineBufferLen]; 13 char line_buffer[kLineBufferLen];
14 14
15 // Shortcut for trimming whitespace from both ends of the line. 15 // Shortcut for trimming whitespace from both ends of the line.
16 void TrimLine(std::string* line) { 16 void TrimLine(std::string* line) {
17 if (line->size() > 3 && 17 if (line->size() > 3 &&
18 static_cast<unsigned char>((*line)[0]) == 0xef && 18 static_cast<unsigned char>((*line)[0]) == 0xef &&
19 static_cast<unsigned char>((*line)[1]) == 0xbb && 19 static_cast<unsigned char>((*line)[1]) == 0xbb &&
20 static_cast<unsigned char>((*line)[2]) == 0xbf) 20 static_cast<unsigned char>((*line)[2]) == 0xbf)
21 *line = line->substr(3); 21 *line = line->substr(3);
22 22
23 TrimWhitespace(*line, TRIM_ALL, line); 23 TrimWhitespaceUTF8(*line, TRIM_ALL, line);
24 } 24 }
25 25
26 std::string ReadLine(FILE* file) { 26 std::string ReadLine(FILE* file) {
27 const char* line = fgets(line_buffer, kLineBufferLen - 1, file); 27 const char* line = fgets(line_buffer, kLineBufferLen - 1, file);
28 if (!line) 28 if (!line)
29 return std::string(); 29 return std::string();
30 30
31 std::string str = line; 31 std::string str = line;
32 TrimLine(&str); 32 TrimLine(&str);
33 return str; 33 return str;
34 } 34 }
35 35
36 void StripComment(std::string* line) { 36 void StripComment(std::string* line) {
37 for (size_t i = 0; i < line->size(); i++) { 37 for (size_t i = 0; i < line->size(); i++) {
38 if ((*line)[i] == '#') { 38 if ((*line)[i] == '#') {
39 line->resize(i); 39 line->resize(i);
40 TrimLine(line); 40 TrimLine(line);
41 return; 41 return;
42 } 42 }
43 } 43 }
44 } 44 }
45 45
46 } // namespace convert_dict 46 } // namespace convert_dict
OLDNEW
« no previous file with comments | « chrome/test/selenium/selenium_test.cc ('k') | webkit/activex_shim/activex_shared.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698