updating bsd patch, moving it back to usr.bin
Change-Id: Ibc356c932693729ebf86cc4cc51aeca65163af9b
This commit is contained in:
parent
18e90974b2
commit
757e83288a
16 changed files with 62 additions and 160 deletions
|
@ -17,7 +17,7 @@ SUBDIR= add_route arp ash at backup btrace \
|
|||
lpd lspci mail MAKEDEV \
|
||||
mined \
|
||||
mount mt netconf \
|
||||
nonamed patch \
|
||||
nonamed \
|
||||
ping postinstall prep printroot \
|
||||
profile progressbar pr_routes ps pwdauth \
|
||||
ramdisk rarpd rawspeed rcp readclock \
|
||||
|
|
|
@ -19,7 +19,7 @@ SUBDIR= asa \
|
|||
mkdep mkfifo mkstr mktemp \
|
||||
msgc \
|
||||
nbperf newgrp nice nl nohup \
|
||||
passwd paste pathchk pr \
|
||||
passwd paste patch pathchk pr \
|
||||
printenv printf pwhash \
|
||||
renice rev \
|
||||
\
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: backupfile.c,v 1.14 2008/09/19 18:33:34 joerg Exp $");
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
|
@ -113,7 +114,7 @@ max_backup_version(const char *file, const char *dir)
|
|||
file_name_length = strlen(file);
|
||||
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
if (strlen(dp->d_name) <= file_name_length)
|
||||
if (dp->d_namlen <= file_name_length)
|
||||
continue;
|
||||
|
||||
this_version = version_number(file, dp->d_name, file_name_length);
|
||||
|
@ -132,14 +133,9 @@ static char *
|
|||
make_version_name(const char *file, int version)
|
||||
{
|
||||
char *backup_name;
|
||||
int len = strlen(file)+20;
|
||||
|
||||
if(!(backup_name = malloc(len)))
|
||||
if (asprintf(&backup_name, "%s.~%d~", file, version) == -1)
|
||||
return NULL;
|
||||
|
||||
if (snprintf(backup_name, len, "%s.~%d~", file, version) == -1)
|
||||
return NULL;
|
||||
|
||||
return backup_name;
|
||||
}
|
||||
|
||||
|
@ -172,14 +168,9 @@ static char *
|
|||
concat(const char *str1, const char *str2)
|
||||
{
|
||||
char *newstr;
|
||||
int len = strlen(str1) + strlen(str2) + 1;
|
||||
|
||||
if(!(newstr = malloc(strlen(str1) + strlen(str2) + 1)))
|
||||
if (asprintf(&newstr, "%s%s", str1, str2) == -1)
|
||||
return NULL;
|
||||
|
||||
if (snprintf(newstr, len, "%s%s", str1, str2) == -1)
|
||||
return NULL;
|
||||
|
||||
return newstr;
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $OpenBSD: inp.c,v 1.34 2006/03/11 19:41:30 otto Exp $
|
||||
* $DragonFly: src/usr.bin/patch/inp.c,v 1.6 2007/09/29 23:11:10 swildner Exp $
|
||||
* $NetBSD: inp.c,v 1.19 2008/09/19 18:33:34 joerg Exp $
|
||||
* $NetBSD: inp.c,v 1.23 2009/10/21 17:16:11 joerg Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -31,6 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: inp.c,v 1.23 2009/10/21 17:16:11 joerg Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/file.h>
|
||||
|
@ -38,6 +39,7 @@
|
|||
#include <sys/mman.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <libgen.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
@ -45,7 +47,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "util.h"
|
||||
|
@ -74,24 +75,6 @@ static bool plan_a(const char *);
|
|||
|
||||
static void plan_b(const char *);
|
||||
|
||||
static int readfile(int fd, char *buf, size_t s)
|
||||
{
|
||||
int ntoread, nread;
|
||||
|
||||
ntoread = s;
|
||||
nread = 0;
|
||||
|
||||
while(ntoread > 0) {
|
||||
if((nread = read(fd, buf, ntoread)) < 0) {
|
||||
return nread;
|
||||
}
|
||||
buf += nread;
|
||||
ntoread -= nread;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* New patch--prepare to edit another file. */
|
||||
|
||||
void
|
||||
|
@ -102,11 +85,7 @@ re_input(void)
|
|||
free(i_ptr);
|
||||
i_ptr = NULL;
|
||||
if (i_womp != NULL) {
|
||||
#ifndef __minix
|
||||
munmap(i_womp, i_size);
|
||||
#else
|
||||
free(i_womp);
|
||||
#endif
|
||||
i_womp = NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -143,11 +122,7 @@ reallocate_lines(size_t *lines_allocated)
|
|||
new_size = *lines_allocated * 3 / 2;
|
||||
p = realloc(i_ptr, (new_size + 2) * sizeof(char *));
|
||||
if (p == NULL) { /* shucks, it was a near thing */
|
||||
#ifndef __minix
|
||||
munmap(i_womp, i_size);
|
||||
#else
|
||||
free(i_womp);
|
||||
#endif
|
||||
i_womp = NULL;
|
||||
free(i_ptr);
|
||||
i_ptr = NULL;
|
||||
|
@ -279,44 +254,30 @@ plan_a(const char *filename)
|
|||
out_of_mem = false;
|
||||
return false; /* force plan b because plan a bombed */
|
||||
}
|
||||
#ifndef __minix
|
||||
if (i_size > SIZE_MAX) {
|
||||
if ((uintmax_t)i_size > (uintmax_t)SIZE_MAX) {
|
||||
say("block too large to mmap\n");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if ((ifd = open(filename, O_RDONLY)) < 0)
|
||||
pfatal("can't open file %s", filename);
|
||||
|
||||
#ifndef __minix
|
||||
i_womp = mmap(NULL, i_size, PROT_READ, MAP_PRIVATE, ifd, 0);
|
||||
if (i_womp == MAP_FAILED) {
|
||||
perror("mmap failed");
|
||||
if (i_size) {
|
||||
i_womp = mmap(NULL, i_size, PROT_READ, MAP_PRIVATE, ifd, 0);
|
||||
if (i_womp == MAP_FAILED) {
|
||||
perror("mmap failed");
|
||||
i_womp = NULL;
|
||||
close(ifd);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
i_womp = NULL;
|
||||
close(ifd);
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
i_womp = malloc(i_size);
|
||||
if(i_size && i_womp == NULL) {
|
||||
fprintf(stderr, "Malloc failed.\n");
|
||||
i_womp = NULL;
|
||||
close(ifd);
|
||||
return false;
|
||||
}
|
||||
if(readfile(ifd, i_womp, i_size) < 0) {
|
||||
perror("Readfile failed.");
|
||||
i_womp = NULL;
|
||||
close(ifd);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
close(ifd);
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (i_size)
|
||||
madvise(i_womp, i_size, MADV_SEQUENTIAL);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
/* estimate the number of lines */
|
||||
lines_allocated = i_size / 25;
|
||||
|
@ -349,11 +310,7 @@ plan_a(const char *filename)
|
|||
if (p == NULL) {
|
||||
free(i_ptr);
|
||||
i_ptr = NULL;
|
||||
#ifndef __minix
|
||||
munmap(i_womp, i_size);
|
||||
#else
|
||||
free(i_womp);
|
||||
#endif
|
||||
i_womp = NULL;
|
||||
return false;
|
||||
}
|
|
@ -34,6 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: mkpath.c,v 1.1 2008/09/19 18:33:34 joerg Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
|
@ -1,6 +1,6 @@
|
|||
.\" $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 $
|
||||
.\" $NetBSD: patch.1,v 1.13 2008/09/19 18:33:34 joerg Exp $
|
||||
.\" $NetBSD: patch.1,v 1.16 2013/01/29 09:30:11 wiz Exp $
|
||||
.\" Copyright 1986, Larry Wall
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
|
@ -29,7 +29,6 @@
|
|||
.Nd apply a diff file to an original
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Bk -words
|
||||
.Op Fl bCcEeflNnRstuv
|
||||
.Op Fl B Ar backup-prefix
|
||||
.Op Fl D Ar symbol
|
||||
|
@ -44,7 +43,6 @@
|
|||
.Op Fl z Ar backup-ext
|
||||
.Op Fl Fl posix
|
||||
.Op Ar origfile Op Ar patchfile
|
||||
.Ek
|
||||
.Nm
|
||||
.Pf \*(Lt Ar patchfile
|
||||
.Sh DESCRIPTION
|
||||
|
@ -87,10 +85,7 @@ below).
|
|||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width Ds
|
||||
.It Xo
|
||||
.Fl B Ar backup-prefix ,
|
||||
.Fl Fl prefix Ar backup-prefix
|
||||
.Xc
|
||||
.It Fl B Ar backup-prefix , Fl Fl prefix Ar backup-prefix
|
||||
Causes the next argument to be interpreted as a prefix to the backup file
|
||||
name.
|
||||
If this argument is specified, any argument to
|
||||
|
@ -113,10 +108,7 @@ Checks that the patch would apply cleanly, but does not modify anything.
|
|||
Forces
|
||||
.Nm
|
||||
to interpret the patch file as a context diff.
|
||||
.It Xo
|
||||
.Fl D Ar symbol ,
|
||||
.Fl Fl ifdef Ar symbol
|
||||
.Xc
|
||||
.It Fl D Ar symbol , Fl Fl ifdef Ar symbol
|
||||
Causes
|
||||
.Nm
|
||||
to use the
|
||||
|
@ -126,10 +118,7 @@ The argument following will be used as the differentiating symbol.
|
|||
Note that, unlike the C compiler, there must be a space between the
|
||||
.Fl D
|
||||
and the argument.
|
||||
.It Xo
|
||||
.Fl d Ar directory ,
|
||||
.Fl Fl directory Ar directory
|
||||
.Xc
|
||||
.It Fl d Ar directory , Fl Fl directory Ar directory
|
||||
Causes
|
||||
.Nm
|
||||
to interpret the next argument as a directory,
|
||||
|
@ -145,10 +134,7 @@ Forces
|
|||
to interpret the patch file as an
|
||||
.Xr ed 1
|
||||
script.
|
||||
.It Xo
|
||||
.Fl F Ar max-fuzz ,
|
||||
.Fl Fl fuzz Ar max-fuzz
|
||||
.Xc
|
||||
.It Fl F Ar max-fuzz , Fl Fl fuzz Ar max-fuzz
|
||||
Sets the maximum fuzz factor.
|
||||
This option only applies to context diffs, and causes
|
||||
.Nm
|
||||
|
@ -170,12 +156,9 @@ and assume that patches are not reversed even if they look like they are.
|
|||
This option does not suppress commentary; use
|
||||
.Fl s
|
||||
for that.
|
||||
.It Xo
|
||||
.Fl i Ar patchfile ,
|
||||
.Fl Fl input Ar patchfile
|
||||
.Xc
|
||||
.It Fl i Ar patchfile , Fl Fl input Ar patchfile
|
||||
Causes the next argument to be interpreted as the input file name
|
||||
(i.e. a patchfile).
|
||||
(i.e., a patchfile).
|
||||
This option may be specified multiple times.
|
||||
.It Fl l , Fl Fl ignore-whitespace
|
||||
Causes the pattern matching to be done loosely, in case the tabs and
|
||||
|
@ -194,15 +177,9 @@ See also
|
|||
Forces
|
||||
.Nm
|
||||
to interpret the patch file as a normal diff.
|
||||
.It Xo
|
||||
.Fl o Ar out-file ,
|
||||
.Fl Fl output Ar out-file
|
||||
.Xc
|
||||
.It Fl o Ar out-file , Fl Fl output Ar out-file
|
||||
Causes the next argument to be interpreted as the output file name.
|
||||
.It Xo
|
||||
.Fl p Ar strip-count ,
|
||||
.Fl Fl strip Ar strip-count
|
||||
.Xc
|
||||
.It Fl p Ar strip-count , Fl Fl strip Ar strip-count
|
||||
Sets the pathname strip count,
|
||||
which controls how pathnames found in the patch file are treated,
|
||||
in case you keep your files in a different directory than the person who sent
|
||||
|
@ -263,21 +240,15 @@ If it can, you will be asked if you want to have the
|
|||
option set.
|
||||
If it can't, the patch will continue to be applied normally.
|
||||
(Note: this method cannot detect a reversed patch if it is a normal diff
|
||||
and if the first command is an append (i.e. it should have been a delete)
|
||||
and if the first command is an append (i.e., it should have been a delete)
|
||||
since appends always succeed, due to the fact that a null context will match
|
||||
anywhere.
|
||||
Luckily, most patches add or change lines rather than delete them, so most
|
||||
reversed normal diffs will begin with a delete, which will fail, triggering
|
||||
the heuristic.)
|
||||
.It Xo
|
||||
.Fl r Ar rej-name ,
|
||||
.Fl Fl reject-file Ar rej-name
|
||||
.Xc
|
||||
.It Fl r Ar rej-name , Fl Fl reject-file Ar rej-name
|
||||
Causes the next argument to be interpreted as the reject file name.
|
||||
.It Xo
|
||||
.Fl s , Fl Fl quiet ,
|
||||
.Fl Fl silent
|
||||
.Xc
|
||||
.It Fl s , Fl Fl quiet , Fl Fl silent
|
||||
Makes
|
||||
.Nm
|
||||
do its work silently, unless an error occurs.
|
||||
|
@ -295,10 +266,7 @@ and assume that patches are reversed if they look like they are.
|
|||
Forces
|
||||
.Nm
|
||||
to interpret the patch file as a unified context diff (a unidiff).
|
||||
.It Xo
|
||||
.Fl V Cm t | nil | never ,
|
||||
.Fl Fl version-control Cm t | nil | never
|
||||
.Xc
|
||||
.It Fl V Cm t | nil | never , Fl Fl version-control Cm t | nil | never
|
||||
Causes the next argument to be interpreted as a method for creating
|
||||
backup file names.
|
||||
The type of backups made can also be given in the
|
||||
|
@ -333,17 +301,11 @@ Always make simple backups.
|
|||
Causes
|
||||
.Nm
|
||||
to print out its revision header and patch level.
|
||||
.It Xo
|
||||
.Fl x Ar number ,
|
||||
.Fl Fl debug Ar number
|
||||
.Xc
|
||||
.It Fl x Ar number , Fl Fl debug Ar number
|
||||
Sets internal debugging flags, and is of interest only to
|
||||
.Nm
|
||||
patchers.
|
||||
.It Xo
|
||||
.Fl z Ar backup-ext ,
|
||||
.Fl Fl suffix Ar backup-ext
|
||||
.Xc
|
||||
.It Fl z Ar backup-ext , Fl Fl suffix Ar backup-ext
|
||||
Causes the next argument to be interpreted as the backup extension, to be
|
||||
used in place of
|
||||
.Qq .orig .
|
|
@ -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.27 2008/09/19 18:33:34 joerg Exp $
|
||||
* $NetBSD: patch.c,v 1.29 2011/09/06 18:25:14 joerg Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -31,6 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: patch.c,v 1.29 2011/09/06 18:25:14 joerg Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -105,7 +106,7 @@ static bool spew_output(void);
|
|||
static void dump_line(LINENUM, bool);
|
||||
static bool patch_match(LINENUM, LINENUM, LINENUM);
|
||||
static bool similar(const char *, const char *, int);
|
||||
static void usage(void);
|
||||
__dead static void usage(void);
|
||||
|
||||
/* true if -E was specified on command line. */
|
||||
static bool remove_empty_files = false;
|
||||
|
@ -155,46 +156,36 @@ main(int argc, char *argv[])
|
|||
LINENUM where = 0, newwhere, fuzz, mymaxfuzz;
|
||||
const char *tmpdir;
|
||||
char *v;
|
||||
int alloclen;
|
||||
|
||||
setbuf(stderr, serrbuf);
|
||||
for (i = 0; i < MAXFILEC; i++)
|
||||
filearg[i] = NULL;
|
||||
|
||||
|
||||
/* Cons up the names of the temporary files. */
|
||||
if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0')
|
||||
tmpdir = _PATH_TMP;
|
||||
for (i = strlen(tmpdir) - 1; i > 0 && tmpdir[i] == '/'; i--)
|
||||
;
|
||||
i++;
|
||||
|
||||
alloclen = i + 100;
|
||||
#define TMPALLOC(var) if(!(var = malloc(alloclen))) { fatal(#var); exit(1); }
|
||||
TMPALLOC(TMPOUTNAME);
|
||||
TMPALLOC(TMPINNAME);
|
||||
TMPALLOC(TMPREJNAME);
|
||||
TMPALLOC(TMPPATNAME);
|
||||
|
||||
if (snprintf(TMPOUTNAME, alloclen, "%.*s/patchoXXXXXXXXXX", i, tmpdir) == -1)
|
||||
if (asprintf(&TMPOUTNAME, "%.*s/patchoXXXXXXXXXX", i, tmpdir) == -1)
|
||||
fatal("cannot allocate memory");
|
||||
if ((fd = mkstemp(TMPOUTNAME)) < 0)
|
||||
pfatal("can't create %s", TMPOUTNAME);
|
||||
close(fd);
|
||||
|
||||
if (snprintf(TMPINNAME, alloclen, "%.*s/patchiXXXXXXXXXX", i, tmpdir) == -1)
|
||||
if (asprintf(&TMPINNAME, "%.*s/patchiXXXXXXXXXX", i, tmpdir) == -1)
|
||||
fatal("cannot allocate memory");
|
||||
if ((fd = mkstemp(TMPINNAME)) < 0)
|
||||
pfatal("can't create %s", TMPINNAME);
|
||||
close(fd);
|
||||
|
||||
if (snprintf(TMPREJNAME, alloclen, "%.*s/patchrXXXXXXXXXX", i, tmpdir) == -1)
|
||||
if (asprintf(&TMPREJNAME, "%.*s/patchrXXXXXXXXXX", i, tmpdir) == -1)
|
||||
fatal("cannot allocate memory");
|
||||
if ((fd = mkstemp(TMPREJNAME)) < 0)
|
||||
pfatal("can't create %s", TMPREJNAME);
|
||||
close(fd);
|
||||
|
||||
if (snprintf(TMPPATNAME, alloclen, "%.*s/patchpXXXXXXXXXX", i, tmpdir) == -1)
|
||||
if (asprintf(&TMPPATNAME, "%.*s/patchpXXXXXXXXXX", i, tmpdir) == -1)
|
||||
fatal("cannot allocate memory");
|
||||
if ((fd = mkstemp(TMPPATNAME)) < 0)
|
||||
pfatal("can't create %s", TMPPATNAME);
|
||||
|
@ -632,7 +623,7 @@ usage(void)
|
|||
" [-r rej-name] [-V t | nil | never] [-x number] [-z backup-ext]\n"
|
||||
" [--posix] [origfile [patchfile]]\n"
|
||||
" patch <patchfile\n");
|
||||
my_exit(EXIT_SUCCESS);
|
||||
my_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/*
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $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 $
|
||||
* $NetBSD: pch.c,v 1.23 2008/09/19 18:33:34 joerg Exp $
|
||||
* $NetBSD: pch.c,v 1.25 2013/01/29 09:30:11 wiz Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -31,6 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: pch.c,v 1.25 2013/01/29 09:30:11 wiz Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -447,7 +448,7 @@ skip_to(LINENUM file_pos, LINENUM file_line)
|
|||
}
|
||||
|
||||
/* Make this a function for better debugging. */
|
||||
static void
|
||||
__dead static void
|
||||
malformed(void)
|
||||
{
|
||||
fatal("malformed patch at line %ld: %s", p_input_line, buf);
|
||||
|
@ -455,7 +456,7 @@ malformed(void)
|
|||
}
|
||||
|
||||
/*
|
||||
* True if the line has been discarded (i.e. it is a line saying
|
||||
* True if the line has been discarded (i.e., it is a line saying
|
||||
* "\ No newline at end of file".)
|
||||
*/
|
||||
static bool
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $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 $
|
||||
* $NetBSD: util.c,v 1.24 2008/09/19 18:33:34 joerg Exp $
|
||||
* $NetBSD: util.c,v 1.26 2010/10/02 19:31:14 wiz Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -31,6 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: util.c,v 1.26 2010/10/02 19:31:14 wiz Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -325,8 +326,10 @@ makedirs(const char *filename, bool striplast)
|
|||
|
||||
if (striplast) {
|
||||
char *s = strrchr(tmpbuf, '/');
|
||||
if (s == NULL)
|
||||
if (s == NULL) {
|
||||
free(tmpbuf);
|
||||
return; /* nothing to be done */
|
||||
}
|
||||
*s = '\0';
|
||||
}
|
||||
if (mkpath(tmpbuf) != 0)
|
||||
|
@ -415,7 +418,7 @@ checked_in(char *file)
|
|||
void
|
||||
version(void)
|
||||
{
|
||||
fprintf(stderr, "Patch version 2.0-12u8-NetBSD\n");
|
||||
printf("Patch version 2.0-12u8-NetBSD\n");
|
||||
my_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $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 $
|
||||
* $NetBSD: util.h,v 1.11 2008/09/19 18:33:34 joerg Exp $
|
||||
* $NetBSD: util.h,v 1.12 2011/09/06 18:25:14 joerg Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -35,20 +35,16 @@ char *checked_in(char *);
|
|||
int backup_file(const char *);
|
||||
int move_file(const char *, const char *);
|
||||
int copy_file(const char *, const char *);
|
||||
void say(const char *, ...)
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
void fatal(const char *, ...)
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
void pfatal(const char *, ...)
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
void ask(const char *, ...)
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
void say(const char *, ...) __printflike(1, 2);
|
||||
void fatal(const char *, ...) __printflike(1, 2) __dead;
|
||||
void pfatal(const char *, ...) __printflike(1, 2) __dead;
|
||||
void ask(const char *, ...) __printflike(1, 2);
|
||||
char *savestr(const char *);
|
||||
void set_signals(int);
|
||||
void ignore_signals(void);
|
||||
void makedirs(const char *, bool);
|
||||
void version(void);
|
||||
void my_exit(int) __attribute__((noreturn));
|
||||
void version(void) __dead;
|
||||
void my_exit(int) __dead;
|
||||
|
||||
/* in mkpath.c */
|
||||
extern int mkpath(char *);
|
Loading…
Reference in a new issue