| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | #include "def.h" |
| 31 | #include <string.h> |
| 32 | size_t pr( struct inclist *ip, char *file,char *base); |
| 33 | |
| 34 | extern struct inclist inclist[ MAXFILES65536 ], |
| 35 | *inclistp; |
| 36 | extern char *objprefix; |
| 37 | extern char *objsuffix; |
| 38 | extern int width; |
| 39 | extern boolean printed; |
| 40 | extern boolean verbose; |
| 41 | extern boolean show_where_not; |
| 42 | |
| 43 | void add_include(struct filepointer *filep, struct inclist *file, struct inclist *file_red, char *include, boolean dot, boolean failOK, struct IncludesCollection* incCollection, struct symhash *symbols) |
| 44 | { |
| 45 | register struct inclist *newfile; |
| 46 | register struct filepointer *content; |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | newfile = inc_path(file->i_file, include, dot, incCollection); |
| 52 | if (newfile == NULL((void*)0)) { |
| 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 = TRUE1; |
| 62 | newfile = inc_path(file->i_file, include, dot, incCollection); |
| 63 | show_where_not = FALSE0; |
| 64 | } |
| 65 | |
| 66 | if (newfile) { |
| 67 | |
| 68 | |
| 69 | if (!(newfile && newfile->i_file && strstr(newfile->i_file, "/usr/"))) { |
| 70 | included_by(file, newfile); |
| 71 | } |
| 72 | |
| 73 | if (!newfile->i_searched) { |
| 74 | newfile->i_searched = TRUE1; |
| 75 | content = getfile(newfile->i_file); |
| 76 | find_includes(content, newfile, file_red, 0, failOK, incCollection, symbols); |
| 77 | freefile(content); |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | void recursive_pr_include(head, file, base) |
| 83 | register struct inclist *head; |
| 84 | register char *file, *base; |
| 85 | { |
| 86 | register int i; |
| 87 | |
| 88 | if (head->i_marked) |
| |
| |
| |
| 89 | return; |
| 90 | head->i_marked = TRUE1; |
| 91 | if (head->i_file != file) |
| |
| |
| |
| 92 | pr(head, file, base); |
| 93 | for (i=0; i<head->i_listlen; i++) |
| 3 | | Loop condition is true. Entering loop body | |
|
| 4 | | Loop condition is true. Entering loop body | |
|
| 5 | | Loop condition is true. Entering loop body | |
|
| 6 | | Loop condition is true. Entering loop body | |
|
| 10 | | Loop condition is true. Entering loop body | |
|
| 14 | | Loop condition is true. Entering loop body | |
|
| 94 | recursive_pr_include(head->i_list[ i ], file, base); |
| 7 | | Calling 'recursive_pr_include' | |
|
| 11 | | Calling 'recursive_pr_include' | |
|
| 15 | | Array access (via field 'i_list') results in a null pointer dereference |
|
| 95 | } |
| 96 | |
| 97 | size_t pr(ip, file, base) |
| 98 | register struct inclist *ip; |
| 99 | char *file, *base; |
| 100 | { |
| 101 | size_t ret; |
| 102 | static char *lastfile; |
| 103 | static int current_len; |
| 104 | register int len, i; |
| 105 | char buf[ BUFSIZ8192 ]; |
| 106 | |
| 107 | printed = TRUE1; |
| 108 | len = (int)strlen(ip->i_file)+1; |
| 109 | if (current_len + len > width || file != lastfile) { |
| 110 | lastfile = file; |
| 111 | sprintf(buf, "\n%s%s%s: %s", objprefix, base, objsuffix, |
| 112 | ip->i_file); |
| 113 | len = current_len = (int)strlen(buf); |
| 114 | } |
| 115 | else { |
| 116 | buf[0] = ' '; |
| 117 | strcpy(buf+1, ip->i_file); |
| 118 | current_len += len; |
| 119 | } |
| 120 | ret = fwrite(buf, len, 1, stdoutstdout); |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | if (! verbose || ip->i_list == NULL((void*)0) || ip->i_notified) |
| 126 | return ret; |
| 127 | ip->i_notified = TRUE1; |
| 128 | lastfile = NULL((void*)0); |
| 129 | printf("\n# %s includes:", ip->i_file); |
| 130 | for (i=0; i<ip->i_listlen; i++) |
| 131 | printf("\n#\t%s", ip->i_list[ i ]->i_incstring); |
| 132 | return ret; |
| 133 | } |
| 134 | |
| 135 | |