Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/config Pre-calc file path len/suffix. Misc. clean up.
details: https://anonhg.NetBSD.org/src/rev/f1e54617788f
branches: trunk
changeset: 333799:f1e54617788f
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Mon Nov 17 00:53:15 2014 +0000
description:
Pre-calc file path len/suffix. Misc. clean up.
diffstat:
usr.bin/config/defs.h | 6 +++++-
usr.bin/config/files.c | 6 ++++--
usr.bin/config/mkmakefile.c | 45 +++++++++++++++++++--------------------------
3 files changed, 28 insertions(+), 29 deletions(-)
diffs (185 lines):
diff -r 71d5c928f0ea -r f1e54617788f usr.bin/config/defs.h
--- a/usr.bin/config/defs.h Mon Nov 17 00:50:40 2014 +0000
+++ b/usr.bin/config/defs.h Mon Nov 17 00:53:15 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.63 2014/11/15 08:21:38 uebayasi Exp $ */
+/* $NetBSD: defs.h,v 1.64 2014/11/17 00:53:15 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -340,6 +340,8 @@
char fit_lastc; /* last char from path */
const char *fit_path; /* full file path */
const char *fit_prefix; /* any file prefix */
+ size_t fit_len; /* path string length */
+ int fit_suffix; /* single char suffix */
struct attr *fit_attr; /* owner attr */
TAILQ_ENTRY(files) fit_anext; /* next file in attr */
};
@@ -371,6 +373,8 @@
#define fi_lastc fi_fit.fit_lastc
#define fi_path fi_fit.fit_path
#define fi_prefix fi_fit.fit_prefix
+#define fi_suffix fi_fit.fit_suffix
+#define fi_len fi_fit.fit_len
#define fi_attr fi_fit.fit_attr
#define fi_anext fi_fit.fit_anext
diff -r 71d5c928f0ea -r f1e54617788f usr.bin/config/files.c
--- a/usr.bin/config/files.c Mon Nov 17 00:50:40 2014 +0000
+++ b/usr.bin/config/files.c Mon Nov 17 00:53:15 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: files.c,v 1.17 2014/10/29 17:14:50 christos Exp $ */
+/* $NetBSD: files.c,v 1.18 2014/11/17 00:53:15 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: files.c,v 1.17 2014/10/29 17:14:50 christos Exp $");
+__RCSID("$NetBSD: files.c,v 1.18 2014/11/17 00:53:15 uebayasi Exp $");
#include <sys/param.h>
#include <errno.h>
@@ -158,6 +158,8 @@
fi->fi_base = intern(base);
fi->fi_prefix = SLIST_EMPTY(&prefixes) ? NULL :
SLIST_FIRST(&prefixes)->pf_prefix;
+ fi->fi_len = strlen(path);
+ fi->fi_suffix = path[fi->fi_len - 1];
fi->fi_optx = optx;
fi->fi_optf = NULL;
fi->fi_mkrule = rule;
diff -r 71d5c928f0ea -r f1e54617788f usr.bin/config/mkmakefile.c
--- a/usr.bin/config/mkmakefile.c Mon Nov 17 00:50:40 2014 +0000
+++ b/usr.bin/config/mkmakefile.c Mon Nov 17 00:53:15 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mkmakefile.c,v 1.32 2014/11/16 15:10:54 uebayasi Exp $ */
+/* $NetBSD: mkmakefile.c,v 1.33 2014/11/17 00:53:15 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: mkmakefile.c,v 1.32 2014/11/16 15:10:54 uebayasi Exp $");
+__RCSID("$NetBSD: mkmakefile.c,v 1.33 2014/11/17 00:53:15 uebayasi Exp $");
#include <sys/param.h>
#include <ctype.h>
@@ -273,19 +273,15 @@
static const char *
filetype_prologue(struct filetype *fit)
{
- if (*fit->fit_path == '/')
- return ("");
- else
- return ("$S/");
+
+ return (*fit->fit_path == '/') ? "" : "$S/";
}
static const char *
prefix_prologue(const char *path)
{
- if (*path == '/')
- return ("");
- else
- return ("$S/");
+
+ return (*path == '/') ? "" : "$S/";
}
static void
@@ -300,23 +296,25 @@
/* Skip any options output to a header file */
if (DEFINED_OPTION(nv->nv_name))
continue;
+ const char *s = nv->nv_str;
fprintf(fp, "\t-D%s%s%s%s \\\n", nv->nv_name,
- (nv->nv_str != NULL) ? "=\"" : "",
- (nv->nv_str != NULL) ? nv->nv_str : "",
- (nv->nv_str != NULL) ? "\"" : "");
+ s ? "=\"" : "",
+ s ? s : "",
+ s ? "\"" : "");
}
putc('\n', fp);
fprintf(fp, "PARAM=-DMAXUSERS=%d\n", maxusers);
fprintf(fp, "MACHINE=%s\n", machine);
- if (*srcdir == '/' || *srcdir == '.') {
- fprintf(fp, "S=\t%s\n", srcdir);
- } else {
+
+ const char *subdir = "";
+ if (*srcdir != '/' && *srcdir != '.') {
/*
* libkern and libcompat "Makefile.inc"s want relative S
* specification to begin with '.'.
*/
- fprintf(fp, "S=\t./%s\n", srcdir);
+ subdir = "./";
}
+ fprintf(fp, "S=\t%s%s\n", subdir, srcdir);
for (nv = mkoptions; nv != NULL; nv = nv->nv_next)
fprintf(fp, "%s=%s\n", nv->nv_name, nv->nv_str);
}
@@ -482,7 +480,6 @@
emitfiles(FILE *fp, int suffix, int upper_suffix)
{
struct files *fi;
- size_t len;
const char *fpath;
struct config *cf;
char swapname[100];
@@ -494,8 +491,7 @@
if ((fi->fi_flags & FI_SEL) == 0)
continue;
fpath = srcpath(fi);
- len = strlen(fpath);
- if (fpath[len - 1] != suffix && fpath[len - 1] != upper_suffix)
+ if (fi->fi_suffix != suffix && fi->fi_suffix != upper_suffix)
continue;
prologue = prefix = sep = "";
if (*fi->fi_path != '/') {
@@ -532,9 +528,7 @@
emitrules(FILE *fp)
{
struct files *fi;
- size_t len;
const char *fpath;
- int suffix;
TAILQ_FOREACH(fi, &allfiles, fi_next) {
const char *prologue, *prefix, *sep;
@@ -542,8 +536,6 @@
if ((fi->fi_flags & FI_SEL) == 0)
continue;
fpath = srcpath(fi);
- len = strlen(fpath);
- suffix = fpath[len - 1];
prologue = prefix = sep = "";
if (*fpath != '/') {
if (fi->fi_prefix != NULL) {
@@ -559,7 +551,7 @@
if (fi->fi_mkrule != NULL) {
fprintf(fp, "\t%s\n\n", fi->fi_mkrule);
} else {
- fprintf(fp, "\t${NORMAL_%c}\n\n", toupper(suffix));
+ fprintf(fp, "\t${NORMAL_%c}\n\n", toupper(fi->fi_suffix));
}
}
}
@@ -574,7 +566,8 @@
{
struct config *cf;
- fputs(".MAIN: all\nall:", fp);
+ fputs(".MAIN: all\n", fp);
+ fputs("all:", fp);
TAILQ_FOREACH(cf, &allcf, cf_next) {
fprintf(fp, " %s", cf->cf_name);
/*
Home |
Main Index |
Thread Index |
Old Index