- Refresh code with latest OpenBSD revisions.

- Remove $DragonFly$ tags as they are using git nowadays and VCS tags will
   not help merging.
 - Other changes to Copyright headers to make them consistent with other
   source code, we intend to fork from this point.

Reviewed by:	pfg
This commit is contained in:
Xin LI 2013-01-29 20:05:16 +00:00
parent e38120d46f
commit e56ef7d358
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=246091
14 changed files with 71 additions and 87 deletions

View File

@ -1,6 +1,5 @@
# $FreeBSD$
# $OpenBSD: Makefile,v 1.4 2005/05/16 15:22:46 espie Exp $ # $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> .include <bsd.own.mk>

View File

@ -1,6 +1,4 @@
/* $FreeBSD$ */
/*- /*-
*
* Copyright (C) 1990 Free Software Foundation, Inc. * Copyright (C) 1990 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify it * 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. * 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 $ * $OpenBSD: backupfile.c,v 1.20 2009/10/27 23:59:41 deraadt Exp $
* $DragonFly: src/usr.bin/patch/backupfile.c,v 1.5 2008/08/11 00:05:06 joerg Exp $ * $FreeBSD$
*/ */
#include <ctype.h> #include <ctype.h>

View File

@ -1,6 +1,4 @@
/* $FreeBSD$ */
/*- /*-
* backupfile.h -- declarations for making Emacs style backup file names
* Copyright (C) 1990 Free Software Foundation, Inc. * Copyright (C) 1990 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify it * 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 * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. * 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 $ * $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. */ /* When to make backup files. */

View File

@ -1,6 +1,4 @@
/* $FreeBSD$ */
/*- /*-
*
* Copyright 1986, Larry Wall * Copyright 1986, Larry Wall
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -26,7 +24,7 @@
* behaviour * behaviour
* *
* $OpenBSD: common.h,v 1.26 2006/03/11 19:41:30 otto Exp $ * $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> #include <sys/types.h>

View File

@ -1,6 +1,4 @@
/* $FreeBSD$ */
/*- /*-
*
* Copyright 1986, Larry Wall * Copyright 1986, Larry Wall
* *
* Redistribution and use in source and binary forms, with or without * 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 * -C option added in 1998, original code by Marc Espie, based on FreeBSD
* behaviour * 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> #include <sys/types.h>

View File

@ -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 * Copyright 1986, Larry Wall
* *
* Redistribution and use in source and binary forms, with or without * 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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* patch - a program to apply diffs to original files
*
* -C option added in 1998, original code by Marc Espie, based on FreeBSD * -C option added in 1998, original code by Marc Espie, based on FreeBSD
* behaviour * behaviour
*
* $OpenBSD: inp.h,v 1.8 2003/08/15 08:00:51 otto Exp $
* $FreeBSD$
*/ */
void re_input(void); void re_input(void);

View File

@ -1,4 +1,3 @@
/* $FreeBSD$ */
/*- /*-
* Copyright (c) 1983, 1992, 1993 * Copyright (c) 1983, 1992, 1993
* The Regents of the University of California. All rights reserved. * 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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $OpenBSD: mkpath.c,v 1.2 2005/06/20 07:14:06 otto Exp $ * $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 $ * $FreeBSD$
*/ */
#include <sys/types.h> #include <sys/types.h>

View File

@ -1,4 +1,4 @@
.\" $FreeBSD$ .\"-
.\" Copyright 1986, Larry Wall .\" Copyright 1986, Larry Wall
.\" .\"
.\" Redistribution and use in source and binary forms, with or without .\" 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 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: patch.1,v 1.22 2008/06/06 20:44:00 jmc Exp $ .\" $OpenBSD: patch.1,v 1.26 2010/09/03 11:09:29 jmc Exp $
.\" $DragonFly: src/usr.bin/patch/patch.1,v 1.10 2008/08/18 19:15:55 joerg Exp $ .\" $FreeBSD$
.Dd August 18, 2008 .Dd January 29, 2013
.Dt PATCH 1 .Dt PATCH 1
.Os .Os
.Sh NAME .Sh NAME
@ -59,7 +59,7 @@ If
is omitted, or is a hyphen, the patch will be read from the standard input. is omitted, or is a hyphen, the patch will be read from the standard input.
.Pp .Pp
.Nm .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 c ,
.Fl e , .Fl e ,
.Fl n , .Fl n ,
@ -349,7 +349,7 @@ used in place of
.Qq .orig . .Qq .orig .
.It Fl Fl posix .It Fl Fl posix
Enables strict Enables strict
.St -p1003.1-2004 .St -p1003.1-2008
conformance, specifically: conformance, specifically:
.Bl -enum .Bl -enum
.It .It
@ -463,7 +463,7 @@ match used:
If If
.Nm .Nm
is operating in strict is operating in strict
.St -p1003.1-2004 .St -p1003.1-2008
mode, the first of the mode, the first of the
.Dq old , .Dq old ,
.Dq new .Dq new
@ -605,6 +605,22 @@ used to read input when
.Nm .Nm
prompts the user prompts the user
.El .El
.Sh EXIT STATUS
The
.Nm
utility exits with one of the following values:
.Pp
.Bl -tag -width Ds -offset indent -compact
.It 0
Successful completion.
.It 1
One or more lines were written to a reject file.
.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 .Sh DIAGNOSTICS
Too many to list here, but generally indicative that Too many to list here, but generally indicative that
.Nm .Nm
@ -616,29 +632,13 @@ indicates that there is unprocessed text in the patch file and that
.Nm .Nm
is attempting to intuit whether there is a patch in that text and, if so, is attempting to intuit whether there is a patch in that text and, if so,
what kind of patch it is. what kind of patch it is.
.Pp
The
.Nm
utility exits with one of the following values:
.Pp
.Bl -tag -width Ds -compact -offset indent
.It \&0
Successful completion.
.It \&1
One or more lines were written to a reject file.
.It \*[Gt]\&1
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 SEE ALSO .Sh SEE ALSO
.Xr diff 1 .Xr diff 1
.Sh STANDARDS .Sh STANDARDS
The The
.Nm .Nm
utility is compliant with the utility is compliant with the
.St -p1003.1-2004 .St -p1003.1-2008
specification specification
(except as detailed above for the (except as detailed above for the
.Fl -posix .Fl -posix
@ -648,7 +648,7 @@ though the presence of
itself is optional. itself is optional.
.Pp .Pp
The flags The flags
.Op Fl CEfstuvBFVxz .Op Fl BCEFfstVvxz
and and
.Op Fl -posix .Op Fl -posix
are extensions to that specification. are extensions to that specification.

View File

@ -1,6 +1,4 @@
/* $FreeBSD$ */
/*- /*-
*
* Copyright 1986, Larry Wall * Copyright 1986, Larry Wall
* *
* Redistribution and use in source and binary forms, with or without * 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 * -C option added in 1998, original code by Marc Espie, based on FreeBSD
* behaviour * behaviour
* *
* $OpenBSD: patch.c,v 1.45 2007/04/18 21:52:24 sobrado Exp $ * $OpenBSD: patch.c,v 1.50 2012/05/15 19:32:02 millert Exp $
* $DragonFly: src/usr.bin/patch/patch.c,v 1.10 2008/08/10 23:39:56 joerg Exp $ * $FreeBSD$
* *
*/ */
@ -114,9 +112,6 @@ static bool reverse_flag_specified = false;
/* buffer holding the name of the rejected patch file. */ /* buffer holding the name of the rejected patch file. */
static char rejname[NAME_MAX + 1]; static char rejname[NAME_MAX + 1];
/* buffer for stderr */
static char serrbuf[BUFSIZ];
/* how many input lines have been irretractibly output */ /* how many input lines have been irretractibly output */
static LINENUM last_frozen_line = 0; static LINENUM last_frozen_line = 0;
@ -150,11 +145,13 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int error = 0, hunk, failed, i, fd; int error = 0, hunk, failed, i, fd;
bool patch_seen;
LINENUM where = 0, newwhere, fuzz, mymaxfuzz; LINENUM where = 0, newwhere, fuzz, mymaxfuzz;
const char *tmpdir; const char *tmpdir;
char *v; char *v;
setbuf(stderr, serrbuf); setlinebuf(stdout);
setlinebuf(stderr);
for (i = 0; i < MAXFILEC; i++) for (i = 0; i < MAXFILEC; i++)
filearg[i] = NULL; filearg[i] = NULL;
@ -214,9 +211,12 @@ main(int argc, char *argv[])
/* make sure we clean up /tmp in case of disaster */ /* make sure we clean up /tmp in case of disaster */
set_signals(0); set_signals(0);
patch_seen = false;
for (open_patch_file(filearg[1]); there_is_another_patch(); for (open_patch_file(filearg[1]); there_is_another_patch();
reinitialize_almost_everything()) { reinitialize_almost_everything()) {
/* for each patch in patch file */ /* for each patch in patch file */
patch_seen = true;
warn_on_invalid_line = true; warn_on_invalid_line = true;
@ -400,18 +400,21 @@ main(int argc, char *argv[])
sizeof(rejname)) >= sizeof(rejname)) sizeof(rejname)) >= sizeof(rejname))
fatal("filename %s is too long\n", outname); fatal("filename %s is too long\n", outname);
} }
if (skip_rest_of_patch) { if (!check_only)
say("%d out of %d hunks ignored--saving rejects to %s\n", say("%d out of %d hunks %s--saving rejects to %s\n",
failed, hunk, rejname); failed, hunk, skip_rest_of_patch ? "ignored" : "failed", rejname);
} else { else
say("%d out of %d hunks failed--saving rejects to %s\n", say("%d out of %d hunks %s\n",
failed, hunk, rejname); failed, hunk, skip_rest_of_patch ? "ignored" : "failed");
}
if (!check_only && move_file(TMPREJNAME, rejname) < 0) if (!check_only && move_file(TMPREJNAME, rejname) < 0)
trejkeep = true; trejkeep = true;
} }
set_signals(1); set_signals(1);
} }
if (!patch_seen)
error = 2;
my_exit(error); my_exit(error);
/* NOTREACHED */ /* NOTREACHED */
} }

View File

@ -1,10 +1,9 @@
/* $FreeBSD$ */
/*- /*-
* Placed in the public domain by Todd C. Miller <Todd.Miller@courtesan.com> * Placed in the public domain by Todd C. Miller <Todd.Miller@courtesan.com>
* on July 29, 2003. * on July 29, 2003.
* *
* $OpenBSD: pathnames.h,v 1.1 2003/07/29 20:10:17 millert Exp $ * $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$
*/ */

View File

@ -1,6 +1,5 @@
/* $FreeBSD$ */
/*- /*-
*
* Copyright 1986, Larry Wall * Copyright 1986, Larry Wall
* *
* Redistribution and use in source and binary forms, with or without * 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 * -C option added in 1998, original code by Marc Espie, based on FreeBSD
* behaviour * behaviour
* *
* $OpenBSD: pch.c,v 1.37 2007/09/02 15:19:33 deraadt Exp $ * $OpenBSD: pch.c,v 1.39 2012/04/11 08:07:13 ajacoutot Exp $
* $DragonFly: src/usr.bin/patch/pch.c,v 1.6 2008/08/10 23:35:40 joerg Exp $ * $FreeBSD$
*/ */
#include <sys/types.h> #include <sys/types.h>

View File

@ -1,6 +1,4 @@
/* $FreeBSD$ */
/*- /*-
*
* Copyright 1986, Larry Wall * Copyright 1986, Larry Wall
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -26,7 +24,7 @@
* behaviour * behaviour
* *
* $OpenBSD: pch.h,v 1.9 2003/10/31 20:20:45 millert Exp $ * $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 #define OLD_FILE 0

View File

@ -1,6 +1,4 @@
/* $FreeBSD$ */
/*- /*-
*
* Copyright 1986, Larry Wall * Copyright 1986, Larry Wall
* *
* Redistribution and use in source and binary forms, with or without * 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 * -C option added in 1998, original code by Marc Espie, based on FreeBSD
* behaviour * behaviour
* *
* $OpenBSD: util.c,v 1.32 2006/03/11 19:41:30 otto Exp $ * $OpenBSD: util.c,v 1.35 2010/07/24 01:10:12 ray Exp $
* $DragonFly: src/usr.bin/patch/util.c,v 1.9 2007/09/29 23:11:10 swildner Exp $ * $FreeBSD$
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -212,9 +210,9 @@ say(const char *fmt, ...)
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
vfprintf(stderr, fmt, ap); vfprintf(stdout, fmt, ap);
va_end(ap); va_end(ap);
fflush(stderr); fflush(stdout);
} }
/* /*

View File

@ -1,6 +1,4 @@
/* $FreeBSD$ */
/*- /*-
*
* Copyright 1986, Larry Wall * Copyright 1986, Larry Wall
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -26,8 +24,7 @@
* behaviour * behaviour
* *
* $OpenBSD: util.h,v 1.15 2005/06/20 07:14:06 otto Exp $ * $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); char *fetchname(const char *, bool *, int);