Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/config Print one file per line. Simplify code.



details:   https://anonhg.NetBSD.org/src/rev/2c3b3c1bcf9d
branches:  trunk
changeset: 332794:2c3b3c1bcf9d
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Thu Oct 09 17:36:10 2014 +0000

description:
Print one file per line.  Simplify code.

diffstat:

 usr.bin/config/mkmakefile.c |  69 +++++++-------------------------------------
 1 files changed, 12 insertions(+), 57 deletions(-)

diffs (136 lines):

diff -r 5ebe502581e4 -r 2c3b3c1bcf9d usr.bin/config/mkmakefile.c
--- a/usr.bin/config/mkmakefile.c       Thu Oct 09 17:22:55 2014 +0000
+++ b/usr.bin/config/mkmakefile.c       Thu Oct 09 17:36:10 2014 +0000
@@ -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 @@
 {
        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 @@
 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 @@
                        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 @@
                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);



Home | Main Index | Thread Index | Old Index