| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stdio.h> | 5 #include <stdio.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (!editor_ptr) | 204 if (!editor_ptr) |
| 205 editor_ptr = "vi"; | 205 editor_ptr = "vi"; |
| 206 | 206 |
| 207 std::string cmd(editor_ptr); | 207 std::string cmd(editor_ptr); |
| 208 cmd.append(" \""); | 208 cmd.append(" \""); |
| 209 | 209 |
| 210 // Its impossible to do this properly since we don't know the user's shell, | 210 // Its impossible to do this properly since we don't know the user's shell, |
| 211 // but quoting and escaping internal quotes should handle 99.999% of all | 211 // but quoting and escaping internal quotes should handle 99.999% of all |
| 212 // cases. | 212 // cases. |
| 213 std::string escaped_name = file_to_edit.value(); | 213 std::string escaped_name = file_to_edit.value(); |
| 214 ReplaceSubstringsAfterOffset(&escaped_name, 0, "\"", "\\\""); | 214 base::ReplaceSubstringsAfterOffset(&escaped_name, 0, "\"", "\\\""); |
| 215 cmd.append(escaped_name); | 215 cmd.append(escaped_name); |
| 216 cmd.push_back('"'); | 216 cmd.push_back('"'); |
| 217 | 217 |
| 218 OutputString("Waiting for editor on \"" + file_to_edit.value() + | 218 OutputString("Waiting for editor on \"" + file_to_edit.value() + |
| 219 "\"...\n"); | 219 "\"...\n"); |
| 220 return system(cmd.c_str()) == 0; | 220 return system(cmd.c_str()) == 0; |
| 221 } | 221 } |
| 222 | 222 |
| 223 #endif | 223 #endif |
| 224 | 224 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 243 if (!base::PathExists(arg_file)) { | 243 if (!base::PathExists(arg_file)) { |
| 244 std::string argfile_default_contents = | 244 std::string argfile_default_contents = |
| 245 "# Build arguments go here. Examples:\n" | 245 "# Build arguments go here. Examples:\n" |
| 246 "# is_component_build = true\n" | 246 "# is_component_build = true\n" |
| 247 "# is_debug = false\n" | 247 "# is_debug = false\n" |
| 248 "# See \"gn args <out_dir> --list\" for available build " | 248 "# See \"gn args <out_dir> --list\" for available build " |
| 249 "arguments.\n"; | 249 "arguments.\n"; |
| 250 #if defined(OS_WIN) | 250 #if defined(OS_WIN) |
| 251 // Use Windows lineendings for this file since it will often open in | 251 // Use Windows lineendings for this file since it will often open in |
| 252 // Notepad which can't handle Unix ones. | 252 // Notepad which can't handle Unix ones. |
| 253 ReplaceSubstringsAfterOffset(&argfile_default_contents, 0, "\n", "\r\n"); | 253 base::ReplaceSubstringsAfterOffset( |
| 254 &argfile_default_contents, 0, "\n", "\r\n"); |
| 254 #endif | 255 #endif |
| 255 base::CreateDirectory(arg_file.DirName()); | 256 base::CreateDirectory(arg_file.DirName()); |
| 256 base::WriteFile(arg_file, argfile_default_contents.c_str(), | 257 base::WriteFile(arg_file, argfile_default_contents.c_str(), |
| 257 static_cast<int>(argfile_default_contents.size())); | 258 static_cast<int>(argfile_default_contents.size())); |
| 258 } | 259 } |
| 259 | 260 |
| 260 ScopedTrace editor_trace(TraceItem::TRACE_SETUP, "Waiting for editor"); | 261 ScopedTrace editor_trace(TraceItem::TRACE_SETUP, "Waiting for editor"); |
| 261 if (!RunEditor(arg_file)) | 262 if (!RunEditor(arg_file)) |
| 262 return 1; | 263 return 1; |
| 263 } | 264 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 "Or see \"gn help args\" for more variants.").PrintToStdout(); | 340 "Or see \"gn help args\" for more variants.").PrintToStdout(); |
| 340 return 1; | 341 return 1; |
| 341 } | 342 } |
| 342 | 343 |
| 343 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList)) | 344 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList)) |
| 344 return ListArgs(args[0]); | 345 return ListArgs(args[0]); |
| 345 return EditArgsFile(args[0]); | 346 return EditArgsFile(args[0]); |
| 346 } | 347 } |
| 347 | 348 |
| 348 } // namespace commands | 349 } // namespace commands |
| OLD | NEW |