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 D6CFF1391DB for ; Fri, 21 Mar 2014 05:32:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7B3DCE0AA5; Fri, 21 Mar 2014 05:32:32 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0A730E0AA5 for ; Fri, 21 Mar 2014 05:32:31 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1082933FCC2 for ; Fri, 21 Mar 2014 05:32:31 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 6D66018875 for ; Fri, 21 Mar 2014 05:32:29 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1395379715.214d027f0d92d1d042451765e875f0a84c3fa37d.vapier@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: /, libq/ X-VCS-Repository: proj/portage-utils X-VCS-Files: .depend Makefile.am libq/libq.c libq/which.c q.c X-VCS-Directories: / libq/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 214d027f0d92d1d042451765e875f0a84c3fa37d X-VCS-Branch: master Date: Fri, 21 Mar 2014 05:32:29 +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: f1fed6c1-10fd-407d-9f28-8caf907f9600 X-Archives-Hash: 14cf401f8a7cbcf3f7e1288970cc0bea commit: 214d027f0d92d1d042451765e875f0a84c3fa37d Author: Mike Frysinger gentoo org> AuthorDate: Fri Mar 21 05:28:35 2014 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Fri Mar 21 05:28:35 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=214d027f which: punt! This code is only used by --install, and only when /proc/self/exe does not work. We rarely utilize --install, and it's rare for /proc to be broken in a way we can't rely on. So having this func just for that does not make much sense. Even then, the code was not correct. It walked $PATH in reverse order (when it should have been forward order), and it would abort scanning beofre it checked the first element. It also doesn't support empty path elements (which is supposed to be $PWD). If we want a which() in the future, we can grab the updated version from Gentoo's pax-utils project. --- .depend | 2 +- Makefile.am | 1 - libq/libq.c | 1 - libq/which.c | 25 ------------------------- q.c | 13 ++++--------- 5 files changed, 5 insertions(+), 37 deletions(-) diff --git a/.depend b/.depend index 259c95c..3b63d1f 100644 --- a/.depend +++ b/.depend @@ -1,7 +1,7 @@ main.o: main.c porting.h main.h libq/libq.c libq/busybox.h libq/i18n.h \ libq/libq.h libq/colors.c libq/xmalloc.c libq/xstrdup.c libq/xasprintf.c \ libq/hash_fd.c libq/md5_sha1_sum.c libq/human_readable.c libq/rmspace.c \ - libq/which.c libq/compat.c libq/copy_file.c libq/safe_io.c libq/xchdir.c \ + libq/compat.c libq/copy_file.c libq/safe_io.c libq/xchdir.c \ libq/xgetcwd.c libq/xmkdir.c libq/xreadlink.c libq/xregex.c \ libq/xsystem.c libq/xarray.c libq/atom_explode.c libq/atom_compare.c \ libq/basename.c libq/scandirat.c libq/prelink.c libq/profile.c \ diff --git a/Makefile.am b/Makefile.am index ed5c184..14bc649 100644 --- a/Makefile.am +++ b/Makefile.am @@ -112,7 +112,6 @@ EXTRA_DIST += \ libq/vdb.c \ libq/vdb_get_next_dir.c \ libq/virtuals.c \ - libq/which.c \ libq/xarray.c \ libq/xasprintf.c \ libq/xchdir.c \ diff --git a/libq/libq.c b/libq/libq.c index 528db75..5c6eb5c 100644 --- a/libq/libq.c +++ b/libq/libq.c @@ -17,7 +17,6 @@ #include "md5_sha1_sum.c" #include "human_readable.c" #include "rmspace.c" -#include "which.c" #include "compat.c" #include "copy_file.c" diff --git a/libq/which.c b/libq/which.c deleted file mode 100644 index ce33121..0000000 --- a/libq/which.c +++ /dev/null @@ -1,25 +0,0 @@ -/* find the path to a file by name */ -static char *which(const char *fname) -{ - static char fullpath[BUFSIZ]; - char *ret, *path, *p; - - ret = NULL; - - path = getenv("PATH"); - if (!path) - return ret; - - path = xstrdup(path); - while ((p = strrchr(path, ':')) != NULL) { - snprintf(fullpath, sizeof(fullpath), "%s/%s", p + 1, fname); - *p = 0; - if (access(fullpath, R_OK) != -1) { - ret = fullpath; - break; - } - } - free(path); - - return ret; -} diff --git a/q.c b/q.c index 394a035..443ce4b 100644 --- a/q.c +++ b/q.c @@ -104,15 +104,10 @@ int q_main(int argc, char **argv) rret = readlink("/proc/self/exe", buf, sizeof(buf) - 1); if (rret == -1) { - char *ptr = which("q"); - if (ptr == NULL) { - warnfp("haha no symlink love for you"); - return 1; - } - strncpy(buf, ptr, sizeof(buf)); - buf[sizeof(buf) - 1] = '\0'; - } else - buf[rret] = '\0'; + warnfp("haha no symlink love for you"); + return 1; + } + buf[rret] = '\0'; prog = basename(buf); dir = dirname(buf);