3 Copyright (c) 1993, 1994 X Consortium
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
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 X CONSORTIUM 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.
22 Except as contained in this notice, the name of the X Consortium 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 X Consortium.
29 #pragma warning(disable : 4996)
36 //extern struct inclist inc_list[ MAXFILES ], *inclistp;
37 extern char *objprefix;
38 extern char *objsuffix;
42 extern bool show_where_not;
44 void add_include(filepointer *filep, inclist *file,
45 inclist *file_red, char *include, bool dot, bool failOK)
47 register struct inclist *newfile;
48 register struct filepointer *content;
51 * First decide what the pathname of this include file really is.
53 newfile = inc_path(file->i_file, include, dot, failOK);
54 if (newfile == NULL) {
58 warning("%s (reading %s, line %d): ",
59 file_red->i_file, file->i_file, filep->f_line);
61 warning("%s, line %d: ", file->i_file, filep->f_line);
62 warning1("cannot find include file \"%s\"\n", include);
63 fatalerr("cannot find include file \"%s\"\n", include);
64 show_where_not = true;
65 newfile = inc_path(file->i_file, include, dot, failOK);
66 show_where_not = false;
70 included_by(file, newfile);
71 if (!newfile->i_searched) {
72 newfile->i_searched = true;
73 content = getfile(newfile->i_file);
74 find_includes(content, newfile, file_red, 0, failOK);
80 void recursive_pr_include(register struct inclist *head, register char *file,
87 head->i_marked = true;
88 if (head->i_file != file) {
90 if ((strlen(file) >= 3) && !strcmp(file + strlen(file) - 3, ".rc"))
92 pr(head, file, base, rc_file);
94 for (i=0; i<head->i_listlen; i++)
95 recursive_pr_include(head->i_list[ i ], file, base);
98 void pr(register struct inclist *ip, char *file, char *base, bool rc_file)
100 static char *lastfile;
101 static int current_len;
106 len = int(strlen(ip->i_file)+1);
107 if (current_len + len > width || file != lastfile) {
109 char *temp_suff = objsuffix;
110 if (rc_file) temp_suff = (char *)".res";
111 sprintf(buf, "\n%s%s%s: %s ", objprefix, base, temp_suff, ip->i_file);
112 len = current_len = int(strlen(buf));
115 strcpy(buf, ip->i_file);
116 //printf("ip->file=%s\n", ip->i_file);
117 char tmp[2] = { ' ', '\0' };
118 //printf("tmp=%s\n", tmp);
120 //printf("buf=%s\n", buf);
123 fwrite(buf, len, 1, stdout);
125 // If verbose is set, then print out what this file includes.
126 if (! verbose || ip->i_list == NULL || ip->i_notified)
128 ip->i_notified = true;
130 printf("\n# %s includes:", ip->i_file);
131 for (i=0; i<ip->i_listlen; i++)
132 printf("\n#\t%s", ip->i_list[ i ]->i_incstring);