Took over addition of -d flag from Erik Baalbergen

This commit is contained in:
ceriel 1988-10-07 09:48:23 +00:00
parent b909bb629b
commit c488a4d491
2 changed files with 33 additions and 17 deletions

View file

@ -3,7 +3,7 @@
.SH NAME .SH NAME
mkdep \- dependency generator for C-programs mkdep \- dependency generator for C-programs
.SH SYNOPSYS .SH SYNOPSYS
.B mkdep .B mkdep [ -d ]
file ... file ...
.SH DESCRIPTION .SH DESCRIPTION
.I Mkdep .I Mkdep
@ -20,6 +20,8 @@ and produces for each file \fIarg\fR in the argument list lines of the form
where \fIfile1\fR, \fIfile2\fR, etc. are filenames included by \fIarg\fR, or where \fIfile1\fR, \fIfile2\fR, etc. are filenames included by \fIarg\fR, or
by a file included by \fIarg\fR, etc. by a file included by \fIarg\fR, etc.
.PP .PP
The \fB-d\fP suppresses the \fIarg\fR: part.
.PP
Only files in the current directory are scanned. Only files in the current directory are scanned.
.SH "SEE ALSO" .SH "SEE ALSO"
make(1) make(1)

View file

@ -4,11 +4,17 @@
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
/* make dependencies; Date: jan 07, 1986; Author: Erik Baalbergen */ /* make dependencies; Date: jan 07, 1986; Author: Erik Baalbergen */
/* Log:
[Thu Oct 6 09:56:30 MET 1988; erikb]
Added option '-d' which suppresses "file.c :" be printed
*/
#include <stdio.h> #include <stdio.h>
#define BSIZ 1024 #define BSIZ 1024
char *progname; char *prog;
int dflag = 0; /* suppress "file.c :" */
struct namelist { struct namelist {
struct namelist *next; struct namelist *next;
@ -57,9 +63,7 @@ free_namelist(nlp)
add_name(nm) add_name(nm)
char *nm; char *nm;
{ {
struct namelist *nlp = nl; struct namelist *nlp = nl, *lnlp = 0, *nnlp;
struct namelist *lnlp = 0;
struct namelist *nnlp;
char *strcpy(); char *strcpy();
while (nlp) { while (nlp) {
@ -88,21 +92,31 @@ print_namelist(nm, nlp)
char *nm; char *nm;
struct namelist *nlp; struct namelist *nlp;
{ {
if (nlp) {
while (nlp) { while (nlp) {
printf("%s: %s\n", nm, nlp->name); if (!dflag)
printf("%s: ", nm);
printf("%s\n", nlp->name);
nlp = nlp->next; nlp = nlp->next;
} }
} }
}
main(argc, argv) main(argc, argv)
char *argv[]; char *argv[];
{ {
int err = 0; int err = 0;
progname = *argv++; prog = *argv++;
while (--argc > 0) { if (**argv == '-') {
char *opt = &(*argv++)[1];
if (*opt++ != 'd' || *opt) {
fprintf(stderr, "use: %s [-d] [file ...]\n", prog);
exit(1);
}
dflag = 1;
}
while (*argv) {
free_namelist(nl); free_namelist(nl);
nl = 0; nl = 0;
if (dofile(*argv) == 0) if (dofile(*argv) == 0)
@ -116,9 +130,8 @@ int
contains_slash(s) contains_slash(s)
register char *s; register char *s;
{ {
while (*s) { while (*s)
if (*s++ == '/') return 1; if (*s++ == '/') return 1;
}
return 0; return 0;
} }
@ -130,12 +143,12 @@ dofile(fn)
char *nm, *include_line(); char *nm, *include_line();
if ((fp = fopen(fn, "r")) == 0) { if ((fp = fopen(fn, "r")) == 0) {
fprintf(stderr, "%s: cannot read %s\n", progname, fn); fprintf(stderr, "%s: cannot read %s\n", prog, fn);
return 0; return 0;
} }
if (contains_slash(fn)) { if (contains_slash(fn)) {
fprintf(stderr, "%s: (warning) %s not in current directory; not checked\n", progname, fn); fprintf(stderr, "%s: (warning) %s not in current directory; not checked\n", prog, fn);
fclose(fp); fclose(fp);
return 1; return 1;
} }
@ -172,7 +185,8 @@ include_line(s)
while ((*s == '\t') || (*s == ' ')) while ((*s == '\t') || (*s == ' '))
s++; s++;
if (*s++ == '"') { if (*s++ == '"') {
register char *nm = s; char *nm = s;
while (*s != 0 && *s != '"') while (*s != 0 && *s != '"')
s++; s++;
*s = '\0'; *s = '\0';