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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 Problem("Can't serialize encoded program."); | 210 Problem("Can't serialize encoded program."); |
211 courgette::DeleteEncodedProgram(encoded_program); | 211 courgette::DeleteEncodedProgram(encoded_program); |
212 | 212 |
213 courgette::SinkStreamSet model_sinks; | 213 courgette::SinkStreamSet model_sinks; |
214 const courgette::Status write_model_status = | 214 const courgette::Status write_model_status = |
215 courgette::WriteEncodedProgram(encoded_model, &model_sinks); | 215 courgette::WriteEncodedProgram(encoded_model, &model_sinks); |
216 if (write_model_status != courgette::C_OK) | 216 if (write_model_status != courgette::C_OK) |
217 Problem("Can't serialize encoded model."); | 217 Problem("Can't serialize encoded model."); |
218 courgette::DeleteEncodedProgram(encoded_model); | 218 courgette::DeleteEncodedProgram(encoded_model); |
219 | 219 |
| 220 courgette::SinkStream empty_sink; |
220 for (int i = 0; ; ++i) { | 221 for (int i = 0; ; ++i) { |
221 courgette::SinkStream* old_stream = model_sinks.stream(i); | 222 courgette::SinkStream* old_stream = model_sinks.stream(i); |
222 courgette::SinkStream* new_stream = program_sinks.stream(i); | 223 courgette::SinkStream* new_stream = program_sinks.stream(i); |
223 if (old_stream == NULL && new_stream == NULL) | 224 if (old_stream == NULL && new_stream == NULL) |
224 break; | 225 break; |
225 | 226 |
226 courgette::SourceStream old_source; | 227 courgette::SourceStream old_source; |
227 courgette::SourceStream new_source; | 228 courgette::SourceStream new_source; |
228 old_source.Init(*old_stream); | 229 old_source.Init(old_stream ? *old_stream : empty_sink); |
229 new_source.Init(*new_stream); | 230 new_source.Init(new_stream ? *new_stream : empty_sink); |
230 courgette::SinkStream patch_stream; | 231 courgette::SinkStream patch_stream; |
231 courgette::BSDiffStatus status = | 232 courgette::BSDiffStatus status = |
232 courgette::CreateBinaryPatch(&old_source, &new_source, &patch_stream); | 233 courgette::CreateBinaryPatch(&old_source, &new_source, &patch_stream); |
233 if (status != courgette::OK) Problem("-xxx failed."); | 234 if (status != courgette::OK) Problem("-xxx failed."); |
234 | 235 |
235 WriteSinkToFile(&patch_stream, | 236 WriteSinkToFile(&patch_stream, |
236 output_file_root + L"-" + IntToWString(i)); | 237 output_file_root + L"-" + IntToWString(i)); |
237 } | 238 } |
238 } | 239 } |
239 | 240 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 } else if (cmd_spread_1_adjusted || cmd_spread_1_unadjusted) { | 409 } else if (cmd_spread_1_adjusted || cmd_spread_1_unadjusted) { |
409 if (values.size() != 3) | 410 if (values.size() != 3) |
410 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); | 411 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); |
411 DisassembleAdjustDiff(values[0], values[1], values[2], | 412 DisassembleAdjustDiff(values[0], values[1], values[2], |
412 cmd_spread_1_adjusted); | 413 cmd_spread_1_adjusted); |
413 } else { | 414 } else { |
414 UsageProblem("No operation specified"); | 415 UsageProblem("No operation specified"); |
415 } | 416 } |
416 } | 417 } |
417 } | 418 } |
OLD | NEW |