* file.c (rb_get_path): get path string via "to_path" method if
path object is not a string. [Ruby2] * gc.c (rb_gc_call_finalizer_at_exit): do not free threads in the exit finalizers. * io.c (rb_io_reopen): should use rb_io_check_io(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
43db576e61
commit
4ded52b623
10
ChangeLog
10
ChangeLog
@ -13,6 +13,16 @@ Wed Apr 7 00:24:34 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
|
|||||||
|
|
||||||
* test/rinda/test_rinda.rb
|
* test/rinda/test_rinda.rb
|
||||||
|
|
||||||
|
Tue Apr 6 18:24:18 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* file.c (rb_get_path): get path string via "to_path" method if
|
||||||
|
path object is not a string. [Ruby2]
|
||||||
|
|
||||||
|
* gc.c (rb_gc_call_finalizer_at_exit): do not free threads in the
|
||||||
|
exit finalizers.
|
||||||
|
|
||||||
|
* io.c (rb_io_reopen): should use rb_io_check_io().
|
||||||
|
|
||||||
Tue Apr 6 16:46:09 2004 Tanaka Akira <akr@m17n.org>
|
Tue Apr 6 16:46:09 2004 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
* configure.in: check the size of time_t.
|
* configure.in: check the size of time_t.
|
||||||
|
60
array.c
60
array.c
@ -16,11 +16,13 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "st.h"
|
#include "st.h"
|
||||||
|
|
||||||
VALUE rb_cArray;
|
VALUE rb_cArray, rb_cValues;
|
||||||
|
|
||||||
static ID id_cmp;
|
static ID id_cmp;
|
||||||
|
|
||||||
#define ARY_DEFAULT_SIZE 16
|
#define ARY_DEFAULT_SIZE 16
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_mem_clear(mem, size)
|
rb_mem_clear(mem, size)
|
||||||
register VALUE *mem;
|
register VALUE *mem;
|
||||||
@ -192,18 +194,51 @@ rb_ary_new4(n, elts)
|
|||||||
return ary;
|
return ary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
#ifdef HAVE_STDARG_PROTOTYPES
|
||||||
|
rb_values_new(long n, ...)
|
||||||
|
#else
|
||||||
|
rb_values_new(n, va_alist)
|
||||||
|
long n;
|
||||||
|
va_dcl
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
va_list ar;
|
||||||
|
VALUE val;
|
||||||
|
long i;
|
||||||
|
|
||||||
|
val = ary_new(rb_cValues, n);
|
||||||
|
va_init_list(ar, n);
|
||||||
|
for (i=0; i<n; i++) {
|
||||||
|
RARRAY(val)->ptr[i] = va_arg(ar, VALUE);
|
||||||
|
}
|
||||||
|
va_end(ar);
|
||||||
|
RARRAY(val)->len = n;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
rb_values_new2(n, elts)
|
||||||
|
long n;
|
||||||
|
const VALUE *elts;
|
||||||
|
{
|
||||||
|
VALUE val;
|
||||||
|
|
||||||
|
val = ary_new(rb_cValues, n);
|
||||||
|
if (n > 0 && elts) {
|
||||||
|
MEMCPY(RARRAY(val)->ptr, elts, VALUE, n);
|
||||||
|
}
|
||||||
|
RARRAY(val)->len = n;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_assoc_new(car, cdr)
|
rb_assoc_new(car, cdr)
|
||||||
VALUE car, cdr;
|
VALUE car, cdr;
|
||||||
{
|
{
|
||||||
VALUE ary;
|
return rb_values_new(2, car, cdr);
|
||||||
|
|
||||||
ary = rb_ary_new2(2);
|
|
||||||
RARRAY(ary)->ptr[0] = car;
|
|
||||||
RARRAY(ary)->ptr[1] = cdr;
|
|
||||||
RARRAY(ary)->len = 2;
|
|
||||||
|
|
||||||
return ary;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -905,7 +940,6 @@ rb_ary_indexes(argc, argv, ary)
|
|||||||
VALUE new_ary;
|
VALUE new_ary;
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
rb_warn("Array#%s is deprecated; use Array#values_at", rb_id2name(rb_frame_last_func()));
|
|
||||||
new_ary = rb_ary_new2(argc);
|
new_ary = rb_ary_new2(argc);
|
||||||
for (i=0; i<argc; i++) {
|
for (i=0; i<argc; i++) {
|
||||||
rb_ary_push(new_ary, rb_ary_aref(1, argv+i, ary));
|
rb_ary_push(new_ary, rb_ary_aref(1, argv+i, ary));
|
||||||
@ -1696,7 +1730,7 @@ rb_ary_collect_bang(ary)
|
|||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_values_at(obj, olen, argc, argv, func)
|
rb_get_values_at(obj, olen, argc, argv, func)
|
||||||
VALUE obj;
|
VALUE obj;
|
||||||
long olen;
|
long olen;
|
||||||
int argc;
|
int argc;
|
||||||
@ -1749,7 +1783,7 @@ rb_ary_values_at(argc, argv, ary)
|
|||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE ary;
|
VALUE ary;
|
||||||
{
|
{
|
||||||
return rb_values_at(ary, RARRAY(ary)->len, argc, argv, rb_ary_entry);
|
return rb_get_values_at(ary, RARRAY(ary)->len, argc, argv, rb_ary_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3016,4 +3050,6 @@ Init_Array()
|
|||||||
|
|
||||||
id_cmp = rb_intern("<=>");
|
id_cmp = rb_intern("<=>");
|
||||||
inspect_key = rb_intern("__inspect_key__");
|
inspect_key = rb_intern("__inspect_key__");
|
||||||
|
|
||||||
|
rb_cValues = rb_define_class("Values", rb_cArray);
|
||||||
}
|
}
|
||||||
|
8
dir.c
8
dir.c
@ -379,7 +379,7 @@ dir_initialize(dir, dirname)
|
|||||||
{
|
{
|
||||||
struct dir_data *dp;
|
struct dir_data *dp;
|
||||||
|
|
||||||
SafeStringValue(dirname);
|
dirname = rb_get_path(dirname);
|
||||||
Data_Get_Struct(dir, struct dir_data, dp);
|
Data_Get_Struct(dir, struct dir_data, dp);
|
||||||
if (dp->dir) closedir(dp->dir);
|
if (dp->dir) closedir(dp->dir);
|
||||||
if (dp->path) free(dp->path);
|
if (dp->path) free(dp->path);
|
||||||
@ -744,7 +744,7 @@ dir_s_chdir(argc, argv, obj)
|
|||||||
|
|
||||||
rb_secure(2);
|
rb_secure(2);
|
||||||
if (rb_scan_args(argc, argv, "01", &path) == 1) {
|
if (rb_scan_args(argc, argv, "01", &path) == 1) {
|
||||||
SafeStringValue(path);
|
path = rb_get_path(path);
|
||||||
dist = RSTRING(path)->ptr;
|
dist = RSTRING(path)->ptr;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -806,8 +806,8 @@ check_dirname(dir)
|
|||||||
{
|
{
|
||||||
char *path, *pend;
|
char *path, *pend;
|
||||||
|
|
||||||
SafeStringValue(*dir);
|
|
||||||
rb_secure(2);
|
rb_secure(2);
|
||||||
|
*dir = rb_get_path(*dir);
|
||||||
path = RSTRING(*dir)->ptr;
|
path = RSTRING(*dir)->ptr;
|
||||||
if (path && *(pend = rb_path_end(rb_path_skip_prefix(path)))) {
|
if (path && *(pend = rb_path_end(rb_path_skip_prefix(path)))) {
|
||||||
*dir = rb_str_new(path, pend - path);
|
*dir = rb_str_new(path, pend - path);
|
||||||
@ -1439,7 +1439,7 @@ rb_push_glob(str, flags)
|
|||||||
else
|
else
|
||||||
ary = rb_ary_new();
|
ary = rb_ary_new();
|
||||||
|
|
||||||
SafeStringValue(str);
|
str = rb_get_path(str);
|
||||||
buf = xmalloc(RSTRING(str)->len + 1);
|
buf = xmalloc(RSTRING(str)->len + 1);
|
||||||
|
|
||||||
p = RSTRING(str)->ptr;
|
p = RSTRING(str)->ptr;
|
||||||
|
9
eval.c
9
eval.c
@ -6385,11 +6385,11 @@ rb_load(fname, wrap)
|
|||||||
NODE *saved_cref = ruby_cref;
|
NODE *saved_cref = ruby_cref;
|
||||||
TMP_PROTECT;
|
TMP_PROTECT;
|
||||||
|
|
||||||
if (wrap && ruby_safe_level >= 4) {
|
if (wrap && ruby_safe_level >= 4 && OBJ_TAINTED(fname)) {
|
||||||
StringValue(fname);
|
StringValue(fname);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SafeStringValue(fname);
|
fname = rb_get_path(fname);
|
||||||
}
|
}
|
||||||
tmp = rb_find_file(fname);
|
tmp = rb_find_file(fname);
|
||||||
if (!tmp) {
|
if (!tmp) {
|
||||||
@ -6714,10 +6714,7 @@ rb_require_safe(fname, safe)
|
|||||||
} volatile saved;
|
} volatile saved;
|
||||||
char *volatile ftptr = 0;
|
char *volatile ftptr = 0;
|
||||||
|
|
||||||
if (OBJ_TAINTED(fname)) {
|
fname = rb_get_path(fname);
|
||||||
rb_check_safe_obj(fname);
|
|
||||||
}
|
|
||||||
StringValue(fname);
|
|
||||||
saved.vmode = scope_vmode;
|
saved.vmode = scope_vmode;
|
||||||
saved.node = ruby_current_node;
|
saved.node = ruby_current_node;
|
||||||
saved.func = ruby_frame->last_func;
|
saved.func = ruby_frame->last_func;
|
||||||
|
@ -1757,6 +1757,7 @@ gzfile_close(gz, closeflag)
|
|||||||
int closeflag;
|
int closeflag;
|
||||||
{
|
{
|
||||||
VALUE io = gz->io;
|
VALUE io = gz->io;
|
||||||
|
|
||||||
gz->end(gz);
|
gz->end(gz);
|
||||||
gz->io = Qnil;
|
gz->io = Qnil;
|
||||||
gz->orig_name = Qnil;
|
gz->orig_name = Qnil;
|
||||||
@ -2157,6 +2158,7 @@ gzfile_writer_end(gz)
|
|||||||
gzfile_make_footer(gz);
|
gzfile_make_footer(gz);
|
||||||
|
|
||||||
if (ZSTREAM_IS_FINALIZE(&gz->z)) {
|
if (ZSTREAM_IS_FINALIZE(&gz->z)) {
|
||||||
|
if (NIL_P(gz->io)) return;
|
||||||
rb_warn("Zlib::GzipWriter object must be closed explicitly.");
|
rb_warn("Zlib::GzipWriter object must be closed explicitly.");
|
||||||
if (OBJ_IS_FREED(gz->io)) {
|
if (OBJ_IS_FREED(gz->io)) {
|
||||||
aborted = 1;
|
aborted = 1;
|
||||||
|
118
file.c
118
file.c
@ -72,6 +72,31 @@ VALUE rb_cFile;
|
|||||||
VALUE rb_mFileTest;
|
VALUE rb_mFileTest;
|
||||||
static VALUE rb_cStat;
|
static VALUE rb_cStat;
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
rb_get_path(obj)
|
||||||
|
VALUE obj;
|
||||||
|
{
|
||||||
|
VALUE tmp;
|
||||||
|
static ID to_path;
|
||||||
|
|
||||||
|
rb_check_safe_obj(obj);
|
||||||
|
tmp = rb_check_string_type(obj);
|
||||||
|
if (!NIL_P(tmp)) goto exit;
|
||||||
|
|
||||||
|
if (!to_path) {
|
||||||
|
to_path = rb_intern("to_path");
|
||||||
|
}
|
||||||
|
if (rb_respond_to(obj, to_path)) {
|
||||||
|
obj = rb_funcall(obj, to_path, 0, 0);
|
||||||
|
}
|
||||||
|
tmp = rb_str_to_str(obj);
|
||||||
|
exit:
|
||||||
|
if (obj != tmp) {
|
||||||
|
rb_check_safe_obj(tmp);
|
||||||
|
}
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
static long
|
static long
|
||||||
apply2files(func, vargs, arg)
|
apply2files(func, vargs, arg)
|
||||||
void (*func)();
|
void (*func)();
|
||||||
@ -82,9 +107,9 @@ apply2files(func, vargs, arg)
|
|||||||
VALUE path;
|
VALUE path;
|
||||||
struct RArray *args = RARRAY(vargs);
|
struct RArray *args = RARRAY(vargs);
|
||||||
|
|
||||||
|
rb_secure(4);
|
||||||
for (i=0; i<args->len; i++) {
|
for (i=0; i<args->len; i++) {
|
||||||
path = args->ptr[i];
|
path = rb_get_path(args->ptr[i]);
|
||||||
SafeStringValue(path);
|
|
||||||
(*func)(StringValueCStr(path), arg);
|
(*func)(StringValueCStr(path), arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,15 +583,15 @@ rb_stat(file, st)
|
|||||||
{
|
{
|
||||||
VALUE tmp;
|
VALUE tmp;
|
||||||
|
|
||||||
|
rb_secure(2);
|
||||||
tmp = rb_check_convert_type(file, T_FILE, "IO", "to_io");
|
tmp = rb_check_convert_type(file, T_FILE, "IO", "to_io");
|
||||||
if (!NIL_P(tmp)) {
|
if (!NIL_P(tmp)) {
|
||||||
OpenFile *fptr;
|
OpenFile *fptr;
|
||||||
|
|
||||||
rb_secure(2);
|
|
||||||
GetOpenFile(tmp, fptr);
|
GetOpenFile(tmp, fptr);
|
||||||
return fstat(fileno(fptr->f), st);
|
return fstat(fileno(fptr->f), st);
|
||||||
}
|
}
|
||||||
SafeStringValue(file);
|
file = rb_get_path(file);
|
||||||
return stat(StringValueCStr(file), st);
|
return stat(StringValueCStr(file), st);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,7 +612,8 @@ rb_file_s_stat(klass, fname)
|
|||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
SafeStringValue(fname);
|
rb_secure(4);
|
||||||
|
fname = rb_get_path(fname);
|
||||||
if (rb_stat(fname, &st) < 0) {
|
if (rb_stat(fname, &st) < 0) {
|
||||||
rb_sys_fail(StringValueCStr(fname));
|
rb_sys_fail(StringValueCStr(fname));
|
||||||
}
|
}
|
||||||
@ -644,7 +670,8 @@ rb_file_s_lstat(klass, fname)
|
|||||||
#ifdef HAVE_LSTAT
|
#ifdef HAVE_LSTAT
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
SafeStringValue(fname);
|
rb_secure(2);
|
||||||
|
fname = rb_get_path(fname);
|
||||||
if (lstat(StringValueCStr(fname), &st) == -1) {
|
if (lstat(StringValueCStr(fname), &st) == -1) {
|
||||||
rb_sys_fail(RSTRING(fname)->ptr);
|
rb_sys_fail(RSTRING(fname)->ptr);
|
||||||
}
|
}
|
||||||
@ -852,7 +879,8 @@ test_l(obj, fname)
|
|||||||
#ifdef S_ISLNK
|
#ifdef S_ISLNK
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
SafeStringValue(fname);
|
rb_secure(2);
|
||||||
|
fname = rb_get_path(fname);
|
||||||
if (lstat(StringValueCStr(fname), &st) < 0) return Qfalse;
|
if (lstat(StringValueCStr(fname), &st) < 0) return Qfalse;
|
||||||
if (S_ISLNK(st.st_mode)) return Qtrue;
|
if (S_ISLNK(st.st_mode)) return Qtrue;
|
||||||
#endif
|
#endif
|
||||||
@ -977,7 +1005,8 @@ static VALUE
|
|||||||
test_r(obj, fname)
|
test_r(obj, fname)
|
||||||
VALUE obj, fname;
|
VALUE obj, fname;
|
||||||
{
|
{
|
||||||
SafeStringValue(fname);
|
rb_secure(2);
|
||||||
|
fname = rb_get_path(fname);
|
||||||
if (eaccess(StringValueCStr(fname), R_OK) < 0) return Qfalse;
|
if (eaccess(StringValueCStr(fname), R_OK) < 0) return Qfalse;
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
}
|
}
|
||||||
@ -994,7 +1023,8 @@ static VALUE
|
|||||||
test_R(obj, fname)
|
test_R(obj, fname)
|
||||||
VALUE obj, fname;
|
VALUE obj, fname;
|
||||||
{
|
{
|
||||||
SafeStringValue(fname);
|
rb_secure(2);
|
||||||
|
fname = rb_get_path(fname);
|
||||||
if (access(StringValueCStr(fname), R_OK) < 0) return Qfalse;
|
if (access(StringValueCStr(fname), R_OK) < 0) return Qfalse;
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
}
|
}
|
||||||
@ -1048,7 +1078,8 @@ static VALUE
|
|||||||
test_w(obj, fname)
|
test_w(obj, fname)
|
||||||
VALUE obj, fname;
|
VALUE obj, fname;
|
||||||
{
|
{
|
||||||
SafeStringValue(fname);
|
rb_secure(2);
|
||||||
|
fname = rb_get_path(fname);
|
||||||
if (eaccess(StringValueCStr(fname), W_OK) < 0) return Qfalse;
|
if (eaccess(StringValueCStr(fname), W_OK) < 0) return Qfalse;
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
}
|
}
|
||||||
@ -1065,7 +1096,8 @@ static VALUE
|
|||||||
test_W(obj, fname)
|
test_W(obj, fname)
|
||||||
VALUE obj, fname;
|
VALUE obj, fname;
|
||||||
{
|
{
|
||||||
SafeStringValue(fname);
|
rb_secure(2);
|
||||||
|
fname = rb_get_path(fname);
|
||||||
if (access(StringValueCStr(fname), W_OK) < 0) return Qfalse;
|
if (access(StringValueCStr(fname), W_OK) < 0) return Qfalse;
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
}
|
}
|
||||||
@ -1111,7 +1143,8 @@ static VALUE
|
|||||||
test_x(obj, fname)
|
test_x(obj, fname)
|
||||||
VALUE obj, fname;
|
VALUE obj, fname;
|
||||||
{
|
{
|
||||||
SafeStringValue(fname);
|
rb_secure(2);
|
||||||
|
fname = rb_get_path(fname);
|
||||||
if (eaccess(StringValueCStr(fname), X_OK) < 0) return Qfalse;
|
if (eaccess(StringValueCStr(fname), X_OK) < 0) return Qfalse;
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
}
|
}
|
||||||
@ -1128,7 +1161,8 @@ static VALUE
|
|||||||
test_X(obj, fname)
|
test_X(obj, fname)
|
||||||
VALUE obj, fname;
|
VALUE obj, fname;
|
||||||
{
|
{
|
||||||
SafeStringValue(fname);
|
rb_secure(2);
|
||||||
|
fname = rb_get_path(fname);
|
||||||
if (access(StringValueCStr(fname), X_OK) < 0) return Qfalse;
|
if (access(StringValueCStr(fname), X_OK) < 0) return Qfalse;
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
}
|
}
|
||||||
@ -1255,7 +1289,8 @@ check3rdbyte(fname, mode)
|
|||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
SafeStringValue(fname);
|
rb_secure(2);
|
||||||
|
fname = rb_get_path(fname);
|
||||||
if (stat(StringValueCStr(fname), &st) < 0) return Qfalse;
|
if (stat(StringValueCStr(fname), &st) < 0) return Qfalse;
|
||||||
if (st.st_mode & mode) return Qtrue;
|
if (st.st_mode & mode) return Qtrue;
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
@ -1397,7 +1432,8 @@ rb_file_s_ftype(klass, fname)
|
|||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
SafeStringValue(fname);
|
rb_secure(2);
|
||||||
|
fname = rb_get_path(fname);
|
||||||
if (lstat(StringValueCStr(fname), &st) == -1) {
|
if (lstat(StringValueCStr(fname), &st) == -1) {
|
||||||
rb_sys_fail(RSTRING(fname)->ptr);
|
rb_sys_fail(RSTRING(fname)->ptr);
|
||||||
}
|
}
|
||||||
@ -1930,8 +1966,9 @@ rb_file_s_link(klass, from, to)
|
|||||||
VALUE klass, from, to;
|
VALUE klass, from, to;
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LINK
|
#ifdef HAVE_LINK
|
||||||
SafeStringValue(from);
|
rb_secure(2);
|
||||||
SafeStringValue(to);
|
from = rb_get_path(from);
|
||||||
|
to = rb_get_path(to);
|
||||||
|
|
||||||
if (link(StringValueCStr(from), StringValueCStr(to)) < 0) {
|
if (link(StringValueCStr(from), StringValueCStr(to)) < 0) {
|
||||||
sys_fail2(from, to);
|
sys_fail2(from, to);
|
||||||
@ -1960,8 +1997,9 @@ rb_file_s_symlink(klass, from, to)
|
|||||||
VALUE klass, from, to;
|
VALUE klass, from, to;
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SYMLINK
|
#ifdef HAVE_SYMLINK
|
||||||
SafeStringValue(from);
|
rb_secure(2);
|
||||||
SafeStringValue(to);
|
from = rb_get_path(from);
|
||||||
|
to = rb_get_path(to);
|
||||||
|
|
||||||
if (symlink(StringValueCStr(from), StringValueCStr(to)) < 0) {
|
if (symlink(StringValueCStr(from), StringValueCStr(to)) < 0) {
|
||||||
sys_fail2(from, to);
|
sys_fail2(from, to);
|
||||||
@ -1994,7 +2032,8 @@ rb_file_s_readlink(klass, path)
|
|||||||
int rv;
|
int rv;
|
||||||
VALUE v;
|
VALUE v;
|
||||||
|
|
||||||
SafeStringValue(path);
|
rb_secure(2);
|
||||||
|
path = rb_get_path(path);
|
||||||
buf = xmalloc(size);
|
buf = xmalloc(size);
|
||||||
while ((rv = readlink(StringValueCStr(path), buf, size)) == size) {
|
while ((rv = readlink(StringValueCStr(path), buf, size)) == size) {
|
||||||
size *= 2;
|
size *= 2;
|
||||||
@ -2058,10 +2097,11 @@ rb_file_s_rename(klass, from, to)
|
|||||||
VALUE klass, from, to;
|
VALUE klass, from, to;
|
||||||
{
|
{
|
||||||
const char *src, *dst;
|
const char *src, *dst;
|
||||||
SafeStringValue(from);
|
|
||||||
SafeStringValue(to);
|
|
||||||
|
|
||||||
|
rb_secure(2);
|
||||||
|
from = rb_get_path(from);
|
||||||
src = StringValueCStr(from);
|
src = StringValueCStr(from);
|
||||||
|
to = rb_get_path(to);
|
||||||
dst = StringValueCStr(to);
|
dst = StringValueCStr(to);
|
||||||
if (rename(src, dst) < 0) {
|
if (rename(src, dst) < 0) {
|
||||||
#if defined __CYGWIN__
|
#if defined __CYGWIN__
|
||||||
@ -2684,6 +2724,24 @@ rb_file_s_extname(klass, fname)
|
|||||||
return extname;
|
return extname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* call-seq:
|
||||||
|
* File.path(path) -> string
|
||||||
|
*
|
||||||
|
* Returns the string representation of the path
|
||||||
|
*
|
||||||
|
* File.path("/dev/null") #=> "/dev/null"
|
||||||
|
* File.path(Pathname.new("/tmp")) #=> "/tmp"
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
rb_file_s_path(klass, fname)
|
||||||
|
VALUE klass, fname;
|
||||||
|
{
|
||||||
|
return rb_get_path(fname);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* File.split(file_name) => array
|
* File.split(file_name) => array
|
||||||
@ -2810,7 +2868,7 @@ rb_file_s_truncate(klass, path, len)
|
|||||||
VALUE klass, path, len;
|
VALUE klass, path, len;
|
||||||
{
|
{
|
||||||
rb_secure(2);
|
rb_secure(2);
|
||||||
SafeStringValue(path);
|
path = rb_get_path(path);
|
||||||
|
|
||||||
#ifdef HAVE_TRUNCATE
|
#ifdef HAVE_TRUNCATE
|
||||||
if (truncate(StringValueCStr(path), NUM2OFFT(len)) < 0)
|
if (truncate(StringValueCStr(path), NUM2OFFT(len)) < 0)
|
||||||
@ -2995,14 +3053,15 @@ test_check(n, argc, argv)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
rb_secure(2);
|
||||||
n+=1;
|
n+=1;
|
||||||
if (n != argc) rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, n);
|
if (n != argc) rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, n);
|
||||||
for (i=1; i<n; i++) {
|
for (i=1; i<n; i++) {
|
||||||
switch (TYPE(argv[i])) {
|
switch (TYPE(argv[i])) {
|
||||||
case T_STRING:
|
case T_STRING:
|
||||||
default:
|
default:
|
||||||
SafeStringValue(argv[i]);
|
argv[i] = rb_get_path(argv[i]);
|
||||||
break;
|
break;
|
||||||
case T_FILE:
|
case T_FILE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3245,8 +3304,8 @@ rb_stat_init(obj, fname)
|
|||||||
{
|
{
|
||||||
struct stat st, *nst;
|
struct stat st, *nst;
|
||||||
|
|
||||||
SafeStringValue(fname);
|
rb_secure(2);
|
||||||
|
fname = rb_get_path(fname);
|
||||||
if (stat(StringValueCStr(fname), &st) == -1) {
|
if (stat(StringValueCStr(fname), &st) == -1) {
|
||||||
rb_sys_fail(RSTRING(fname)->ptr);
|
rb_sys_fail(RSTRING(fname)->ptr);
|
||||||
}
|
}
|
||||||
@ -4015,7 +4074,7 @@ rb_find_file_ext(filep, ext)
|
|||||||
for (i=0;i<RARRAY(rb_load_path)->len;i++) {
|
for (i=0;i<RARRAY(rb_load_path)->len;i++) {
|
||||||
VALUE str = RARRAY(rb_load_path)->ptr[i];
|
VALUE str = RARRAY(rb_load_path)->ptr[i];
|
||||||
|
|
||||||
SafeStringValue(str);
|
str = rb_get_path(str);
|
||||||
if (RSTRING(str)->len == 0) continue;
|
if (RSTRING(str)->len == 0) continue;
|
||||||
path = RSTRING(str)->ptr;
|
path = RSTRING(str)->ptr;
|
||||||
for (j=0; ext[j]; j++) {
|
for (j=0; ext[j]; j++) {
|
||||||
@ -4074,7 +4133,7 @@ rb_find_file(path)
|
|||||||
tmp = rb_ary_new();
|
tmp = rb_ary_new();
|
||||||
for (i=0;i<RARRAY(rb_load_path)->len;i++) {
|
for (i=0;i<RARRAY(rb_load_path)->len;i++) {
|
||||||
VALUE str = RARRAY(rb_load_path)->ptr[i];
|
VALUE str = RARRAY(rb_load_path)->ptr[i];
|
||||||
SafeStringValue(str);
|
str = rb_get_path(str);
|
||||||
if (RSTRING(str)->len > 0) {
|
if (RSTRING(str)->len > 0) {
|
||||||
rb_ary_push(tmp, str);
|
rb_ary_push(tmp, str);
|
||||||
}
|
}
|
||||||
@ -4212,6 +4271,7 @@ Init_File()
|
|||||||
rb_define_singleton_method(rb_cFile, "basename", rb_file_s_basename, -1);
|
rb_define_singleton_method(rb_cFile, "basename", rb_file_s_basename, -1);
|
||||||
rb_define_singleton_method(rb_cFile, "dirname", rb_file_s_dirname, 1);
|
rb_define_singleton_method(rb_cFile, "dirname", rb_file_s_dirname, 1);
|
||||||
rb_define_singleton_method(rb_cFile, "extname", rb_file_s_extname, 1);
|
rb_define_singleton_method(rb_cFile, "extname", rb_file_s_extname, 1);
|
||||||
|
rb_define_singleton_method(rb_cFile, "path", rb_file_s_path, 1);
|
||||||
|
|
||||||
separator = rb_obj_freeze(rb_str_new2("/"));
|
separator = rb_obj_freeze(rb_str_new2("/"));
|
||||||
rb_define_const(rb_cFile, "Separator", separator);
|
rb_define_const(rb_cFile, "Separator", separator);
|
||||||
|
12
gc.c
12
gc.c
@ -45,7 +45,7 @@ extern unsigned long __libc_ia64_register_backing_store_base;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void re_free_registers _((struct re_registers*));
|
void re_free_registers _((struct re_registers*));
|
||||||
void rb_io_fptr_finalize _((struct OpenFile*));
|
int rb_io_fptr_finalize _((struct OpenFile*));
|
||||||
|
|
||||||
#if !defined(setjmp) && defined(HAVE__SETJMP)
|
#if !defined(setjmp) && defined(HAVE__SETJMP)
|
||||||
#define setjmp(env) _setjmp(env)
|
#define setjmp(env) _setjmp(env)
|
||||||
@ -1786,11 +1786,12 @@ rb_gc_call_finalizer_at_exit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* run data object's finalizers */
|
/* run data object's finalizers */
|
||||||
for (i = 0; i < heaps_used; i++) {
|
for (i = heaps_used-1; 0 <= i; i--) {
|
||||||
p = heaps[i].slot; pend = p + heaps[i].limit;
|
p = heaps[i].slot; pend = p + heaps[i].limit;
|
||||||
while (p < pend) {
|
while (p < pend) {
|
||||||
if (BUILTIN_TYPE(p) == T_DATA &&
|
if (BUILTIN_TYPE(p) == T_DATA &&
|
||||||
DATA_PTR(p) && RANY(p)->as.data.dfree) {
|
DATA_PTR(p) && RANY(p)->as.data.dfree &&
|
||||||
|
RANY(p)->as.basic.klass != rb_cThread) {
|
||||||
p->as.free.flags = 0;
|
p->as.free.flags = 0;
|
||||||
if ((long)RANY(p)->as.data.dfree == -1) {
|
if ((long)RANY(p)->as.data.dfree == -1) {
|
||||||
RUBY_CRITICAL(free(DATA_PTR(p)));
|
RUBY_CRITICAL(free(DATA_PTR(p)));
|
||||||
@ -1800,8 +1801,9 @@ rb_gc_call_finalizer_at_exit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (BUILTIN_TYPE(p) == T_FILE) {
|
else if (BUILTIN_TYPE(p) == T_FILE) {
|
||||||
p->as.free.flags = 0;
|
if (rb_io_fptr_finalize(RANY(p)->as.file.fptr)) {
|
||||||
rb_io_fptr_finalize(RANY(p)->as.file.fptr);
|
p->as.free.flags = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
4
hash.c
4
hash.c
@ -576,8 +576,6 @@ rb_hash_indexes(argc, argv, hash)
|
|||||||
VALUE indexes;
|
VALUE indexes;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
rb_warn("Hash#%s is deprecated; use Hash#values_at",
|
|
||||||
rb_id2name(rb_frame_last_func()));
|
|
||||||
indexes = rb_ary_new2(argc);
|
indexes = rb_ary_new2(argc);
|
||||||
for (i=0; i<argc; i++) {
|
for (i=0; i<argc; i++) {
|
||||||
RARRAY(indexes)->ptr[i] = rb_hash_aref(hash, argv[i]);
|
RARRAY(indexes)->ptr[i] = rb_hash_aref(hash, argv[i]);
|
||||||
@ -2214,8 +2212,6 @@ env_indexes(argc, argv)
|
|||||||
int i;
|
int i;
|
||||||
VALUE indexes = rb_ary_new2(argc);
|
VALUE indexes = rb_ary_new2(argc);
|
||||||
|
|
||||||
rb_warn("ENV.%s is deprecated; use ENV.values_at",
|
|
||||||
rb_id2name(rb_frame_last_func()));
|
|
||||||
for (i=0;i<argc;i++) {
|
for (i=0;i<argc;i++) {
|
||||||
VALUE tmp = rb_check_string_type(argv[i]);
|
VALUE tmp = rb_check_string_type(argv[i]);
|
||||||
if (NIL_P(tmp)) {
|
if (NIL_P(tmp)) {
|
||||||
|
5
intern.h
5
intern.h
@ -30,6 +30,8 @@ VALUE rb_ary_new _((void));
|
|||||||
VALUE rb_ary_new2 _((long));
|
VALUE rb_ary_new2 _((long));
|
||||||
VALUE rb_ary_new3 __((long,...));
|
VALUE rb_ary_new3 __((long,...));
|
||||||
VALUE rb_ary_new4 _((long, const VALUE *));
|
VALUE rb_ary_new4 _((long, const VALUE *));
|
||||||
|
VALUE rb_values_new __((long,...));
|
||||||
|
VALUE rb_values_new2 _((long, const VALUE *));
|
||||||
VALUE rb_ary_freeze _((VALUE));
|
VALUE rb_ary_freeze _((VALUE));
|
||||||
VALUE rb_ary_aref _((int, VALUE*, VALUE));
|
VALUE rb_ary_aref _((int, VALUE*, VALUE));
|
||||||
void rb_ary_store _((VALUE, long, VALUE));
|
void rb_ary_store _((VALUE, long, VALUE));
|
||||||
@ -59,7 +61,7 @@ VALUE rb_ary_cmp _((VALUE, VALUE));
|
|||||||
VALUE rb_protect_inspect _((VALUE(*)(ANYARGS),VALUE,VALUE));
|
VALUE rb_protect_inspect _((VALUE(*)(ANYARGS),VALUE,VALUE));
|
||||||
VALUE rb_inspecting_p _((VALUE));
|
VALUE rb_inspecting_p _((VALUE));
|
||||||
VALUE rb_check_array_value _((VALUE));
|
VALUE rb_check_array_value _((VALUE));
|
||||||
VALUE rb_values_at _((VALUE, long, int, VALUE*, VALUE(*) _((VALUE,long))));
|
VALUE rb_get_values_at _((VALUE, long, int, VALUE*, VALUE(*) _((VALUE,long))));
|
||||||
/* bignum.c */
|
/* bignum.c */
|
||||||
VALUE rb_big_clone _((VALUE));
|
VALUE rb_big_clone _((VALUE));
|
||||||
void rb_big_2comp _((VALUE));
|
void rb_big_2comp _((VALUE));
|
||||||
@ -222,6 +224,7 @@ VALUE rb_thread_local_aset _((VALUE, ID, VALUE));
|
|||||||
void rb_thread_atfork _((void));
|
void rb_thread_atfork _((void));
|
||||||
/* file.c */
|
/* file.c */
|
||||||
int eaccess _((const char*, int));
|
int eaccess _((const char*, int));
|
||||||
|
VALUE rb_get_path _((VALUE));
|
||||||
VALUE rb_file_s_expand_path _((int, VALUE *));
|
VALUE rb_file_s_expand_path _((int, VALUE *));
|
||||||
void rb_file_const _((const char*, VALUE));
|
void rb_file_const _((const char*, VALUE));
|
||||||
int rb_find_file_ext _((VALUE*, const char* const*));
|
int rb_find_file_ext _((VALUE*, const char* const*));
|
||||||
|
80
io.c
80
io.c
@ -195,6 +195,20 @@ rb_io_check_closed(fptr)
|
|||||||
|
|
||||||
static void io_fflush _((FILE *, OpenFile *));
|
static void io_fflush _((FILE *, OpenFile *));
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
rb_io_get_io(io)
|
||||||
|
VALUE io;
|
||||||
|
{
|
||||||
|
return rb_convert_type(io, T_FILE, "IO", "to_io");
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
rb_io_check_io(io)
|
||||||
|
VALUE io;
|
||||||
|
{
|
||||||
|
return rb_check_convert_type(io, T_FILE, "IO", "to_io");
|
||||||
|
}
|
||||||
|
|
||||||
static OpenFile *
|
static OpenFile *
|
||||||
flush_before_seek(fptr)
|
flush_before_seek(fptr)
|
||||||
OpenFile *fptr;
|
OpenFile *fptr;
|
||||||
@ -435,15 +449,16 @@ io_write(io, str)
|
|||||||
OpenFile *fptr;
|
OpenFile *fptr;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
long n;
|
long n;
|
||||||
|
VALUE tmp;
|
||||||
|
|
||||||
rb_secure(4);
|
rb_secure(4);
|
||||||
if (TYPE(str) != T_STRING)
|
str = rb_obj_as_string(str);
|
||||||
str = rb_obj_as_string(str);
|
tmp = rb_io_check_io(io);
|
||||||
|
if (NIL_P(tmp)) {
|
||||||
if (TYPE(io) != T_FILE) {
|
|
||||||
/* port is not IO, call write method for it. */
|
/* port is not IO, call write method for it. */
|
||||||
return rb_funcall(io, id_write, 1, str);
|
return rb_funcall(io, id_write, 1, str);
|
||||||
}
|
}
|
||||||
|
io = tmp;
|
||||||
if (RSTRING(str)->len == 0) return INT2FIX(0);
|
if (RSTRING(str)->len == 0) return INT2FIX(0);
|
||||||
|
|
||||||
GetOpenFile(io, fptr);
|
GetOpenFile(io, fptr);
|
||||||
@ -1775,20 +1790,22 @@ rb_io_fptr_cleanup(fptr, noraise)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
rb_io_fptr_finalize(fptr)
|
rb_io_fptr_finalize(fptr)
|
||||||
OpenFile *fptr;
|
OpenFile *fptr;
|
||||||
{
|
{
|
||||||
if (!fptr) return;
|
if (!fptr) return 0;
|
||||||
if (fptr->refcnt <= 0 || --fptr->refcnt) return;
|
if (fptr->refcnt <= 0 || --fptr->refcnt) return 0;
|
||||||
if (fptr->path) {
|
if (fptr->path) {
|
||||||
free(fptr->path);
|
free(fptr->path);
|
||||||
|
fptr->path = 0;
|
||||||
}
|
}
|
||||||
if (!fptr->f && !fptr->f2) return;
|
if (!fptr->f && !fptr->f2) return 0;
|
||||||
if (fileno(fptr->f) < 3) return;
|
if (fileno(fptr->f) < 3) return 0;
|
||||||
|
|
||||||
rb_io_fptr_cleanup(fptr, Qtrue);
|
rb_io_fptr_cleanup(fptr, Qtrue);
|
||||||
free(fptr);
|
free(fptr);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
@ -2866,7 +2883,7 @@ rb_open_file(argc, argv, io)
|
|||||||
int flags, fmode;
|
int flags, fmode;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
|
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
|
||||||
SafeStringValue(fname);
|
fname = rb_get_path(fname);
|
||||||
path = RSTRING(fname)->ptr;
|
path = RSTRING(fname)->ptr;
|
||||||
|
|
||||||
if (FIXNUM_P(vmode) || !NIL_P(perm)) {
|
if (FIXNUM_P(vmode) || !NIL_P(perm)) {
|
||||||
@ -2936,7 +2953,7 @@ rb_io_s_sysopen(argc, argv)
|
|||||||
int flags, fmode, fd;
|
int flags, fmode, fd;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
|
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
|
||||||
SafeStringValue(fname);
|
fname = rb_get_path(fname);
|
||||||
|
|
||||||
if (NIL_P(vmode)) flags = O_RDONLY;
|
if (NIL_P(vmode)) flags = O_RDONLY;
|
||||||
else if (FIXNUM_P(vmode)) flags = FIX2INT(vmode);
|
else if (FIXNUM_P(vmode)) flags = FIX2INT(vmode);
|
||||||
@ -3045,10 +3062,12 @@ rb_f_open(argc, argv)
|
|||||||
return rb_funcall2(argv[0], to_open, argc-1, argv+1);
|
return rb_funcall2(argv[0], to_open, argc-1, argv+1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char *str = StringValuePtr(argv[0]);
|
VALUE tmp = rb_check_string_type(argv[0]);
|
||||||
|
if (!NIL_P(tmp)) {
|
||||||
if (str[0] == '|') {
|
char *str = StringValuePtr(tmp);
|
||||||
return rb_io_popen(str+1, argc, argv, rb_cIO);
|
if (str && str[0] == '|') {
|
||||||
|
return rb_io_popen(str+1, argc, argv, rb_cIO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3067,20 +3086,6 @@ rb_io_open(fname, mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
|
||||||
rb_io_get_io(io)
|
|
||||||
VALUE io;
|
|
||||||
{
|
|
||||||
return rb_convert_type(io, T_FILE, "IO", "to_io");
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
|
||||||
rb_io_check_io(io)
|
|
||||||
VALUE io;
|
|
||||||
{
|
|
||||||
return rb_check_convert_type(io, T_FILE, "IO", "to_io");
|
|
||||||
}
|
|
||||||
|
|
||||||
static char*
|
static char*
|
||||||
rb_io_mode_string(fptr)
|
rb_io_mode_string(fptr)
|
||||||
OpenFile *fptr;
|
OpenFile *fptr;
|
||||||
@ -3210,13 +3215,13 @@ rb_io_reopen(argc, argv, file)
|
|||||||
|
|
||||||
rb_secure(4);
|
rb_secure(4);
|
||||||
if (rb_scan_args(argc, argv, "11", &fname, &nmode) == 1) {
|
if (rb_scan_args(argc, argv, "11", &fname, &nmode) == 1) {
|
||||||
if (TYPE(fname) != T_STRING) { /* fname must be IO */
|
VALUE tmp = rb_io_check_io(fname);
|
||||||
return io_reopen(file, fname);
|
if (!NIL_P(tmp)) {
|
||||||
|
return io_reopen(file, tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeStringValue(fname);
|
fname = rb_get_path(fname);
|
||||||
|
|
||||||
rb_io_taint_check(file);
|
rb_io_taint_check(file);
|
||||||
fptr = RFILE(file)->fptr;
|
fptr = RFILE(file)->fptr;
|
||||||
if (!fptr) {
|
if (!fptr) {
|
||||||
@ -4864,8 +4869,7 @@ rb_io_s_foreach(argc, argv)
|
|||||||
struct foreach_arg arg;
|
struct foreach_arg arg;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "11", &fname, &arg.sep);
|
rb_scan_args(argc, argv, "11", &fname, &arg.sep);
|
||||||
SafeStringValue(fname);
|
fname = rb_get_path(fname);
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
arg.sep = rb_default_rs;
|
arg.sep = rb_default_rs;
|
||||||
}
|
}
|
||||||
@ -4907,8 +4911,7 @@ rb_io_s_readlines(argc, argv, io)
|
|||||||
struct foreach_arg arg;
|
struct foreach_arg arg;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "11", &fname, &arg.sep);
|
rb_scan_args(argc, argv, "11", &fname, &arg.sep);
|
||||||
SafeStringValue(fname);
|
fname = rb_get_path(fname);
|
||||||
|
|
||||||
arg.argc = argc - 1;
|
arg.argc = argc - 1;
|
||||||
arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
|
arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
|
||||||
if (NIL_P(arg.io)) return Qnil;
|
if (NIL_P(arg.io)) return Qnil;
|
||||||
@ -4945,8 +4948,7 @@ rb_io_s_read(argc, argv, io)
|
|||||||
struct foreach_arg arg;
|
struct foreach_arg arg;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "12", &fname, &arg.sep, &offset);
|
rb_scan_args(argc, argv, "12", &fname, &arg.sep, &offset);
|
||||||
SafeStringValue(fname);
|
fname = rb_get_path(fname);
|
||||||
|
|
||||||
arg.argc = argc ? 1 : 0;
|
arg.argc = argc ? 1 : 0;
|
||||||
arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
|
arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
|
||||||
if (NIL_P(arg.io)) return Qnil;
|
if (NIL_P(arg.io)) return Qnil;
|
||||||
|
@ -717,7 +717,7 @@ module FileUtils
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fu_list(arg)
|
def fu_list(arg)
|
||||||
Array(arg).map {|path| path.to_str }
|
Array(arg).map {|path| File.path(path) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def fu_each_src_dest(src, dest)
|
def fu_each_src_dest(src, dest)
|
||||||
@ -730,13 +730,15 @@ module FileUtils
|
|||||||
def fu_each_src_dest0(src, dest)
|
def fu_each_src_dest0(src, dest)
|
||||||
if src.is_a?(Array)
|
if src.is_a?(Array)
|
||||||
src.each do |s|
|
src.each do |s|
|
||||||
yield s.to_str, File.join(dest, File.basename(s))
|
s = File.path(s)
|
||||||
|
yield s, File.join(dest, File.basename(s))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
src = File.path(src)
|
||||||
if File.directory?(dest)
|
if File.directory?(dest)
|
||||||
yield src.to_str, File.join(dest, File.basename(src))
|
yield src, File.join(dest, File.basename(src))
|
||||||
else
|
else
|
||||||
yield src.to_str, dest.to_str
|
yield src, File.path(dest)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -223,7 +223,7 @@ class Pathname
|
|||||||
end
|
end
|
||||||
|
|
||||||
# to_str is implemented so Pathname objects are usable with File.open, etc.
|
# to_str is implemented so Pathname objects are usable with File.open, etc.
|
||||||
alias to_str to_s
|
alias to_path to_s
|
||||||
|
|
||||||
def inspect # :nodoc:
|
def inspect # :nodoc:
|
||||||
"#<#{self.class}:#{@path}>"
|
"#<#{self.class}:#{@path}>"
|
||||||
|
4
pack.c
4
pack.c
@ -868,10 +868,10 @@ pack_pack(ary, fmt)
|
|||||||
from = NEXTFROM;
|
from = NEXTFROM;
|
||||||
from = rb_to_int(from);
|
from = rb_to_int(from);
|
||||||
l = num2i32(from);
|
l = num2i32(from);
|
||||||
le = uv_to_utf8(buf, l);
|
if (l < 0) {
|
||||||
if (TYPE(from) == T_BIGNUM) {
|
|
||||||
rb_raise(rb_eRangeError, "pack(U): value out of range");
|
rb_raise(rb_eRangeError, "pack(U): value out of range");
|
||||||
}
|
}
|
||||||
|
le = uv_to_utf8(buf, l);
|
||||||
rb_str_buf_cat(res, (char*)buf, le);
|
rb_str_buf_cat(res, (char*)buf, le);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
2
re.c
2
re.c
@ -1233,7 +1233,7 @@ match_values_at(argc, argv, match)
|
|||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE match;
|
VALUE match;
|
||||||
{
|
{
|
||||||
return rb_values_at(match, RMATCH(match)->regs->num_regs, argc, argv, match_entry);
|
return rb_get_values_at(match, RMATCH(match)->regs->num_regs, argc, argv, match_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
1
ruby.h
1
ruby.h
@ -567,6 +567,7 @@ RUBY_EXTERN VALUE rb_mProcess;
|
|||||||
|
|
||||||
RUBY_EXTERN VALUE rb_cObject;
|
RUBY_EXTERN VALUE rb_cObject;
|
||||||
RUBY_EXTERN VALUE rb_cArray;
|
RUBY_EXTERN VALUE rb_cArray;
|
||||||
|
RUBY_EXTERN VALUE rb_cValues;
|
||||||
RUBY_EXTERN VALUE rb_cBignum;
|
RUBY_EXTERN VALUE rb_cBignum;
|
||||||
RUBY_EXTERN VALUE rb_cClass;
|
RUBY_EXTERN VALUE rb_cClass;
|
||||||
RUBY_EXTERN VALUE rb_cDir;
|
RUBY_EXTERN VALUE rb_cDir;
|
||||||
|
2
rubyio.h
2
rubyio.h
@ -65,7 +65,7 @@ long rb_io_fwrite _((const char *, long, FILE *));
|
|||||||
int rb_io_mode_flags _((const char*));
|
int rb_io_mode_flags _((const char*));
|
||||||
void rb_io_check_writable _((OpenFile*));
|
void rb_io_check_writable _((OpenFile*));
|
||||||
void rb_io_check_readable _((OpenFile*));
|
void rb_io_check_readable _((OpenFile*));
|
||||||
void rb_io_fptr_finalize _((OpenFile*));
|
int rb_io_fptr_finalize _((OpenFile*));
|
||||||
void rb_io_synchronized _((OpenFile*));
|
void rb_io_synchronized _((OpenFile*));
|
||||||
void rb_io_check_closed _((OpenFile*));
|
void rb_io_check_closed _((OpenFile*));
|
||||||
int rb_io_wait_readable _((int));
|
int rb_io_wait_readable _((int));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user