Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ulysses.UUCP Path: utzoo!linus!vaxine!wjh12!foxvax1!brunix!ulysses!gsp From: gsp@ulysses.UUCP (Gary Perlman) Newsgroups: net.unix,net.sources Subject: file include follower Message-ID: <855@ulysses.UUCP> Date: Tue, 29-May-84 08:11:47 EDT Article-I.D.: ulysses.855 Posted: Tue May 29 08:11:47 1984 Date-Received: Fri, 1-Jun-84 08:00:47 EDT Organization: AT&T Bell Laboratories, Murray Hill Lines: 50 Maybe this should only go to net.sources, but it is pretty small. I found it under a log. I hope this is useful to all the people who have asked for it. Gary Perlman BTL MH 5D-105 (201) 582-3624 ulysses!gsp #include #include main (argc, argv) char **argv; { while (--argc) include (*++argv, 0); } include (file, depth) { int indent; FILE *ioptr; for (indent = 0; indent < depth; indent++) putchar ('\t'); if (ioptr = fopen (file, "r")) { char line[BUFSIZ]; register char *lptr; printf ("%s\n", file); while (fgets (lptr = line, BUFSIZ, ioptr)) if (*line == '#') { lptr++; while (isspace (*lptr)) lptr++; if (!strncmp (lptr, "include", 7)) { int matcher; char *eptr; lptr += 7; while (isspace (*lptr)) lptr++; matcher = *lptr++; if (matcher == '<') matcher = '>'; for (eptr = lptr; *eptr && *eptr != matcher; eptr++); *eptr = NULL; if (matcher == '>') { char fullname[BUFSIZ]; sprintf (fullname, "/usr/include/%s", lptr); lptr = fullname; } include (lptr, depth+1); } } fclose (ioptr); } else printf ("%s: can't open!\n", file); }