security/nss/coreconf/mkdepend/pr.c

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* $Xorg: pr.c,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
michael@0 2 /*
michael@0 3
michael@0 4 Copyright (c) 1993, 1994, 1998 The Open Group
michael@0 5
michael@0 6 Permission to use, copy, modify, distribute, and sell this software and its
michael@0 7 documentation for any purpose is hereby granted without fee, provided that
michael@0 8 the above copyright notice appear in all copies and that both that
michael@0 9 copyright notice and this permission notice appear in supporting
michael@0 10 documentation.
michael@0 11
michael@0 12 The above copyright notice and this permission notice shall be included in
michael@0 13 all copies or substantial portions of the Software.
michael@0 14
michael@0 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
michael@0 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
michael@0 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
michael@0 18 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
michael@0 19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
michael@0 20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
michael@0 21
michael@0 22 Except as contained in this notice, the name of The Open Group shall not be
michael@0 23 used in advertising or otherwise to promote the sale, use or other dealings
michael@0 24 in this Software without prior written authorization from The Open Group.
michael@0 25
michael@0 26 */
michael@0 27 /* $XFree86: xc/config/makedepend/pr.c,v 1.5 2001/12/14 19:53:21 dawes Exp $ */
michael@0 28
michael@0 29 #include "def.h"
michael@0 30
michael@0 31 extern struct inclist inclist[ MAXFILES ],
michael@0 32 *inclistp;
michael@0 33 extern char *objprefix;
michael@0 34 extern char *objsuffix;
michael@0 35 extern int width;
michael@0 36 extern boolean printed;
michael@0 37 extern boolean verbose;
michael@0 38 extern boolean show_where_not;
michael@0 39
michael@0 40 void
michael@0 41 add_include(struct filepointer *filep, struct inclist *file,
michael@0 42 struct inclist *file_red, char *include, int type,
michael@0 43 boolean failOK)
michael@0 44 {
michael@0 45 register struct inclist *newfile;
michael@0 46 register struct filepointer *content;
michael@0 47
michael@0 48 /*
michael@0 49 * First decide what the pathname of this include file really is.
michael@0 50 */
michael@0 51 newfile = inc_path(file->i_file, include, type);
michael@0 52 if (newfile == NULL) {
michael@0 53 if (failOK)
michael@0 54 return;
michael@0 55 if (file != file_red)
michael@0 56 warning("%s (reading %s, line %d): ",
michael@0 57 file_red->i_file, file->i_file, filep->f_line);
michael@0 58 else
michael@0 59 warning("%s, line %d: ", file->i_file, filep->f_line);
michael@0 60 warning1("cannot find include file \"%s\"\n", include);
michael@0 61 show_where_not = TRUE;
michael@0 62 newfile = inc_path(file->i_file, include, type);
michael@0 63 show_where_not = FALSE;
michael@0 64 }
michael@0 65
michael@0 66 if (newfile) {
michael@0 67 included_by(file, newfile);
michael@0 68 if (!(newfile->i_flags & SEARCHED)) {
michael@0 69 newfile->i_flags |= SEARCHED;
michael@0 70 content = getfile(newfile->i_file);
michael@0 71 find_includes(content, newfile, file_red, 0, failOK);
michael@0 72 freefile(content);
michael@0 73 }
michael@0 74 }
michael@0 75 }
michael@0 76
michael@0 77 static void
michael@0 78 pr(struct inclist *ip, char *file, char *base)
michael@0 79 {
michael@0 80 static char *lastfile;
michael@0 81 static int current_len;
michael@0 82 register int len, i;
michael@0 83 char buf[ BUFSIZ ];
michael@0 84
michael@0 85 printed = TRUE;
michael@0 86 len = strlen(ip->i_file)+1;
michael@0 87 if (current_len + len > width || file != lastfile) {
michael@0 88 lastfile = file;
michael@0 89 sprintf(buf, "\n%s%s%s: %s", objprefix, base, objsuffix,
michael@0 90 ip->i_file);
michael@0 91 len = current_len = strlen(buf);
michael@0 92 }
michael@0 93 else {
michael@0 94 buf[0] = ' ';
michael@0 95 strcpy(buf+1, ip->i_file);
michael@0 96 current_len += len;
michael@0 97 }
michael@0 98 fwrite(buf, len, 1, stdout);
michael@0 99
michael@0 100 /*
michael@0 101 * If verbose is set, then print out what this file includes.
michael@0 102 */
michael@0 103 if (! verbose || ip->i_list == NULL || ip->i_flags & NOTIFIED)
michael@0 104 return;
michael@0 105 ip->i_flags |= NOTIFIED;
michael@0 106 lastfile = NULL;
michael@0 107 printf("\n# %s includes:", ip->i_file);
michael@0 108 for (i=0; i<ip->i_listlen; i++)
michael@0 109 printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
michael@0 110 }
michael@0 111
michael@0 112 void
michael@0 113 recursive_pr_include(struct inclist *head, char *file, char *base)
michael@0 114 {
michael@0 115 int i;
michael@0 116
michael@0 117 if (head->i_flags & MARKED)
michael@0 118 return;
michael@0 119 head->i_flags |= MARKED;
michael@0 120 if (head->i_file != file)
michael@0 121 pr(head, file, base);
michael@0 122 for (i=0; i<head->i_listlen; i++)
michael@0 123 recursive_pr_include(head->i_list[ i ], file, base);
michael@0 124 }

mercurial