mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* pack.c (pack_pack): use NUM2INT() instead of num2i32().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
66d0389895
commit
df84c64be9
10 changed files with 63 additions and 52 deletions
|
@ -1,3 +1,7 @@
|
|||
Wed Apr 7 15:29:24 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* pack.c (pack_pack): use NUM2INT() instead of num2i32().
|
||||
|
||||
Wed Apr 7 12:32:02 2004 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* lib/rss/parser.rb, lib/rss/1.0.rb: accepted rdf:resource or
|
||||
|
|
8
dir.c
8
dir.c
|
@ -379,7 +379,7 @@ dir_initialize(dir, dirname)
|
|||
{
|
||||
struct dir_data *dp;
|
||||
|
||||
dirname = rb_get_path(dirname);
|
||||
FilePathValue(dirname);
|
||||
Data_Get_Struct(dir, struct dir_data, dp);
|
||||
if (dp->dir) closedir(dp->dir);
|
||||
if (dp->path) free(dp->path);
|
||||
|
@ -744,7 +744,7 @@ dir_s_chdir(argc, argv, obj)
|
|||
|
||||
rb_secure(2);
|
||||
if (rb_scan_args(argc, argv, "01", &path) == 1) {
|
||||
path = rb_get_path(path);
|
||||
FilePathValue(path);
|
||||
dist = RSTRING(path)->ptr;
|
||||
}
|
||||
else {
|
||||
|
@ -807,7 +807,7 @@ check_dirname(dir)
|
|||
char *path, *pend;
|
||||
|
||||
rb_secure(2);
|
||||
*dir = rb_get_path(*dir);
|
||||
FilePathValue(*dir);
|
||||
path = RSTRING(*dir)->ptr;
|
||||
if (path && *(pend = rb_path_end(rb_path_skip_prefix(path)))) {
|
||||
*dir = rb_str_new(path, pend - path);
|
||||
|
@ -1439,7 +1439,7 @@ rb_push_glob(str, flags)
|
|||
else
|
||||
ary = rb_ary_new();
|
||||
|
||||
str = rb_get_path(str);
|
||||
FilePathValue(str);
|
||||
buf = xmalloc(RSTRING(str)->len + 1);
|
||||
|
||||
p = RSTRING(str)->ptr;
|
||||
|
|
21
eval.c
21
eval.c
|
@ -4778,19 +4778,20 @@ rb_yield_values(n, va_alist)
|
|||
va_dcl
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
va_list args;
|
||||
VALUE ary;
|
||||
VALUE val;
|
||||
|
||||
if (n == 0) {
|
||||
return rb_yield_0(Qundef, 0, 0, 0, Qfalse);
|
||||
}
|
||||
ary = rb_ary_new2(n);
|
||||
val = rb_values_new2(n, 0);
|
||||
va_init_list(args, n);
|
||||
while (n--) {
|
||||
rb_ary_push(ary, va_arg(args, VALUE));
|
||||
for (i=0; i<n; i++) {
|
||||
RARRAY(val)->ptr[i] = va_arg(args, VALUE);
|
||||
}
|
||||
va_end(args);
|
||||
return rb_yield_0(ary, 0, 0, 0, Qtrue);
|
||||
return rb_yield_0(val, 0, 0, 0, Qtrue);
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
@ -6385,12 +6386,8 @@ rb_load(fname, wrap)
|
|||
NODE *saved_cref = ruby_cref;
|
||||
TMP_PROTECT;
|
||||
|
||||
if (wrap && ruby_safe_level >= 4 && OBJ_TAINTED(fname)) {
|
||||
StringValue(fname);
|
||||
}
|
||||
else {
|
||||
fname = rb_get_path(fname);
|
||||
}
|
||||
if (!wrap) rb_secure(4);
|
||||
FilePathValue(fname);
|
||||
tmp = rb_find_file(fname);
|
||||
if (!tmp) {
|
||||
load_failed(fname);
|
||||
|
@ -6714,7 +6711,7 @@ rb_require_safe(fname, safe)
|
|||
} volatile saved;
|
||||
char *volatile ftptr = 0;
|
||||
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
saved.vmode = scope_vmode;
|
||||
saved.node = ruby_current_node;
|
||||
saved.func = ruby_frame->last_func;
|
||||
|
|
|
@ -361,12 +361,14 @@ struct zstream {
|
|||
#define ZSTREAM_FLAG_IN_STREAM 0x2
|
||||
#define ZSTREAM_FLAG_FINISHED 0x4
|
||||
#define ZSTREAM_FLAG_FINALIZE 0x8
|
||||
#define ZSTREAM_FLAG_UNUSED 0x10
|
||||
#define ZSTREAM_FLAG_CLOSED 0x10
|
||||
#define ZSTREAM_FLAG_UNUSED 0x20
|
||||
|
||||
#define ZSTREAM_READY(z) ((z)->flags |= ZSTREAM_FLAG_READY)
|
||||
#define ZSTREAM_IS_READY(z) ((z)->flags & ZSTREAM_FLAG_READY)
|
||||
#define ZSTREAM_IS_FINISHED(z) ((z)->flags & ZSTREAM_FLAG_FINISHED)
|
||||
#define ZSTREAM_IS_FINALIZE(z) ((z)->flags & ZSTREAM_FLAG_FINALIZE)
|
||||
#define ZSTREAM_IS_CLOSED(z) ((z)->flags & ZSTREAM_FLAG_CLOSED)
|
||||
|
||||
/* I think that more better value should be found,
|
||||
but I gave up finding it. B) */
|
||||
|
@ -1097,7 +1099,7 @@ static VALUE
|
|||
rb_deflate_s_allocate(klass)
|
||||
VALUE klass;
|
||||
{
|
||||
return zstream_deflate_new(klass);
|
||||
return zstream_deflate_new(klass);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2150,6 +2152,9 @@ gzfile_writer_end(gz)
|
|||
{
|
||||
int aborted;
|
||||
|
||||
if (ZSTREAM_IS_CLOSED(&gz->z)) return;
|
||||
gz->z.flags |= ZSTREAM_FLAG_CLOSED;
|
||||
|
||||
if (!(gz->z.flags & GZFILE_FLAG_HEADER_FINISHED)) {
|
||||
gzfile_make_header(gz);
|
||||
}
|
||||
|
@ -2160,7 +2165,7 @@ gzfile_writer_end(gz)
|
|||
if (ZSTREAM_IS_FINALIZE(&gz->z)) {
|
||||
if (NIL_P(gz->io)) return;
|
||||
rb_warn("Zlib::GzipWriter object must be closed explicitly.");
|
||||
if (OBJ_IS_FREED(gz->io)) {
|
||||
if (!SPECIAL_CONST_P(gz->io) && OBJ_IS_FREED(gz->io)) {
|
||||
aborted = 1;
|
||||
}
|
||||
else {
|
||||
|
@ -2180,6 +2185,9 @@ static void
|
|||
gzfile_reader_end(gz)
|
||||
struct gzfile *gz;
|
||||
{
|
||||
if (ZSTREAM_IS_CLOSED(&gz->z)) return;
|
||||
gz->z.flags |= ZSTREAM_FLAG_CLOSED;
|
||||
|
||||
if (GZFILE_IS_FINISHED(gz)
|
||||
&& !ZSTREAM_IS_FINALIZE(&gz->z)
|
||||
&& !(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
|
||||
|
|
48
file.c
48
file.c
|
@ -591,7 +591,7 @@ rb_stat(file, st)
|
|||
GetOpenFile(tmp, fptr);
|
||||
return fstat(fileno(fptr->f), st);
|
||||
}
|
||||
file = rb_get_path(file);
|
||||
FilePathValue(file);
|
||||
return stat(StringValueCStr(file), st);
|
||||
}
|
||||
|
||||
|
@ -613,7 +613,7 @@ rb_file_s_stat(klass, fname)
|
|||
struct stat st;
|
||||
|
||||
rb_secure(4);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (rb_stat(fname, &st) < 0) {
|
||||
rb_sys_fail(StringValueCStr(fname));
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ rb_file_s_lstat(klass, fname)
|
|||
struct stat st;
|
||||
|
||||
rb_secure(2);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (lstat(StringValueCStr(fname), &st) == -1) {
|
||||
rb_sys_fail(RSTRING(fname)->ptr);
|
||||
}
|
||||
|
@ -880,7 +880,7 @@ test_l(obj, fname)
|
|||
struct stat st;
|
||||
|
||||
rb_secure(2);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (lstat(StringValueCStr(fname), &st) < 0) return Qfalse;
|
||||
if (S_ISLNK(st.st_mode)) return Qtrue;
|
||||
#endif
|
||||
|
@ -1006,7 +1006,7 @@ test_r(obj, fname)
|
|||
VALUE obj, fname;
|
||||
{
|
||||
rb_secure(2);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (eaccess(StringValueCStr(fname), R_OK) < 0) return Qfalse;
|
||||
return Qtrue;
|
||||
}
|
||||
|
@ -1024,7 +1024,7 @@ test_R(obj, fname)
|
|||
VALUE obj, fname;
|
||||
{
|
||||
rb_secure(2);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (access(StringValueCStr(fname), R_OK) < 0) return Qfalse;
|
||||
return Qtrue;
|
||||
}
|
||||
|
@ -1079,7 +1079,7 @@ test_w(obj, fname)
|
|||
VALUE obj, fname;
|
||||
{
|
||||
rb_secure(2);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (eaccess(StringValueCStr(fname), W_OK) < 0) return Qfalse;
|
||||
return Qtrue;
|
||||
}
|
||||
|
@ -1097,7 +1097,7 @@ test_W(obj, fname)
|
|||
VALUE obj, fname;
|
||||
{
|
||||
rb_secure(2);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (access(StringValueCStr(fname), W_OK) < 0) return Qfalse;
|
||||
return Qtrue;
|
||||
}
|
||||
|
@ -1144,7 +1144,7 @@ test_x(obj, fname)
|
|||
VALUE obj, fname;
|
||||
{
|
||||
rb_secure(2);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (eaccess(StringValueCStr(fname), X_OK) < 0) return Qfalse;
|
||||
return Qtrue;
|
||||
}
|
||||
|
@ -1162,7 +1162,7 @@ test_X(obj, fname)
|
|||
VALUE obj, fname;
|
||||
{
|
||||
rb_secure(2);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (access(StringValueCStr(fname), X_OK) < 0) return Qfalse;
|
||||
return Qtrue;
|
||||
}
|
||||
|
@ -1290,7 +1290,7 @@ check3rdbyte(fname, mode)
|
|||
struct stat st;
|
||||
|
||||
rb_secure(2);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (stat(StringValueCStr(fname), &st) < 0) return Qfalse;
|
||||
if (st.st_mode & mode) return Qtrue;
|
||||
return Qfalse;
|
||||
|
@ -1433,7 +1433,7 @@ rb_file_s_ftype(klass, fname)
|
|||
struct stat st;
|
||||
|
||||
rb_secure(2);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (lstat(StringValueCStr(fname), &st) == -1) {
|
||||
rb_sys_fail(RSTRING(fname)->ptr);
|
||||
}
|
||||
|
@ -1967,8 +1967,8 @@ rb_file_s_link(klass, from, to)
|
|||
{
|
||||
#ifdef HAVE_LINK
|
||||
rb_secure(2);
|
||||
from = rb_get_path(from);
|
||||
to = rb_get_path(to);
|
||||
FilePathValue(from);
|
||||
FilePathValue(to);
|
||||
|
||||
if (link(StringValueCStr(from), StringValueCStr(to)) < 0) {
|
||||
sys_fail2(from, to);
|
||||
|
@ -1998,8 +1998,8 @@ rb_file_s_symlink(klass, from, to)
|
|||
{
|
||||
#ifdef HAVE_SYMLINK
|
||||
rb_secure(2);
|
||||
from = rb_get_path(from);
|
||||
to = rb_get_path(to);
|
||||
FilePathValue(from);
|
||||
FilePathValue(to);
|
||||
|
||||
if (symlink(StringValueCStr(from), StringValueCStr(to)) < 0) {
|
||||
sys_fail2(from, to);
|
||||
|
@ -2033,7 +2033,7 @@ rb_file_s_readlink(klass, path)
|
|||
VALUE v;
|
||||
|
||||
rb_secure(2);
|
||||
path = rb_get_path(path);
|
||||
FilePathValue(path);
|
||||
buf = xmalloc(size);
|
||||
while ((rv = readlink(StringValueCStr(path), buf, size)) == size) {
|
||||
size *= 2;
|
||||
|
@ -2099,9 +2099,9 @@ rb_file_s_rename(klass, from, to)
|
|||
const char *src, *dst;
|
||||
|
||||
rb_secure(2);
|
||||
from = rb_get_path(from);
|
||||
FilePathValue(from);
|
||||
FilePathValue(to);
|
||||
src = StringValueCStr(from);
|
||||
to = rb_get_path(to);
|
||||
dst = StringValueCStr(to);
|
||||
if (rename(src, dst) < 0) {
|
||||
#if defined __CYGWIN__
|
||||
|
@ -2868,7 +2868,7 @@ rb_file_s_truncate(klass, path, len)
|
|||
VALUE klass, path, len;
|
||||
{
|
||||
rb_secure(2);
|
||||
path = rb_get_path(path);
|
||||
FilePathValue(path);
|
||||
|
||||
#ifdef HAVE_TRUNCATE
|
||||
if (truncate(StringValueCStr(path), NUM2OFFT(len)) < 0)
|
||||
|
@ -3060,7 +3060,7 @@ test_check(n, argc, argv)
|
|||
switch (TYPE(argv[i])) {
|
||||
case T_STRING:
|
||||
default:
|
||||
argv[i] = rb_get_path(argv[i]);
|
||||
FilePathValue(argv[i]);
|
||||
break;
|
||||
case T_FILE:
|
||||
break;
|
||||
|
@ -3305,7 +3305,7 @@ rb_stat_init(obj, fname)
|
|||
struct stat st, *nst;
|
||||
|
||||
rb_secure(2);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (stat(StringValueCStr(fname), &st) == -1) {
|
||||
rb_sys_fail(RSTRING(fname)->ptr);
|
||||
}
|
||||
|
@ -4074,7 +4074,7 @@ rb_find_file_ext(filep, ext)
|
|||
for (i=0;i<RARRAY(rb_load_path)->len;i++) {
|
||||
VALUE str = RARRAY(rb_load_path)->ptr[i];
|
||||
|
||||
str = rb_get_path(str);
|
||||
FilePathValue(str);
|
||||
if (RSTRING(str)->len == 0) continue;
|
||||
path = RSTRING(str)->ptr;
|
||||
for (j=0; ext[j]; j++) {
|
||||
|
@ -4133,7 +4133,7 @@ rb_find_file(path)
|
|||
tmp = rb_ary_new();
|
||||
for (i=0;i<RARRAY(rb_load_path)->len;i++) {
|
||||
VALUE str = RARRAY(rb_load_path)->ptr[i];
|
||||
str = rb_get_path(str);
|
||||
FilePathValue(str);
|
||||
if (RSTRING(str)->len > 0) {
|
||||
rb_ary_push(tmp, str);
|
||||
}
|
||||
|
|
2
gc.c
2
gc.c
|
@ -1786,7 +1786,7 @@ rb_gc_call_finalizer_at_exit()
|
|||
}
|
||||
}
|
||||
/* run data object's finalizers */
|
||||
for (i = heaps_used-1; 0 <= i; i--) {
|
||||
for (i = 0; i < heaps_used; i++) {
|
||||
p = heaps[i].slot; pend = p + heaps[i].limit;
|
||||
while (p < pend) {
|
||||
if (BUILTIN_TYPE(p) == T_DATA &&
|
||||
|
|
1
intern.h
1
intern.h
|
@ -224,7 +224,6 @@ VALUE rb_thread_local_aset _((VALUE, ID, VALUE));
|
|||
void rb_thread_atfork _((void));
|
||||
/* file.c */
|
||||
int eaccess _((const char*, int));
|
||||
VALUE rb_get_path _((VALUE));
|
||||
VALUE rb_file_s_expand_path _((int, VALUE *));
|
||||
void rb_file_const _((const char*, VALUE));
|
||||
int rb_find_file_ext _((VALUE*, const char* const*));
|
||||
|
|
12
io.c
12
io.c
|
@ -2883,7 +2883,7 @@ rb_open_file(argc, argv, io)
|
|||
int flags, fmode;
|
||||
|
||||
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
path = RSTRING(fname)->ptr;
|
||||
|
||||
if (FIXNUM_P(vmode) || !NIL_P(perm)) {
|
||||
|
@ -2953,7 +2953,7 @@ rb_io_s_sysopen(argc, argv)
|
|||
int flags, fmode, fd;
|
||||
|
||||
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
|
||||
if (NIL_P(vmode)) flags = O_RDONLY;
|
||||
else if (FIXNUM_P(vmode)) flags = FIX2INT(vmode);
|
||||
|
@ -3221,7 +3221,7 @@ rb_io_reopen(argc, argv, file)
|
|||
}
|
||||
}
|
||||
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
rb_io_taint_check(file);
|
||||
fptr = RFILE(file)->fptr;
|
||||
if (!fptr) {
|
||||
|
@ -4869,7 +4869,7 @@ rb_io_s_foreach(argc, argv)
|
|||
struct foreach_arg arg;
|
||||
|
||||
rb_scan_args(argc, argv, "11", &fname, &arg.sep);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
if (argc == 1) {
|
||||
arg.sep = rb_default_rs;
|
||||
}
|
||||
|
@ -4911,7 +4911,7 @@ rb_io_s_readlines(argc, argv, io)
|
|||
struct foreach_arg arg;
|
||||
|
||||
rb_scan_args(argc, argv, "11", &fname, &arg.sep);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
arg.argc = argc - 1;
|
||||
arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
|
||||
if (NIL_P(arg.io)) return Qnil;
|
||||
|
@ -4948,7 +4948,7 @@ rb_io_s_read(argc, argv, io)
|
|||
struct foreach_arg arg;
|
||||
|
||||
rb_scan_args(argc, argv, "12", &fname, &arg.sep, &offset);
|
||||
fname = rb_get_path(fname);
|
||||
FilePathValue(fname);
|
||||
arg.argc = argc ? 1 : 0;
|
||||
arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
|
||||
if (NIL_P(arg.io)) return Qnil;
|
||||
|
|
2
pack.c
2
pack.c
|
@ -867,7 +867,7 @@ pack_pack(ary, fmt)
|
|||
|
||||
from = NEXTFROM;
|
||||
from = rb_to_int(from);
|
||||
l = num2i32(from);
|
||||
l = NUM2INT(from);
|
||||
if (l < 0) {
|
||||
rb_raise(rb_eRangeError, "pack(U): value out of range");
|
||||
}
|
||||
|
|
3
ruby.h
3
ruby.h
|
@ -232,6 +232,9 @@ void rb_check_safe_str _((VALUE));
|
|||
/* obsolete macro - use SafeStringValue(v) */
|
||||
#define Check_SafeStr(v) rb_check_safe_str((VALUE)(v))
|
||||
|
||||
VALUE rb_get_path _((VALUE));
|
||||
#define FilePathValue(v) ((v) = rb_get_path(v))
|
||||
|
||||
void rb_secure _((int));
|
||||
RUBY_EXTERN int ruby_safe_level;
|
||||
#define rb_safe_level() (ruby_safe_level)
|
||||
|
|
Loading…
Add table
Reference in a new issue