* dir.c (glob_helper): fix memory leak.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d5ffbb20e8
commit
debe0485f0
@ -1,3 +1,7 @@
|
|||||||
|
Wed Jan 7 22:28:12 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* dir.c (glob_helper): fix memory leak.
|
||||||
|
|
||||||
Wed Jan 7 21:15:07 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
Wed Jan 7 21:15:07 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||||
|
|
||||||
* sample/webrick/*: new files.
|
* sample/webrick/*: new files.
|
||||||
|
16
dir.c
16
dir.c
@ -162,7 +162,7 @@ range(pat, test, flags)
|
|||||||
return ok == not ? 0 : ++pat;
|
return ok == not ? 0 : ++pat;
|
||||||
else if (escape && *pstart == '\\')
|
else if (escape && *pstart == '\\')
|
||||||
pstart = pend = ++pat;
|
pstart = pend = ++pat;
|
||||||
Inc(pat);
|
Inc(pat);
|
||||||
if (*pat == '-' && pat[1] != ']') {
|
if (*pat == '-' && pat[1] != ']') {
|
||||||
if (escape && pat[1] == '\\')
|
if (escape && pat[1] == '\\')
|
||||||
pat++;
|
pat++;
|
||||||
@ -197,13 +197,14 @@ fnmatch(pat, string, flags)
|
|||||||
|
|
||||||
while (c = *pat) {
|
while (c = *pat) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '?':
|
case '?':
|
||||||
if (!*s || ISDIRSEP(*s) || PERIOD_S())
|
if (!*s || ISDIRSEP(*s) || PERIOD_S())
|
||||||
return FNM_NOMATCH;
|
return FNM_NOMATCH;
|
||||||
INC_S();
|
INC_S();
|
||||||
++pat;
|
++pat;
|
||||||
break;
|
break;
|
||||||
case '*':
|
|
||||||
|
case '*':
|
||||||
while ((c = *++pat) == '*')
|
while ((c = *++pat) == '*')
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -236,7 +237,7 @@ fnmatch(pat, string, flags)
|
|||||||
}
|
}
|
||||||
return FNM_NOMATCH;
|
return FNM_NOMATCH;
|
||||||
|
|
||||||
case '[':
|
case '[':
|
||||||
if (!*s || ISDIRSEP(*s) || PERIOD_S())
|
if (!*s || ISDIRSEP(*s) || PERIOD_S())
|
||||||
return FNM_NOMATCH;
|
return FNM_NOMATCH;
|
||||||
pat = range(pat+1, s, flags);
|
pat = range(pat+1, s, flags);
|
||||||
@ -245,7 +246,7 @@ fnmatch(pat, string, flags)
|
|||||||
INC_S();
|
INC_S();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
if (escape && pat[1]
|
if (escape && pat[1]
|
||||||
#if defined DOSISH
|
#if defined DOSISH
|
||||||
&& strchr("*?[\\", pat[1])
|
&& strchr("*?[\\", pat[1])
|
||||||
@ -255,13 +256,13 @@ fnmatch(pat, string, flags)
|
|||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
#if defined DOSISH
|
#if defined DOSISH
|
||||||
if (ISDIRSEP(c) && isdirsep(*s))
|
if (ISDIRSEP(c) && isdirsep(*s))
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if(Compare(pat, s) != 0)
|
if (Compare(pat, s) != 0)
|
||||||
return FNM_NOMATCH;
|
return FNM_NOMATCH;
|
||||||
INC_S();
|
INC_S();
|
||||||
Inc(pat);
|
Inc(pat);
|
||||||
@ -1129,6 +1130,7 @@ glob_helper(path, sub, separator, flags, func, arg) /* if separator p[-1] is rem
|
|||||||
strcpy(buf+n1, link->name);
|
strcpy(buf+n1, link->name);
|
||||||
strcpy(buf+n2, m);
|
strcpy(buf+n2, m);
|
||||||
status = glob_helper(buf, buf+n2+1, 1, flags, func, arg);
|
status = glob_helper(buf, buf+n2+1, 1, flags, func, arg);
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
tmp = link;
|
tmp = link;
|
||||||
link = link->next;
|
link = link->next;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user