summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.bin/patch/Makefile3
-rw-r--r--usr.bin/patch/backupfile.c6
-rw-r--r--usr.bin/patch/backupfile.h8
-rw-r--r--usr.bin/patch/common.h4
-rw-r--r--usr.bin/patch/inp.c5
-rw-r--r--usr.bin/patch/inp.h15
-rw-r--r--usr.bin/patch/mkpath.c5
-rw-r--r--usr.bin/patch/patch.150
-rw-r--r--usr.bin/patch/patch.c33
-rw-r--r--usr.bin/patch/pathnames.h3
-rw-r--r--usr.bin/patch/pch.c7
-rw-r--r--usr.bin/patch/pch.h4
-rw-r--r--usr.bin/patch/util.c10
-rw-r--r--usr.bin/patch/util.h5
14 files changed, 71 insertions, 87 deletions
diff --git a/usr.bin/patch/Makefile b/usr.bin/patch/Makefile
index 5ee0a83..382a05f 100644
--- a/usr.bin/patch/Makefile
+++ b/usr.bin/patch/Makefile
@@ -1,6 +1,5 @@
-# $FreeBSD$
# $OpenBSD: Makefile,v 1.4 2005/05/16 15:22:46 espie Exp $
-# $DragonFly: src/usr.bin/patch/Makefile,v 1.8 2008/08/10 23:50:12 joerg Exp $
+# $FreeBSD$
.include <bsd.own.mk>
diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c
index 9a33040..d22d607 100644
--- a/usr.bin/patch/backupfile.c
+++ b/usr.bin/patch/backupfile.c
@@ -1,6 +1,4 @@
-/* $FreeBSD$ */
/*-
- *
* Copyright (C) 1990 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify it
@@ -14,8 +12,8 @@
*
* David MacKenzie <djm@ai.mit.edu>. Some algorithms adapted from GNU Emacs.
*
- * $OpenBSD: backupfile.c,v 1.19 2006/03/11 19:41:30 otto Exp $
- * $DragonFly: src/usr.bin/patch/backupfile.c,v 1.5 2008/08/11 00:05:06 joerg Exp $
+ * $OpenBSD: backupfile.c,v 1.20 2009/10/27 23:59:41 deraadt Exp $
+ * $FreeBSD$
*/
#include <ctype.h>
diff --git a/usr.bin/patch/backupfile.h b/usr.bin/patch/backupfile.h
index 595d146..71999f7 100644
--- a/usr.bin/patch/backupfile.h
+++ b/usr.bin/patch/backupfile.h
@@ -1,6 +1,4 @@
-/* $FreeBSD$ */
/*-
- * backupfile.h -- declarations for making Emacs style backup file names
* Copyright (C) 1990 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify it
@@ -9,9 +7,11 @@
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
- *
+ *
+ * backupfile.h -- declarations for making Emacs style backup file names
+ *
* $OpenBSD: backupfile.h,v 1.6 2003/07/28 18:35:36 otto Exp $
- * $DragonFly: src/usr.bin/patch/backupfile.h,v 1.3 2007/09/29 23:11:10 swildner Exp $
+ * $FreeBSD$
*/
/* When to make backup files. */
diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h
index 10a64e6..9425968 100644
--- a/usr.bin/patch/common.h
+++ b/usr.bin/patch/common.h
@@ -1,6 +1,4 @@
-/* $FreeBSD$ */
/*-
- *
* Copyright 1986, Larry Wall
*
* Redistribution and use in source and binary forms, with or without
@@ -26,7 +24,7 @@
* behaviour
*
* $OpenBSD: common.h,v 1.26 2006/03/11 19:41:30 otto Exp $
- * $DragonFly: src/usr.bin/patch/common.h,v 1.5 2008/08/10 23:50:12 joerg Exp $
+ * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index f307cd4..54b0bf2 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,6 +1,4 @@
-/* $FreeBSD$ */
/*-
- *
* Copyright 1986, Larry Wall
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +23,8 @@
* -C option added in 1998, original code by Marc Espie, based on FreeBSD
* behaviour
*
- * $OpenBSD: inp.c,v 1.34 2006/03/11 19:41:30 otto Exp $
+ * $OpenBSD: inp.c,v 1.36 2012/04/10 14:46:34 ajacoutot Exp $
+ * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/usr.bin/patch/inp.h b/usr.bin/patch/inp.h
index 0f6103f..062798a 100644
--- a/usr.bin/patch/inp.h
+++ b/usr.bin/patch/inp.h
@@ -1,12 +1,4 @@
-/*
- * $FreeBSD$
- * $OpenBSD: inp.h,v 1.8 2003/08/15 08:00:51 otto Exp $
- * $DragonFly: src/usr.bin/patch/inp.h,v 1.1 2004/09/24 18:44:28 joerg Exp $
- */
-
-/*
- * patch - a program to apply diffs to original files
- *
+/*-
* Copyright 1986, Larry Wall
*
* Redistribution and use in source and binary forms, with or without
@@ -26,8 +18,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
+ * patch - a program to apply diffs to original files
+ *
* -C option added in 1998, original code by Marc Espie, based on FreeBSD
* behaviour
+ *
+ * $OpenBSD: inp.h,v 1.8 2003/08/15 08:00:51 otto Exp $
+ * $FreeBSD$
*/
void re_input(void);
diff --git a/usr.bin/patch/mkpath.c b/usr.bin/patch/mkpath.c
index 73aea6f..04fd537 100644
--- a/usr.bin/patch/mkpath.c
+++ b/usr.bin/patch/mkpath.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*-
* Copyright (c) 1983, 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -27,8 +26,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: mkpath.c,v 1.2 2005/06/20 07:14:06 otto Exp $
- * $DragonFly: src/usr.bin/patch/mkpath.c,v 1.1 2007/09/29 23:11:10 swildner Exp $
+ * $OpenBSD: mkpath.c,v 1.2 2005/06/20 07:14:06 otto Exp $
+ * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/usr.bin/patch/patch.1 b/usr.bin/patch/patch.1
index 88237d9..312b8a2 100644
--- a/usr.bin/patch/patch.1
+++ b/usr.bin/patch/patch.1
@@ -1,4 +1,4 @@
-.\" $FreeBSD$
+.\"-
.\" Copyright 1986, Larry Wall
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -19,9 +19,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: patch.1,v 1.22 2008/06/06 20:44:00 jmc Exp $
-.\" $DragonFly: src/usr.bin/patch/patch.1,v 1.10 2008/08/18 19:15:55 joerg Exp $
-.Dd August 18, 2008
+.\" $OpenBSD: patch.1,v 1.26 2010/09/03 11:09:29 jmc Exp $
+.\" $FreeBSD$
+.Dd January 29, 2013
.Dt PATCH 1
.Os
.Sh NAME
@@ -59,7 +59,7 @@ If
is omitted, or is a hyphen, the patch will be read from the standard input.
.Pp
.Nm
-will attempt to determine the type of the diff listing, unless over-ruled by a
+will attempt to determine the type of the diff listing, unless overruled by a
.Fl c ,
.Fl e ,
.Fl n ,
@@ -349,7 +349,7 @@ used in place of
.Qq .orig .
.It Fl Fl posix
Enables strict
-.St -p1003.1-2004
+.St -p1003.1-2008
conformance, specifically:
.Bl -enum
.It
@@ -463,7 +463,7 @@ match used:
If
.Nm
is operating in strict
-.St -p1003.1-2004
+.St -p1003.1-2008
mode, the first of the
.Dq old ,
.Dq new
@@ -605,40 +605,40 @@ used to read input when
.Nm
prompts the user
.El
-.Sh DIAGNOSTICS
-Too many to list here, but generally indicative that
-.Nm
-couldn't parse your patch file.
-.Pp
-The message
-.Qq Hmm...
-indicates that there is unprocessed text in the patch file and that
-.Nm
-is attempting to intuit whether there is a patch in that text and, if so,
-what kind of patch it is.
-.Pp
+.Sh EXIT STATUS
The
.Nm
utility exits with one of the following values:
.Pp
-.Bl -tag -width Ds -compact -offset indent
-.It \&0
+.Bl -tag -width Ds -offset indent -compact
+.It 0
Successful completion.
-.It \&1
+.It 1
One or more lines were written to a reject file.
-.It \*[Gt]\&1
+.It \*(Gt1
An error occurred.
.El
.Pp
When applying a set of patches in a loop it behooves you to check this
exit status so you don't apply a later patch to a partially patched file.
+.Sh DIAGNOSTICS
+Too many to list here, but generally indicative that
+.Nm
+couldn't parse your patch file.
+.Pp
+The message
+.Qq Hmm...
+indicates that there is unprocessed text in the patch file and that
+.Nm
+is attempting to intuit whether there is a patch in that text and, if so,
+what kind of patch it is.
.Sh SEE ALSO
.Xr diff 1
.Sh STANDARDS
The
.Nm
utility is compliant with the
-.St -p1003.1-2004
+.St -p1003.1-2008
specification
(except as detailed above for the
.Fl -posix
@@ -648,7 +648,7 @@ though the presence of
itself is optional.
.Pp
The flags
-.Op Fl CEfstuvBFVxz
+.Op Fl BCEFfstVvxz
and
.Op Fl -posix
are extensions to that specification.
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index 0865849..d008c0f 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,6 +1,4 @@
-/* $FreeBSD$ */
/*-
- *
* Copyright 1986, Larry Wall
*
* Redistribution and use in source and binary forms, with or without
@@ -25,8 +23,8 @@
* -C option added in 1998, original code by Marc Espie, based on FreeBSD
* behaviour
*
- * $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 $
+ * $OpenBSD: patch.c,v 1.50 2012/05/15 19:32:02 millert Exp $
+ * $FreeBSD$
*
*/
@@ -114,9 +112,6 @@ static bool reverse_flag_specified = false;
/* buffer holding the name of the rejected patch file. */
static char rejname[NAME_MAX + 1];
-/* buffer for stderr */
-static char serrbuf[BUFSIZ];
-
/* how many input lines have been irretractibly output */
static LINENUM last_frozen_line = 0;
@@ -150,11 +145,13 @@ int
main(int argc, char *argv[])
{
int error = 0, hunk, failed, i, fd;
+ bool patch_seen;
LINENUM where = 0, newwhere, fuzz, mymaxfuzz;
const char *tmpdir;
char *v;
- setbuf(stderr, serrbuf);
+ setlinebuf(stdout);
+ setlinebuf(stderr);
for (i = 0; i < MAXFILEC; i++)
filearg[i] = NULL;
@@ -214,9 +211,12 @@ main(int argc, char *argv[])
/* make sure we clean up /tmp in case of disaster */
set_signals(0);
+ patch_seen = false;
for (open_patch_file(filearg[1]); there_is_another_patch();
reinitialize_almost_everything()) {
/* for each patch in patch file */
+
+ patch_seen = true;
warn_on_invalid_line = true;
@@ -400,18 +400,21 @@ main(int argc, char *argv[])
sizeof(rejname)) >= sizeof(rejname))
fatal("filename %s is too long\n", outname);
}
- if (skip_rest_of_patch) {
- say("%d out of %d hunks ignored--saving rejects to %s\n",
- failed, hunk, rejname);
- } else {
- say("%d out of %d hunks failed--saving rejects to %s\n",
- failed, hunk, rejname);
- }
+ if (!check_only)
+ say("%d out of %d hunks %s--saving rejects to %s\n",
+ failed, hunk, skip_rest_of_patch ? "ignored" : "failed", rejname);
+ else
+ say("%d out of %d hunks %s\n",
+ failed, hunk, skip_rest_of_patch ? "ignored" : "failed");
if (!check_only && move_file(TMPREJNAME, rejname) < 0)
trejkeep = true;
}
set_signals(1);
}
+
+ if (!patch_seen)
+ error = 2;
+
my_exit(error);
/* NOTREACHED */
}
diff --git a/usr.bin/patch/pathnames.h b/usr.bin/patch/pathnames.h
index 79bece6..d31300e 100644
--- a/usr.bin/patch/pathnames.h
+++ b/usr.bin/patch/pathnames.h
@@ -1,10 +1,9 @@
-/* $FreeBSD$ */
/*-
* Placed in the public domain by Todd C. Miller <Todd.Miller@courtesan.com>
* on July 29, 2003.
*
* $OpenBSD: pathnames.h,v 1.1 2003/07/29 20:10:17 millert Exp $
- * $DragonFly: src/usr.bin/patch/pathnames.h,v 1.2 2008/08/11 00:04:12 joerg Exp $
+ * $FreeBSD$
*/
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index 036898f..4c06bbf 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -1,6 +1,5 @@
-/* $FreeBSD$ */
+
/*-
- *
* Copyright 1986, Larry Wall
*
* Redistribution and use in source and binary forms, with or without
@@ -25,8 +24,8 @@
* -C option added in 1998, original code by Marc Espie, based on FreeBSD
* behaviour
*
- * $OpenBSD: pch.c,v 1.37 2007/09/02 15:19:33 deraadt Exp $
- * $DragonFly: src/usr.bin/patch/pch.c,v 1.6 2008/08/10 23:35:40 joerg Exp $
+ * $OpenBSD: pch.c,v 1.39 2012/04/11 08:07:13 ajacoutot Exp $
+ * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/usr.bin/patch/pch.h b/usr.bin/patch/pch.h
index d42220b..42910c2 100644
--- a/usr.bin/patch/pch.h
+++ b/usr.bin/patch/pch.h
@@ -1,6 +1,4 @@
-/* $FreeBSD$ */
/*-
- *
* Copyright 1986, Larry Wall
*
* Redistribution and use in source and binary forms, with or without
@@ -26,7 +24,7 @@
* behaviour
*
* $OpenBSD: pch.h,v 1.9 2003/10/31 20:20:45 millert Exp $
- * $DragonFly: src/usr.bin/patch/pch.h,v 1.1 2004/09/24 18:44:28 joerg Exp $
+ * $FreeBSD$
*/
#define OLD_FILE 0
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c
index 90f2f9a..3895b2c 100644
--- a/usr.bin/patch/util.c
+++ b/usr.bin/patch/util.c
@@ -1,6 +1,4 @@
-/* $FreeBSD$ */
/*-
- *
* Copyright 1986, Larry Wall
*
* Redistribution and use in source and binary forms, with or without
@@ -25,8 +23,8 @@
* -C option added in 1998, original code by Marc Espie, based on FreeBSD
* behaviour
*
- * $OpenBSD: util.c,v 1.32 2006/03/11 19:41:30 otto Exp $
- * $DragonFly: src/usr.bin/patch/util.c,v 1.9 2007/09/29 23:11:10 swildner Exp $
+ * $OpenBSD: util.c,v 1.35 2010/07/24 01:10:12 ray Exp $
+ * $FreeBSD$
*/
#include <sys/param.h>
@@ -212,9 +210,9 @@ say(const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
+ vfprintf(stdout, fmt, ap);
va_end(ap);
- fflush(stderr);
+ fflush(stdout);
}
/*
diff --git a/usr.bin/patch/util.h b/usr.bin/patch/util.h
index ae38960..5759d68 100644
--- a/usr.bin/patch/util.h
+++ b/usr.bin/patch/util.h
@@ -1,6 +1,4 @@
-/* $FreeBSD$ */
/*-
- *
* Copyright 1986, Larry Wall
*
* Redistribution and use in source and binary forms, with or without
@@ -26,8 +24,7 @@
* behaviour
*
* $OpenBSD: util.h,v 1.15 2005/06/20 07:14:06 otto Exp $
- * $DragonFly: src/usr.bin/patch/util.h,v 1.2 2007/09/29 23:11:10 swildner Exp $
-
+ * $FreeBSD$
*/
char *fetchname(const char *, bool *, int);
OpenPOWER on IntegriCloud