removed the lflag, added check for '/' in filenames
This commit is contained in:
parent
60cf3639ce
commit
a3aa9aac88
1 changed files with 16 additions and 26 deletions
|
@ -14,8 +14,6 @@ struct namelist *freelist;
|
|||
struct namelist *new_namelist();
|
||||
struct namelist *nl = 0;
|
||||
|
||||
int lflag = 0; /* produce vertical list of included files */
|
||||
|
||||
char *Malloc(u)
|
||||
unsigned u;
|
||||
{
|
||||
|
@ -86,20 +84,12 @@ print_namelist(nm, nlp)
|
|||
struct namelist *nlp;
|
||||
{
|
||||
if (nlp) {
|
||||
if (lflag) {
|
||||
while (nlp) {
|
||||
printf("%s\n", nlp->name);
|
||||
nlp = nlp->next;
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("%s:", nm);
|
||||
while (nlp) {
|
||||
printf(" %s", nlp->name);
|
||||
nlp = nlp->next;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,22 +99,6 @@ main(argc, argv)
|
|||
int err = 0;
|
||||
|
||||
progname = *argv++;
|
||||
if (**argv == '-') {
|
||||
register char *s = *argv++;
|
||||
|
||||
argc--;
|
||||
while (*++s) {
|
||||
switch (*s) {
|
||||
case 'l':
|
||||
lflag = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "use: %s [-l] file ...\n",
|
||||
progname);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (--argc > 0) {
|
||||
free_namelist(nl);
|
||||
nl = 0;
|
||||
|
@ -135,6 +109,16 @@ main(argc, argv)
|
|||
return err ? 1 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
contains_slash(s)
|
||||
register char *s;
|
||||
{
|
||||
while (*s) {
|
||||
if (*s++ == '/') return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
dofile(fn)
|
||||
char *fn;
|
||||
{
|
||||
|
@ -147,6 +131,12 @@ dofile(fn)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (contains_slash(fn)) {
|
||||
fprintf(stderr, "%s: (warning) %s not in current directory; not checked\n", progname, fn);
|
||||
fclose(fp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (fgets(buf, BSIZ, fp) != NULL)
|
||||
if (nm = include_line(buf)) {
|
||||
add_name(nm);
|
||||
|
|
Loading…
Reference in a new issue