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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 OutputString("Waiting for editor on \"" + FilePathToUTF8(file_to_edit) + | 191 OutputString("Waiting for editor on \"" + FilePathToUTF8(file_to_edit) + |
192 "\"...\n"); | 192 "\"...\n"); |
193 ::WaitForSingleObject(info.hProcess, INFINITE); | 193 ::WaitForSingleObject(info.hProcess, INFINITE); |
194 ::CloseHandle(info.hProcess); | 194 ::CloseHandle(info.hProcess); |
195 } | 195 } |
196 return true; | 196 return true; |
197 } | 197 } |
198 | 198 |
199 #else // POSIX | 199 #else // POSIX |
200 | 200 |
201 void RunEditor(const base::FilePath& file_to_edit) { | 201 bool RunEditor(const base::FilePath& file_to_edit) { |
202 // Prefer $VISUAL, then $EDITOR, then vi. | 202 // Prefer $VISUAL, then $EDITOR, then vi. |
203 const char* editor_ptr = getenv("VISUAL"); | 203 const char* editor_ptr = getenv("VISUAL"); |
204 if (!editor_ptr) | 204 if (!editor_ptr) |
205 editor_ptr = getenv("EDITOR"); | 205 editor_ptr = getenv("EDITOR"); |
206 if (!editor_ptr) | 206 if (!editor_ptr) |
207 editor_ptr = "vi"; | 207 editor_ptr = "vi"; |
208 | 208 |
209 std::string cmd(editor_ptr); | 209 std::string cmd(editor_ptr); |
210 cmd.append(" \""); | 210 cmd.append(" \""); |
211 | 211 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 "Or see \"gn help args\" for more variants.").PrintToStdout(); | 338 "Or see \"gn help args\" for more variants.").PrintToStdout(); |
339 return 1; | 339 return 1; |
340 } | 340 } |
341 | 341 |
342 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList)) | 342 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList)) |
343 return ListArgs(args[0]); | 343 return ListArgs(args[0]); |
344 return EditArgsFile(args[0]); | 344 return EditArgsFile(args[0]); |
345 } | 345 } |
346 | 346 |
347 } // namespace commands | 347 } // namespace commands |
OLD | NEW |