mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* node.h (NODE_TYPESHIFT): allow 4 more bits for line numbers.
[ruby-talk:117841] * ruby.h (FL_ABLE): nodes are not subject for flag operations. * io.c (ARGF_FORWARD): should have specified argv explicitly, since we no longer have frame->argv saved. [ruby-dev:24602] * string.c (RESIZE_CAPA): check string attribute before modifying capacity member of string structure. [ruby-dev:24594] * ext/zlib/zlib.c (gzreader_gets): use memchr() to to gain performance. [ruby-talk:117701] * sprintf.c (rb_f_sprintf): raise ArgumentError for extra arguments, unless (digit)$ style used. * io.c (rb_io_fptr_finalize): leave stdin/stdout/stderr open in interpreter termination. [ruby-dev:24579] * eval.c (frame_free): Guy Decoux solved the leak problem. Thanks. [ruby-core:03549] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6ffdbac5ed
commit
018837b84f
18 changed files with 149 additions and 80 deletions
35
ChangeLog
35
ChangeLog
|
@ -3,11 +3,36 @@ Wed Oct 27 09:17:30 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
* string.c (str_gsub): use a string object for exception safeness.
|
* string.c (str_gsub): use a string object for exception safeness.
|
||||||
[ruby-dev:24601]
|
[ruby-dev:24601]
|
||||||
|
|
||||||
|
Wed Oct 27 07:38:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* node.h (NODE_TYPESHIFT): allow 4 more bits for line numbers.
|
||||||
|
[ruby-talk:117841]
|
||||||
|
|
||||||
|
* ruby.h (FL_ABLE): nodes are not subject for flag operations.
|
||||||
|
|
||||||
|
* io.c (ARGF_FORWARD): should have specified argv explicitly,
|
||||||
|
since we no longer have frame->argv saved. [ruby-dev:24602]
|
||||||
|
|
||||||
Tue Oct 26 23:30:39 2004 Dave Thomas <dave@pragprog.com>
|
Tue Oct 26 23:30:39 2004 Dave Thomas <dave@pragprog.com>
|
||||||
|
|
||||||
* lib/rdoc/code_objects.rb (RDoc::Context::add_class_or_module):
|
* lib/rdoc/code_objects.rb (RDoc::Context::add_class_or_module):
|
||||||
Restore correct :nopdoc: behavior with nested classes and modules.
|
Restore correct :nopdoc: behavior with nested classes and modules.
|
||||||
|
|
||||||
|
Tue Oct 26 18:21:29 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (RESIZE_CAPA): check string attribute before modifying
|
||||||
|
capacity member of string structure. [ruby-dev:24594]
|
||||||
|
|
||||||
|
Tue Oct 26 11:33:26 2004 David G. Andersen <dga@lcs.mit.edu>
|
||||||
|
|
||||||
|
* ext/zlib/zlib.c (gzreader_gets): use memchr() to to gain
|
||||||
|
performance. [ruby-talk:117701]
|
||||||
|
|
||||||
|
Tue Oct 26 10:56:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* sprintf.c (rb_f_sprintf): raise ArgumentError for extra
|
||||||
|
arguments, unless (digit)$ style used.
|
||||||
|
|
||||||
Mon Oct 25 18:35:39 2004 WATANABE Hirofumi <eban@ruby-lang.org>
|
Mon Oct 25 18:35:39 2004 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* win32/win32.c (isUNCRoot): should check NUL after '.'.
|
* win32/win32.c (isUNCRoot): should check NUL after '.'.
|
||||||
|
@ -24,6 +49,16 @@ Sun Oct 24 00:40:50 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
* eval.c (rb_load, search_required, rb_require_safe, rb_require): use
|
* eval.c (rb_load, search_required, rb_require_safe, rb_require): use
|
||||||
frozen shared string to avoid outside modification. [ruby-dev:24580]
|
frozen shared string to avoid outside modification. [ruby-dev:24580]
|
||||||
|
|
||||||
|
Sat Oct 23 23:40:34 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (rb_io_fptr_finalize): leave stdin/stdout/stderr open in
|
||||||
|
interpreter termination. [ruby-dev:24579]
|
||||||
|
|
||||||
|
Sat Oct 23 22:18:32 2004 Guy Decoux <ts@moulon.inra.fr>
|
||||||
|
|
||||||
|
* eval.c (frame_free): Guy Decoux solved the leak problem.
|
||||||
|
Thanks. [ruby-core:03549]
|
||||||
|
|
||||||
Sat Oct 23 00:20:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Sat Oct 23 00:20:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* ext/zlib/zlib.c (zstream_append_input): clear klass for z->input
|
* ext/zlib/zlib.c (zstream_append_input): clear klass for z->input
|
||||||
|
|
15
array.c
15
array.c
|
@ -816,9 +816,6 @@ rb_ary_aref(argc, argv, ary)
|
||||||
long beg, len;
|
long beg, len;
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
if (SYMBOL_P(argv[0])) {
|
|
||||||
rb_raise(rb_eTypeError, "Symbol as array index");
|
|
||||||
}
|
|
||||||
beg = NUM2LONG(argv[0]);
|
beg = NUM2LONG(argv[0]);
|
||||||
len = NUM2LONG(argv[1]);
|
len = NUM2LONG(argv[1]);
|
||||||
if (beg < 0) {
|
if (beg < 0) {
|
||||||
|
@ -834,9 +831,6 @@ rb_ary_aref(argc, argv, ary)
|
||||||
if (FIXNUM_P(arg)) {
|
if (FIXNUM_P(arg)) {
|
||||||
return rb_ary_entry(ary, FIX2LONG(arg));
|
return rb_ary_entry(ary, FIX2LONG(arg));
|
||||||
}
|
}
|
||||||
if (SYMBOL_P(arg)) {
|
|
||||||
rb_raise(rb_eTypeError, "Symbol as array index");
|
|
||||||
}
|
|
||||||
/* check if idx is Range */
|
/* check if idx is Range */
|
||||||
switch (rb_range_beg_len(arg, &beg, &len, RARRAY(ary)->len, 0)) {
|
switch (rb_range_beg_len(arg, &beg, &len, RARRAY(ary)->len, 0)) {
|
||||||
case Qfalse:
|
case Qfalse:
|
||||||
|
@ -1178,12 +1172,6 @@ rb_ary_aset(argc, argv, ary)
|
||||||
long offset, beg, len;
|
long offset, beg, len;
|
||||||
|
|
||||||
if (argc == 3) {
|
if (argc == 3) {
|
||||||
if (SYMBOL_P(argv[0])) {
|
|
||||||
rb_raise(rb_eTypeError, "Symbol as array index");
|
|
||||||
}
|
|
||||||
if (SYMBOL_P(argv[1])) {
|
|
||||||
rb_raise(rb_eTypeError, "Symbol as subarray length");
|
|
||||||
}
|
|
||||||
rb_ary_update(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
|
rb_ary_update(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
|
||||||
return argv[2];
|
return argv[2];
|
||||||
}
|
}
|
||||||
|
@ -1194,9 +1182,6 @@ rb_ary_aset(argc, argv, ary)
|
||||||
offset = FIX2LONG(argv[0]);
|
offset = FIX2LONG(argv[0]);
|
||||||
goto fixnum;
|
goto fixnum;
|
||||||
}
|
}
|
||||||
if (SYMBOL_P(argv[0])) {
|
|
||||||
rb_raise(rb_eTypeError, "Symbol as array index");
|
|
||||||
}
|
|
||||||
if (rb_range_beg_len(argv[0], &beg, &len, RARRAY(ary)->len, 1)) {
|
if (rb_range_beg_len(argv[0], &beg, &len, RARRAY(ary)->len, 1)) {
|
||||||
/* check if idx is Range */
|
/* check if idx is Range */
|
||||||
rb_ary_update(ary, beg, len, argv[1]);
|
rb_ary_update(ary, beg, len, argv[1]);
|
||||||
|
|
|
@ -348,7 +348,7 @@ freebsd*) LIBS="-lm $LIBS"
|
||||||
rb_cv_supplementary_lib_c_r=no,
|
rb_cv_supplementary_lib_c_r=no,
|
||||||
rb_cv_supplementary_lib_c_r=yes,
|
rb_cv_supplementary_lib_c_r=yes,
|
||||||
rb_cv_supplementary_lib_c_r=yes)])
|
rb_cv_supplementary_lib_c_r=yes)])
|
||||||
if test ; then
|
if test "$rb_cv_supplementary_lib_c_r" = yes; then
|
||||||
MAINLIBS="-lc_r $MAINLIBS"
|
MAINLIBS="-lc_r $MAINLIBS"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
18
eval.c
18
eval.c
|
@ -7737,19 +7737,27 @@ blk_mark(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
blk_free(data)
|
frame_free(frame)
|
||||||
struct BLOCK *data;
|
|
||||||
{
|
|
||||||
struct FRAME *frame;
|
struct FRAME *frame;
|
||||||
void *tmp;
|
{
|
||||||
|
struct FRAME *tmp;
|
||||||
|
|
||||||
frame = data->frame.prev;
|
frame = frame->prev;
|
||||||
while (frame) {
|
while (frame) {
|
||||||
tmp = frame;
|
tmp = frame;
|
||||||
frame = frame->prev;
|
frame = frame->prev;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
blk_free(data)
|
||||||
|
struct BLOCK *data;
|
||||||
|
{
|
||||||
|
void *tmp;
|
||||||
|
|
||||||
while (data) {
|
while (data) {
|
||||||
|
frame_free(&data->frame);
|
||||||
tmp = data;
|
tmp = data;
|
||||||
data = data->prev;
|
data = data->prev;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
|
@ -544,7 +544,6 @@ ossl_ssl_write(VALUE self, VALUE str)
|
||||||
{
|
{
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
int nwrite = 0;
|
int nwrite = 0;
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
Data_Get_Struct(self, SSL, ssl);
|
Data_Get_Struct(self, SSL, ssl);
|
||||||
StringValue(str);
|
StringValue(str);
|
||||||
|
|
|
@ -701,7 +701,7 @@ zstream_run(z, src, len, flush)
|
||||||
uInt n;
|
uInt n;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (len == 0) {
|
if (NIL_P(z->input) && len == 0) {
|
||||||
z->stream.next_in = "";
|
z->stream.next_in = "";
|
||||||
z->stream.avail_in = 0;
|
z->stream.avail_in = 0;
|
||||||
}
|
}
|
||||||
|
@ -3137,6 +3137,16 @@ gzreader_skip_linebreaks(gz)
|
||||||
gzfile_calc_crc(gz, str);
|
gzfile_calc_crc(gz, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rscheck(rsptr, rslen, rs)
|
||||||
|
char *rsptr;
|
||||||
|
long rslen;
|
||||||
|
VALUE rs;
|
||||||
|
{
|
||||||
|
if (RSTRING(rs)->ptr != rsptr && RSTRING(rs)->len != rslen)
|
||||||
|
rb_raise(rb_eRuntimeError, "rs modified");
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
gzreader_gets(argc, argv, obj)
|
gzreader_gets(argc, argv, obj)
|
||||||
int argc;
|
int argc;
|
||||||
|
@ -3144,8 +3154,9 @@ gzreader_gets(argc, argv, obj)
|
||||||
VALUE obj;
|
VALUE obj;
|
||||||
{
|
{
|
||||||
struct gzfile *gz = get_gzfile(obj);
|
struct gzfile *gz = get_gzfile(obj);
|
||||||
VALUE rs, dst;
|
volatile VALUE rs;
|
||||||
char *rsptr, *p;
|
VALUE dst;
|
||||||
|
char *rsptr, *p, *res;
|
||||||
long rslen, n;
|
long rslen, n;
|
||||||
int rspara;
|
int rspara;
|
||||||
|
|
||||||
|
@ -3187,17 +3198,25 @@ gzreader_gets(argc, argv, obj)
|
||||||
gzfile_read_more(gz);
|
gzfile_read_more(gz);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = rslen;
|
|
||||||
p = RSTRING(gz->z.buf)->ptr;
|
p = RSTRING(gz->z.buf)->ptr;
|
||||||
|
n = rslen;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (n > gz->z.buf_filled) {
|
if (n > gz->z.buf_filled) {
|
||||||
if (ZSTREAM_IS_FINISHED(&gz->z)) break;
|
if (ZSTREAM_IS_FINISHED(&gz->z)) break;
|
||||||
gzfile_read_more(gz);
|
gzfile_read_more(gz);
|
||||||
p = RSTRING(gz->z.buf)->ptr + n - rslen;
|
p = RSTRING(gz->z.buf)->ptr + n - rslen;
|
||||||
}
|
}
|
||||||
if (memcmp(p, rsptr, rslen) == 0) break;
|
if (!rspara) rscheck(rsptr, rslen, rs);
|
||||||
|
res = memchr(p, rsptr[0], (gz->z.buf_filled - n + 1));
|
||||||
|
if (!res) {
|
||||||
|
n = gz->z.buf_filled + 1;
|
||||||
|
} else {
|
||||||
|
n += (long)(res - p);
|
||||||
|
p = res;
|
||||||
|
if (rslen == 1 || memcmp(p, rsptr, rslen) == 0) break;
|
||||||
p++, n++;
|
p++, n++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gz->lineno++;
|
gz->lineno++;
|
||||||
dst = gzfile_read(gz, n);
|
dst = gzfile_read(gz, n);
|
||||||
|
|
11
gc.c
11
gc.c
|
@ -1422,6 +1422,15 @@ rb_gc_start()
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ruby_set_stack_size(size)
|
||||||
|
size_t size;
|
||||||
|
{
|
||||||
|
#ifndef STACK_LEVEL_MAX
|
||||||
|
STACK_LEVEL_MAX = size/sizeof(VALUE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Init_stack(addr)
|
Init_stack(addr)
|
||||||
VALUE *addr;
|
VALUE *addr;
|
||||||
|
@ -1752,7 +1761,7 @@ rb_gc_copy_finalizer(dest, obj)
|
||||||
if (st_lookup(finalizer_table, obj, &table)) {
|
if (st_lookup(finalizer_table, obj, &table)) {
|
||||||
st_insert(finalizer_table, dest, table);
|
st_insert(finalizer_table, dest, table);
|
||||||
}
|
}
|
||||||
RBASIC(dest)->flags |= FL_FINALIZE;
|
FL_SET(dest, FL_FINALIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
1
intern.h
1
intern.h
|
@ -235,6 +235,7 @@ char *rb_path_skip_prefix _((const char *));
|
||||||
char *rb_path_last_separator _((const char *));
|
char *rb_path_last_separator _((const char *));
|
||||||
char *rb_path_end _((const char *));
|
char *rb_path_end _((const char *));
|
||||||
/* gc.c */
|
/* gc.c */
|
||||||
|
void ruby_set_stack_size _((size_t));
|
||||||
NORETURN(void rb_memerror __((void)));
|
NORETURN(void rb_memerror __((void)));
|
||||||
int ruby_stack_check _((void));
|
int ruby_stack_check _((void));
|
||||||
int ruby_stack_length _((VALUE**));
|
int ruby_stack_length _((VALUE**));
|
||||||
|
|
46
io.c
46
io.c
|
@ -1391,7 +1391,7 @@ rscheck(rsptr, rslen, rs)
|
||||||
{
|
{
|
||||||
if (RSTRING(rs)->ptr != rsptr && RSTRING(rs)->len != rslen)
|
if (RSTRING(rs)->ptr != rsptr && RSTRING(rs)->len != rslen)
|
||||||
rb_raise(rb_eRuntimeError, "rs modified");
|
rb_raise(rb_eRuntimeError, "rs modified");
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -1433,7 +1433,7 @@ rb_io_getline(rs, fptr)
|
||||||
|
|
||||||
while ((c = appendline(fptr, newline, &str)) != EOF &&
|
while ((c = appendline(fptr, newline, &str)) != EOF &&
|
||||||
(c != newline || RSTRING(str)->len < rslen ||
|
(c != newline || RSTRING(str)->len < rslen ||
|
||||||
(rspara || rscheck(rsptr,rslen,rs), 0) ||
|
(rspara || rscheck(rsptr,rslen,rs)) ||
|
||||||
memcmp(RSTRING(str)->ptr+RSTRING(str)->len-rslen,rsptr,rslen)));
|
memcmp(RSTRING(str)->ptr+RSTRING(str)->len-rslen,rsptr,rslen)));
|
||||||
|
|
||||||
if (rspara) {
|
if (rspara) {
|
||||||
|
@ -1927,6 +1927,9 @@ rb_io_fptr_finalize(fptr)
|
||||||
OpenFile *fptr;
|
OpenFile *fptr;
|
||||||
{
|
{
|
||||||
if (!fptr) return 0;
|
if (!fptr) return 0;
|
||||||
|
if (fptr->f == stdin || fptr->f == stdout || fptr->f == stderr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (fptr->refcnt <= 0 || --fptr->refcnt) return 0;
|
if (fptr->refcnt <= 0 || --fptr->refcnt) return 0;
|
||||||
if (fptr->path) {
|
if (fptr->path) {
|
||||||
free(fptr->path);
|
free(fptr->path);
|
||||||
|
@ -4128,16 +4131,19 @@ rb_io_s_for_fd(argc, argv, klass)
|
||||||
static int binmode = 0;
|
static int binmode = 0;
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
argf_forward()
|
argf_forward(argv)
|
||||||
|
VALUE *argv;
|
||||||
{
|
{
|
||||||
return rb_funcall3(current_file, ruby_frame->last_func,
|
return rb_funcall3(current_file, ruby_frame->last_func, ruby_frame->argc, argv);
|
||||||
ruby_frame->argc, ruby_scope->local_vars + 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ARGF_FORWARD() do { if (TYPE(current_file) != T_FILE) return argf_forward(); } while (0)
|
#define ARGF_FORWARD(argv) do {\
|
||||||
#define NEXT_ARGF_FORWARD() do {\
|
if (TYPE(current_file) != T_FILE)\
|
||||||
|
return argf_forward(argv);\
|
||||||
|
} while (0)
|
||||||
|
#define NEXT_ARGF_FORWARD(argv) do {\
|
||||||
if (!next_argv()) return Qnil;\
|
if (!next_argv()) return Qnil;\
|
||||||
ARGF_FORWARD();\
|
ARGF_FORWARD(argv);\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -4396,7 +4402,7 @@ rb_f_readline(argc, argv)
|
||||||
VALUE line;
|
VALUE line;
|
||||||
|
|
||||||
if (!next_argv()) rb_eof_error();
|
if (!next_argv()) rb_eof_error();
|
||||||
ARGF_FORWARD();
|
ARGF_FORWARD(argv);
|
||||||
line = rb_f_gets(argc, argv);
|
line = rb_f_gets(argc, argv);
|
||||||
if (NIL_P(line)) {
|
if (NIL_P(line)) {
|
||||||
rb_eof_error();
|
rb_eof_error();
|
||||||
|
@ -4433,7 +4439,7 @@ rb_f_readlines(argc, argv)
|
||||||
{
|
{
|
||||||
VALUE line, ary;
|
VALUE line, ary;
|
||||||
|
|
||||||
NEXT_ARGF_FORWARD();
|
NEXT_ARGF_FORWARD(argv);
|
||||||
ary = rb_ary_new();
|
ary = rb_ary_new();
|
||||||
while (!NIL_P(line = argf_getline(argc, argv))) {
|
while (!NIL_P(line = argf_getline(argc, argv))) {
|
||||||
rb_ary_push(ary, line);
|
rb_ary_push(ary, line);
|
||||||
|
@ -5126,7 +5132,7 @@ argf_tell()
|
||||||
if (!next_argv()) {
|
if (!next_argv()) {
|
||||||
rb_raise(rb_eArgError, "no stream to tell");
|
rb_raise(rb_eArgError, "no stream to tell");
|
||||||
}
|
}
|
||||||
ARGF_FORWARD();
|
ARGF_FORWARD(0);
|
||||||
return rb_io_tell(current_file);
|
return rb_io_tell(current_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5139,7 +5145,7 @@ argf_seek_m(argc, argv, self)
|
||||||
if (!next_argv()) {
|
if (!next_argv()) {
|
||||||
rb_raise(rb_eArgError, "no stream to seek");
|
rb_raise(rb_eArgError, "no stream to seek");
|
||||||
}
|
}
|
||||||
ARGF_FORWARD();
|
ARGF_FORWARD(argv);
|
||||||
return rb_io_seek_m(argc, argv, current_file);
|
return rb_io_seek_m(argc, argv, current_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5150,7 +5156,7 @@ argf_set_pos(self, offset)
|
||||||
if (!next_argv()) {
|
if (!next_argv()) {
|
||||||
rb_raise(rb_eArgError, "no stream to set position");
|
rb_raise(rb_eArgError, "no stream to set position");
|
||||||
}
|
}
|
||||||
ARGF_FORWARD();
|
ARGF_FORWARD(&offset);
|
||||||
return rb_io_set_pos(current_file, offset);
|
return rb_io_set_pos(current_file, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5160,7 +5166,7 @@ argf_rewind()
|
||||||
if (!next_argv()) {
|
if (!next_argv()) {
|
||||||
rb_raise(rb_eArgError, "no stream to rewind");
|
rb_raise(rb_eArgError, "no stream to rewind");
|
||||||
}
|
}
|
||||||
ARGF_FORWARD();
|
ARGF_FORWARD(0);
|
||||||
return rb_io_rewind(current_file);
|
return rb_io_rewind(current_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5170,7 +5176,7 @@ argf_fileno()
|
||||||
if (!next_argv()) {
|
if (!next_argv()) {
|
||||||
rb_raise(rb_eArgError, "no stream");
|
rb_raise(rb_eArgError, "no stream");
|
||||||
}
|
}
|
||||||
ARGF_FORWARD();
|
ARGF_FORWARD(0);
|
||||||
return rb_io_fileno(current_file);
|
return rb_io_fileno(current_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5178,7 +5184,7 @@ static VALUE
|
||||||
argf_to_io()
|
argf_to_io()
|
||||||
{
|
{
|
||||||
next_argv();
|
next_argv();
|
||||||
ARGF_FORWARD();
|
ARGF_FORWARD(0);
|
||||||
return current_file;
|
return current_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5187,7 +5193,7 @@ argf_eof()
|
||||||
{
|
{
|
||||||
if (current_file) {
|
if (current_file) {
|
||||||
if (init_p == 0) return Qtrue;
|
if (init_p == 0) return Qtrue;
|
||||||
ARGF_FORWARD();
|
ARGF_FORWARD(0);
|
||||||
if (rb_io_eof(current_file)) {
|
if (rb_io_eof(current_file)) {
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
}
|
}
|
||||||
|
@ -5269,7 +5275,7 @@ argf_readchar()
|
||||||
{
|
{
|
||||||
VALUE c;
|
VALUE c;
|
||||||
|
|
||||||
NEXT_ARGF_FORWARD();
|
NEXT_ARGF_FORWARD(0);
|
||||||
c = argf_getc();
|
c = argf_getc();
|
||||||
if (NIL_P(c)) {
|
if (NIL_P(c)) {
|
||||||
rb_eof_error();
|
rb_eof_error();
|
||||||
|
@ -5328,7 +5334,7 @@ argf_binmode()
|
||||||
{
|
{
|
||||||
binmode = 1;
|
binmode = 1;
|
||||||
next_argv();
|
next_argv();
|
||||||
ARGF_FORWARD();
|
ARGF_FORWARD(0);
|
||||||
rb_io_binmode(current_file);
|
rb_io_binmode(current_file);
|
||||||
return argf;
|
return argf;
|
||||||
}
|
}
|
||||||
|
@ -5359,7 +5365,7 @@ static VALUE
|
||||||
argf_closed()
|
argf_closed()
|
||||||
{
|
{
|
||||||
next_argv();
|
next_argv();
|
||||||
ARGF_FORWARD();
|
ARGF_FORWARD(0);
|
||||||
return rb_io_closed(current_file);
|
return rb_io_closed(current_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -770,7 +770,7 @@ class CGI
|
||||||
# cookie1.domain = 'domain'
|
# cookie1.domain = 'domain'
|
||||||
# cookie1.expires = Time.now + 30
|
# cookie1.expires = Time.now + 30
|
||||||
# cookie1.secure = true
|
# cookie1.secure = true
|
||||||
class Cookie < SimpleDelegator
|
class Cookie < DelegateClass(Array)
|
||||||
|
|
||||||
# Create a new CGI::Cookie object.
|
# Create a new CGI::Cookie object.
|
||||||
#
|
#
|
||||||
|
@ -1012,9 +1012,12 @@ class CGI
|
||||||
end
|
end
|
||||||
|
|
||||||
c = if bufsize < content_length
|
c = if bufsize < content_length
|
||||||
stdinput.read(bufsize) or ''
|
stdinput.read(bufsize)
|
||||||
else
|
else
|
||||||
stdinput.read(content_length) or ''
|
stdinput.read(content_length)
|
||||||
|
end
|
||||||
|
if c.nil?
|
||||||
|
raise EOFError, "bad content body"
|
||||||
end
|
end
|
||||||
buf.concat(c)
|
buf.concat(c)
|
||||||
content_length -= c.size
|
content_length -= c.size
|
||||||
|
|
|
@ -58,6 +58,13 @@ class OpenStruct
|
||||||
@table = @table.dup
|
@table = @table.dup
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new_ostruct_member(name)
|
||||||
|
self.instance_eval %{
|
||||||
|
def #{name}; @table[:#{name}]; end
|
||||||
|
def #{name}=(x); @table[:#{name}] = x; end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def method_missing(mid, *args) # :nodoc:
|
def method_missing(mid, *args) # :nodoc:
|
||||||
mname = mid.id2name
|
mname = mid.id2name
|
||||||
len = args.length
|
len = args.length
|
||||||
|
@ -70,6 +77,7 @@ class OpenStruct
|
||||||
end
|
end
|
||||||
mname.chop!
|
mname.chop!
|
||||||
@table[mname.intern] = args[0]
|
@table[mname.intern] = args[0]
|
||||||
|
self.new_ostruct_member(mname)
|
||||||
elsif len == 0
|
elsif len == 0
|
||||||
@table[mid]
|
@table[mid]
|
||||||
else
|
else
|
||||||
|
|
13
node.h
13
node.h
|
@ -156,18 +156,21 @@ typedef struct RNode {
|
||||||
|
|
||||||
#define RNODE(obj) (R_CAST(RNode)(obj))
|
#define RNODE(obj) (R_CAST(RNode)(obj))
|
||||||
|
|
||||||
#define nd_type(n) ((int)(((RNODE(n))->flags>>FL_USHIFT)&0x7f))
|
#define NODE_TYPESHIFT 7
|
||||||
|
#define NODE_TYPEMASK (0xff<<NODE_TYPESHIFT)
|
||||||
|
|
||||||
|
#define nd_type(n) ((int)(((RNODE(n))->flags>>NODE_TYPESHIFT)&0x7f))
|
||||||
#define nd_set_type(n,t) \
|
#define nd_set_type(n,t) \
|
||||||
RNODE(n)->flags=((RNODE(n)->flags&~FL_UMASK)|(((t)<<FL_USHIFT)&FL_UMASK))
|
RNODE(n)->flags=((RNODE(n)->flags&~NODE_TYPEMASK)|(((t)<<NODE_TYPESHIFT)&NODE_TYPEMASK))
|
||||||
|
|
||||||
#define NODE_NEWLINE FL_USER7
|
#define NODE_LSHIFT (NODE_TYPESHIFT+8)
|
||||||
|
|
||||||
#define NODE_LSHIFT (FL_USHIFT+8)
|
|
||||||
#define NODE_LMASK (((long)1<<(sizeof(NODE*)*CHAR_BIT-NODE_LSHIFT))-1)
|
#define NODE_LMASK (((long)1<<(sizeof(NODE*)*CHAR_BIT-NODE_LSHIFT))-1)
|
||||||
#define nd_line(n) ((unsigned int)(((RNODE(n))->flags>>NODE_LSHIFT)&NODE_LMASK))
|
#define nd_line(n) ((unsigned int)(((RNODE(n))->flags>>NODE_LSHIFT)&NODE_LMASK))
|
||||||
#define nd_set_line(n,l) \
|
#define nd_set_line(n,l) \
|
||||||
RNODE(n)->flags=((RNODE(n)->flags&~(-1<<NODE_LSHIFT))|(((l)&NODE_LMASK)<<NODE_LSHIFT))
|
RNODE(n)->flags=((RNODE(n)->flags&~(-1<<NODE_LSHIFT))|(((l)&NODE_LMASK)<<NODE_LSHIFT))
|
||||||
|
|
||||||
|
#define NODE_NEWLINE FL_USER7
|
||||||
|
|
||||||
#define nd_head u1.node
|
#define nd_head u1.node
|
||||||
#define nd_alen u2.argc
|
#define nd_alen u2.argc
|
||||||
#define nd_next u3.node
|
#define nd_next u3.node
|
||||||
|
|
|
@ -1521,9 +1521,6 @@ rb_num2long(val)
|
||||||
case T_BIGNUM:
|
case T_BIGNUM:
|
||||||
return rb_big2long(val);
|
return rb_big2long(val);
|
||||||
|
|
||||||
case T_SYMBOL:
|
|
||||||
rb_warning("treating Symbol as an integer");
|
|
||||||
/* fall through */
|
|
||||||
default:
|
default:
|
||||||
val = rb_to_int(val);
|
val = rb_to_int(val);
|
||||||
return NUM2LONG(val);
|
return NUM2LONG(val);
|
||||||
|
|
2
object.c
2
object.c
|
@ -1092,7 +1092,6 @@ rb_obj_pattern_match(obj1, obj2)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* sym.to_i => fixnum
|
* sym.to_i => fixnum
|
||||||
* sym.to_int => fixnum
|
|
||||||
*
|
*
|
||||||
* Returns an integer that is unique for each symbol within a
|
* Returns an integer that is unique for each symbol within a
|
||||||
* particular execution of a program.
|
* particular execution of a program.
|
||||||
|
@ -2631,7 +2630,6 @@ Init_Object()
|
||||||
rb_undef_method(CLASS_OF(rb_cSymbol), "new");
|
rb_undef_method(CLASS_OF(rb_cSymbol), "new");
|
||||||
|
|
||||||
rb_define_method(rb_cSymbol, "to_i", sym_to_i, 0);
|
rb_define_method(rb_cSymbol, "to_i", sym_to_i, 0);
|
||||||
rb_define_method(rb_cSymbol, "to_int", sym_to_i, 0);
|
|
||||||
rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0);
|
rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0);
|
||||||
rb_define_method(rb_cSymbol, "to_s", sym_to_s, 0);
|
rb_define_method(rb_cSymbol, "to_s", sym_to_s, 0);
|
||||||
rb_define_method(rb_cSymbol, "id2name", sym_to_s, 0);
|
rb_define_method(rb_cSymbol, "id2name", sym_to_s, 0);
|
||||||
|
|
4
ruby.h
4
ruby.h
|
@ -441,11 +441,9 @@ struct RBignum {
|
||||||
#define FL_USER6 (1<<(FL_USHIFT+6))
|
#define FL_USER6 (1<<(FL_USHIFT+6))
|
||||||
#define FL_USER7 (1<<(FL_USHIFT+7))
|
#define FL_USER7 (1<<(FL_USHIFT+7))
|
||||||
|
|
||||||
#define FL_UMASK (0xff<<FL_USHIFT)
|
|
||||||
|
|
||||||
#define SPECIAL_CONST_P(x) (IMMEDIATE_P(x) || !RTEST(x))
|
#define SPECIAL_CONST_P(x) (IMMEDIATE_P(x) || !RTEST(x))
|
||||||
|
|
||||||
#define FL_ABLE(x) (!SPECIAL_CONST_P(x))
|
#define FL_ABLE(x) (!SPECIAL_CONST_P(x) && BUILTIN_TYPE(x) != T_NODE)
|
||||||
#define FL_TEST(x,f) (FL_ABLE(x)?(RBASIC(x)->flags&(f)):0)
|
#define FL_TEST(x,f) (FL_ABLE(x)?(RBASIC(x)->flags&(f)):0)
|
||||||
#define FL_SET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags |= (f);} while (0)
|
#define FL_SET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags |= (f);} while (0)
|
||||||
#define FL_UNSET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags &= ~(f);} while (0)
|
#define FL_UNSET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags &= ~(f);} while (0)
|
||||||
|
|
|
@ -767,14 +767,11 @@ rb_f_sprintf(argc, argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
sprint_exit:
|
sprint_exit:
|
||||||
#if 0
|
/* XXX - We cannot validiate the number of arguments if (digit)$ style used.
|
||||||
/* XXX - We cannot validiate the number of arguments because
|
|
||||||
* the format string may contain `n$'-style argument selector.
|
|
||||||
*/
|
*/
|
||||||
if (RTEST(ruby_verbose) && nextarg < argc) {
|
if (RTEST(ruby_verbose) && posarg >= 0 && nextarg < argc) {
|
||||||
rb_raise(rb_eArgError, "too many arguments for format string");
|
rb_raise(rb_eArgError, "too many arguments for format string");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
rb_str_resize(result, blen);
|
rb_str_resize(result, blen);
|
||||||
|
|
||||||
if (tainted) OBJ_TAINT(result);
|
if (tainted) OBJ_TAINT(result);
|
||||||
|
|
20
string.c
20
string.c
|
@ -28,9 +28,11 @@
|
||||||
VALUE rb_cString;
|
VALUE rb_cString;
|
||||||
|
|
||||||
#define STR_ASSOC FL_USER3
|
#define STR_ASSOC FL_USER3
|
||||||
|
#define STR_NOCAPA (ELTS_SHARED|STR_ASSOC)
|
||||||
|
|
||||||
#define RESIZE_CAPA(str,capacity) do {\
|
#define RESIZE_CAPA(str,capacity) do {\
|
||||||
REALLOC_N(RSTRING(str)->ptr, char, (capacity)+1);\
|
REALLOC_N(RSTRING(str)->ptr, char, (capacity)+1);\
|
||||||
|
if (!FL_TEST(str, STR_NOCAPA))\
|
||||||
RSTRING(str)->aux.capa = (capacity);\
|
RSTRING(str)->aux.capa = (capacity);\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -253,14 +255,14 @@ rb_str_shared_replace(str, str2)
|
||||||
RSTRING(str)->ptr = 0;
|
RSTRING(str)->ptr = 0;
|
||||||
RSTRING(str)->len = 0;
|
RSTRING(str)->len = 0;
|
||||||
RSTRING(str)->aux.capa = 0;
|
RSTRING(str)->aux.capa = 0;
|
||||||
FL_UNSET(str, ELTS_SHARED|STR_ASSOC);
|
FL_UNSET(str, STR_NOCAPA);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RSTRING(str)->ptr = RSTRING(str2)->ptr;
|
RSTRING(str)->ptr = RSTRING(str2)->ptr;
|
||||||
RSTRING(str)->len = RSTRING(str2)->len;
|
RSTRING(str)->len = RSTRING(str2)->len;
|
||||||
FL_UNSET(str, ELTS_SHARED|STR_ASSOC);
|
FL_UNSET(str, STR_NOCAPA);
|
||||||
if (FL_TEST(str2, ELTS_SHARED|STR_ASSOC)) {
|
if (FL_TEST(str2, STR_NOCAPA)) {
|
||||||
FL_SET(str, RBASIC(str2)->flags & (ELTS_SHARED|STR_ASSOC));
|
FL_SET(str, RBASIC(str2)->flags & STR_NOCAPA);
|
||||||
RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
|
RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -269,7 +271,7 @@ rb_str_shared_replace(str, str2)
|
||||||
RSTRING(str2)->ptr = 0; /* abandon str2 */
|
RSTRING(str2)->ptr = 0; /* abandon str2 */
|
||||||
RSTRING(str2)->len = 0;
|
RSTRING(str2)->len = 0;
|
||||||
RSTRING(str2)->aux.capa = 0;
|
RSTRING(str2)->aux.capa = 0;
|
||||||
FL_UNSET(str2, ELTS_SHARED|STR_ASSOC);
|
FL_UNSET(str2, STR_NOCAPA);
|
||||||
if (OBJ_TAINTED(str2)) OBJ_TAINT(str);
|
if (OBJ_TAINTED(str2)) OBJ_TAINT(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +482,7 @@ str_make_independent(str)
|
||||||
ptr[RSTRING(str)->len] = 0;
|
ptr[RSTRING(str)->len] = 0;
|
||||||
RSTRING(str)->ptr = ptr;
|
RSTRING(str)->ptr = ptr;
|
||||||
RSTRING(str)->aux.capa = RSTRING(str)->len;
|
RSTRING(str)->aux.capa = RSTRING(str)->len;
|
||||||
FL_UNSET(str, ELTS_SHARED|STR_ASSOC);
|
FL_UNSET(str, STR_NOCAPA);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -643,7 +645,7 @@ rb_str_resize(str, len)
|
||||||
rb_str_modify(str);
|
rb_str_modify(str);
|
||||||
if (RSTRING(str)->len < len || RSTRING(str)->len - len > 1024) {
|
if (RSTRING(str)->len < len || RSTRING(str)->len - len > 1024) {
|
||||||
REALLOC_N(RSTRING(str)->ptr, char, len+1);
|
REALLOC_N(RSTRING(str)->ptr, char, len+1);
|
||||||
if (!FL_TEST(str, STR_ASSOC|ELTS_SHARED)) {
|
if (!FL_TEST(str, STR_NOCAPA)) {
|
||||||
RSTRING(str)->aux.capa = len;
|
RSTRING(str)->aux.capa = len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1615,7 +1617,7 @@ rb_str_splice(str, beg, len, val)
|
||||||
StringValue(val);
|
StringValue(val);
|
||||||
if (len < RSTRING(val)->len) {
|
if (len < RSTRING(val)->len) {
|
||||||
/* expand string */
|
/* expand string */
|
||||||
RESIZE_CAPA(str, RSTRING(str)->len + RSTRING(val)->len - len);
|
RESIZE_CAPA(str, RSTRING(str)->len + RSTRING(val)->len - len + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RSTRING(val)->len != len) {
|
if (RSTRING(val)->len != len) {
|
||||||
|
@ -2252,7 +2254,7 @@ rb_str_clear(str)
|
||||||
free(RSTRING(str)->ptr);
|
free(RSTRING(str)->ptr);
|
||||||
}
|
}
|
||||||
RSTRING(str)->aux.shared = 0;
|
RSTRING(str)->aux.shared = 0;
|
||||||
FL_UNSET(str, ELTS_SHARED|STR_ASSOC);
|
FL_UNSET(str, STR_NOCAPA);
|
||||||
RSTRING(str)->ptr = 0;
|
RSTRING(str)->ptr = 0;
|
||||||
RARRAY(str)->len = 0;
|
RARRAY(str)->len = 0;
|
||||||
return str;
|
return str;
|
||||||
|
|
|
@ -967,6 +967,7 @@ rb_free_generic_ivar(obj)
|
||||||
{
|
{
|
||||||
st_table *tbl;
|
st_table *tbl;
|
||||||
|
|
||||||
|
// if (!generic_iv_tbl) return;
|
||||||
if (st_delete(generic_iv_tbl, &obj, (st_data_t *)&tbl))
|
if (st_delete(generic_iv_tbl, &obj, (st_data_t *)&tbl))
|
||||||
st_free_table(tbl);
|
st_free_table(tbl);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue