ntpd: default to FEATURE_NTP_AUTH=y
[oweals/busybox.git] / editors / patch_toybox.c
index 7f3234e66e2c589310584592b13c2d1e0e950a39..2c958d2876b5767f829f51830650a5cb86095b4d 100644 (file)
@@ -26,7 +26,7 @@
 USE_PATCH(NEWTOY(patch, USE_TOYBOX_DEBUG("x")"up#i:R", TOYFLAG_USR|TOYFLAG_BIN))
 
 config PATCH
-       bool "patch"
+       bool "patch (9.1 kb)"
        default y
        help
          usage: patch [-i file] [-p depth] [-Ru]
@@ -335,7 +335,7 @@ static int apply_one_hunk(void)
                // Figure out which line of hunk to compare with next.  (Skip lines
                // of the hunk we'd be adding.)
                while (plist && *plist->data == "+-"[reverse]) {
-                       if (data && !strcmp(data, plist->data+1)) {
+                       if (data && strcmp(data, plist->data+1) == 0) {
                                if (!backwarn) {
                                        fdprintf(2,"Possibly reversed hunk %d at %ld\n",
                                                TT.hunknum, TT.linenum);
@@ -522,15 +522,14 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
                                int oldsum, newsum, del = 0;
                                char *s, *name;
 
-                               oldsum = TT.oldline + TT.oldlen;
+                               oldsum = TT.oldline + TT.oldlen;
                                newsum = TT.newline + TT.newlen;
 
                                name = reverse ? oldname : newname;
 
                                // We're deleting oldname if new file is /dev/null (before -p)
                                // or if new hunk is empty (zero context) after patching
-                               if (!strcmp(name, "/dev/null") || !(reverse ? oldsum : newsum))
-                               {
+                               if (strcmp(name, "/dev/null") == 0 || !(reverse ? oldsum : newsum)) {
                                        name = reverse ? newname : oldname;
                                        del++;
                                }
@@ -551,7 +550,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
                                // If we've got a file to open, do so.
                                } else if (!(option_mask32 & FLAG_PATHLEN) || i <= TT.prefix) {
                                        // If the old file was null, we're creating a new one.
-                                       if (!strcmp(oldname, "/dev/null") || !oldsum) {
+                                       if (strcmp(oldname, "/dev/null") == 0 || !oldsum) {
                                                printf("creating %s\n", name);
                                                s = strrchr(name, '/');
                                                if (s) {
@@ -559,7 +558,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
                                                        xmkpath(name, -1);
                                                        *s = '/';
                                                }
-                                               TT.filein = xopen3(name, O_CREAT|O_EXCL|O_RDWR, 0666);
+                                               TT.filein = xopen(name, O_CREAT|O_EXCL|O_RDWR);
                                        } else {
                                                printf("patching file %s\n", name);
                                                TT.filein = xopen(name, O_RDWR);