| Index: net/tools/tld_cleanup/tld_cleanup.cc
|
| diff --git a/net/tools/tld_cleanup/tld_cleanup.cc b/net/tools/tld_cleanup/tld_cleanup.cc
|
| index a33bce6c38a2539a6ccaed4200f88363cdcb34e0..659584284c2f207c6bcaa926354bf7a5ffda05bb 100644
|
| --- a/net/tools/tld_cleanup/tld_cleanup.cc
|
| +++ b/net/tools/tld_cleanup/tld_cleanup.cc
|
| @@ -38,13 +38,26 @@ typedef std::set<std::string> StringSet;
|
| // been created with write access.
|
| bool WriteRules(const StringSet& rules, FilePath outfile) {
|
| std::string data;
|
| + data.append(
|
| + "// Copyright (c) 2009 The Chromium Authors. All rights reserved.\n"
|
| + "// Use of this source code is governed by a BSD-style license that\n"
|
| + "// can be found in the LICENSE file.\n\n"
|
| + "// This file is generated by net/tools/tld_cleanup/.\n"
|
| + "// DO NOT MANUALLY EDIT!\n"
|
| + "#include \"net/base/registry_controlled_domain.h\"\n\n"
|
| + "const char net::RegistryControlledDomainService::kDomainData[] =\n"
|
| + );
|
| +
|
| for (StringSet::const_iterator iter = rules.begin();
|
| iter != rules.end();
|
| ++iter) {
|
| + data.append(" \"");
|
| data.append(*iter);
|
| - data.append("\n");
|
| + data.append("\\n\"\n");
|
| }
|
|
|
| + data.append(";\n");
|
| +
|
| int written = file_util::WriteFile(outfile.ToWStringHack(), data.data(),
|
| data.size());
|
|
|
| @@ -130,11 +143,11 @@ NormalizeResult NormalizeRule(std::string* rule) {
|
| // Loads the file described by 'in_filename', converts it to the desired format
|
| // (see the file comments above), and saves it into 'out_filename'. Returns
|
| // the most severe of the result codes encountered when normalizing the rules.
|
| -NormalizeResult NormalizeFile(const std::wstring& in_filename,
|
| - const std::wstring& out_filename) {
|
| +NormalizeResult NormalizeFile(const FilePath& in_filename,
|
| + const FilePath& out_filename) {
|
| std::string data;
|
| if (!file_util::ReadFileToString(in_filename, &data)) {
|
| - fwprintf(stderr, L"Unable to read file %ls\n", in_filename.c_str());
|
| + LOG(ERROR) << "Unable to read file";
|
| // We return success since we've already reported the error.
|
| return kSuccess;
|
| }
|
| @@ -181,8 +194,8 @@ NormalizeResult NormalizeFile(const std::wstring& in_filename,
|
| line_start = data.size();
|
| }
|
|
|
| - if (!WriteRules(rules, FilePath::FromWStringHack(out_filename))) {
|
| - LOG(ERROR) << "Error(s) writing " << out_filename;
|
| + if (!WriteRules(rules, out_filename)) {
|
| + LOG(ERROR) << "Error(s) writing output file";
|
| result = kError;
|
| }
|
|
|
| @@ -191,9 +204,9 @@ NormalizeResult NormalizeFile(const std::wstring& in_filename,
|
|
|
| int main(int argc, const char* argv[]) {
|
| base::EnableTerminationOnHeapCorruption();
|
| - if (argc != 3) {
|
| + if (argc != 1) {
|
| fprintf(stderr, "Normalizes and verifies UTF-8 TLD data files\n");
|
| - fprintf(stderr, "Usage: %s <input> <output>\n", argv[0]);
|
| + fprintf(stderr, "Usage: %s\n", argv[0]);
|
| return 1;
|
| }
|
|
|
| @@ -220,8 +233,17 @@ int main(int argc, const char* argv[]) {
|
|
|
| icu_util::Initialize();
|
|
|
| - NormalizeResult result = NormalizeFile(UTF8ToWide(argv[1]),
|
| - UTF8ToWide(argv[2]));
|
| + FilePath input_file;
|
| + PathService::Get(base::DIR_SOURCE_ROOT, &input_file);
|
| + input_file = input_file.Append(FILE_PATH_LITERAL("net"))
|
| + .Append(FILE_PATH_LITERAL("base"))
|
| + .Append(FILE_PATH_LITERAL("effective_tld_names.dat"));
|
| + FilePath output_file;
|
| + PathService::Get(base::DIR_SOURCE_ROOT, &output_file);
|
| + output_file = output_file.Append(FILE_PATH_LITERAL("net"))
|
| + .Append(FILE_PATH_LITERAL("base"))
|
| + .Append(FILE_PATH_LITERAL("effective_tld_names.cc"));
|
| + NormalizeResult result = NormalizeFile(input_file, output_file);
|
| if (result != kSuccess) {
|
| fprintf(stderr,
|
| "Errors or warnings processing file. See log in tld_cleanup.log.");
|
|
|