Skip to content

Commit

Permalink
* pack.c (pack_pack): use NUM2INT() instead of num2i32().
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Apr 7, 2004
1 parent 66d0389 commit df84c64
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 52 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Wed Apr 7 15:29:24 2004 Yukihiro Matsumoto <[email protected]>

* pack.c (pack_pack): use NUM2INT() instead of num2i32().

Wed Apr 7 12:32:02 2004 Kouhei Sutou <[email protected]>

* lib/rss/parser.rb, lib/rss/1.0.rb: accepted rdf:resource or
Expand Down
8 changes: 4 additions & 4 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
21 changes: 9 additions & 12 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 11 additions & 3 deletions ext/zlib/zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down Expand Up @@ -1097,7 +1099,7 @@ static VALUE
rb_deflate_s_allocate(klass)
VALUE klass;
{
return zstream_deflate_new(klass);
return zstream_deflate_new(klass);
}

/*
Expand Down Expand Up @@ -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);
}
Expand All @@ -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 {
Expand All @@ -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)) {
Expand Down
48 changes: 24 additions & 24 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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));
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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__
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
1 change: 0 additions & 1 deletion intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*));
Expand Down
Loading

0 comments on commit df84c64

Please sign in to comment.