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.
|
||||
[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>
|
||||
|
||||
* lib/rdoc/code_objects.rb (RDoc::Context::add_class_or_module):
|
||||
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>
|
||||
|
||||
* 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
|
||||
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>
|
||||
|
||||
* 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;
|
||||
|
||||
if (argc == 2) {
|
||||
if (SYMBOL_P(argv[0])) {
|
||||
rb_raise(rb_eTypeError, "Symbol as array index");
|
||||
}
|
||||
beg = NUM2LONG(argv[0]);
|
||||
len = NUM2LONG(argv[1]);
|
||||
if (beg < 0) {
|
||||
|
@ -834,9 +831,6 @@ rb_ary_aref(argc, argv, ary)
|
|||
if (FIXNUM_P(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 */
|
||||
switch (rb_range_beg_len(arg, &beg, &len, RARRAY(ary)->len, 0)) {
|
||||
case Qfalse:
|
||||
|
@ -1178,12 +1172,6 @@ rb_ary_aset(argc, argv, ary)
|
|||
long offset, beg, len;
|
||||
|
||||
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]);
|
||||
return argv[2];
|
||||
}
|
||||
|
@ -1194,9 +1182,6 @@ rb_ary_aset(argc, argv, ary)
|
|||
offset = FIX2LONG(argv[0]);
|
||||
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)) {
|
||||
/* check if idx is Range */
|
||||
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=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"
|
||||
fi
|
||||
fi
|
||||
|
|
18
eval.c
18
eval.c
|
@ -7737,19 +7737,27 @@ blk_mark(data)
|
|||
}
|
||||
|
||||
static void
|
||||
blk_free(data)
|
||||
struct BLOCK *data;
|
||||
{
|
||||
frame_free(frame)
|
||||
struct FRAME *frame;
|
||||
void *tmp;
|
||||
{
|
||||
struct FRAME *tmp;
|
||||
|
||||
frame = data->frame.prev;
|
||||
frame = frame->prev;
|
||||
while (frame) {
|
||||
tmp = frame;
|
||||
frame = frame->prev;
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
blk_free(data)
|
||||
struct BLOCK *data;
|
||||
{
|
||||
void *tmp;
|
||||
|
||||
while (data) {
|
||||
frame_free(&data->frame);
|
||||
tmp = data;
|
||||
data = data->prev;
|
||||
free(tmp);
|
||||
|
|
|
@ -544,7 +544,6 @@ ossl_ssl_write(VALUE self, VALUE str)
|
|||
{
|
||||
SSL *ssl;
|
||||
int nwrite = 0;
|
||||
FILE *fp;
|
||||
|
||||
Data_Get_Struct(self, SSL, ssl);
|
||||
StringValue(str);
|
||||
|
|
|
@ -701,7 +701,7 @@ zstream_run(z, src, len, flush)
|
|||
uInt n;
|
||||
int err;
|
||||
|
||||
if (len == 0) {
|
||||
if (NIL_P(z->input) && len == 0) {
|
||||
z->stream.next_in = "";
|
||||
z->stream.avail_in = 0;
|
||||
}
|
||||
|
@ -3137,6 +3137,16 @@ gzreader_skip_linebreaks(gz)
|
|||
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
|
||||
gzreader_gets(argc, argv, obj)
|
||||
int argc;
|
||||
|
@ -3144,8 +3154,9 @@ gzreader_gets(argc, argv, obj)
|
|||
VALUE obj;
|
||||
{
|
||||
struct gzfile *gz = get_gzfile(obj);
|
||||
VALUE rs, dst;
|
||||
char *rsptr, *p;
|
||||
volatile VALUE rs;
|
||||
VALUE dst;
|
||||
char *rsptr, *p, *res;
|
||||
long rslen, n;
|
||||
int rspara;
|
||||
|
||||
|
@ -3187,16 +3198,24 @@ gzreader_gets(argc, argv, obj)
|
|||
gzfile_read_more(gz);
|
||||
}
|
||||
|
||||
n = rslen;
|
||||
p = RSTRING(gz->z.buf)->ptr;
|
||||
n = rslen;
|
||||
for (;;) {
|
||||
if (n > gz->z.buf_filled) {
|
||||
if (ZSTREAM_IS_FINISHED(&gz->z)) break;
|
||||
gzfile_read_more(gz);
|
||||
p = RSTRING(gz->z.buf)->ptr + n - rslen;
|
||||
}
|
||||
if (memcmp(p, rsptr, rslen) == 0) break;
|
||||
p++, n++;
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
gz->lineno++;
|
||||
|
|
11
gc.c
11
gc.c
|
@ -1422,6 +1422,15 @@ rb_gc_start()
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
void
|
||||
ruby_set_stack_size(size)
|
||||
size_t size;
|
||||
{
|
||||
#ifndef STACK_LEVEL_MAX
|
||||
STACK_LEVEL_MAX = size/sizeof(VALUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
Init_stack(addr)
|
||||
VALUE *addr;
|
||||
|
@ -1752,7 +1761,7 @@ rb_gc_copy_finalizer(dest, obj)
|
|||
if (st_lookup(finalizer_table, obj, &table)) {
|
||||
st_insert(finalizer_table, dest, table);
|
||||
}
|
||||
RBASIC(dest)->flags |= FL_FINALIZE;
|
||||
FL_SET(dest, FL_FINALIZE);
|
||||
}
|
||||
|
||||
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_end _((const char *));
|
||||
/* gc.c */
|
||||
void ruby_set_stack_size _((size_t));
|
||||
NORETURN(void rb_memerror __((void)));
|
||||
int ruby_stack_check _((void));
|
||||
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)
|
||||
rb_raise(rb_eRuntimeError, "rs modified");
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -1433,7 +1433,7 @@ rb_io_getline(rs, fptr)
|
|||
|
||||
while ((c = appendline(fptr, newline, &str)) != EOF &&
|
||||
(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)));
|
||||
|
||||
if (rspara) {
|
||||
|
@ -1927,6 +1927,9 @@ rb_io_fptr_finalize(fptr)
|
|||
OpenFile *fptr;
|
||||
{
|
||||
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->path) {
|
||||
free(fptr->path);
|
||||
|
@ -4128,16 +4131,19 @@ rb_io_s_for_fd(argc, argv, klass)
|
|||
static int binmode = 0;
|
||||
|
||||
static VALUE
|
||||
argf_forward()
|
||||
argf_forward(argv)
|
||||
VALUE *argv;
|
||||
{
|
||||
return rb_funcall3(current_file, ruby_frame->last_func,
|
||||
ruby_frame->argc, ruby_scope->local_vars + 2);
|
||||
return rb_funcall3(current_file, ruby_frame->last_func, ruby_frame->argc, argv);
|
||||
}
|
||||
|
||||
#define ARGF_FORWARD() do { if (TYPE(current_file) != T_FILE) return argf_forward(); } while (0)
|
||||
#define NEXT_ARGF_FORWARD() do {\
|
||||
#define ARGF_FORWARD(argv) do {\
|
||||
if (TYPE(current_file) != T_FILE)\
|
||||
return argf_forward(argv);\
|
||||
} while (0)
|
||||
#define NEXT_ARGF_FORWARD(argv) do {\
|
||||
if (!next_argv()) return Qnil;\
|
||||
ARGF_FORWARD();\
|
||||
ARGF_FORWARD(argv);\
|
||||
} while (0)
|
||||
|
||||
static void
|
||||
|
@ -4396,7 +4402,7 @@ rb_f_readline(argc, argv)
|
|||
VALUE line;
|
||||
|
||||
if (!next_argv()) rb_eof_error();
|
||||
ARGF_FORWARD();
|
||||
ARGF_FORWARD(argv);
|
||||
line = rb_f_gets(argc, argv);
|
||||
if (NIL_P(line)) {
|
||||
rb_eof_error();
|
||||
|
@ -4433,7 +4439,7 @@ rb_f_readlines(argc, argv)
|
|||
{
|
||||
VALUE line, ary;
|
||||
|
||||
NEXT_ARGF_FORWARD();
|
||||
NEXT_ARGF_FORWARD(argv);
|
||||
ary = rb_ary_new();
|
||||
while (!NIL_P(line = argf_getline(argc, argv))) {
|
||||
rb_ary_push(ary, line);
|
||||
|
@ -5126,7 +5132,7 @@ argf_tell()
|
|||
if (!next_argv()) {
|
||||
rb_raise(rb_eArgError, "no stream to tell");
|
||||
}
|
||||
ARGF_FORWARD();
|
||||
ARGF_FORWARD(0);
|
||||
return rb_io_tell(current_file);
|
||||
}
|
||||
|
||||
|
@ -5139,7 +5145,7 @@ argf_seek_m(argc, argv, self)
|
|||
if (!next_argv()) {
|
||||
rb_raise(rb_eArgError, "no stream to seek");
|
||||
}
|
||||
ARGF_FORWARD();
|
||||
ARGF_FORWARD(argv);
|
||||
return rb_io_seek_m(argc, argv, current_file);
|
||||
}
|
||||
|
||||
|
@ -5150,7 +5156,7 @@ argf_set_pos(self, offset)
|
|||
if (!next_argv()) {
|
||||
rb_raise(rb_eArgError, "no stream to set position");
|
||||
}
|
||||
ARGF_FORWARD();
|
||||
ARGF_FORWARD(&offset);
|
||||
return rb_io_set_pos(current_file, offset);
|
||||
}
|
||||
|
||||
|
@ -5160,7 +5166,7 @@ argf_rewind()
|
|||
if (!next_argv()) {
|
||||
rb_raise(rb_eArgError, "no stream to rewind");
|
||||
}
|
||||
ARGF_FORWARD();
|
||||
ARGF_FORWARD(0);
|
||||
return rb_io_rewind(current_file);
|
||||
}
|
||||
|
||||
|
@ -5170,7 +5176,7 @@ argf_fileno()
|
|||
if (!next_argv()) {
|
||||
rb_raise(rb_eArgError, "no stream");
|
||||
}
|
||||
ARGF_FORWARD();
|
||||
ARGF_FORWARD(0);
|
||||
return rb_io_fileno(current_file);
|
||||
}
|
||||
|
||||
|
@ -5178,7 +5184,7 @@ static VALUE
|
|||
argf_to_io()
|
||||
{
|
||||
next_argv();
|
||||
ARGF_FORWARD();
|
||||
ARGF_FORWARD(0);
|
||||
return current_file;
|
||||
}
|
||||
|
||||
|
@ -5187,7 +5193,7 @@ argf_eof()
|
|||
{
|
||||
if (current_file) {
|
||||
if (init_p == 0) return Qtrue;
|
||||
ARGF_FORWARD();
|
||||
ARGF_FORWARD(0);
|
||||
if (rb_io_eof(current_file)) {
|
||||
return Qtrue;
|
||||
}
|
||||
|
@ -5269,7 +5275,7 @@ argf_readchar()
|
|||
{
|
||||
VALUE c;
|
||||
|
||||
NEXT_ARGF_FORWARD();
|
||||
NEXT_ARGF_FORWARD(0);
|
||||
c = argf_getc();
|
||||
if (NIL_P(c)) {
|
||||
rb_eof_error();
|
||||
|
@ -5328,7 +5334,7 @@ argf_binmode()
|
|||
{
|
||||
binmode = 1;
|
||||
next_argv();
|
||||
ARGF_FORWARD();
|
||||
ARGF_FORWARD(0);
|
||||
rb_io_binmode(current_file);
|
||||
return argf;
|
||||
}
|
||||
|
@ -5359,7 +5365,7 @@ static VALUE
|
|||
argf_closed()
|
||||
{
|
||||
next_argv();
|
||||
ARGF_FORWARD();
|
||||
ARGF_FORWARD(0);
|
||||
return rb_io_closed(current_file);
|
||||
}
|
||||
|
||||
|
|
|
@ -770,7 +770,7 @@ class CGI
|
|||
# cookie1.domain = 'domain'
|
||||
# cookie1.expires = Time.now + 30
|
||||
# cookie1.secure = true
|
||||
class Cookie < SimpleDelegator
|
||||
class Cookie < DelegateClass(Array)
|
||||
|
||||
# Create a new CGI::Cookie object.
|
||||
#
|
||||
|
@ -1012,10 +1012,13 @@ class CGI
|
|||
end
|
||||
|
||||
c = if bufsize < content_length
|
||||
stdinput.read(bufsize) or ''
|
||||
stdinput.read(bufsize)
|
||||
else
|
||||
stdinput.read(content_length) or ''
|
||||
stdinput.read(content_length)
|
||||
end
|
||||
if c.nil?
|
||||
raise EOFError, "bad content body"
|
||||
end
|
||||
buf.concat(c)
|
||||
content_length -= c.size
|
||||
end
|
||||
|
|
|
@ -58,6 +58,13 @@ class OpenStruct
|
|||
@table = @table.dup
|
||||
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:
|
||||
mname = mid.id2name
|
||||
len = args.length
|
||||
|
@ -70,6 +77,7 @@ class OpenStruct
|
|||
end
|
||||
mname.chop!
|
||||
@table[mname.intern] = args[0]
|
||||
self.new_ostruct_member(mname)
|
||||
elsif len == 0
|
||||
@table[mid]
|
||||
else
|
||||
|
|
13
node.h
13
node.h
|
@ -156,18 +156,21 @@ typedef struct RNode {
|
|||
|
||||
#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) \
|
||||
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 (FL_USHIFT+8)
|
||||
#define NODE_LSHIFT (NODE_TYPESHIFT+8)
|
||||
#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_set_line(n,l) \
|
||||
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_alen u2.argc
|
||||
#define nd_next u3.node
|
||||
|
|
|
@ -1521,9 +1521,6 @@ rb_num2long(val)
|
|||
case T_BIGNUM:
|
||||
return rb_big2long(val);
|
||||
|
||||
case T_SYMBOL:
|
||||
rb_warning("treating Symbol as an integer");
|
||||
/* fall through */
|
||||
default:
|
||||
val = rb_to_int(val);
|
||||
return NUM2LONG(val);
|
||||
|
|
2
object.c
2
object.c
|
@ -1092,7 +1092,6 @@ rb_obj_pattern_match(obj1, obj2)
|
|||
/*
|
||||
* call-seq:
|
||||
* sym.to_i => fixnum
|
||||
* sym.to_int => fixnum
|
||||
*
|
||||
* Returns an integer that is unique for each symbol within a
|
||||
* particular execution of a program.
|
||||
|
@ -2631,7 +2630,6 @@ Init_Object()
|
|||
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_int", sym_to_i, 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, "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_USER7 (1<<(FL_USHIFT+7))
|
||||
|
||||
#define FL_UMASK (0xff<<FL_USHIFT)
|
||||
|
||||
#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_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)
|
||||
|
|
|
@ -767,14 +767,11 @@ rb_f_sprintf(argc, argv)
|
|||
}
|
||||
|
||||
sprint_exit:
|
||||
#if 0
|
||||
/* XXX - We cannot validiate the number of arguments because
|
||||
* the format string may contain `n$'-style argument selector.
|
||||
/* XXX - We cannot validiate the number of arguments if (digit)$ style used.
|
||||
*/
|
||||
if (RTEST(ruby_verbose) && nextarg < argc) {
|
||||
if (RTEST(ruby_verbose) && posarg >= 0 && nextarg < argc) {
|
||||
rb_raise(rb_eArgError, "too many arguments for format string");
|
||||
}
|
||||
#endif
|
||||
rb_str_resize(result, blen);
|
||||
|
||||
if (tainted) OBJ_TAINT(result);
|
||||
|
|
22
string.c
22
string.c
|
@ -28,10 +28,12 @@
|
|||
VALUE rb_cString;
|
||||
|
||||
#define STR_ASSOC FL_USER3
|
||||
#define STR_NOCAPA (ELTS_SHARED|STR_ASSOC)
|
||||
|
||||
#define RESIZE_CAPA(str,capacity) do {\
|
||||
REALLOC_N(RSTRING(str)->ptr, char, (capacity)+1);\
|
||||
RSTRING(str)->aux.capa = (capacity);\
|
||||
if (!FL_TEST(str, STR_NOCAPA))\
|
||||
RSTRING(str)->aux.capa = (capacity);\
|
||||
} while (0)
|
||||
|
||||
VALUE rb_fs;
|
||||
|
@ -253,14 +255,14 @@ rb_str_shared_replace(str, str2)
|
|||
RSTRING(str)->ptr = 0;
|
||||
RSTRING(str)->len = 0;
|
||||
RSTRING(str)->aux.capa = 0;
|
||||
FL_UNSET(str, ELTS_SHARED|STR_ASSOC);
|
||||
FL_UNSET(str, STR_NOCAPA);
|
||||
return;
|
||||
}
|
||||
RSTRING(str)->ptr = RSTRING(str2)->ptr;
|
||||
RSTRING(str)->len = RSTRING(str2)->len;
|
||||
FL_UNSET(str, ELTS_SHARED|STR_ASSOC);
|
||||
if (FL_TEST(str2, ELTS_SHARED|STR_ASSOC)) {
|
||||
FL_SET(str, RBASIC(str2)->flags & (ELTS_SHARED|STR_ASSOC));
|
||||
FL_UNSET(str, STR_NOCAPA);
|
||||
if (FL_TEST(str2, STR_NOCAPA)) {
|
||||
FL_SET(str, RBASIC(str2)->flags & STR_NOCAPA);
|
||||
RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
|
||||
}
|
||||
else {
|
||||
|
@ -269,7 +271,7 @@ rb_str_shared_replace(str, str2)
|
|||
RSTRING(str2)->ptr = 0; /* abandon str2 */
|
||||
RSTRING(str2)->len = 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);
|
||||
}
|
||||
|
||||
|
@ -480,7 +482,7 @@ str_make_independent(str)
|
|||
ptr[RSTRING(str)->len] = 0;
|
||||
RSTRING(str)->ptr = ptr;
|
||||
RSTRING(str)->aux.capa = RSTRING(str)->len;
|
||||
FL_UNSET(str, ELTS_SHARED|STR_ASSOC);
|
||||
FL_UNSET(str, STR_NOCAPA);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -643,7 +645,7 @@ rb_str_resize(str, len)
|
|||
rb_str_modify(str);
|
||||
if (RSTRING(str)->len < len || RSTRING(str)->len - len > 1024) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1615,7 +1617,7 @@ rb_str_splice(str, beg, len, val)
|
|||
StringValue(val);
|
||||
if (len < RSTRING(val)->len) {
|
||||
/* 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) {
|
||||
|
@ -2252,7 +2254,7 @@ rb_str_clear(str)
|
|||
free(RSTRING(str)->ptr);
|
||||
}
|
||||
RSTRING(str)->aux.shared = 0;
|
||||
FL_UNSET(str, ELTS_SHARED|STR_ASSOC);
|
||||
FL_UNSET(str, STR_NOCAPA);
|
||||
RSTRING(str)->ptr = 0;
|
||||
RARRAY(str)->len = 0;
|
||||
return str;
|
||||
|
|
|
@ -967,6 +967,7 @@ rb_free_generic_ivar(obj)
|
|||
{
|
||||
st_table *tbl;
|
||||
|
||||
// if (!generic_iv_tbl) return;
|
||||
if (st_delete(generic_iv_tbl, &obj, (st_data_t *)&tbl))
|
||||
st_free_table(tbl);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue