From 6854da447508380d0154ef8ba81d05c36c59804e Mon Sep 17 00:00:00 2001 From: eban Date: Mon, 24 Jul 2000 09:58:10 +0000 Subject: eban git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index 783695ef9..3e018f63d 100644 --- a/ruby.c +++ b/ruby.c @@ -119,12 +119,12 @@ rubylib_mangle(s, l) static char *newp, *oldp; static int newl, oldl, notfound; static char ret[STATIC_FILE_LENGTH+1]; - + if (!newp && !notfound) { newp = getenv("RUBYLIB_PREFIX"); if (newp) { char *s; - + oldp = newp; while (*newp && !ISSPACE(*newp) && *newp != ';') { newp++; oldl++; /* Skip digits. */ @@ -146,19 +146,19 @@ rubylib_mangle(s, l) notfound = 1; } } - if (!newp) { - return s; - } if (l == 0) { l = strlen(s); } - if (l < oldl || strncasecmp(oldp, s, oldl) != 0) { - return s; + if (!newp || l < oldl || strncasecmp(oldp, s, oldl) != 0) { + strncpy(ret, s, l); + ret[l] = 0; + return ret; } if (l + newl - oldl > STATIC_FILE_LENGTH || newl > STATIC_FILE_LENGTH) { rb_fatal("malformed RUBYLIB_PREFIX"); } strcpy(ret + newl, s + oldl); + ret[l + newl - oldl] = 0; return ret; } #define rubylib_mangled_path(s, l) rb_str_new2(rubylib_mangle((s), (l))) -- cgit