security/nss/coreconf/mkdepend/pr.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/coreconf/mkdepend/pr.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,124 @@
     1.4 +/* $Xorg: pr.c,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
     1.5 +/*
     1.6 +
     1.7 +Copyright (c) 1993, 1994, 1998 The Open Group
     1.8 +
     1.9 +Permission to use, copy, modify, distribute, and sell this software and its
    1.10 +documentation for any purpose is hereby granted without fee, provided that
    1.11 +the above copyright notice appear in all copies and that both that
    1.12 +copyright notice and this permission notice appear in supporting
    1.13 +documentation.
    1.14 +
    1.15 +The above copyright notice and this permission notice shall be included in
    1.16 +all copies or substantial portions of the Software.
    1.17 +
    1.18 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    1.19 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    1.20 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    1.21 +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
    1.22 +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
    1.23 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    1.24 +
    1.25 +Except as contained in this notice, the name of The Open Group shall not be
    1.26 +used in advertising or otherwise to promote the sale, use or other dealings
    1.27 +in this Software without prior written authorization from The Open Group.
    1.28 +
    1.29 +*/
    1.30 +/* $XFree86: xc/config/makedepend/pr.c,v 1.5 2001/12/14 19:53:21 dawes Exp $ */
    1.31 +
    1.32 +#include "def.h"
    1.33 +
    1.34 +extern struct	inclist	inclist[ MAXFILES ],
    1.35 +			*inclistp;
    1.36 +extern char	*objprefix;
    1.37 +extern char	*objsuffix;
    1.38 +extern int	width;
    1.39 +extern boolean	printed;
    1.40 +extern boolean	verbose;
    1.41 +extern boolean	show_where_not;
    1.42 +
    1.43 +void
    1.44 +add_include(struct filepointer *filep, struct inclist *file, 
    1.45 +	    struct inclist *file_red, char *include, int type,
    1.46 +	    boolean failOK)
    1.47 +{
    1.48 +	register struct inclist	*newfile;
    1.49 +	register struct filepointer	*content;
    1.50 +
    1.51 +	/*
    1.52 +	 * First decide what the pathname of this include file really is.
    1.53 +	 */
    1.54 +	newfile = inc_path(file->i_file, include, type);
    1.55 +	if (newfile == NULL) {
    1.56 +		if (failOK)
    1.57 +		    return;
    1.58 +		if (file != file_red)
    1.59 +			warning("%s (reading %s, line %d): ",
    1.60 +				file_red->i_file, file->i_file, filep->f_line);
    1.61 +		else
    1.62 +			warning("%s, line %d: ", file->i_file, filep->f_line);
    1.63 +		warning1("cannot find include file \"%s\"\n", include);
    1.64 +		show_where_not = TRUE;
    1.65 +		newfile = inc_path(file->i_file, include, type);
    1.66 +		show_where_not = FALSE;
    1.67 +	}
    1.68 +
    1.69 +	if (newfile) {
    1.70 +		included_by(file, newfile);
    1.71 +		if (!(newfile->i_flags & SEARCHED)) {
    1.72 +			newfile->i_flags |= SEARCHED;
    1.73 +			content = getfile(newfile->i_file);
    1.74 +			find_includes(content, newfile, file_red, 0, failOK);
    1.75 +			freefile(content);
    1.76 +		}
    1.77 +	}
    1.78 +}
    1.79 +
    1.80 +static void
    1.81 +pr(struct inclist *ip, char *file, char *base)
    1.82 +{
    1.83 +	static char	*lastfile;
    1.84 +	static int	current_len;
    1.85 +	register int	len, i;
    1.86 +	char	buf[ BUFSIZ ];
    1.87 +
    1.88 +	printed = TRUE;
    1.89 +	len = strlen(ip->i_file)+1;
    1.90 +	if (current_len + len > width || file != lastfile) {
    1.91 +		lastfile = file;
    1.92 +		sprintf(buf, "\n%s%s%s: %s", objprefix, base, objsuffix,
    1.93 +			ip->i_file);
    1.94 +		len = current_len = strlen(buf);
    1.95 +	}
    1.96 +	else {
    1.97 +		buf[0] = ' ';
    1.98 +		strcpy(buf+1, ip->i_file);
    1.99 +		current_len += len;
   1.100 +	}
   1.101 +	fwrite(buf, len, 1, stdout);
   1.102 +
   1.103 +	/*
   1.104 +	 * If verbose is set, then print out what this file includes.
   1.105 +	 */
   1.106 +	if (! verbose || ip->i_list == NULL || ip->i_flags & NOTIFIED)
   1.107 +		return;
   1.108 +	ip->i_flags |= NOTIFIED;
   1.109 +	lastfile = NULL;
   1.110 +	printf("\n# %s includes:", ip->i_file);
   1.111 +	for (i=0; i<ip->i_listlen; i++)
   1.112 +		printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
   1.113 +}
   1.114 +
   1.115 +void
   1.116 +recursive_pr_include(struct inclist *head, char *file, char *base)
   1.117 +{
   1.118 +	int	i;
   1.119 +
   1.120 +	if (head->i_flags & MARKED)
   1.121 +		return;
   1.122 +	head->i_flags |= MARKED;
   1.123 +	if (head->i_file != file)
   1.124 +		pr(head, file, base);
   1.125 +	for (i=0; i<head->i_listlen; i++)
   1.126 +		recursive_pr_include(head->i_list[ i ], file, base);
   1.127 +}

mercurial