Chromium Code Reviews| Index: tools/gn/command_args.cc |
| diff --git a/tools/gn/command_args.cc b/tools/gn/command_args.cc |
| index ad1a59699d00aa6fddb14f786f90ab4da5ae3d1a..b5b6eb7c60327a9a7a8ef10b6718c61d17afd42f 100644 |
| --- a/tools/gn/command_args.cc |
| +++ b/tools/gn/command_args.cc |
| @@ -42,12 +42,18 @@ size_t BackUpToLineBegin(const std::string& data, size_t offset) { |
| return 0; |
| } |
| -// Assumes DoesLineBeginWithComment(). |
| -std::string StripCommentFromLine(const base::StringPiece& line) { |
| - std::string ret = line.as_string(); |
| - for (size_t i = 0; i < ret.size(); i++) { |
| - if (ret[i] == '#') { |
| - ret[i] = ' '; |
| +// Assumes DoesLineBeginWithComment(), this strips the # character from the |
| +// beginning and normalizes preceeding whitespace. |
| +std::string StripHashFromLine(const base::StringPiece& line) { |
| + std::string ret; |
|
viettrungluu
2014/02/12 23:09:35
Can't this just be something like:
return " " +
|
| + for (size_t i = 0; i < line.size(); i++) { |
| + if (line[i] == '#') { |
| + // Replace the # sign and everything before it with 3 spaces, so that |
| + // a normal comment that has a space after the # will be indented 4 |
| + // spaces (which makes our formatting come out nicely). If the comment is |
| + // indented from there, we want to preserve that indenting. |
| + ret.assign(" "); |
| + ret.append(line.substr(i + 1).as_string()); |
| break; |
| } |
| } |
| @@ -79,7 +85,7 @@ void GetContextForValue(const Value& value, |
| if (!DoesLineBeginWithComment(line)) |
| break; |
| - comment->insert(0, StripCommentFromLine(line) + "\n"); |
| + comment->insert(0, StripHashFromLine(line) + "\n"); |
| line_off = previous_line_offset; |
| } |
| } |
| @@ -150,6 +156,12 @@ int RunArgs(const std::vector<std::string>& args) { |
| i != build_args.end(); ++i) |
| sorted_args.insert(*i); |
| + OutputString( |
| + "Available build arguments. Note that the which arguments are declared\n" |
| + "and their default values may depend on other arguments or the current\n" |
| + "platform and architecture. So setting some values may add, remove, or\n" |
| + "change the default value of other values.\n\n"); |
| + |
| for (std::map<base::StringPiece, Value>::iterator i = sorted_args.begin(); |
| i != sorted_args.end(); ++i) { |
| PrintArgHelp(i->first, i->second); |