/[jscoverage]/trunk/js/config/mkdepend/pr.c
ViewVC logotype

Contents of /trunk/js/config/mkdepend/pr.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 399 - (show annotations)
Tue Dec 9 03:37:47 2008 UTC (10 years, 11 months ago) by siliconforks
File MIME type: text/plain
File size: 3609 byte(s)
Use SpiderMonkey from Firefox 3.1b2.

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

  ViewVC Help
Powered by ViewVC 1.1.24