diff options
author | Niall O'Higgins <niallo@cvs.openbsd.org> | 2005-10-05 23:11:16 +0000 |
---|---|---|
committer | Niall O'Higgins <niallo@cvs.openbsd.org> | 2005-10-05 23:11:16 +0000 |
commit | 7eeaf4d565877ca5a6c5820bce12c24b950d4205 (patch) | |
tree | 538edcf49c4f27345f5abd697f62cd50f57dfbb4 /usr.bin | |
parent | 0e486b2d7d033e8d2caddc680eeb828b4bf8cdc8 (diff) |
- add a diff.h header file, corresponding to public functions in diff.c
and some #defines
- include this header in rcs.c
- link rcs against diff.c
this allows us to use the existing diff work from opencvs within functions
in the rcs.c API and thus in rcs programs. paves the way for diff support
in usr.bin/rcs programs.
ok joris@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/diff.c | 52 | ||||
-rw-r--r-- | usr.bin/cvs/diff.h | 98 | ||||
-rw-r--r-- | usr.bin/cvs/rcs.c | 3 | ||||
-rw-r--r-- | usr.bin/rcs/Makefile | 4 |
4 files changed, 117 insertions, 40 deletions
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c index c064040a589..db37b8b1487 100644 --- a/usr.bin/cvs/diff.c +++ b/usr.bin/cvs/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.55 2005/08/14 19:49:18 xsa Exp $ */ +/* $OpenBSD: diff.c,v 1.56 2005/10/05 23:11:06 niallo Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -143,37 +143,10 @@ #include "buf.h" #include "cvs.h" +#include "diff.h" #include "log.h" #include "proto.h" - -#define CVS_DIFF_DEFCTX 3 /* default context length */ - - -/* - * Output format options - */ -#define D_NORMAL 0 /* Normal output */ -#define D_CONTEXT 1 /* Diff with context */ -#define D_UNIFIED 2 /* Unified context diff */ -#define D_IFDEF 3 /* Diff with merged #ifdef's */ -#define D_BRIEF 4 /* Say if the files differ */ -#define D_RCSDIFF 5 /* Reverse editor output: RCS format */ - -/* - * Status values for print_status() and diffreg() return values - */ -#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 */ - struct cand { int x; int y; @@ -204,13 +177,13 @@ struct diff_arg { char *date2; }; - -static int cvs_diff_init(struct cvs_cmd *, int, char **, int *); +#if !defined(RCSPROG) +static int cvs_diff_init(struct cvs_cmd *, int, char **, int *); static int cvs_diff_remote(CVSFILE *, void *); static int cvs_diff_local(CVSFILE *, void *); static int cvs_diff_pre_exec(struct cvsroot *); static int cvs_diff_cleanup(void); -int cvs_diffreg(const char *, const char *); +#endif static void output(const char *, FILE *, const char *, FILE *); static void check(FILE *, FILE *); @@ -240,11 +213,15 @@ static char *match_function(const long *, int, FILE *); static char *preadline(int, size_t, off_t); -static int aflag, bflag, dflag, iflag, Nflag, pflag, tflag, Tflag, wflag; +#if !defined(RCSPROG) +static int Nflag; +static char diffargs[128]; +#endif +static int aflag, bflag, dflag, iflag, pflag, tflag, Tflag, wflag; static int context; static int format = D_NORMAL; static struct stat stb1, stb2; -static char *ifdefname, *ignore_pats, diffargs[128]; +static char *ifdefname, *ignore_pats; static const char *diff_file; regex_t ignore_re; @@ -272,8 +249,6 @@ static struct context_vec *context_vec_ptr; static char lastbuf[FUNCTION_CONTEXT_SIZE]; static int lastline; static int lastmatchline; - - /* * chrtran points to one of 2 translation tables: cup2low if folding upper to * lower case clow2low if not folding case @@ -332,7 +307,7 @@ u_char cup2low[256] = { 0xfd, 0xfe, 0xff }; - +#if !defined(RCSPROG) struct cvs_cmd cvs_cmd_diff = { CVS_OP_DIFF, CVS_REQ_DIFF, "diff", { "di", "dif" }, @@ -369,7 +344,9 @@ struct cvs_cmd cvs_cmd_rdiff = { cvs_diff_cleanup, CVS_CMD_SENDARGS2 | CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR }; +#endif +#if !defined(RCSPROG) static struct diff_arg *dap = NULL; static int recurse; @@ -698,6 +675,7 @@ cvs_diff_local(CVSFILE *cf, void *arg) return (0); } +#endif int diff --git a/usr.bin/cvs/diff.h b/usr.bin/cvs/diff.h new file mode 100644 index 00000000000..3702077375b --- /dev/null +++ b/usr.bin/cvs/diff.h @@ -0,0 +1,98 @@ +/* $OpenBSD: diff.h,v 1.1 2005/10/05 23:11:07 niallo Exp $ */ +/* + * Copyright (C) Caldera International Inc. 2001-2002. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code and documentation must retain the above + * copyright notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed or owned by Caldera + * International, Inc. + * 4. Neither the name of Caldera International, Inc. nor the names of other + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA + * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, + * INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 2004 Jean-Francois Brousseau. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 + */ +#ifndef CVS_DIFF_H +#define CVS_DIFF_H +#define CVS_DIFF_DEFCTX 3 /* default context length */ + + +/* + * Output format options + */ +#define D_NORMAL 0 /* Normal output */ +#define D_CONTEXT 1 /* Diff with context */ +#define D_UNIFIED 2 /* Unified context diff */ +#define D_IFDEF 3 /* Diff with merged #ifdef's */ +#define D_BRIEF 4 /* Say if the files differ */ +#define D_RCSDIFF 5 /* Reverse editor output: RCS format */ + +/* + * Status values for print_status() and diffreg() return values + */ +#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 */ + + + +int cvs_diffreg(const char *, const char *); +#endif diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index a04463c7624..c09d902e538 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.78 2005/10/05 17:34:59 joris Exp $ */ +/* $OpenBSD: rcs.c,v 1.79 2005/10/05 23:11:07 niallo Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -38,6 +38,7 @@ #include <string.h> #include <unistd.h> +#include "diff.h" #include "log.h" #include "rcs.h" #include "strtab.h" diff --git a/usr.bin/rcs/Makefile b/usr.bin/rcs/Makefile index f884e336604..5c5bd522186 100644 --- a/usr.bin/rcs/Makefile +++ b/usr.bin/rcs/Makefile @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile,v 1.7 2005/10/03 01:45:33 joris Exp $ +# $OpenBSD: Makefile,v 1.8 2005/10/05 23:11:15 niallo Exp $ .PATH: ${.CURDIR}/../cvs PROG= rcs MAN= rcs.1 -SRCS= ci.c co.c rcsprog.c buf.c log.c rcs.c rcsnum.c strtab.c +SRCS= ci.c co.c rcsprog.c buf.c diff.c log.c rcs.c rcsnum.c strtab.c CFLAGS+=-I${.CURDIR}/../cvs # Don't build the links until we actually support those commands |