From: Julian Seward Date: Fri, 25 Jul 2003 19:58:11 +0000 (+0000) Subject: VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH): remove leading spaces and X-Git-Tag: svn/VALGRIND_2_1_0~230 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c924c63b2091993fb76040e8e09fe7cf9eeef08e;p=thirdparty%2Fvalgrind.git VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH): remove leading spaces and colon created by this mechanism. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1787 --- diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index f70c5bc995..1d29a6f3d6 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -1659,6 +1659,17 @@ void VG_(oynk) ( Int n ) it to $(libdir)/lib/valgrinq, so as to make our libpthread.so disappear. */ +static void slideleft ( Char* s ) +{ + vg_assert(s && (*s == ' ' || *s == ':')); + while (True) { + s[0] = s[1]; + if (s[0] == '\0') break; + s++; + } +} + + void VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH) ( Char* ld_preload_str, Char* ld_library_path_str ) { @@ -1737,7 +1748,14 @@ void VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH) ( Char* ld_preload_str, /* LD_LIBRARY_PATH: ":Y" --> " :Y" */ for (i = 0; i < coredir_len; i++) coredir2[i] = ' '; - + + /* Zap the leading spaces and : in both strings. */ + while (ld_preload_str[0] == ' ') slideleft(ld_preload_str); + if (ld_preload_str[0] == ':') slideleft(ld_preload_str); + + while (ld_library_path_str[0] == ' ') slideleft(ld_library_path_str); + if (ld_library_path_str[0] == ':') slideleft(ld_library_path_str); + /* VG_(printf)("post:\n%s\n%s\n", ld_preload_str, ld_library_path_str); */ return;