hbase

heirloom base
git clone git://git.2f30.org/hbase
Log | Files | Refs | README

diff.h (7200B)


      1 /*
      2  * This code contains changes by
      3  * Gunnar Ritter, Freiburg i. Br., Germany, March 2003. All rights reserved.
      4  *
      5  * Conditions 1, 2, and 4 and the no-warranty notice below apply
      6  * to these changes.
      7  *
      8  *
      9  * Copyright (c) 1991
     10  * 	The Regents of the University of California.  All rights reserved.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  * 	This product includes software developed by the University of
     23  * 	California, Berkeley and its contributors.
     24  * 4. Neither the name of the University nor the names of its contributors
     25  *    may be used to endorse or promote products derived from this software
     26  *    without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  * SUCH DAMAGE.
     39  *
     40  *
     41  * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
     42  *
     43  * Redistribution and use in source and binary forms, with or without
     44  * modification, are permitted provided that the following conditions
     45  * are met:
     46  *   Redistributions of source code and documentation must retain the
     47  *    above copyright notice, this list of conditions and the following
     48  *    disclaimer.
     49  *   Redistributions in binary form must reproduce the above copyright
     50  *    notice, this list of conditions and the following disclaimer in the
     51  *    documentation and/or other materials provided with the distribution.
     52  *   All advertising materials mentioning features or use of this software
     53  *    must display the following acknowledgement:
     54  *      This product includes software developed or owned by Caldera
     55  *      International, Inc.
     56  *   Neither the name of Caldera International, Inc. nor the names of
     57  *    other contributors may be used to endorse or promote products
     58  *    derived from this software without specific prior written permission.
     59  *
     60  * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
     61  * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
     62  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     63  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     64  * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
     65  * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
     66  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     67  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     68  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     69  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     70  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     71  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     72  */
     73 
     74 /*	Sccsid @(#)diff.h	1.15 (gritter) 3/26/05>	*/
     75 /*	from 4.3BSD diff.h	4.7	85/08/16	*/
     76 
     77 /*
     78  * diff - common declarations
     79  */
     80 
     81 #include <stdio.h>
     82 #include <ctype.h>
     83 #include <sys/param.h>
     84 #include <sys/stat.h>
     85 #include <dirent.h>
     86 #include <stdlib.h>
     87 #include <string.h>
     88 #include <limits.h>
     89 #include <libgen.h>
     90 #include <errno.h>
     91 #include <setjmp.h>
     92 
     93 #if defined (__GLIBC__)
     94 #if defined (_IO_getc_unlocked)
     95 #undef	getc
     96 #define	getc(f)		_IO_getc_unlocked(f)
     97 #endif
     98 #if defined (_IO_putc_unlocked)
     99 #undef	putc
    100 #define	putc(c, f)	_IO_putc_unlocked(c, f)
    101 #undef	putchar
    102 #define	putchar(c)	_IO_putc_unlocked(c, stdout)
    103 #endif
    104 #endif
    105 
    106 /*
    107  * Output format options
    108  */
    109 int	opt;
    110 
    111 #define	D_NORMAL	0	/* Normal output */
    112 #define	D_EDIT		-1	/* Editor script out */
    113 #define	D_REVERSE	1	/* Reverse editor script */
    114 #define	D_CONTEXT	2	/* Diff with context */
    115 #define	D_IFDEF		3	/* Diff with merged #ifdef's */
    116 #define	D_NREVERSE	4	/* Reverse ed script with numbered
    117 				   lines and no trailing . */
    118 #define	D_UNIFIED	5	/* Unified diff */
    119 
    120 int	aflag;			/* diff binary files */
    121 int	tflag;			/* expand tabs on output */
    122 int	pflag;			/* show surrounding C function */
    123 
    124 /*
    125  * Algorithm related options
    126  */
    127 int	hflag;			/* -h, use halfhearted DIFFH */
    128 int	bflag;			/* ignore blanks in comparisons */
    129 int	wflag;			/* totally ignore blanks in comparisons */
    130 int	iflag;			/* ignore case in comparisons */
    131 int	Bflag;			/* ignore changes that consist of blank lines */
    132 
    133 /*
    134  * Options on hierarchical diffs.
    135  */
    136 int	lflag;			/* long output format with header */
    137 int	rflag;			/* recursively trace directories */
    138 int	sflag;			/* announce files which are same */
    139 int	Nflag;			/* write text of nonexistant files */
    140 const char	*start;		/* do file only if name >= this */
    141 
    142 struct xclusion {
    143 	struct xclusion	*x_nxt;
    144 	const char	*x_pat;
    145 }	*xflag;			/* patterns to exclude from comparison */
    146 
    147 /*
    148  * Variables for -I D_IFDEF option.
    149  */
    150 int	wantelses;		/* -E */
    151 char	*ifdef1;		/* String for -1 */
    152 char	*ifdef2;		/* String for -2 */
    153 char	*endifname;		/* What we will print on next #endif */
    154 int	inifdef;
    155 
    156 /*
    157  * Variables for -c context option.
    158  */
    159 int	context;		/* lines of context to be printed */
    160 
    161 /*
    162  * State for exit status.
    163  */
    164 int	status;
    165 int	anychange;
    166 char	*tempfile1;		/* used when comparing against std input */
    167 char	*tempfile2;		/* used when comparing against std input */
    168 
    169 /*
    170  * Variables for diffdir.
    171  */
    172 char	**diffargv;		/* option list to pass to recursive diffs */
    173 int	recdepth;		/* recursion depth */
    174 jmp_buf	recenv;			/* jump stack on error */
    175 
    176 struct stackblk {
    177 	struct stackblk	*s_prev;
    178 	struct stackblk	*s_next;
    179 } *curstack;
    180 
    181 /*
    182  * Input file names.
    183  * With diffdir, file1 and file2 are allocated BUFSIZ space,
    184  * and padded with a '/', and then efile0 and efile1 point after
    185  * the '/'.
    186  */
    187 char	*file1, *file2, *efile1, *efile2;
    188 struct	stat stb1, stb2;
    189 
    190 extern	const char diffh[], diff[], pr[];
    191 extern	const char *argv0;
    192 extern	const char *progname;
    193 int	mb_cur_max;
    194 extern int	sysv3;
    195 
    196 /* diff.c */
    197 void	diffany(char **);
    198 int	min(int, int);
    199 int	max(int, int);
    200 void	done(void);
    201 void	*dalloc(size_t);
    202 void	*talloc(size_t);
    203 void	*ralloc(void *, size_t);
    204 void	tfree(void *);
    205 void	purgestack(void);
    206 void	oomsg(const char *);
    207 /* diffdir.c */
    208 void	diffdir(char **);
    209 int	ascii(int);
    210 /* diffreg.c */
    211 void	diffreg(void);