00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef __WIN32__
00029 #pragma warning(disable : 4996)
00030 #endif
00031
00032 #include "def.h"
00033
00034 #include <string.h>
00035
00036 extern struct inclist inc_list[ MAXFILES ], *inclistp;
00037 extern char *objprefix;
00038 extern char *objsuffix;
00039 extern int width;
00040 extern bool printed;
00041 extern bool verbose;
00042 extern bool show_where_not;
00043
00044 void add_include(filepointer *filep, inclist *file,
00045 inclist *file_red, char *include, bool dot, bool failOK)
00046 {
00047 register struct inclist *newfile;
00048 register struct filepointer *content;
00049
00050
00051
00052
00053 newfile = inc_path(file->i_file, include, dot, failOK);
00054 if (newfile == NULL) {
00055 if (failOK)
00056 return;
00057 if (file != file_red)
00058 warning("%s (reading %s, line %d): ",
00059 file_red->i_file, file->i_file, filep->f_line);
00060 else
00061 warning("%s, line %d: ", file->i_file, filep->f_line);
00062 warning1("cannot find include file \"%s\"\n", include);
00063 fatalerr("cannot find include file \"%s\"\n", include);
00064 show_where_not = true;
00065 newfile = inc_path(file->i_file, include, dot, failOK);
00066 show_where_not = false;
00067 }
00068
00069 if (newfile) {
00070 included_by(file, newfile);
00071 if (!newfile->i_searched) {
00072 newfile->i_searched = true;
00073 content = getfile(newfile->i_file);
00074 find_includes(content, newfile, file_red, 0, failOK);
00075 freefile(content);
00076 }
00077 }
00078 }
00079
00080 void recursive_pr_include(register struct inclist *head, register char *file,
00081 register char *base)
00082 {
00083 register int i;
00084
00085 if (head->i_marked)
00086 return;
00087 head->i_marked = true;
00088 if (head->i_file != file) {
00089 bool rc_file = false;
00090 if ((strlen(file) >= 3) && !strcmp(file + strlen(file) - 3, ".rc"))
00091 rc_file = true;
00092 pr(head, file, base, rc_file);
00093 }
00094 for (i=0; i<head->i_listlen; i++)
00095 recursive_pr_include(head->i_list[ i ], file, base);
00096 }
00097
00098 void pr(register struct inclist *ip, char *file, char *base, bool rc_file)
00099 {
00100 static char *lastfile;
00101 static int current_len;
00102 register int len, i;
00103 char buf[ BUFSIZ ];
00104
00105 printed = true;
00106 len = int(strlen(ip->i_file)+1);
00107 if (current_len + len > width || file != lastfile) {
00108 lastfile = file;
00109 char *temp_suff = objsuffix;
00110 if (rc_file) temp_suff = (char *)".res";
00111 sprintf(buf, "\n%s%s%s: %s ", objprefix, base, temp_suff, ip->i_file);
00112 len = current_len = int(strlen(buf));
00113 }
00114 else {
00115 strcpy(buf, ip->i_file);
00116
00117 char tmp[2] = { ' ', '\0' };
00118
00119 strcat(buf, tmp);
00120
00121 current_len += len;
00122 }
00123 fwrite(buf, len, 1, stdout);
00124
00125
00126 if (! verbose || ip->i_list == NULL || ip->i_notified)
00127 return;
00128 ip->i_notified = true;
00129 lastfile = NULL;
00130 printf("\n# %s includes:", ip->i_file);
00131 for (i=0; i<ip->i_listlen; i++)
00132 printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
00133 }
00134