From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 4674D59CB4 for ; Mon, 18 Apr 2016 08:07:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6211721C131; Mon, 18 Apr 2016 08:07:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D0FAD21C131 for ; Mon, 18 Apr 2016 08:07:06 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C15BB340931 for ; Mon, 18 Apr 2016 08:07:05 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 8CF1115F for ; Mon, 18 Apr 2016 08:07:01 +0000 (UTC) From: "Michael Haubenwallner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michael Haubenwallner" Message-ID: <1460966760.1f90d833970f8f6813a48f9385c234e197c3ee55.haubi@gentoo> Subject: [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/files/ X-VCS-Repository: repo/proj/prefix X-VCS-Files: sys-devel/binutils-config/files/ldwrapper.c X-VCS-Directories: sys-devel/binutils-config/files/ X-VCS-Committer: haubi X-VCS-Committer-Name: Michael Haubenwallner X-VCS-Revision: 1f90d833970f8f6813a48f9385c234e197c3ee55 X-VCS-Branch: master Date: Mon, 18 Apr 2016 08:07:01 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 82950b4e-78ed-4ef4-a688-b008f606a23a X-Archives-Hash: 406b3cae29c7db2836082c1a71828ce0 commit: 1f90d833970f8f6813a48f9385c234e197c3ee55 Author: Michael Haubenwallner ssi-schaefer com> AuthorDate: Fri Apr 15 09:07:19 2016 +0000 Commit: Michael Haubenwallner gentoo org> CommitDate: Mon Apr 18 08:06:00 2016 +0000 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=1f90d833 ldwrapper.c: check last PATH env entry; restore PATH env value; fix missing string.h warnings sys-devel/binutils-config/files/ldwrapper.c | 36 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/sys-devel/binutils-config/files/ldwrapper.c b/sys-devel/binutils-config/files/ldwrapper.c index 958bed4..9823da8 100644 --- a/sys-devel/binutils-config/files/ldwrapper.c +++ b/sys-devel/binutils-config/files/ldwrapper.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,9 @@ find_real_ld(char **ld, char verbose, char *wrapper) char *e; struct stat lde; + /* we may not succeed finding the linker */ + *ld = NULL; + /* respect the override in environment */ ldoveride = getenv("BINUTILS_CONFIG_LD"); if (ldoveride != NULL && *ldoveride != '\0') { @@ -67,23 +71,20 @@ find_real_ld(char **ld, char verbose, char *wrapper) /* find ld in PATH, allowing easy PATH overrides */ path = getenv("PATH"); - if (path != NULL && *path != '\0') { - char *p; - char *q; - - for (p = path; (q = strchr(p, ':')) != NULL; p = q + 1) { - if (q) - *q = '\0'; - if (strstr(p, "/" CHOST "/binutils-bin/") != NULL) { - snprintf(e, ESIZ, "%s/%s", p, wrapper); - if (stat(e, &lde) == 0) { - *ld = e; - return; - } - } - if (!q) - break; + while (path > (char*)1 && *path != '\0') { + char *q = strchr(path, ':'); + if (q) + *q = '\0'; + if (strstr(path, "/" CHOST "/binutils-bin/") != NULL) { + snprintf(e, ESIZ, "%s/%s", path, wrapper); + if (stat(e, &lde) == 0) + *ld = e; } + if (q) + *q = ':'; /* restore PATH value */ + if (*ld) + return; + path = q + 1; } if (verbose) fprintf(stdout, "%s: linker not found in PATH\n", wrapper); @@ -135,9 +136,6 @@ find_real_ld(char **ld, char verbose, char *wrapper) if (verbose) fprintf(stdout, "%s: linker not found via binutils-config -c\n", wrapper); - - /* we didn't succeed finding the linker */ - *ld = NULL; } int