aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/patch.c20
-rw-r--r--editors/patch_toybox.c7
-rw-r--r--editors/sed.c5
3 files changed, 23 insertions, 9 deletions
diff --git a/editors/patch.c b/editors/patch.c
index 988021d77..731a8c58a 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -247,7 +247,7 @@ static int apply_one_hunk(void)
247 // Figure out which line of hunk to compare with next. (Skip lines 247 // Figure out which line of hunk to compare with next. (Skip lines
248 // of the hunk we'd be adding.) 248 // of the hunk we'd be adding.)
249 while (plist && *plist->data == "+-"[reverse]) { 249 while (plist && *plist->data == "+-"[reverse]) {
250 if (data && !strcmp(data, plist->data+1)) { 250 if (data && strcmp(data, plist->data+1) == 0) {
251 if (!backwarn) { 251 if (!backwarn) {
252 backwarn = TT.linenum; 252 backwarn = TT.linenum;
253 if (option_mask32 & FLAG_IGNORE) { 253 if (option_mask32 & FLAG_IGNORE) {
@@ -290,12 +290,24 @@ static int apply_one_hunk(void)
290 // out of buffer. 290 // out of buffer.
291 291
292 for (;;) { 292 for (;;) {
293 while (plist && *plist->data == "+-"[reverse]) {
294 if (strcmp(check->data, plist->data+1) == 0
295 && !backwarn
296 ) {
297 backwarn = TT.linenum;
298 if (option_mask32 & FLAG_IGNORE) {
299 dummy_revert = 1;
300 reverse ^= 1;
301 }
302 }
303 plist = plist->next;
304 }
293 if (!plist || strcmp(check->data, plist->data+1)) { 305 if (!plist || strcmp(check->data, plist->data+1)) {
294 // Match failed. Write out first line of buffered data and 306 // Match failed. Write out first line of buffered data and
295 // recheck remaining buffered data for a new match. 307 // recheck remaining buffered data for a new match.
296 308
297 if (PATCH_DEBUG) 309 if (PATCH_DEBUG)
298 fdprintf(2, "NOT: %s\n", plist->data); 310 fdprintf(2, "NOT: %s\n", plist ? plist->data : "EOF");
299 311
300 TT.state = 3; 312 TT.state = 3;
301 check = buf; 313 check = buf;
@@ -480,7 +492,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
480 492
481 // We're deleting oldname if new file is /dev/null (before -p) 493 // We're deleting oldname if new file is /dev/null (before -p)
482 // or if new hunk is empty (zero context) after patching 494 // or if new hunk is empty (zero context) after patching
483 if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum)) { 495 if (strcmp(name, "/dev/null") == 0 || !(reverse ? oldsum : newsum)) {
484 name = reverse ? newname : oldname; 496 name = reverse ? newname : oldname;
485 empty = 1; 497 empty = 1;
486 } 498 }
@@ -516,7 +528,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
516 struct stat statbuf; 528 struct stat statbuf;
517 529
518 // If the old file was null, we're creating a new one. 530 // If the old file was null, we're creating a new one.
519 if (!strcmp(oldname, "/dev/null") || !oldsum) { 531 if (strcmp(oldname, "/dev/null") == 0 || !oldsum) {
520 printf("creating %s\n", name); 532 printf("creating %s\n", name);
521 s = strrchr(name, '/'); 533 s = strrchr(name, '/');
522 if (s) { 534 if (s) {
diff --git a/editors/patch_toybox.c b/editors/patch_toybox.c
index a60bf070f..5174acd6a 100644
--- a/editors/patch_toybox.c
+++ b/editors/patch_toybox.c
@@ -335,7 +335,7 @@ static int apply_one_hunk(void)
335 // Figure out which line of hunk to compare with next. (Skip lines 335 // Figure out which line of hunk to compare with next. (Skip lines
336 // of the hunk we'd be adding.) 336 // of the hunk we'd be adding.)
337 while (plist && *plist->data == "+-"[reverse]) { 337 while (plist && *plist->data == "+-"[reverse]) {
338 if (data && !strcmp(data, plist->data+1)) { 338 if (data && strcmp(data, plist->data+1) == 0) {
339 if (!backwarn) { 339 if (!backwarn) {
340 fdprintf(2,"Possibly reversed hunk %d at %ld\n", 340 fdprintf(2,"Possibly reversed hunk %d at %ld\n",
341 TT.hunknum, TT.linenum); 341 TT.hunknum, TT.linenum);
@@ -529,8 +529,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
529 529
530 // We're deleting oldname if new file is /dev/null (before -p) 530 // We're deleting oldname if new file is /dev/null (before -p)
531 // or if new hunk is empty (zero context) after patching 531 // or if new hunk is empty (zero context) after patching
532 if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum)) 532 if (strcmp(name, "/dev/null") == 0 || !(reverse ? oldsum : newsum)) {
533 {
534 name = reverse ? newname : oldname; 533 name = reverse ? newname : oldname;
535 del++; 534 del++;
536 } 535 }
@@ -551,7 +550,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
551 // If we've got a file to open, do so. 550 // If we've got a file to open, do so.
552 } else if (!(option_mask32 & FLAG_PATHLEN) || i <= TT.prefix) { 551 } else if (!(option_mask32 & FLAG_PATHLEN) || i <= TT.prefix) {
553 // If the old file was null, we're creating a new one. 552 // If the old file was null, we're creating a new one.
554 if (!strcmp(oldname, "/dev/null") || !oldsum) { 553 if (strcmp(oldname, "/dev/null") == 0 || !oldsum) {
555 printf("creating %s\n", name); 554 printf("creating %s\n", name);
556 s = strrchr(name, '/'); 555 s = strrchr(name, '/');
557 if (s) { 556 if (s) {
diff --git a/editors/sed.c b/editors/sed.c
index 63ca1dc99..86230ea42 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -892,7 +892,10 @@ static sed_cmd_t *branch_to(char *label)
892 sed_cmd_t *sed_cmd; 892 sed_cmd_t *sed_cmd;
893 893
894 for (sed_cmd = G.sed_cmd_head; sed_cmd; sed_cmd = sed_cmd->next) { 894 for (sed_cmd = G.sed_cmd_head; sed_cmd; sed_cmd = sed_cmd->next) {
895 if (sed_cmd->cmd == ':' && sed_cmd->string && !strcmp(sed_cmd->string, label)) { 895 if (sed_cmd->cmd == ':'
896 && sed_cmd->string
897 && strcmp(sed_cmd->string, label) == 0
898 ) {
896 return sed_cmd; 899 return sed_cmd;
897 } 900 }
898 } 901 }