Skip to content

Commit

Permalink
* array.c (rb_ary_delete): element comparison might change array
Browse files Browse the repository at this point in the history
  size. [ruby-dev:24273]

* parse.y: make ruby parser reentrant. merge ripper parser to the
  real one.  this change makes ruby require bison.

* file.c (rb_file_truncate): clear stdio buffer before truncating
  the file.  [ruby-dev:24191]

* ext/digest/digest.c: use rb_obj_class() instead of CLASS_OF
  which might return singleton class.  [ruby-dev:24202]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Sep 17, 2004
1 parent 7b66963 commit e77ddaf
Show file tree
Hide file tree
Showing 12 changed files with 569 additions and 587 deletions.
25 changes: 25 additions & 0 deletions ChangeLog
@@ -1,3 +1,17 @@
Fri Sep 17 17:11:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org>

* array.c (rb_ary_delete): element comparison might change array
size. [ruby-dev:24273]

* parse.y: make ruby parser reentrant. merge ripper parser to the
real one. this change makes ruby require bison.

* file.c (rb_file_truncate): clear stdio buffer before truncating
the file. [ruby-dev:24191]

* ext/digest/digest.c: use rb_obj_class() instead of CLASS_OF
which might return singleton class. [ruby-dev:24202]

Fri Sep 17 16:07:09 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>

* ext/tk/lib/multi-tk.rb: improve exit operation
Expand Down Expand Up @@ -28,6 +42,11 @@ Thu Sep 16 18:12:13 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
(WEBrick::HTTPServlet::FileHandler#initialize): should expand
the pathname of document root directory.

Thu Sep 16 15:49:28 2004 Yukihiro Matsumoto <matz@ruby-lang.org>

* string.c (rb_str_intern): protect string argument from GC.
[ruby-core:03411]

Wed Sep 15 20:22:23 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>

* ext/tk/sample/tkoptdb-safeTk.rb: fix a bug depend on the changes
Expand Down Expand Up @@ -321,6 +340,12 @@ Tue Sep 7 12:48:22 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/socket/socket.c (wait_connectable, ruby_connect): support
nonblocking connect on various platforms.

Mon Sep 6 11:00:47 2004 Yukihiro Matsumoto <matz@ruby-lang.org>

* dir.c (dir_s_chdir): the patch to shut up false warning when
exception occurred within a block. a patch was given from Johan
Holmberg <holmberg@iar.se>. [ruby-core:03292]

Mon Sep 6 10:57:40 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>

* ext/tk/lib/tk/menu.rb(TkOptionMenubutton#insert): call correct method
Expand Down
39 changes: 18 additions & 21 deletions array.c
Expand Up @@ -1923,7 +1923,8 @@ rb_ary_delete(ary, item)
return Qnil;
}

RARRAY(ary)->len = i2;
if (RARRAY(ary)->len > i2)
RARRAY(ary)->len = i2;
if (i2 * 2 < RARRAY(ary)->aux.capa &&
RARRAY(ary)->aux.capa > ARY_DEFAULT_SIZE) {
REALLOC_N(RARRAY(ary)->ptr, VALUE, i2 * 2);
Expand Down Expand Up @@ -2467,17 +2468,15 @@ VALUE
rb_ary_assoc(ary, key)
VALUE ary, key;
{
VALUE *p, *pend;
long i;
VALUE v;

p = RARRAY(ary)->ptr;
pend = p + RARRAY(ary)->len;

while (p < pend) {
if (TYPE(*p) == T_ARRAY &&
RARRAY(*p)->len > 0 &&
rb_equal(RARRAY(*p)->ptr[0], key))
return *p;
p++;
for (i = 0; i < RARRAY(ary)->len; ++i) {
v = RARRAY(ary)->ptr[i];
if (TYPE(v) == T_ARRAY &&
RARRAY(v)->len > 0 &&
rb_equal(RARRAY(v)->ptr[0], key))
return v;
}
return Qnil;
}
Expand All @@ -2500,17 +2499,15 @@ VALUE
rb_ary_rassoc(ary, value)
VALUE ary, value;
{
VALUE *p, *pend;

p = RARRAY(ary)->ptr;
pend = p + RARRAY(ary)->len;
long i;
VALUE v;

while (p < pend) {
if (TYPE(*p) == T_ARRAY
&& RARRAY(*p)->len > 1
&& rb_equal(RARRAY(*p)->ptr[1], value))
return *p;
p++;
for (i = 0; i < RARRAY(ary)->len; ++i) {
v = RARRAY(ary)->ptr[i];
if (TYPE(v) == T_ARRAY &&
RARRAY(v)->len > 1 &&
rb_equal(RARRAY(v)->ptr[1], value))
return v;
}
return Qnil;
}
Expand Down
22 changes: 18 additions & 4 deletions dir.c
@@ -1,4 +1,3 @@

/**********************************************************************
dir.c -
Expand Down Expand Up @@ -687,6 +686,19 @@ dir_chdir(path)
static int chdir_blocking = 0;
static VALUE chdir_thread = Qnil;

struct chdir_data {
char *dist;
VALUE path;
};

static VALUE
chdir_yield(args)
struct chdir_data *args;
{
dir_chdir(args->dist);
return rb_yield(args->path);
}

static VALUE
chdir_restore(path)
char *path;
Expand All @@ -695,7 +707,6 @@ chdir_restore(path)
if (chdir_blocking == 0)
chdir_thread = Qnil;
dir_chdir(path);
free(path);
return Qnil;
}

Expand Down Expand Up @@ -767,11 +778,14 @@ dir_s_chdir(argc, argv, obj)

if (rb_block_given_p()) {
char *cwd = my_getcwd();
struct chdir_data args;

chdir_blocking++;
if (chdir_thread == Qnil)
chdir_thread = rb_thread_current();
dir_chdir(dist);
return rb_ensure(rb_yield, path, chdir_restore, (VALUE)cwd);
args.dist = dist;
args.path = path;
return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)cwd);
}
dir_chdir(dist);

Expand Down
14 changes: 7 additions & 7 deletions ext/digest/digest.c
Expand Up @@ -149,8 +149,8 @@ rb_digest_base_copy(copy, obj)

if (copy == obj) return copy;
rb_check_frozen(copy);
algo = get_digest_base_metadata(CLASS_OF(copy));
if (algo != get_digest_base_metadata(CLASS_OF(obj))) {
algo = get_digest_base_metadata(rb_obj_class(copy));
if (algo != get_digest_base_metadata(rb_obj_class(obj))) {
rb_raise(rb_eTypeError, "wrong argument class");
}
Data_Get_Struct(obj, void, pctx1);
Expand All @@ -168,7 +168,7 @@ rb_digest_base_update(self, str)
void *pctx;

StringValue(str);
algo = get_digest_base_metadata(CLASS_OF(self));
algo = get_digest_base_metadata(rb_obj_class(self));
Data_Get_Struct(self, void, pctx);

algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
Expand Down Expand Up @@ -201,7 +201,7 @@ rb_digest_base_digest(self)
size_t len;
VALUE str;

algo = get_digest_base_metadata(CLASS_OF(self));
algo = get_digest_base_metadata(rb_obj_class(self));
Data_Get_Struct(self, void, pctx1);

len = algo->ctx_size;
Expand Down Expand Up @@ -232,7 +232,7 @@ rb_digest_base_hexdigest(self)
size_t len;
VALUE str;

algo = get_digest_base_metadata(CLASS_OF(self));
algo = get_digest_base_metadata(rb_obj_class(self));
Data_Get_Struct(self, void, pctx1);

len = algo->ctx_size;
Expand Down Expand Up @@ -261,10 +261,10 @@ rb_digest_base_equal(self, other)
VALUE klass;
VALUE str1, str2;

klass = CLASS_OF(self);
klass = rb_obj_class(self);
algo = get_digest_base_metadata(klass);

if (CLASS_OF(other) == klass) {
if (rb_obj_class(other) == klass) {
void *pctx1, *pctx2;

Data_Get_Struct(self, void, pctx1);
Expand Down
5 changes: 1 addition & 4 deletions ext/digest/sha1/sha1init.c
Expand Up @@ -22,7 +22,6 @@ void
Init_sha1()
{
VALUE mDigest, cDigest_Base, cDigest_SHA1;
ID id_metadata;

rb_require("digest.so");

Expand All @@ -31,8 +30,6 @@ Init_sha1()

cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);

id_metadata = rb_intern("metadata");

rb_cvar_set(cDigest_SHA1, id_metadata,
rb_cvar_set(cDigest_SHA1, rb_intern("metadata"),
Data_Wrap_Struct(rb_cObject, 0, 0, &sha1), Qtrue);
}
7 changes: 5 additions & 2 deletions file.c
Expand Up @@ -2965,18 +2965,21 @@ rb_file_truncate(obj, len)
VALUE obj, len;
{
OpenFile *fptr;
FILE *f;

rb_secure(2);
GetOpenFile(obj, fptr);
if (!(fptr->mode & FMODE_WRITABLE)) {
rb_raise(rb_eIOError, "not opened for writing");
}
f = GetWriteFile(fptr);
fflush(f);
#ifdef HAVE_TRUNCATE
if (ftruncate(fileno(fptr->f), NUM2OFFT(len)) < 0)
if (ftruncate(fileno(f), NUM2OFFT(len)) < 0)
rb_sys_fail(fptr->path);
#else
# ifdef HAVE_CHSIZE
if (chsize(fileno(fptr->f), NUM2OFFT(len)) < 0)
if (chsize(fileno(f), NUM2OFFT(len)) < 0)
rb_sys_fail(fptr->path);
# else
rb_notimplement();
Expand Down
1 change: 0 additions & 1 deletion intern.h
Expand Up @@ -325,7 +325,6 @@ double rb_str_to_dbl _((VALUE, int));
/* parse.y */
RUBY_EXTERN int ruby_sourceline;
RUBY_EXTERN char *ruby_sourcefile;
int ruby_yyparse _((void));
ID rb_id_attrset _((ID));
void rb_parser_append_print _((void));
void rb_parser_while_loop _((int, int));
Expand Down
37 changes: 37 additions & 0 deletions lib/cgi/session.rb
Expand Up @@ -458,5 +458,42 @@ def delete
GLOBAL_HASH_TABLE.delete(@session_id)
end
end

# Dummy session storage class.
#
# Implements session storage place holder. No actual storage
# will be done.
class NullStore
# Create a new NullStore instance.
#
# +session+ is the session this instance is associated with.
# +option+ is a list of initialisation options. None are
# currently recognised.
def initialize(session, option=nil)
end

# Restore (empty) session state.
def restore
{}
end

# Update session state.
#
# A no-op.
def update
end

# Close session storage.
#
# A no-op.
def close
end

# Delete the session state.
#
# A no-op.
def delete
end
end
end
end
4 changes: 2 additions & 2 deletions lib/mkmf.rb
Expand Up @@ -475,15 +475,15 @@ def checking_for(m)
r
end

def have_library(lib, func = nil, &b)
def have_library(lib, func = nil, header=nil, &b)
func = "main" if !func or func.empty?
lib = with_config(lib+'lib', lib)
checking_for "#{func}() in #{LIBARG%lib}" do
if COMMON_LIBS.include?(lib)
true
else
libs = append_library($libs, lib)
if try_func(func, libs, &b)
if try_func(func, libs, header, &b)
$libs = libs
true
else
Expand Down

0 comments on commit e77ddaf

Please sign in to comment.