summaryrefslogtreecommitdiff
path: root/usr.bin/patch
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-03-11 19:41:31 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-03-11 19:41:31 +0000
commit0602b73ec15a8277cd9d17df0b64329377368829 (patch)
tree5b0f8ad26f4db55eaa206f9989cc3cb9f1ae35e5 /usr.bin/patch
parente636efd76e49a691912f28b0f3a2fcc4d39d3698 (diff)
type police and assorted cleanup. From Lionel Fourquaux; ok ray@
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/backupfile.c11
-rw-r--r--usr.bin/patch/common.h6
-rw-r--r--usr.bin/patch/inp.c16
-rw-r--r--usr.bin/patch/patch.c6
-rw-r--r--usr.bin/patch/pch.c7
-rw-r--r--usr.bin/patch/util.c5
6 files changed, 27 insertions, 24 deletions
diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c
index 856d2a6f948..eb25313f00f 100644
--- a/usr.bin/patch/backupfile.c
+++ b/usr.bin/patch/backupfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: backupfile.c,v 1.18 2004/08/05 21:47:24 deraadt Exp $ */
+/* $OpenBSD: backupfile.c,v 1.19 2006/03/11 19:41:30 otto Exp $ */
/*
* backupfile.c -- make Emacs style backup file names Copyright (C) 1990 Free
@@ -17,7 +17,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: backupfile.c,v 1.18 2004/08/05 21:47:24 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: backupfile.c,v 1.19 2006/03/11 19:41:30 otto Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -45,7 +45,7 @@ char *simple_backup_suffix = "~";
static char *concat(const char *, const char *);
static char *make_version_name(const char *, int);
static int max_backup_version(const char *, const char *);
-static int version_number(const char *, const char *, int);
+static int version_number(const char *, const char *, size_t);
static int argmatch(const char *, const char **);
static void invalid_arg(const char *, const char *, int);
@@ -88,7 +88,8 @@ max_backup_version(const char *file, const char *dir)
{
DIR *dirp;
struct dirent *dp;
- int highest_version, this_version, file_name_length;
+ int highest_version, this_version;
+ size_t file_name_length;
dirp = opendir(dir);
if (dirp == NULL)
@@ -129,7 +130,7 @@ make_version_name(const char *file, int version)
* already have ".~" appended to it.
*/
static int
-version_number(const char *base, const char *backup, int base_length)
+version_number(const char *base, const char *backup, size_t base_length)
{
int version;
const char *p;
diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h
index 4101a575747..57b6614d7d0 100644
--- a/usr.bin/patch/common.h
+++ b/usr.bin/patch/common.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: common.h,v 1.25 2003/10/31 20:20:45 millert Exp $ */
+/* $OpenBSD: common.h,v 1.26 2006/03/11 19:41:30 otto Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -26,6 +26,8 @@
* behaviour
*/
+#include <sys/types.h>
+
#include <stdbool.h>
#define DEBUGGING
@@ -61,7 +63,7 @@ typedef long LINENUM; /* must be signed */
/* globals */
-extern int filemode;
+extern mode_t filemode;
extern char buf[MAXLINELEN];/* general purpose buffer */
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index 5a196a40112..eaf5f527a20 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inp.c,v 1.33 2005/11/14 19:54:10 miod Exp $ */
+/* $OpenBSD: inp.c,v 1.34 2006/03/11 19:41:30 otto Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -27,7 +27,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: inp.c,v 1.33 2005/11/14 19:54:10 miod Exp $";
+static const char rcsid[] = "$OpenBSD: inp.c,v 1.34 2006/03/11 19:41:30 otto Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -136,11 +136,10 @@ plan_a(const char *filename)
{
int ifd, statfailed;
char *p, *s, lbuf[MAXLINELEN];
- LINENUM iline;
struct stat filestat;
off_t i;
ptrdiff_t sz;
- size_t lines_allocated;
+ size_t iline, lines_allocated;
#ifdef DEBUGGING
if (debug & 8)
@@ -339,7 +338,7 @@ static void
plan_b(const char *filename)
{
FILE *ifp;
- int i = 0, j, maxlen = 1;
+ size_t i = 0, j, maxlen = 1;
char *p;
bool found_revision = (revision == NULL);
@@ -439,8 +438,9 @@ ifetch(LINENUM line, int whichbuf)
else {
tiline[whichbuf] = baseline;
- lseek(tifd, (off_t) (baseline / lines_per_buf *
- BUFFERSIZE), SEEK_SET);
+ if (lseek(tifd, (off_t) (baseline / lines_per_buf *
+ BUFFERSIZE), SEEK_SET) < 0)
+ pfatal("cannot seek in the temporary input file");
if (read(tifd, tibuf[whichbuf], BUFFERSIZE) < 0)
pfatal("error reading tmp file %s", TMPINNAME);
@@ -456,7 +456,7 @@ static bool
rev_in_string(const char *string)
{
const char *s;
- int patlen;
+ size_t patlen;
if (revision == NULL)
return true;
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index a4f304804ec..3f90c2e725c 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: patch.c,v 1.43 2004/11/19 20:08:11 otto Exp $ */
+/* $OpenBSD: patch.c,v 1.44 2006/03/11 19:41:30 otto Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -27,7 +27,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: patch.c,v 1.43 2004/11/19 20:08:11 otto Exp $";
+static const char rcsid[] = "$OpenBSD: patch.c,v 1.44 2006/03/11 19:41:30 otto Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -48,7 +48,7 @@ static const char rcsid[] = "$OpenBSD: patch.c,v 1.43 2004/11/19 20:08:11 otto E
#include "backupfile.h"
#include "pathnames.h"
-int filemode = 0644;
+mode_t filemode = 0644;
char buf[MAXLINELEN]; /* general purpose buffer */
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index 8edf5d94553..e41ddf8c757 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pch.c,v 1.35 2004/08/05 21:47:24 deraadt Exp $ */
+/* $OpenBSD: pch.c,v 1.36 2006/03/11 19:41:30 otto Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -27,7 +27,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: pch.c,v 1.35 2004/08/05 21:47:24 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: pch.c,v 1.36 2006/03/11 19:41:30 otto Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -1367,9 +1367,8 @@ do_ed_script(void)
{
char *t;
long beginning_of_this_line;
- FILE *pipefp;
+ FILE *pipefp = NULL;
- pipefp = NULL;
if (!skip_rest_of_patch) {
if (copy_file(filearg[0], TMPOUTNAME) < 0) {
unlink(TMPOUTNAME);
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c
index 52e00c6ddf9..5523450c95e 100644
--- a/usr.bin/patch/util.c
+++ b/usr.bin/patch/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.31 2005/06/20 07:14:06 otto Exp $ */
+/* $OpenBSD: util.c,v 1.32 2006/03/11 19:41:30 otto Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -27,7 +27,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: util.c,v 1.31 2005/06/20 07:14:06 otto Exp $";
+static const char rcsid[] = "$OpenBSD: util.c,v 1.32 2006/03/11 19:41:30 otto Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -38,6 +38,7 @@ static const char rcsid[] = "$OpenBSD: util.c,v 1.31 2005/06/20 07:14:06 otto Ex
#include <fcntl.h>
#include <libgen.h>
#include <paths.h>
+#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>