diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2006-05-05 15:47:37 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2006-05-05 15:47:37 +0000 |
commit | 32adbfb76516082a6df498a61500395a81652210 (patch) | |
tree | 2aafadd376cb47c31811b45afe72b23c7b07ed0e | |
parent | fded76b603159686e912195d2de81fc4ed6ecfbd (diff) |
- fix rcsdiff exit status on success/errors; now matches gnu/usr.bin/rcs.
- add DIAGNOSTICS section to rcsdiff.1 wrt exit codes.
ok ray@ and jmc@ for man page bits.
-rw-r--r-- | usr.bin/rcs/diff.c | 4 | ||||
-rw-r--r-- | usr.bin/rcs/diff.h | 19 | ||||
-rw-r--r-- | usr.bin/rcs/rcsdiff.1 | 15 | ||||
-rw-r--r-- | usr.bin/rcs/rcsdiff.c | 30 |
4 files changed, 33 insertions, 35 deletions
diff --git a/usr.bin/rcs/diff.c b/usr.bin/rcs/diff.c index 10e74089007..c78b33fe05f 100644 --- a/usr.bin/rcs/diff.c +++ b/usr.bin/rcs/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.3 2006/04/29 05:31:28 ray Exp $ */ +/* $OpenBSD: diff.c,v 1.4 2006/05/05 15:47:36 xsa Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -334,7 +334,7 @@ rcs_diffreg(const char *file1, const char *file2, BUF *out) } if (!asciifile(f1) || !asciifile(f2)) { - rval = D_BINARY; + rval = D_ERROR; goto closem; } diff --git a/usr.bin/rcs/diff.h b/usr.bin/rcs/diff.h index 73b3144716a..fdf7cfa821e 100644 --- a/usr.bin/rcs/diff.h +++ b/usr.bin/rcs/diff.h @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.h,v 1.1 2006/04/26 02:55:13 joris Exp $ */ +/* $OpenBSD: diff.h,v 1.2 2006/05/05 15:47:36 xsa Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -64,14 +64,12 @@ * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 */ -#ifndef CVS_DIFF_H -#define CVS_DIFF_H +#ifndef RCS_DIFF_H +#define RCS_DIFF_H #include "buf.h" #include "rcs.h" -#define CVS_DIFF_DEFCTX 3 /* default context length */ - /* * Output format options */ @@ -87,14 +85,7 @@ */ #define D_SAME 0 /* Files are the same */ #define D_DIFFER 1 /* Files are different */ -#define D_BINARY 2 /* Binary files are different */ -#define D_COMMON 3 /* Subdirectory common to both dirs */ -#define D_ONLY 4 /* Only exists in one directory */ -#define D_MISMATCH1 5 /* path1 was a dir, path2 a file */ -#define D_MISMATCH2 6 /* path1 was a file, path2 a dir */ -#define D_ERROR 7 /* An error occurred */ -#define D_SKIPPED1 8 /* path1 was a special file */ -#define D_SKIPPED2 9 /* path2 was a special file */ +#define D_ERROR 2 /* An error occurred */ struct rcs_lines; @@ -111,4 +102,4 @@ extern BUF *diffbuf; extern RCSNUM *diff_rev1; extern RCSNUM *diff_rev2; -#endif +#endif /* RCS_DIFF_H */ diff --git a/usr.bin/rcs/rcsdiff.1 b/usr.bin/rcs/rcsdiff.1 index 4196d304215..3c8fdf370be 100644 --- a/usr.bin/rcs/rcsdiff.1 +++ b/usr.bin/rcs/rcsdiff.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: rcsdiff.1,v 1.21 2006/04/24 08:40:01 jmc Exp $ +.\" $OpenBSD: rcsdiff.1,v 1.22 2006/05/05 15:47:36 xsa Exp $ .\" .\" Copyright (c) 2005 Joris Vink <joris@openbsd.org> .\" All rights reserved. @@ -113,6 +113,19 @@ Compare revision 1.7 and 1.8 of file and ignore differences in keyword values: .Pp .Dl $ rcsdiff -kk -r1.7 -r1.8 foo.c +.Sh DIAGNOSTICS +The +.Nm +utility exits with one of the following values: +.Pp +.Bl -tag -width Ds -compact -offset indent +.It 0 +No differences were found. +.It 1 +Differences were found. +.It 2 +An error occurred. +.El .Sh SEE ALSO .Xr ci 1 , .Xr co 1 , diff --git a/usr.bin/rcs/rcsdiff.c b/usr.bin/rcs/rcsdiff.c index 1964b99b458..389080a6c81 100644 --- a/usr.bin/rcs/rcsdiff.c +++ b/usr.bin/rcs/rcsdiff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsdiff.c,v 1.60 2006/05/04 07:06:58 xsa Exp $ */ +/* $OpenBSD: rcsdiff.c,v 1.61 2006/05/05 15:47:36 xsa Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -45,7 +45,7 @@ rcsdiff_main(int argc, char **argv) rev1 = rev2 = NULL; rev_str1 = rev_str2 = NULL; - status = 0; + status = D_SAME; if (strlcpy(diffargs, "diff", sizeof(diffargs)) >= sizeof(diffargs)) errx(1, "diffargs too long"); @@ -143,18 +143,14 @@ rcsdiff_main(int argc, char **argv) diff_file = argv[i]; /* No revisions given. */ - if (rev_str1 == NULL) { - if (rcsdiff_file(file, file->rf_head, argv[i]) < 0) - status = 2; + if (rev_str1 == NULL) + status = rcsdiff_file(file, file->rf_head, argv[i]); /* One revision given. */ - } else if (rev_str2 == NULL) { - if (rcsdiff_file(file, rev1, argv[i]) < 0) - status = 2; + else if (rev_str2 == NULL) + status = rcsdiff_file(file, rev1, argv[i]); /* Two revisions given. */ - } else { - if (rcsdiff_rev(file, rev1, rev2) < 0) - status = 2; - } + else + status = rcsdiff_rev(file, rev1, rev2); rcs_close(file); @@ -194,7 +190,7 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename) memset(&tv, 0, sizeof(tv)); memset(&tv2, 0, sizeof(tv2)); - ret = -1; + ret = D_ERROR; b1 = b2 = NULL; diff_rev1 = rev; @@ -253,8 +249,7 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename) if (utimes(path2, (const struct timeval *)&tv2) < 0) warn("utimes"); - rcs_diffreg(path1, path2, NULL); - ret = 0; + ret = rcs_diffreg(path1, path2, NULL); out: if (fd != -1) @@ -280,7 +275,7 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2) char rbuf1[64], rbuf2[64]; struct timeval tv[2], tv2[2]; - ret = -1; + ret = D_ERROR; b1 = b2 = NULL; memset(&tv, 0, sizeof(tv)); memset(&tv2, 0, sizeof(tv2)); @@ -335,8 +330,7 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2) if (utimes(path2, (const struct timeval *)&tv2) < 0) warn("utimes"); - rcs_diffreg(path1, path2, NULL); - ret = 0; + ret = rcs_diffreg(path1, path2, NULL); out: if (b1 != NULL) |