diff options
| author | martin <martin@NetBSD.org> | 2021-02-26 13:29:16 +0000 |
|---|---|---|
| committer | martin <martin@NetBSD.org> | 2021-02-26 13:29:16 +0000 |
| commit | f01d8beb5e00a20bf2d70369594af95500b6eb7d (patch) | |
| tree | d05d4288bbc8a1fce797a2222c34ebfd755b117d /usr.bin/patch/patch.c | |
| parent | 66a44ab683e5ee8903339613333723471db02908 (diff) | |
Pull up following revision(s) (requested by nia in ticket #1215):
usr.bin/patch/backupfile.c: revision 1.16
usr.bin/patch/backupfile.h: revision 1.7
usr.bin/patch/patch.c: revision 1.30
patch: make '-V none' work in the expected way
Internally the code confuses the concept of "the user doesn't want
a backup file" and "the user hasn't defined a type of backup file".
Introduce a new "undefined" backup type to serve the purpose "none"
previously did, and make "none" not generate backup files, as expected.
http://mail-index.netbsd.org/tech-userlevel/2021/02/19/msg012901.html
XXX pullup?
Diffstat (limited to 'usr.bin/patch/patch.c')
| -rw-r--r-- | usr.bin/patch/patch.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index 9f49e7f96e1..6faff9df8e8 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1,7 +1,7 @@ /* * $OpenBSD: patch.c,v 1.45 2007/04/18 21:52:24 sobrado Exp $ * $DragonFly: src/usr.bin/patch/patch.c,v 1.10 2008/08/10 23:39:56 joerg Exp $ - * $NetBSD: patch.c,v 1.29 2011/09/06 18:25:14 joerg Exp $ + * $NetBSD: patch.c,v 1.29.44.1 2021/02/26 13:29:16 martin Exp $ */ /* @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: patch.c,v 1.29 2011/09/06 18:25:14 joerg Exp $"); +__RCSID("$NetBSD: patch.c,v 1.29.44.1 2021/02/26 13:29:16 martin Exp $"); #include <sys/types.h> #include <sys/stat.h> @@ -197,17 +197,18 @@ main(int argc, char *argv[]) else simple_backup_suffix = ORIGEXT; + if ((v = getenv("PATCH_VERSION_CONTROL")) == NULL) + v = getenv("VERSION_CONTROL"); + if (v != NULL) + backup_type = get_version(v); + /* parse switches */ Argc = argc; Argv = argv; get_some_switches(); - if (backup_type == none) { - if ((v = getenv("PATCH_VERSION_CONTROL")) == NULL) - v = getenv("VERSION_CONTROL"); - if (v != NULL || !posix) - backup_type = get_version(v); /* OK to pass NULL. */ - } + if (backup_type == undefined) + backup_type = posix ? none : numbered_existing; /* make sure we clean up /tmp in case of disaster */ set_signals(0); @@ -493,7 +494,7 @@ get_some_switches(void) while ((ch = getopt_long(Argc, Argv, options, longopts, NULL)) != -1) { switch (ch) { case 'b': - if (backup_type == none) + if (backup_type == undefined) backup_type = numbered_existing; if (optarg == NULL) break; |
