OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <vector> | 5 #include <vector> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 bool WideStringToInt(const std::wstring& str, int *output) { | 342 bool WideStringToInt(const std::wstring& str, int *output) { |
343 string16 copy(str.begin(), str.end()); | 343 string16 copy(str.begin(), str.end()); |
344 return StringToInt(copy, output); | 344 return StringToInt(copy, output); |
345 } | 345 } |
346 | 346 |
347 int main(int argc, const char* argv[]) { | 347 int main(int argc, const char* argv[]) { |
348 base::AtExitManager at_exit_manager; | 348 base::AtExitManager at_exit_manager; |
349 CommandLine::Init(argc, argv); | 349 CommandLine::Init(argc, argv); |
350 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 350 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
351 | 351 |
352 bool cmd_dis = command_line.HasSwitch(L"dis"); | 352 bool cmd_dis = command_line.HasSwitch("dis"); |
353 bool cmd_asm = command_line.HasSwitch(L"asm"); | 353 bool cmd_asm = command_line.HasSwitch("asm"); |
354 bool cmd_disadj = command_line.HasSwitch(L"disadj"); | 354 bool cmd_disadj = command_line.HasSwitch("disadj"); |
355 bool cmd_make_patch = command_line.HasSwitch(L"gen"); | 355 bool cmd_make_patch = command_line.HasSwitch("gen"); |
356 bool cmd_apply_patch = command_line.HasSwitch(L"apply"); | 356 bool cmd_apply_patch = command_line.HasSwitch("apply"); |
357 bool cmd_make_bsdiff_patch = command_line.HasSwitch(L"genbsdiff"); | 357 bool cmd_make_bsdiff_patch = command_line.HasSwitch("genbsdiff"); |
358 bool cmd_apply_bsdiff_patch = command_line.HasSwitch(L"applybsdiff"); | 358 bool cmd_apply_bsdiff_patch = command_line.HasSwitch("applybsdiff"); |
359 bool cmd_spread_1_adjusted = command_line.HasSwitch(L"gen1a"); | 359 bool cmd_spread_1_adjusted = command_line.HasSwitch("gen1a"); |
360 bool cmd_spread_1_unadjusted = command_line.HasSwitch(L"gen1u"); | 360 bool cmd_spread_1_unadjusted = command_line.HasSwitch("gen1u"); |
361 | 361 |
362 std::vector<std::wstring> values = command_line.GetLooseValues(); | 362 std::vector<std::wstring> values = command_line.GetLooseValues(); |
363 | 363 |
364 // '-repeat=N' is for debugging. Running many iterations can reveal leaks and | 364 // '-repeat=N' is for debugging. Running many iterations can reveal leaks and |
365 // bugs in cleanup. | 365 // bugs in cleanup. |
366 int repeat_count = 1; | 366 int repeat_count = 1; |
367 std::wstring repeat_switch = command_line.GetSwitchValue(L"repeat"); | 367 std::wstring repeat_switch = command_line.GetSwitchValue("repeat"); |
368 if (!repeat_switch.empty()) | 368 if (!repeat_switch.empty()) |
369 if (!WideStringToInt(repeat_switch, &repeat_count)) | 369 if (!WideStringToInt(repeat_switch, &repeat_count)) |
370 repeat_count = 1; | 370 repeat_count = 1; |
371 | 371 |
372 if (cmd_dis + cmd_asm + cmd_disadj + cmd_make_patch + cmd_apply_patch + | 372 if (cmd_dis + cmd_asm + cmd_disadj + cmd_make_patch + cmd_apply_patch + |
373 cmd_make_bsdiff_patch + cmd_apply_bsdiff_patch + | 373 cmd_make_bsdiff_patch + cmd_apply_bsdiff_patch + |
374 cmd_spread_1_adjusted + cmd_spread_1_unadjusted | 374 cmd_spread_1_adjusted + cmd_spread_1_unadjusted |
375 != 1) | 375 != 1) |
376 UsageProblem( | 376 UsageProblem( |
377 "Must have exactly one of:\n" | 377 "Must have exactly one of:\n" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 } else if (cmd_spread_1_adjusted || cmd_spread_1_unadjusted) { | 409 } else if (cmd_spread_1_adjusted || cmd_spread_1_unadjusted) { |
410 if (values.size() != 3) | 410 if (values.size() != 3) |
411 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); | 411 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); |
412 DisassembleAdjustDiff(values[0], values[1], values[2], | 412 DisassembleAdjustDiff(values[0], values[1], values[2], |
413 cmd_spread_1_adjusted); | 413 cmd_spread_1_adjusted); |
414 } else { | 414 } else { |
415 UsageProblem("No operation specified"); | 415 UsageProblem("No operation specified"); |
416 } | 416 } |
417 } | 417 } |
418 } | 418 } |
OLD | NEW |