mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_substr): "a"[1,2] should return ""; need
rubicon upgrade. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ec6e3f9ec3
commit
86833594ff
6 changed files with 84 additions and 26 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
Mon Feb 19 17:46:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_substr): "a"[1,2] should return ""; need
|
||||
rubicon upgrade.
|
||||
|
||||
Mon Feb 19 12:10:36 2001 Triet H. Lai <thlai@mail.usyd.edu.au>
|
||||
|
||||
* error.c (endif): new function to give warning with strerror()
|
||||
message.
|
||||
|
||||
* dir.c (rb_glob_helper): better error handling, along with
|
||||
performance tune.
|
||||
|
||||
Mon Feb 19 01:55:43 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (secure_visibility): visibility check for untainted modules.
|
||||
|
|
2
array.c
2
array.c
|
@ -400,7 +400,7 @@ rb_ary_subseq(ary, beg, len)
|
|||
{
|
||||
VALUE ary2;
|
||||
|
||||
if (beg >= RARRAY(ary)->len) return Qnil;
|
||||
if (beg > RARRAY(ary)->len) return Qnil;
|
||||
if (beg < 0 || len < 0) return Qnil;
|
||||
|
||||
if (beg + len > RARRAY(ary)->len) {
|
||||
|
|
65
dir.c
65
dir.c
|
@ -594,6 +594,11 @@ rb_glob_helper(path, flag, func, arg)
|
|||
if (rb_sys_stat(path, &st) == 0) {
|
||||
(*func)(path, arg);
|
||||
}
|
||||
else {
|
||||
/* In case stat error is other than ENOENT and
|
||||
we may want to know what is wrong. */
|
||||
rb_sys_warning(path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -617,27 +622,29 @@ rb_glob_helper(path, flag, func, arg)
|
|||
else dir = base;
|
||||
|
||||
magic = extract_elem(p);
|
||||
if (m && strcmp(magic, "**") == 0) {
|
||||
recursive = 1;
|
||||
buf = ALLOC_N(char, strlen(base)+strlen(m)+3);
|
||||
sprintf(buf, "%s%s%s", base, (*base)?"":".", m);
|
||||
rb_glob_helper(buf, flag, func, arg);
|
||||
free(buf);
|
||||
}
|
||||
if (lstat(dir, &st) < 0) {
|
||||
rb_sys_warning(dir);
|
||||
free(base);
|
||||
break;
|
||||
}
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
if (m && strcmp(magic, "**") == 0) {
|
||||
recursive = 1;
|
||||
buf = ALLOC_N(char, strlen(base)+strlen(m)+3);
|
||||
sprintf(buf, "%s%s%s", base, (*base)?"":".", m);
|
||||
rb_glob_helper(buf, flag, func, arg);
|
||||
free(buf);
|
||||
}
|
||||
dirp = opendir(dir);
|
||||
if (dirp == NULL) {
|
||||
rb_sys_warning(dir);
|
||||
free(base);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
free(base);
|
||||
break;
|
||||
free(base);
|
||||
break;
|
||||
}
|
||||
|
||||
#define BASE (*base && !(*base == '/' && !base[1]))
|
||||
|
@ -647,8 +654,16 @@ rb_glob_helper(path, flag, func, arg)
|
|||
if (strcmp(".", dp->d_name) == 0 || strcmp("..", dp->d_name) == 0)
|
||||
continue;
|
||||
buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+strlen(m)+6);
|
||||
sprintf(buf, "%s%s%s/**%s", base, (BASE)?"/":"", dp->d_name, m);
|
||||
rb_glob_helper(buf, flag, func, arg);
|
||||
sprintf(buf, "%s%s%s/", base, (BASE)?"/":"", dp->d_name);
|
||||
if (lstat(buf, &st) < 0) {
|
||||
rb_sys_warning(buf);
|
||||
continue;
|
||||
}
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
strcat(buf, "**");
|
||||
strcat(buf, m);
|
||||
rb_glob_helper(buf, flag, func, arg);
|
||||
}
|
||||
free(buf);
|
||||
continue;
|
||||
}
|
||||
|
@ -670,20 +685,24 @@ rb_glob_helper(path, flag, func, arg)
|
|||
free(base);
|
||||
free(magic);
|
||||
while (link) {
|
||||
lstat(link->path, &st); /* should success */
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
int len = strlen(link->path);
|
||||
int mlen = strlen(m);
|
||||
char *t = ALLOC_N(char, len+mlen+1);
|
||||
if (lstat(link->path, &st) == 0) {
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
int len = strlen(link->path);
|
||||
int mlen = strlen(m);
|
||||
char *t = ALLOC_N(char, len+mlen+1);
|
||||
|
||||
sprintf(t, "%s%s", link->path, m);
|
||||
rb_glob_helper(t, flag, func, arg);
|
||||
free(t);
|
||||
sprintf(t, "%s%s", link->path, m);
|
||||
rb_glob_helper(t, flag, func, arg);
|
||||
free(t);
|
||||
}
|
||||
tmp = link;
|
||||
link = link->next;
|
||||
free(tmp->path);
|
||||
free(tmp);
|
||||
}
|
||||
else {
|
||||
rb_sys_warning(link->path);
|
||||
}
|
||||
tmp = link;
|
||||
link = link->next;
|
||||
free(tmp->path);
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
p = m;
|
||||
|
|
26
error.c
26
error.c
|
@ -701,6 +701,32 @@ rb_sys_fail(mesg)
|
|||
rb_exc_raise(ee);
|
||||
}
|
||||
|
||||
void
|
||||
#ifdef HAVE_STDARG_PROTOTYPES
|
||||
rb_sys_warning(const char *fmt, ...)
|
||||
#else
|
||||
rb_sys_warning(fmt, va_alist)
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
va_list args;
|
||||
int errno_save;
|
||||
|
||||
errno_save = errno;
|
||||
|
||||
if (!RTEST(ruby_verbose)) return;
|
||||
|
||||
snprintf(buf, BUFSIZ, "warning: %s", fmt);
|
||||
snprintf(buf+strlen(buf), BUFSIZ-strlen(buf), ": %s", strerror(errno_save));
|
||||
|
||||
va_init_list(args, fmt);
|
||||
warn_print(buf, args);
|
||||
va_end(args);
|
||||
errno = errno_save;
|
||||
}
|
||||
|
||||
void
|
||||
rb_load_fail(path)
|
||||
char *path;
|
||||
|
|
3
ruby.h
3
ruby.h
|
@ -460,8 +460,9 @@ NORETURN(void rb_iter_break _((void)));
|
|||
NORETURN(void rb_exit _((int)));
|
||||
NORETURN(void rb_notimplement _((void)));
|
||||
|
||||
void rb_warn __((const char*, ...));
|
||||
void rb_warning __((const char*, ...)); /* reports if `-w' specified */
|
||||
void rb_sys_warning __((const char*, ...)); /* reports if `-w' specified */
|
||||
void rb_warn __((const char*, ...)); /* reports always */
|
||||
|
||||
VALUE rb_each _((VALUE));
|
||||
VALUE rb_yield _((VALUE));
|
||||
|
|
1
string.c
1
string.c
|
@ -349,7 +349,6 @@ rb_str_substr(str, beg, len)
|
|||
|
||||
if (len < 0) return Qnil;
|
||||
if (beg > RSTRING(str)->len) return Qnil;
|
||||
if (beg == RSTRING(str)->len && len > 0) return Qnil;
|
||||
if (beg < 0) {
|
||||
beg += RSTRING(str)->len;
|
||||
if (beg < 0) return Qnil;
|
||||
|
|
Loading…
Reference in a new issue