Print one file per line. Simplify code.

This commit is contained in:
uebayasi 2014-10-09 17:36:10 +00:00
parent 745a9de44a
commit aeeeb994e8
1 changed files with 12 additions and 57 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkmakefile.c,v 1.19 2014/10/09 17:22:55 uebayasi Exp $ */
/* $NetBSD: mkmakefile.c,v 1.20 2014/10/09 17:36:10 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@ -324,57 +324,29 @@ emitobjs(FILE *fp)
{
struct files *fi;
struct objects *oi;
int lpos, len, sp;
fputs("OBJS=", fp);
sp = '\t';
lpos = 7;
fputs("OBJS= \\\n", fp);
TAILQ_FOREACH(fi, &allfiles, fi_next) {
if ((fi->fi_flags & FI_SEL) == 0)
continue;
len = strlen(fi->fi_base) + 2;
if (lpos + len > 72) {
fputs(" \\\n", fp);
sp = '\t';
lpos = 7;
}
fprintf(fp, "%c%s.o", sp, fi->fi_base);
lpos += len + 1;
sp = ' ';
fprintf(fp, "\t%s.o \\\n", fi->fi_base);
}
TAILQ_FOREACH(oi, &allobjects, oi_next) {
if ((oi->oi_flags & OI_SEL) == 0)
continue;
len = strlen(oi->oi_path);
if (*oi->oi_path != '/')
{
/* e.g. "$S/" */
if (oi->oi_prefix != NULL)
len += strlen(prefix_prologue(oi->oi_path)) +
strlen(oi->oi_prefix) + 1;
else
len += strlen(filetype_prologue(&oi->oi_fit));
}
if (lpos + len > 72) {
fputs(" \\\n", fp);
sp = '\t';
lpos = 7;
}
if (*oi->oi_path == '/') {
fprintf(fp, "%c%s", sp, oi->oi_path);
fprintf(fp, "\t%s \\\n", oi->oi_path);
} else {
if (oi->oi_prefix != NULL) {
fprintf(fp, "%c%s%s/%s", sp,
fprintf(fp, "\t%s%s/%s \\\n",
prefix_prologue(oi->oi_path),
oi->oi_prefix, oi->oi_path);
} else {
fprintf(fp, "%c%s%s", sp,
fprintf(fp, "\t%s%s \\\n",
filetype_prologue(&oi->oi_fit),
oi->oi_path);
}
}
lpos += len + 1;
sp = ' ';
}
putc('\n', fp);
}
@ -457,14 +429,12 @@ static void
emitfiles(FILE *fp, int suffix, int upper_suffix)
{
struct files *fi;
int lpos, len, sp;
int len;
const char *fpath;
struct config *cf;
char swapname[100];
fprintf(fp, "%cFILES=", toupper(suffix));
sp = '\t';
lpos = 7;
fprintf(fp, "%cFILES= \\\n", toupper(suffix));
TAILQ_FOREACH(fi, &allfiles, fi_next) {
if ((fi->fi_flags & FI_SEL) == 0)
continue;
@ -480,26 +450,19 @@ emitfiles(FILE *fp, int suffix, int upper_suffix)
else
len += strlen(filetype_prologue(&fi->fi_fit));
}
if (lpos + len > 72) {
fputs(" \\\n", fp);
sp = '\t';
lpos = 7;
}
if (*fi->fi_path == '/') {
fprintf(fp, "%c%s", sp, fpath);
fprintf(fp, "\t%s \\\n", fpath);
} else {
if (fi->fi_prefix != NULL) {
fprintf(fp, "%c%s%s/%s", sp,
fprintf(fp, "\t%s%s/%s \\\n",
prefix_prologue(fi->fi_prefix),
fi->fi_prefix, fpath);
} else {
fprintf(fp, "%c%s%s", sp,
fprintf(fp, "\t%s%s \\\n",
filetype_prologue(&fi->fi_fit),
fpath);
}
}
lpos += len + 1;
sp = ' ';
}
/*
* The allfiles list does not include the configuration-specific
@ -510,15 +473,7 @@ emitfiles(FILE *fp, int suffix, int upper_suffix)
TAILQ_FOREACH(cf, &allcf, cf_next) {
(void)snprintf(swapname, sizeof(swapname), "swap%s.c",
cf->cf_name);
len = strlen(swapname);
if (lpos + len > 72) {
fputs(" \\\n", fp);
sp = '\t';
lpos = 7;
}
fprintf(fp, "%c%s", sp, swapname);
lpos += len + 1;
sp = ' ';
fprintf(fp, "\t%s \\\n", swapname);
}
}
putc('\n', fp);