source: trunk/src/makedep/pr.c@ 201

Last change on this file since 201 was 173, checked in by bird, 21 years ago

quiet option and objname option.

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