diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h index 7e6ee179117b..cf69f2c0920e 100644 --- a/usr.bin/patch/common.h +++ b/usr.bin/patch/common.h @@ -1,4 +1,4 @@ -/* $NetBSD: common.h,v 1.16 2003/07/30 08:51:55 itojun Exp $ */ +/* $NetBSD: common.h,v 1.17 2005/03/25 23:00:55 skd Exp $ */ /* * Copyright (c) 1988, Larry Wall @@ -90,6 +90,9 @@ typedef int LINENUM; /* must be signed */ EXT int Argc; /* guess */ EXT char **Argv; +/* TRUE if -C was specified on command line. */ +EXT int check_only; + EXT struct stat filestat; /* file statistics area */ EXT mode_t filemode INIT(0644); diff --git a/usr.bin/patch/patch.1 b/usr.bin/patch/patch.1 index 4819958f47cb..f8714ff25aa6 100644 --- a/usr.bin/patch/patch.1 +++ b/usr.bin/patch/patch.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: patch.1,v 1.9 2003/01/06 12:48:06 wiz Exp $ -*- nroff -*- +.\" $NetBSD: patch.1,v 1.10 2005/03/25 23:00:55 skd Exp $ -*- nroff -*- .rn '' }` .de Sh .br @@ -226,6 +226,11 @@ forces .I patch to interpret the patch file as a context diff. .TP 5 +.B \-C or \-\-dry\-run +causes +.I patch +to report what would be done, but not to actully modify any files or create any rejects. +.TP 5 .B \-d or \-\-directory causes .I patch diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index 7a2e041a9d59..e5be242443a4 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1,4 +1,4 @@ -/* $NetBSD: patch.c,v 1.22 2004/12/09 18:06:10 mycroft Exp $ */ +/* $NetBSD: patch.c,v 1.23 2005/03/25 23:00:55 skd Exp $ */ /* patch - a program to apply diffs to original files * @@ -25,7 +25,7 @@ #include #ifndef lint -__RCSID("$NetBSD: patch.c,v 1.22 2004/12/09 18:06:10 mycroft Exp $"); +__RCSID("$NetBSD: patch.c,v 1.23 2005/03/25 23:00:55 skd Exp $"); #endif /* not lint */ #include "INTERN.h" @@ -83,6 +83,8 @@ main(int argc, char *argv[]) myuid = getuid(); + check_only = FALSE; + /* Cons up the names of the temporary files. */ { /* Directory for temporary files. */ @@ -398,10 +400,10 @@ decode_long_option(char *opt) */ static struct option options[] = { { "batch", 't' }, - { "check", 'C' }, { "context", 'c' }, { "debug", 'x' }, { "directory", 'd' }, + { "dry-run", 'C' }, { "ed", 'e' }, { "force", 'f' }, { "forward", 'N' }, @@ -477,6 +479,9 @@ exclusive\n"); case 'c': diff_type = CONTEXT_DIFF; break; + case 'C': + check_only = TRUE; + break; case 'd': if (!*++s) s = nextarg(); diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c index a1381dd7fbb1..0437bb4e673b 100644 --- a/usr.bin/patch/util.c +++ b/usr.bin/patch/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.20 2004/10/30 21:52:09 dsl Exp $ */ +/* $NetBSD: util.c,v 1.21 2005/03/25 23:00:55 skd Exp $ */ /* * Copyright (c) 1988, Larry Wall @@ -24,7 +24,7 @@ #include #ifndef lint -__RCSID("$NetBSD: util.c,v 1.20 2004/10/30 21:52:09 dsl Exp $"); +__RCSID("$NetBSD: util.c,v 1.21 2005/03/25 23:00:55 skd Exp $"); #endif /* not lint */ #include @@ -51,6 +51,9 @@ move_file(char *from, char *to) size_t i; int fromfd; + if ( check_only == TRUE ) + return(0); + /* to stdout? */ if (strEQ(to, "-")) {