Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/editors/patch.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/editors/patch.c
r3232 r3621 346 346 // state 2: In hunk: counting initial context lines 347 347 // state 3: In hunk: getting body 348 // Like GNU patch, we don't require a --- line before the +++, and 349 // also allow the --- after the +++ line. 348 350 349 351 int patch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; … … 371 373 } 372 374 } 373 if (argv[0]) {374 oldname = xstrdup(argv[0]);375 newname = xstrdup(argv[0]);376 }377 375 378 376 // Loop through the lines in the patch … … 413 411 414 412 // Open a new file? 415 if ( !strncmp("--- ", patchline, 4) || !strncmp("+++ ", patchline, 4)) {413 if (is_prefixed_with(patchline, "--- ") || is_prefixed_with(patchline, "+++ ")) { 416 414 char *s, **name = reverse ? &newname : &oldname; 417 415 int i; … … 445 443 // Start a new hunk? Usually @@ -oldline,oldlen +newline,newlen @@ 446 444 // but a missing ,value means the value is 1. 447 } else if (state == 1 && !strncmp("@@ -", patchline, 4)) {445 } else if (state == 1 && is_prefixed_with(patchline, "@@ -")) { 448 446 int i; 449 447 char *s = patchline+4; … … 463 461 state = 2; 464 462 463 // If the --- line is missing or malformed, either oldname 464 // or (for -R) newname could be NULL -- but not both. Like 465 // GNU patch, proceed based on the +++ line, and avoid SEGVs. 466 if (!oldname) 467 oldname = xstrdup("MISSING_FILENAME"); 468 if (!newname) 469 newname = xstrdup("MISSING_FILENAME"); 470 465 471 // If this is the first hunk, open the file. 466 472 if (TT.filein == -1) { … … 477 483 if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum)) { 478 484 name = reverse ? newname : oldname; 479 empty ++;485 empty = 1; 480 486 } 481 487 482 // handle -p path truncation.488 // Handle -p path truncation. 483 489 for (i = 0, s = name; *s;) { 484 490 if ((option_mask32 & FLAG_PATHLEN) && TT.prefix == i) … … 491 497 name = s; 492 498 } 499 // If "patch FILE_TO_PATCH", completely ignore name from patch 500 if (argv[0]) 501 name = argv[0]; 493 502 494 503 if (empty) {
Note:
See TracChangeset
for help on using the changeset viewer.