1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eban 2000-07-24 09:58:10 +00:00
parent a4fe713cb1
commit b9373b7aea
4 changed files with 21 additions and 16 deletions

14
ruby.c
View file

@ -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)))