summaryrefslogtreecommitdiff
path: root/usr.bin/patch
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-09-22 05:45:29 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-09-22 05:45:29 +0000
commit5e8a6177c055d4dd1ca8ae245a5ef3e946d9642f (patch)
tree617311af81a9e114f9f22ff9bbe1dcf122219b84 /usr.bin/patch
parent60e1b12fa81aba493d57be4b0633f029018d923d (diff)
Start of -Wall and cleaning up icky bits.
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/common.h5
-rw-r--r--usr.bin/patch/config.h3
-rw-r--r--usr.bin/patch/inp.c14
-rw-r--r--usr.bin/patch/patch.c9
-rw-r--r--usr.bin/patch/util.c43
-rw-r--r--usr.bin/patch/version.c8
6 files changed, 44 insertions, 38 deletions
diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h
index 2399724954a..8a0203c2df0 100644
--- a/usr.bin/patch/common.h
+++ b/usr.bin/patch/common.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: common.h,v 1.8 1997/09/06 23:51:31 niklas Exp $ */
+/* $OpenBSD: common.h,v 1.9 1997/09/22 05:45:26 millert Exp $ */
#define DEBUGGING
@@ -30,9 +30,12 @@
#include <sys/types.h>
#include <sys/file.h>
#include <sys/stat.h>
+#include <sys/param.h>
#include <ctype.h>
+#include <paths.h>
#include <signal.h>
#include <stdlib.h>
+#include <unistd.h>
#undef malloc
#undef realloc
diff --git a/usr.bin/patch/config.h b/usr.bin/patch/config.h
index ab735a85963..97a5510f744 100644
--- a/usr.bin/patch/config.h
+++ b/usr.bin/patch/config.h
@@ -1,4 +1,5 @@
-/* * $OpenBSD: config.h,v 1.2 1996/06/10 11:21:27 niklas Exp $*/
+/* $OpenBSD: config.h,v 1.3 1997/09/22 05:45:26 millert Exp $ */
+
/* config.h
* This file was produced by running the config.h.SH script, which
* gets its values from config.sh, which is generally produced by
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index d3917a88de0..f5f43659dd3 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: inp.c,v 1.5 1996/09/24 04:19:26 millert Exp $ */
+/* $OpenBSD: inp.c,v 1.6 1997/09/22 05:45:26 millert Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: inp.c,v 1.5 1996/09/24 04:19:26 millert Exp $";
+static char rcsid[] = "$OpenBSD: inp.c,v 1.6 1997/09/22 05:45:26 millert Exp $";
#endif /* not lint */
#include "EXTERN.h"
@@ -13,7 +13,7 @@ static char rcsid[] = "$OpenBSD: inp.c,v 1.5 1996/09/24 04:19:26 millert Exp $";
/* Input-file-with-indexable-lines abstract type */
-static long i_size; /* size of the input file */
+static off_t i_size; /* size of the input file */
static char *i_womp; /* plan a buffer for entire file */
static char **i_ptr; /* pointers to lines in i_womp */
@@ -157,10 +157,10 @@ char *filename;
#endif
if (i_womp == Nullch)
return FALSE;
- if ((ifd = open(filename, 0)) < 0)
+ if ((ifd = open(filename, O_RDONLY)) < 0)
pfatal2("can't open file %s", filename);
#ifndef lint
- if (read(ifd, i_womp, (int)i_size) != i_size) {
+ if (read(ifd, i_womp, (size_t)i_size) != i_size) {
Close(ifd); /* probably means i_size > 15 or 16 bits worth */
free(i_womp); /* at this point it doesn't matter if i_womp was */
return FALSE; /* undersized. */
@@ -296,7 +296,7 @@ char *filename;
}
Fclose(ifp);
Close(tifd);
- if ((tifd = open(TMPINNAME, 0)) < 0) {
+ if ((tifd = open(TMPINNAME, O_RDONLY)) < 0) {
pfatal2("can't reopen file %s", TMPINNAME);
}
}
@@ -323,7 +323,7 @@ int whichbuf; /* ignored when file in memory */
else {
tiline[whichbuf] = baseline;
#ifndef lint /* complains of long accuracy */
- Lseek(tifd, (long)baseline / lines_per_buf * BUFFERSIZE, 0);
+ Lseek(tifd, (off_t)(baseline / lines_per_buf * BUFFERSIZE), 0);
#endif
if (read(tifd, tibuf[whichbuf], BUFFERSIZE) < 0)
pfatal2("error reading tmp file %s", TMPINNAME);
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index 2c438db0789..b1810671167 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: patch.c,v 1.9 1997/01/17 07:13:04 millert Exp $ */
+/* $OpenBSD: patch.c,v 1.10 1997/09/22 05:45:27 millert Exp $ */
/* patch - a program to apply diffs to original files
*
@@ -9,7 +9,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: patch.c,v 1.9 1997/01/17 07:13:04 millert Exp $";
+static char rcsid[] = "$OpenBSD: patch.c,v 1.10 1997/09/22 05:45:27 millert Exp $";
#endif /* not lint */
#include "INTERN.h"
@@ -36,7 +36,11 @@ void dump_line();
bool patch_match();
bool similar();
void re_input();
+#ifdef __GNUC__
+void my_exit() __attribute__((noreturn));
+#else
void my_exit();
+#endif
/* TRUE if -E was specified on command line. */
static int remove_empty_files = FALSE;
@@ -327,6 +331,7 @@ char **argv;
set_signals(1);
}
my_exit(failtotal);
+ /* NOTREACHED */
}
/* Prepare to find the next patch to do in the patch file. */
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c
index 1029caca973..33eeee7ef46 100644
--- a/usr.bin/patch/util.c
+++ b/usr.bin/patch/util.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: util.c,v 1.3 1996/09/24 04:19:30 millert Exp $ */
+/* $OpenBSD: util.c,v 1.4 1997/09/22 05:45:27 millert Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: util.c,v 1.3 1996/09/24 04:19:30 millert Exp $";
+static char rcsid[] = "$OpenBSD: util.c,v 1.4 1997/09/22 05:45:27 millert Exp $";
#endif /* not lint */
#include "EXTERN.h"
@@ -10,7 +10,11 @@ static char rcsid[] = "$OpenBSD: util.c,v 1.3 1996/09/24 04:19:30 millert Exp $"
#include "util.h"
#include "backupfile.h"
+#ifdef __GNUC__
+void my_exit() __attribute__((noreturn));
+#else
void my_exit();
+#endif
/* Rename a file, copying it if necessary. */
@@ -18,7 +22,7 @@ int
move_file(from,to)
char *from, *to;
{
- char bakname[512];
+ char bakname[MAXPATHLEN];
Reg1 char *s;
Reg2 int i;
Reg3 int fromfd;
@@ -30,7 +34,7 @@ char *from, *to;
if (debug & 4)
say2("Moving %s to stdout.\n", from);
#endif
- fromfd = open(from, 0);
+ fromfd = open(from, O_RDONLY);
if (fromfd < 0)
pfatal2("internal error, can't reopen %s", from);
while ((i=read(fromfd, buf, sizeof buf)) > 0)
@@ -95,7 +99,7 @@ char *from, *to;
strerror(errno));
return -1;
}
- tofd = open(to, 0);
+ tofd = open(to, O_RDONLY);
if (tofd < 0)
pfatal2("internal error, can't open %s", to);
while ((i=read(tofd, buf, sizeof buf)) > 0)
@@ -119,7 +123,7 @@ char *from, *to;
to, from, strerror(errno));
return -1;
}
- fromfd = open(from, 0);
+ fromfd = open(from, O_RDONLY);
if (fromfd < 0)
pfatal2("internal error, can't reopen %s", from);
while ((i=read(fromfd, buf, sizeof buf)) > 0)
@@ -145,7 +149,7 @@ char *from, *to;
tofd = creat(to, 0666);
if (tofd < 0)
pfatal2("can't create %s", to);
- fromfd = open(from, 0);
+ fromfd = open(from, O_RDONLY);
if (fromfd < 0)
pfatal2("internal error, can't reopen %s", from);
while ((i=read(fromfd, buf, sizeof buf)) > 0)
@@ -177,7 +181,8 @@ Reg1 char *s;
}
else {
t = rv;
- while (*t++ = *s++);
+ while ((*t++ = *s++))
+ ;
}
return rv;
}
@@ -255,7 +260,7 @@ long arg1,arg2,arg3;
write(1, buf, strlen(buf));
r = read(1, buf, sizeof buf);
}
- else if ((ttyfd = open("/dev/tty", 2)) >= 0 && isatty(ttyfd)) {
+ else if ((ttyfd = open(_PATH_TTY, O_RDWR)) >= 0 && isatty(ttyfd)) {
/* might be deleted or unwriteable */
write(ttyfd, buf, strlen(buf));
r = read(ttyfd, buf, sizeof buf);
@@ -286,27 +291,15 @@ set_signals(reset)
int reset;
{
#ifndef lint
-#ifdef VOIDSIG
- static void (*hupval)(),(*intval)();
-#else
- static int (*hupval)(),(*intval)();
-#endif
+ static sig_t hupval, intval;
if (!reset) {
hupval = signal(SIGHUP, SIG_IGN);
if (hupval != SIG_IGN)
-#ifdef VOIDSIG
- hupval = my_exit;
-#else
- hupval = (int(*)())my_exit;
-#endif
+ hupval = (sig_t)my_exit;
intval = signal(SIGINT, SIG_IGN);
if (intval != SIG_IGN)
-#ifdef VOIDSIG
- intval = my_exit;
-#else
- intval = (int(*)())my_exit;
-#endif
+ intval = (sig_t)my_exit;
}
Signal(SIGHUP, hupval);
Signal(SIGINT, intval);
@@ -430,7 +423,7 @@ int assume_exists;
#define try(f, a1, a2) (Snprintf(tmpbuf + pathlen, sizeof tmpbuf - pathlen, f, a1, a2), stat(tmpbuf, &filestat) == 0)
if ( try("RCS/%s%s", filebase, RCSSUFFIX)
- || try("RCS/%s" , filebase, 0)
+ || try("RCS/%s%s", filebase, "")
|| try( "%s%s", filebase, RCSSUFFIX)
|| try("SCCS/%s%s", SCCSPREFIX, filebase)
|| try( "%s%s", SCCSPREFIX, filebase))
diff --git a/usr.bin/patch/version.c b/usr.bin/patch/version.c
index 52da0ecf865..417956b4004 100644
--- a/usr.bin/patch/version.c
+++ b/usr.bin/patch/version.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: version.c,v 1.2 1996/06/10 11:21:35 niklas Exp $ */
+/* $OpenBSD: version.c,v 1.3 1997/09/22 05:45:28 millert Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: version.c,v 1.2 1996/06/10 11:21:35 niklas Exp $";
+static char rcsid[] = "$OpenBSD: version.c,v 1.3 1997/09/22 05:45:28 millert Exp $";
#endif /* not lint */
#include "EXTERN.h"
@@ -11,7 +11,11 @@ static char rcsid[] = "$OpenBSD: version.c,v 1.2 1996/06/10 11:21:35 niklas Exp
#include "patchlevel.h"
#include "version.h"
+#ifdef __GNUC__
+void my_exit() __attribute__((noreturn));
+#else
void my_exit();
+#endif
/* Print out the version number and die. */