summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--ToDo2
-rw-r--r--configure4
-rw-r--r--configure.in4
-rw-r--r--enum.c36
-rw-r--r--eval.c60
-rw-r--r--file.c24
-rw-r--r--hash.c7
-rw-r--r--intern.h1
-rw-r--r--lib/cgi.rb107
-rw-r--r--range.c21
-rw-r--r--ruby.c4
-rw-r--r--string.c2
-rw-r--r--struct.c9
-rw-r--r--version.h4
15 files changed, 172 insertions, 128 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b5efcbea56..370b3588d0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,13 +1,22 @@
+Tue Dec 7 11:16:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (Init_eval): calculate stack limit from rlimit where
+ getrlimit(2) is available.
+
+Tue Dec 7 09:57:33 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * file.c (rb_file_ftype): should have removed mode_t.
+
Mon Dec 6 15:55:30 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
- * numeric.c (fix_rshift): Fix -1 >> 32 returned 0. (-1 is true)
+ * numeric.c (fix_rshift): Fix -1 >> 32 returned 0 (should be -1).
- * numeric.c (fix_rshift): Fix 1 >> -1 returned 0. (2 is true)
+ * numeric.c (fix_rshift): Fix 1 >> -1 returned 0 (should be 2).
Mon Dec 6 11:47:23 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* sprintf.c (rb_f_sprintf): formatted string must be tainted if
- any of parameters is tainted.
+ any of parameters is a tainted string.
* file.c (rb_file_s_expand_path): expanded file path need not to
be tainted always.
diff --git a/ToDo b/ToDo
index 1e9cd7fd0d8..8bc7ac58a26 100644
--- a/ToDo
+++ b/ToDo
@@ -25,6 +25,7 @@ Hacking Interpreter
- use eban's fnmatch
- RUBYOPT environment variable
- alias $defout $>
+* retrieve STACK_LEVEL_MAX from users' limit.
* remove end_proc registered out of require only
* non-blocking open (e.g. for named pipe) for thread
* avoid blocking with gethostbyname/gethostbyaddr
@@ -42,6 +43,7 @@ Standard Libraries
- Dir.glob(pat){|f|...}
- sprintf/printf's $ to specify argument order
- Dir.glob("**/*.c") ala zsh
+- Remove Enumerable#{size,length}
* SyntaxError and NameError should not be subclasses of StandardError, maybe.
* debugger for thread programming
* Struct::new([name,]member,...) ??
diff --git a/configure b/configure
index fc3575ea036..32b89d596cc 100644
--- a/configure
+++ b/configure
@@ -2199,7 +2199,7 @@ fi
for ac_hdr in stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\
fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
- syscall.h pwd.h a.out.h utime.h memory.h direct.h
+ syscall.h pwd.h a.out.h utime.h memory.h direct.h sys/resource.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
@@ -3102,7 +3102,7 @@ for ac_func in fmod killpg drand48 random wait4 waitpid syscall getcwd\
truncate chsize times utimes fcntl lockf setitimer\
setruid seteuid setreuid setrgid setegid setregid\
getpgrp setpgrp getpgid setpgid getgroups getpriority\
- dlopen sigprocmask sigaction _setjmp setsid
+ dlopen sigprocmask sigaction _setjmp setsid getrlimit
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:3109: checking for $ac_func" >&5
diff --git a/configure.in b/configure.in
index d046257ae6d..962cfc20f52 100644
--- a/configure.in
+++ b/configure.in
@@ -156,7 +156,7 @@ AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\
fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
- syscall.h pwd.h a.out.h utime.h memory.h direct.h)
+ syscall.h pwd.h a.out.h utime.h memory.h direct.h sys/resource.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_UID_T
@@ -180,7 +180,7 @@ AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd\
truncate chsize times utimes fcntl lockf setitimer\
setruid seteuid setreuid setrgid setegid setregid\
getpgrp setpgrp getpgid setpgid getgroups getpriority\
- dlopen sigprocmask sigaction _setjmp setsid)
+ dlopen sigprocmask sigaction _setjmp setsid getrlimit)
AC_STRUCT_TIMEZONE
if test "$ac_cv_func_strftime" = no; then
AC_TRY_LINK([],
diff --git a/enum.c b/enum.c
index ad171f6276e..054c59786d2 100644
--- a/enum.c
+++ b/enum.c
@@ -198,7 +198,7 @@ min_i(i, min)
*min = i;
else {
cmp = rb_funcall(i, id_cmp, 1, *min);
- if (FIX2LONG(cmp) < 0)
+ if (NUM2LONG(cmp) < 0)
*min = i;
}
return Qnil;
@@ -214,7 +214,7 @@ min_ii(i, min)
*min = i;
else {
cmp = rb_yield(rb_assoc_new(i, *min));
- if (FIX2LONG(cmp) < 0)
+ if (NUM2LONG(cmp) < 0)
*min = i;
}
return Qnil;
@@ -240,7 +240,7 @@ max_i(i, max)
*max = i;
else {
cmp = rb_funcall(i, id_cmp, 1, *max);
- if (FIX2LONG(cmp) > 0)
+ if (NUM2LONG(cmp) > 0)
*max = i;
}
return Qnil;
@@ -256,7 +256,7 @@ max_ii(i, max)
*max = i;
else {
cmp = rb_yield(rb_assoc_new(i, *max));
- if (FIX2LONG(cmp) > 0)
+ if (NUM2LONG(cmp) > 0)
*max = i;
}
return Qnil;
@@ -333,32 +333,6 @@ enum_member(obj, val)
}
static VALUE
-length_i(i, length)
- VALUE i;
- int *length;
-{
- (*length)++;
- return Qnil;
-}
-
-static VALUE
-enum_length(obj)
- VALUE obj;
-{
- int length = 0;
-
- rb_iterate(rb_each, obj, length_i, (VALUE)&length);
- return INT2FIX(length);
-}
-
-VALUE
-rb_enum_length(obj)
- VALUE obj;
-{
- return enum_length(obj);
-}
-
-static VALUE
each_with_index_i(val, indexp)
VALUE val;
int *indexp;
@@ -403,8 +377,6 @@ Init_Enumerable()
rb_define_method(rb_mEnumerable,"index", enum_index, 1);
rb_define_method(rb_mEnumerable,"member?", enum_member, 1);
rb_define_method(rb_mEnumerable,"include?", enum_member, 1);
- rb_define_method(rb_mEnumerable,"length", enum_length, 0);
- rb_define_method(rb_mEnumerable,"size", enum_length, 0);
rb_define_method(rb_mEnumerable,"each_with_index", enum_each_with_index, 0);
id_eqq = rb_intern("===");
diff --git a/eval.c b/eval.c
index 32d0155b15c..e1fe0537be1 100644
--- a/eval.c
+++ b/eval.c
@@ -49,6 +49,28 @@ char *strrchr _((const char*,const char));
#endif
#endif
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#else
+#ifndef NT
+struct timeval {
+ long tv_sec; /* seconds */
+ long tv_usec; /* and microseconds */
+};
+#endif /* NT */
+#endif
+#include <signal.h>
+#include <errno.h>
+
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
VALUE rb_cProc;
static VALUE rb_cBinding;
static VALUE proc_call _((VALUE,VALUE));
@@ -3714,9 +3736,14 @@ rb_undefined(obj, id, argc, argv, call_status)
extern int _stacksize;
# define STACK_LEVEL_MAX (_stacksize - 4096)
#else
+#ifdef HAVE_GETRLIMIT
+static int STACK_LEVEL_MAX = 655300;
+#else
# define STACK_LEVEL_MAX 655300
#endif
#endif
+#endif
+
extern VALUE *rb_gc_stack_start;
static int
stack_length()
@@ -3844,7 +3871,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
break;
}
- if ((++tick & 0x3ff) == 0) {
+ if ((++tick & 0xff) == 0) {
CHECK_INTS; /* better than nothing */
if (stack_length() > STACK_LEVEL_MAX) {
rb_raise(rb_eSysStackError, "stack level too deep");
@@ -5389,6 +5416,19 @@ Init_eval()
rb_global_variable(&trace_func);
rb_define_virtual_variable("$SAFE", safe_getter, safe_setter);
+
+#ifdef HAVE_GETRLIMIT
+ {
+ struct rlimit rlim;
+
+ if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
+ double space = (double)rlim.rlim_cur*0.2;
+
+ if (space > 256*1024) space = 256*1024;
+ STACK_LEVEL_MAX = (rlim.rlim_cur - space) / 4;
+ }
+ }
+#endif
}
VALUE rb_f_autoload();
@@ -6042,24 +6082,6 @@ int rb_thread_pending = 0;
VALUE rb_cThread;
-#include <sys/types.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#else
-#ifndef NT
-struct timeval {
- long tv_sec; /* seconds */
- long tv_usec; /* and microseconds */
-};
-#endif /* NT */
-#endif
-#include <signal.h>
-#include <errno.h>
-
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-
extern VALUE rb_last_status;
enum thread_status {
diff --git a/file.c b/file.c
index f22b742d257..e34a6f3a509 100644
--- a/file.c
+++ b/file.c
@@ -731,35 +731,35 @@ rb_file_s_size(obj, fname)
}
static VALUE
-rb_file_ftype(mode)
- mode_t mode;
+rb_file_ftype(st)
+ struct stat *st;
{
char *t;
- if (S_ISREG(mode)) {
+ if (S_ISREG(st->st_mode)) {
t = "file";
- } else if (S_ISDIR(mode)) {
+ } else if (S_ISDIR(st->st_mode)) {
t = "directory";
- } else if (S_ISCHR(mode)) {
+ } else if (S_ISCHR(st->st_mode)) {
t = "characterSpecial";
}
#ifdef S_ISBLK
- else if (S_ISBLK(mode)) {
+ else if (S_ISBLK(st->st_mode)) {
t = "blockSpecial";
}
#endif
#ifdef S_ISFIFO
- else if (S_ISFIFO(mode)) {
+ else if (S_ISFIFO(st->st_mode)) {
t = "fifo";
}
#endif
#ifdef S_ISLNK
- else if (S_ISLNK(mode)) {
+ else if (S_ISLNK(st->st_mode)) {
t = "link";
}
#endif
#ifdef S_ISSOCK
- else if (S_ISSOCK(mode)) {
+ else if (S_ISSOCK(st->st_mode)) {
t = "socket";
}
#endif
@@ -786,7 +786,7 @@ rb_file_s_ftype(obj, fname)
}
#endif
- return rb_file_ftype(st.st_mode);
+ return rb_file_ftype(&st);
}
static VALUE
@@ -1183,7 +1183,6 @@ rb_file_s_expand_path(argc, argv)
s = STR2CSTR(fname);
p = buf;
if (s[0] == '~') {
- tainted = 1;
if (isdirsep(s[1]) || s[1] == '\0') {
char *dir = getenv("HOME");
@@ -1193,6 +1192,7 @@ rb_file_s_expand_path(argc, argv)
strcpy(buf, dir);
p = &buf[strlen(buf)];
s++;
+ tainted = 1;
}
else {
#ifdef HAVE_PWD_H
@@ -1670,7 +1670,7 @@ static VALUE
rb_stat_ftype(obj)
VALUE obj;
{
- return rb_file_ftype(get_stat(obj)->st_mode);
+ return rb_file_ftype(get_stat(obj));
}
static VALUE
diff --git a/hash.c b/hash.c
index fed5b9e7ec4..bebb44b3d2e 100644
--- a/hash.c
+++ b/hash.c
@@ -550,7 +550,7 @@ rb_hash_replace(hash, hash2)
}
static VALUE
-rb_hash_length(hash)
+rb_hash_size(hash)
VALUE hash;
{
return INT2FIX(RHASH(hash)->tbl->num_entries);
@@ -1454,8 +1454,8 @@ Init_Hash()
rb_define_method(rb_cHash,"index", rb_hash_index, 1);
rb_define_method(rb_cHash,"indexes", rb_hash_indexes, -1);
rb_define_method(rb_cHash,"indices", rb_hash_indexes, -1);
- rb_define_method(rb_cHash,"length", rb_hash_length, 0);
- rb_define_alias(rb_cHash, "size", "length");
+ rb_define_method(rb_cHash,"size", rb_hash_size, 0);
+ rb_define_method(rb_cHash,"length", rb_hash_size, 0);
rb_define_method(rb_cHash,"empty?", rb_hash_empty_p, 0);
rb_define_method(rb_cHash,"each", rb_hash_each_pair, 0);
@@ -1503,6 +1503,7 @@ Init_Hash()
rb_define_singleton_method(envtbl,"index", env_index, 1);
rb_define_singleton_method(envtbl,"indexes", env_indexes, -1);
rb_define_singleton_method(envtbl,"indices", env_indexes, -1);
+ rb_define_singleton_method(envtbl,"size", env_size, 0);
rb_define_singleton_method(envtbl,"length", env_size, 0);
rb_define_singleton_method(envtbl,"empty?", env_empty_p, 0);
rb_define_singleton_method(envtbl,"keys", env_keys, 0);
diff --git a/intern.h b/intern.h
index 95f3ad517f2..45bb59e7bab 100644
--- a/intern.h
+++ b/intern.h
@@ -233,6 +233,7 @@ void rb_syswait _((int));
/* range.c */
VALUE rb_range_new _((VALUE, VALUE, int));
VALUE rb_range_beg_len _((VALUE, long*, long*, long, int));
+VALUE rb_length_by_each _((VALUE));
/* re.c */
VALUE rb_reg_nth_defined _((int, VALUE));
VALUE rb_reg_nth_match _((int, VALUE));
diff --git a/lib/cgi.rb b/lib/cgi.rb
index 96f55332632..4a17c8b1918 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -5,7 +5,7 @@ $Date$
CGI.rb
-Version 1.01
+Version 1.10
Copyright (C) 1999 Network Applied Communication Laboratory, Inc.
@@ -24,7 +24,7 @@ Wakou Aoyama <wakou@fsinet.or.jp>
# returns true if form has 'field_name'
cgi.has_key?('field_name')
- cgi.key?('field_name')
+ cgi.has_key?('field_name')
cgi.include?('field_name')
@@ -182,7 +182,7 @@ class CGI
EOL = CR + LF
v = $-v
$-v = false
- VERSION = "1.01"
+ VERSION = "1.10"
RELEASE_DATE = "$Date$"
$-v = v
@@ -391,11 +391,11 @@ status:
options = { "type" => options }
end
- unless options.key?("type")
+ unless options.has_key?("type")
options["type"] = "text/html"
end
- if options.key?("charset")
+ if options.has_key?("charset")
options["type"].concat( "; charset=" )
options["type"].concat( options.delete("charset") )
end
@@ -411,40 +411,40 @@ status:
"Date: " + CGI::rfc1123_date(Time.now) + EOL
)
- unless options.key?("server")
+ unless options.has_key?("server")
options["server"] = (env_table['SERVER_SOFTWARE'] or "")
end
- unless options.key?("connection")
+ unless options.has_key?("connection")
options["connection"] = "close"
end
end
options.delete("status")
- if options.key?("server")
+ if options.has_key?("server")
buf.concat("Server: " + options.delete("server") + EOL)
end
- if options.key?("connection")
+ if options.has_key?("connection")
buf.concat("Connection: " + options.delete("connection") + EOL)
end
buf.concat("Content-Type: " + options.delete("type") + EOL)
- if options.key?("length")
+ if options.has_key?("length")
buf.concat("Content-Length: " + options.delete("length").to_s + EOL)
end
- if options.key?("language")
+ if options.has_key?("language")
buf.concat("Content-Language: " + options.delete("language") + EOL)
end
- if options.key?("expires")
+ if options.has_key?("expires")
buf.concat("Expires: " + CGI::rfc1123_date( options.delete("expires") ) + EOL)
end
- if options.key?("cookie")
+ if options.has_key?("cookie")
if options["cookie"].kind_of?(String) or
options["cookie"].kind_of?(Cookie)
buf.concat("Set-Cookie: " + options.delete("cookie").to_s + EOL)
@@ -468,7 +468,7 @@ status:
buf.concat(key + ": " + value + EOL)
}
- if env_table['MOD_RUBY']
+ if defined?(MOD_RUBY)
buf.scan(/([^:]+): (.+)#{EOL}/n){
Apache::request[$1] = $2
}
@@ -518,18 +518,18 @@ convert string charset, and set language to "ja".
options = { "type" => options } if options.kind_of?(String)
content = yield
- if options.key?("charset")
+ if options.has_key?("charset")
require "nkf"
case options["charset"]
when /iso-2022-jp/ni
content = NKF::nkf('-j', content)
- options["language"] = "ja" unless options.key?("language")
+ options["language"] = "ja" unless options.has_key?("language")
when /euc-jp/ni
content = NKF::nkf('-e', content)
- options["language"] = "ja" unless options.key?("language")
+ options["language"] = "ja" unless options.has_key?("language")
when /shift_jis/ni
content = NKF::nkf('-s', content)
- options["language"] = "ja" unless options.key?("language")
+ options["language"] = "ja" unless options.has_key?("language")
end
end
@@ -588,7 +588,7 @@ convert string charset, and set language to "ja".
else
name
end
- unless options.key?("name")
+ unless options.has_key?("name")
raise ArgumentError, "`name' required"
end
@@ -653,7 +653,7 @@ convert string charset, and set language to "ja".
name, values = pairs.split('=',2)
name = CGI::unescape(name)
values = values.split('&').filter{|v| CGI::unescape(v) }
- if cookies.key?(name)
+ if cookies.has_key?(name)
cookies[name].value.push(*values)
else
cookies[name] = Cookie::new({ "name" => name, "value" => values })
@@ -675,7 +675,7 @@ convert string charset, and set language to "ja".
query.split(/[&;]/n).each do |pairs|
key, value = pairs.split('=',2).filter{|v| CGI::unescape(v) }
- if params.key?(key)
+ if params.has_key?(key)
params[key].push(value)
else
params[key] = [value]
@@ -812,7 +812,7 @@ convert string charset, and set language to "ja".
/Content-Disposition:.* name="?([^\";]*)"?/ni === head
name = $1.dup
- if params.key?(name)
+ if params.has_key?(name)
params[name].push(body)
else
params[name] = [body]
@@ -863,7 +863,7 @@ convert string charset, and set language to "ja".
@params = CGI::parse(
case env_table['REQUEST_METHOD']
when "GET", "HEAD"
- if env_table['MOD_RUBY']
+ if defined?(MOD_RUBY)
Apache::request.args or ""
else
env_table['QUERY_STRING'] or ""
@@ -958,8 +958,8 @@ convert string charset, and set language to "ja".
# - -
def nn_element_def(element)
<<-END.gsub(/element\.downcase/n, element.downcase).gsub(/element\.upcase/n, element.upcase)
- attributes.delete_if{|k,v| v == nil }
"<element.upcase" + attributes.collect{|name, value|
+ next if value == nil
" " + CGI::escapeHTML(name) +
if true == value
""
@@ -979,8 +979,8 @@ convert string charset, and set language to "ja".
# - O EMPTY
def nOE_element_def(element)
<<-END.gsub(/element\.downcase/n, element.downcase).gsub(/element\.upcase/n, element.upcase)
- attributes.delete_if{|k,v| v == nil }
"<element.upcase" + attributes.collect{|name, value|
+ next if value == nil
" " + CGI::escapeHTML(name) +
if true == value
""
@@ -994,8 +994,8 @@ convert string charset, and set language to "ja".
# O O or - O
def nO_element_def(element)
<<-END.gsub(/element\.downcase/n, element.downcase).gsub(/element\.upcase/n, element.upcase)
- attributes.delete_if{|k,v| v == nil }
"<element.upcase" + attributes.collect{|name, value|
+ next if value == nil
" " + CGI::escapeHTML(name) +
if true == value
""
@@ -1210,10 +1210,10 @@ convert string charset, and set language to "ja".
{ "METHOD" => method, "ACTION" => action,
"ENCTYPE" => enctype }
else
- unless method.key?("METHOD")
+ unless method.has_key?("METHOD")
method["METHOD"] = method
end
- unless method.key?("ENCTYPE")
+ unless method.has_key?("ENCTYPE")
method["ENCTYPE"] = enctype
end
method
@@ -1298,7 +1298,7 @@ convert string charset, and set language to "ja".
pretty = attributes.delete("PRETTY")
buf = ""
- if attributes.key?("DOCTYPE")
+ if attributes.has_key?("DOCTYPE")
if attributes["DOCTYPE"]
buf.concat( attributes.delete("DOCTYPE") )
else
@@ -1381,10 +1381,10 @@ convert string charset, and set language to "ja".
{ "METHOD" => "post", "ACTION" => action,
"ENCTYPE" => enctype }
else
- unless action.key?("METHOD")
+ unless action.has_key?("METHOD")
action["METHOD"] = "post"
end
- unless action.key?("ENCTYPE")
+ unless action.has_key?("ENCTYPE")
action["ENCTYPE"] = enctype
end
action
@@ -1837,27 +1837,18 @@ convert string charset, and set language to "ja".
def initialize(type = "query")
- @params = nil
- @cookies = nil
+ extend QueryExtension
+ if defined?(CGI_PARAMS)
+ @params = CGI_PARAMS.nil? ? nil : CGI_PARAMS.dup
+ @cookies = CGI_COOKIES.nil? ? nil : CGI_COOKIES.dup
+ else
+ initialize_query() # set @params, @cookies
+ eval "CGI_PARAMS = @params.nil? ? nil : @params.dup"
+ eval "CGI_COOKIES = @cookies.nil? ? nil : @cookies.dup"
+ end
@output_cookies = nil
@output_hidden = nil
- extend QueryExtension
-
- #if defined? CGI::PARAMS
- # @params = "C" + (CGI::PARAMS.nil? ? nil : CGI::PARAMS.dup).inspect
- # @cookies = "C" + (CGI::COOKIES.nil? ? nil : CGI::COOKIES.dup).inspect
- #else
- initialize_query()
- # @params, @cookies initialized in initialize_query
- # eval "PARAMS = @params.nil? ? nil : @params.dup"
- # eval "COOKIES = @cookies.nil? ? nil : @cookies.dup"
- # at_exit {
- # remove_const(PARAMS)
- # remove_const(COOKIES)
- # }
- #end
-
case type
when "html3"
extend Html3
@@ -1873,6 +1864,17 @@ convert string charset, and set language to "ja".
extend HtmlExtension
end
end
+
+ if defined?(MOD_RUBY) and (RUBY_VERSION < "1.4.3")
+ raise "Please, use ruby1.4.3 or later."
+ else
+ at_exit() do
+ if defined?(CGI_PARAMS)
+ remove_const(:CGI_PARAMS)
+ remove_const(:CGI_COOKIES)
+ end
+ end
+ end
end
@@ -1880,6 +1882,13 @@ end
== HISTRY
+=== Version 1.10 - wakou
+
+1999/12/06 20:16:34
+
+- can make many CGI objects.
+- if use mod_ruby, then require ruby1.4.3 or later.
+
=== Version 1.01 - wakou
1999/11/29 21:35:58
diff --git a/range.c b/range.c
index f521c1405d2..8af5b69d5db 100644
--- a/range.c
+++ b/range.c
@@ -263,6 +263,25 @@ range_inspect(range)
}
static VALUE
+length_i(i, length)
+ VALUE i;
+ int *length;
+{
+ (*length)++;
+ return Qnil;
+}
+
+VALUE
+rb_length_by_each(obj)
+ VALUE obj;
+{
+ int length = 0;
+
+ rb_iterate(rb_each, obj, length_i, (VALUE)&length);
+ return INT2FIX(length);
+}
+
+static VALUE
range_length(range)
VALUE range;
{
@@ -284,7 +303,7 @@ range_length(range)
}
}
if (!rb_obj_is_kind_of(beg, rb_cNumeric)) {
- return rb_enum_length(range);
+ return rb_length_by_each(range);
}
size = rb_funcall(end, '-', 1, beg);
if (!EXCL(range)) {
diff --git a/ruby.c b/ruby.c
index b5c632b4e39..50e425b5628 100644
--- a/ruby.c
+++ b/ruby.c
@@ -73,7 +73,7 @@ usage(name)
const char *name;
{
/* This message really ought to be max 23 lines.
- * Removed -h because the user already knows that opton. Others? */
+ * Removed -h because the user already knows that option. Others? */
static char *usage_msg[] = {
"-0[octal] specify record separator (\\0, if no argument)",
@@ -621,9 +621,9 @@ proc_options(argc, argv)
argc--; argv++;
}
- process_sflag();
ruby_script(script);
ruby_set_argv(argc, argv);
+ process_sflag();
Init_ext(); /* should be called here for some reason :-( */
require_libraries();
diff --git a/string.c b/string.c
index ee22f202e44..df416877c3a 100644
--- a/string.c
+++ b/string.c
@@ -2603,7 +2603,7 @@ Init_String()
rb_define_method(rb_cString, "[]", rb_str_aref_method, -1);
rb_define_method(rb_cString, "[]=", rb_str_aset_method, -1);
rb_define_method(rb_cString, "length", rb_str_length, 0);
- rb_define_alias(rb_cString, "size", "length");
+ rb_define_method(rb_cString, "size", rb_str_length, 0);
rb_define_method(rb_cString, "empty?", rb_str_empty, 0);
rb_define_method(rb_cString, "=~", rb_str_match, 1);
rb_define_method(rb_cString, "~", rb_str_match2, 0);
diff --git a/struct.c b/struct.c
index 50b273b5a42..b14b82065c6 100644
--- a/struct.c
+++ b/struct.c
@@ -547,6 +547,13 @@ rb_struct_hash(s)
return INT2FIX(h);
}
+static VALUE
+rb_struct_size(s)
+ VALUE s;
+{
+ return INT2FIX(RSTRUCT(s)->len);
+}
+
void
Init_Struct()
{
@@ -566,6 +573,8 @@ Init_Struct()
rb_define_method(rb_cStruct, "inspect", rb_struct_inspect, 0);
rb_define_method(rb_cStruct, "to_a", rb_struct_to_a, 0);
rb_define_method(rb_cStruct, "values", rb_struct_to_a, 0);
+ rb_define_method(rb_cStruct, "size", rb_struct_size, 0);
+ rb_define_method(rb_cStruct, "length", rb_struct_size, 0);
rb_define_method(rb_cStruct, "each", rb_struct_each, 0);
rb_define_method(rb_cStruct, "[]", rb_struct_aref, 1);
diff --git a/version.h b/version.h
index 508325f620d..2a54764a1ad 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.0"
-#define RUBY_RELEASE_DATE "1999-12-06"
+#define RUBY_RELEASE_DATE "1999-12-07"
#define RUBY_VERSION_CODE 150
-#define RUBY_RELEASE_CODE 19991206
+#define RUBY_RELEASE_CODE 19991207