summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authoreban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-24 09:58:10 +0000
committereban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-24 09:58:10 +0000
commitb9373b7aeaf51441cd36334635022bd4f9523a4b (patch)
treed0155ef14afb8fb0e930b3ccbe795222586ae989 /ruby.c
parenta4fe713cb199934e8b7870850c50fcc24fb5685f (diff)
eban
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ruby.c b/ruby.c
index 783695ef97..3e018f63d3 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)))