Mercurial > hg > aboriginal
changeset 64:51b8220c37e7
Make wrapper script work when /bin is a symlink to /usr/bin and the wrapper
is in /usr/bin but /bin is first in the path.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 26 Dec 2006 00:02:40 -0500 |
parents | 89cf9497824e |
children | 79295919b775 |
files | sources/toys/gcc-uClibc.c |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/sources/toys/gcc-uClibc.c Mon Dec 25 20:13:08 2006 -0500 +++ b/sources/toys/gcc-uClibc.c Tue Dec 26 00:02:40 2006 -0500 @@ -55,7 +55,9 @@ char *str, *next = path ? index(path, ':') : NULL; int len = next ? next-path : strlen(path); - str = malloc(strlen(filename) + (len ? len : strlen(cwd)) + 2); + // The +3 is a corner case: if strlen(filename) is 1, make sure we + // have enough space to append ".." to make topdir. + str = malloc(strlen(filename) + (len ? len : strlen(cwd)) + 3); if (!len) sprintf(str, "%s/%s", cwd, filename); else { char *str2 = str; @@ -116,14 +118,18 @@ } else { char *path = getenv("PATH"), *temp; - // Add that directory to the start of $PATH. (Better safe than sorry.) + // Add that directory to the start of $PATH. (Better safe than sorry.) *rindex(topdir,'/') = 0; temp = malloc(strlen(topdir)+strlen(path)+7); sprintf(temp,"PATH=%s:%s",topdir,path); putenv(temp); + // The directory above the wrapper script should have include, gcc, + // and lib directories. + // Append ".." instead of simplifying path because the toolchain's bin + // could have a symlink pointing to it, ala /bin -> /usr/bin temp = rindex(topdir,'/'); - if(temp) *temp=0; + if(temp) strcpy(++temp, ".."); else { // Are we in the same directory as the compiler? if (!strcmp(".",topdir)) topdir="..";