|
|
1.1 ! root 1: /* ! 2: * $Header: pr.c,v 1.2 87/08/14 18:08:47 toddb Exp $ ! 3: * ! 4: * $Log: pr.c,v $ ! 5: * Revision 1.2 87/08/14 18:08:47 toddb ! 6: * Don't unmark each included file in recursive_pr_includes(): leaving it ! 7: * marked prevents multiple inclusions from being printed if an include ! 8: * file happens to be a terminal node on the graph. ! 9: * ! 10: * Revision 1.1 87/08/14 18:01:02 toddb ! 11: * Initial revision ! 12: * ! 13: * Revision 1.1 87/04/08 16:40:57 rich ! 14: * Initial revision ! 15: * ! 16: * Revision 1.2 86/04/18 14:06:52 toddb ! 17: * Added a new field to struct inclist: "i_marked". This is used ! 18: * by recursive_pr() to tell if it is traversing a loop of include ! 19: * files. ! 20: * ! 21: * Revision 1.1 86/04/15 08:34:45 toddb ! 22: * Initial revision ! 23: * ! 24: */ ! 25: #include "def.h" ! 26: ! 27: extern struct inclist inclist[ MAXFILES ], ! 28: *inclistp; ! 29: extern char *objfile; ! 30: extern int width; ! 31: extern boolean printed; ! 32: extern boolean verbose; ! 33: extern boolean show_where_not; ! 34: ! 35: add_include(file, file_red, include, dot) ! 36: struct inclist *file, *file_red; ! 37: char *include; ! 38: boolean dot; ! 39: { ! 40: register struct inclist *newfile; ! 41: register struct filepointer *content; ! 42: ! 43: /* ! 44: * First decide what the pathname of this include file really is. ! 45: */ ! 46: newfile = inc_path(file->i_file, include, dot); ! 47: if (newfile == NULL) { ! 48: if (file != file_red) ! 49: log("%s (reading %s): ", ! 50: file_red->i_file, file->i_file); ! 51: else ! 52: log("%s: ", file->i_file); ! 53: log("cannot find include file \"%s\"\n", include); ! 54: show_where_not = TRUE; ! 55: newfile = inc_path(file->i_file, include, dot); ! 56: show_where_not = FALSE; ! 57: } ! 58: ! 59: included_by(file, newfile); ! 60: if (!newfile->i_searched) { ! 61: newfile->i_searched = TRUE; ! 62: content = getfile(newfile->i_file); ! 63: find_includes(content, newfile, file_red, 0); ! 64: freefile(content); ! 65: } ! 66: } ! 67: ! 68: recursive_pr_include(head, file, base) ! 69: register struct inclist *head; ! 70: register char *file, *base; ! 71: { ! 72: register int i; ! 73: ! 74: if (head->i_marked) ! 75: return; ! 76: head->i_marked = TRUE; ! 77: if (head->i_file != file) ! 78: pr(head, file, base); ! 79: for (i=0; i<head->i_listlen; i++) ! 80: recursive_pr_include(head->i_list[ i ], file, base); ! 81: } ! 82: ! 83: pr(ip, file, base) ! 84: register struct inclist *ip; ! 85: char *file, *base; ! 86: { ! 87: static char *lastfile; ! 88: static int current_len; ! 89: register int len, i; ! 90: char buf[ BUFSIZ ]; ! 91: ! 92: printed = TRUE; ! 93: len = strlen(ip->i_file)+1; ! 94: if (current_len + len > width || file != lastfile) { ! 95: lastfile = file; ! 96: sprintf(buf, "\n%s%s: %s", base, objfile, ip->i_file); ! 97: len = current_len = strlen(buf); ! 98: } ! 99: else { ! 100: buf[0] = ' '; ! 101: strcpy(buf+1, ip->i_file); ! 102: current_len += len; ! 103: } ! 104: fwrite(buf, len, 1, stdout); ! 105: ! 106: /* ! 107: * If verbose is set, then print out what this file includes. ! 108: */ ! 109: if (! verbose || ip->i_list == NULL || ip->i_notified) ! 110: return; ! 111: ip->i_notified = TRUE; ! 112: lastfile = NULL; ! 113: printf("\n# %s includes:", ip->i_file); ! 114: for (i=0; i<ip->i_listlen; i++) ! 115: printf("\n#\t%s", ip->i_list[ i ]->i_incstring); ! 116: } ! 117: ! 118: catch(n) ! 119: { ! 120: fflush(stdout); ! 121: log_fatal("got signal %d\n", n); ! 122: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.