Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/xlint lint: make data flow in findlibs simpler
details: https://anonhg.NetBSD.org/src/rev/cd63c5460f4c
branches: trunk
changeset: 1022822:cd63c5460f4c
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Aug 08 14:05:33 2021 +0000
description:
lint: make data flow in findlibs simpler
No functional change.
diffstat:
usr.bin/xlint/xlint/xlint.c | 59 +++++++++++++++++++++++---------------------
1 files changed, 31 insertions(+), 28 deletions(-)
diffs (83 lines):
diff -r bb43436bc62a -r cd63c5460f4c usr.bin/xlint/xlint/xlint.c
--- a/usr.bin/xlint/xlint/xlint.c Sun Aug 08 13:43:09 2021 +0000
+++ b/usr.bin/xlint/xlint/xlint.c Sun Aug 08 14:05:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.65 2021/08/08 13:34:57 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.66 2021/08/08 14:05:33 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.65 2021/08/08 13:34:57 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.66 2021/08/08 14:05:33 rillig Exp $");
#endif
#include <sys/param.h>
@@ -821,35 +821,38 @@
}
static void
+findlib(const char *lib)
+{
+ char *const *dir;
+ char *lfn;
+
+ for (dir = libsrchpath; *dir != NULL; dir++) {
+ lfn = xasprintf("%s/llib-l%s.ln", *dir, lib);
+ if (rdok(lfn))
+ goto found;
+ free(lfn);
+
+ lfn = xasprintf("%s/lint/llib-l%s.ln", *dir, lib);
+ if (rdok(lfn))
+ goto found;
+ free(lfn);
+ }
+
+ warnx("cannot find llib-l%s.ln", lib);
+ return;
+
+found:
+ appstrg(&l2libs, concat2("-l", lfn));
+ free(lfn);
+}
+
+static void
findlibs(char *const *liblst)
{
- int i, k;
- const char *lib, *path;
- char *lfn;
- size_t len;
-
- lfn = NULL;
+ char *const *p;
- for (i = 0; (lib = liblst[i]) != NULL; i++) {
- for (k = 0; (path = libsrchpath[k]) != NULL; k++) {
- len = strlen(path) + strlen(lib);
- lfn = xrealloc(lfn, len + sizeof("/llib-l.ln"));
- (void)sprintf(lfn, "%s/llib-l%s.ln", path, lib);
- if (rdok(lfn))
- break;
- lfn = xrealloc(lfn, len + sizeof("/lint/llib-l.ln"));
- (void)sprintf(lfn, "%s/lint/llib-l%s.ln", path, lib);
- if (rdok(lfn))
- break;
- }
- if (path != NULL) {
- appstrg(&l2libs, concat2("-l", lfn));
- } else {
- warnx("cannot find llib-l%s.ln", lib);
- }
- }
-
- free(lfn);
+ for (p = liblst; *p != NULL; p++)
+ findlib(*p);
}
static bool
Home |
Main Index |
Thread Index |
Old Index