summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-10-29 09:25:48 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-10-29 09:25:48 +0000
commit0d684beafb4258da9606b1e3b4448511b709a2e2 (patch)
tree4a0007dc6a1e7e8ae71ad40000b9ba56332dbaf2
parentcd2af215d4d438bcb217ffce94c208e229dfe58a (diff)
19991029
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog34
-rw-r--r--README.jp2
-rw-r--r--ToDo5
-rw-r--r--array.c20
-rw-r--r--configure2
-rw-r--r--configure.in2
-rw-r--r--enum.c24
-rw-r--r--ext/nkf/lib/kconv.rb15
-rw-r--r--intern.h2
-rw-r--r--io.c6
-rw-r--r--misc/ruby-mode.el10
-rw-r--r--node.h8
-rw-r--r--process.c4
-rw-r--r--string.c1
-rw-r--r--time.c18
-rw-r--r--win32/ruby.def1
16 files changed, 119 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index c551e1792a..f656705e3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+Fri Oct 29 16:57:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/nkf/lib/kconv.rb: new String methods (kconv, tojis, toeuc,
+ tosjis).
+
+ * time.c (time_s_at): now accepts optional second argument to
+ specify micro second.
+
+Thu Oct 28 13:35:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_split_method): should be mbchar aware with
+ single char separators.
+
+Wed Oct 27 12:57:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * random.c (rb_f_srand): random seed should be unsigned.
+
+Tue Oct 26 23:58:15 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_collect): collect for better performance.
+
+Tue Oct 26 19:20:54 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * marshal.c (r_object): should register class/module objects.
+
+Sat Oct 23 15:59:39 1999 Takaaki Tateishi <ttate@jaist.ac.jp>
+
+ * process.c (rb_f_system): should require at least one argument.
+
+Sat Oct 23 12:42:44 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * enum.c (enum_collect): collect without block will collect
+ elements in enumerable.
+
Thu Oct 21 16:14:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* ruby.c (moreswitches): function to process string option;
diff --git a/README.jp b/README.jp
index 19e5e0c896..6c320c89f4 100644
--- a/README.jp
+++ b/README.jp
@@ -10,7 +10,7 @@ Rubyはテキスト処理関係の能力などに優れ,Perlと同じくらい強力
によって,より分かりやすいプログラミングが出来ます.
-* Rubyの特長.
+* Rubyの特長
+ シンプルな文法
+ 普通のオブジェクト指向機能(クラス,メソッドコールなど)
diff --git a/ToDo b/ToDo
index 793565a0e6..adb8a6c07a 100644
--- a/ToDo
+++ b/ToDo
@@ -2,6 +2,8 @@ Language Spec.
- def foo; .. rescue .. end
- compile time string concatenation, "hello" "world" => "helloworld"
+* objectify symbols
+* objectify characters
* ../... outside condition invokes operator method too.
* %w(a\ b\ c abc) => ["a b c", "abc"]
* package or access control for global variables
@@ -46,6 +48,7 @@ Extension Libraries
- FastCGI ruby
* ptk.rb pTk wrapper that is compatible to tk.rb
+* Berkeley DB extension
Ruby Libraries
@@ -54,7 +57,7 @@ Ruby Libraries
Tools
-* extension library maker like XS or SWIG
+- extension library maker like XS or SWIG
* freeze or undump to bundle everything
Misc
diff --git a/array.c b/array.c
index 0615da7551..2cc9a07c89 100644
--- a/array.c
+++ b/array.c
@@ -934,6 +934,25 @@ rb_ary_sort(ary)
return ary;
}
+static VALUE
+rb_ary_collect(ary)
+ VALUE ary;
+{
+ long len, i;
+ VALUE collect;
+
+ if (!rb_iterator_p()) {
+ return rb_ary_dup(ary);
+ }
+
+ len = RARRAY(ary)->len;
+ collect = rb_ary_new2(len);
+ for (i=0; i<len; i++) {
+ rb_ary_push(collect, rb_yield(RARRAY(ary)->ptr[i]));
+ }
+ return collect;
+}
+
VALUE
rb_ary_delete(ary, item)
VALUE ary;
@@ -1494,6 +1513,7 @@ Init_Array()
rb_define_method(rb_cArray, "reverse!", rb_ary_reverse, 0);
rb_define_method(rb_cArray, "sort", rb_ary_sort, 0);
rb_define_method(rb_cArray, "sort!", rb_ary_sort_bang, 0);
+ rb_define_method(rb_cArray, "collect", rb_ary_collect, 0);
rb_define_method(rb_cArray, "delete", rb_ary_delete, 1);
rb_define_method(rb_cArray, "delete_at", rb_ary_delete_at, 1);
rb_define_method(rb_cArray, "delete_if", rb_ary_delete_if, 0);
diff --git a/configure b/configure
index 806621ee08..6399835110 100644
--- a/configure
+++ b/configure
@@ -4093,7 +4093,7 @@ echo "configure:4028: checking whether OS depend dynamic link works" >&5
rb_cv_dlopen=yes ;;
esac ;;
bsdi*) LDSHARED="ld -shared"
- LDFLAGS="-rdynamic -Wl,-rpath,/usr/local/lib/ruby/1.4/i386-bsdi4.0"
+ LDFLAGS='-rdynamic -Wl,-rpath,$(prefix)/lib/ruby/$(MAJOR).$(MINOR)/i386-bsdi4.0'
rb_cv_dlopen=yes ;;
nextstep*) LDSHARED='cc -r -nostdlib'
LDFLAGS="-u libsys_s"
diff --git a/configure.in b/configure.in
index a4b5264f87..9f3030b5c0 100644
--- a/configure.in
+++ b/configure.in
@@ -437,7 +437,7 @@ if test "$with_dln_a_out" != yes; then
rb_cv_dlopen=yes ;;
esac ;;
bsdi*) LDSHARED="ld -shared"
- LDFLAGS="-rdynamic -Wl,-rpath,/usr/local/lib/ruby/1.4/i386-bsdi4.0"
+ LDFLAGS='-rdynamic -Wl,-rpath,$(prefix)/lib/ruby/$(MAJOR).$(MINOR)/i386-bsdi4.0'
rb_cv_dlopen=yes ;;
nextstep*) LDSHARED='cc -r -nostdlib'
LDFLAGS="-u libsys_s"
diff --git a/enum.c b/enum.c
index dc7e2112a4..05194c1f52 100644
--- a/enum.c
+++ b/enum.c
@@ -153,18 +153,6 @@ collect_i(i, tmp)
}
static VALUE
-enum_collect(obj)
- VALUE obj;
-{
- VALUE tmp;
-
- tmp = rb_ary_new();
- rb_iterate(rb_each, obj, collect_i, tmp);
-
- return tmp;
-}
-
-static VALUE
enum_all(i, ary)
VALUE i, ary;
{
@@ -185,6 +173,18 @@ enum_to_a(obj)
}
static VALUE
+enum_collect(obj)
+ VALUE obj;
+{
+ VALUE tmp;
+
+ tmp = rb_ary_new();
+ rb_iterate(rb_each, obj, rb_iterator_p() ? collect_i : enum_all, tmp);
+
+ return tmp;
+}
+
+static VALUE
enum_sort(obj)
VALUE obj;
{
diff --git a/ext/nkf/lib/kconv.rb b/ext/nkf/lib/kconv.rb
index bfd276330d..af6d82275f 100644
--- a/ext/nkf/lib/kconv.rb
+++ b/ext/nkf/lib/kconv.rb
@@ -56,3 +56,18 @@ module Kconv
end
module_function :guess
end
+
+class String
+ def kconv(out_code, in_code=Kconv::AUTO)
+ Kconv::kconv(self, out_code, in_code)
+ end
+ def tojis
+ NKF::nkf('-j', self)
+ end
+ def toeuc
+ NKF::nkf('-e', self)
+ end
+ def tosjis
+ NKF::nkf('-s', self)
+ end
+end
diff --git a/intern.h b/intern.h
index 5dda14481c..40b804011c 100644
--- a/intern.h
+++ b/intern.h
@@ -82,7 +82,7 @@ VALUE rb_singleton_class _((VALUE));
/* enum.c */
VALUE rb_enum_length _((VALUE));
/* error.c */
-extern int ruby_nerrs;
+EXTERN int ruby_nerrs;
VALUE rb_exc_new _((VALUE, const char*, long));
VALUE rb_exc_new2 _((VALUE, const char*));
VALUE rb_exc_new3 _((VALUE, VALUE));
diff --git a/io.c b/io.c
index ae5634e25b..8ee1683385 100644
--- a/io.c
+++ b/io.c
@@ -452,15 +452,15 @@ io_fread(ptr, len, f)
int c;
while (n--) {
+ if (!READ_DATA_PENDING(f)) {
+ rb_thread_wait_fd(fileno(f));
+ }
c = getc(f);
if (c == EOF) {
*ptr = '\0';
break;
}
*ptr++ = c;
- if (!READ_DATA_PENDING(f)) {
- rb_thread_wait_fd(fileno(f));
- }
}
return len - n - 1;
diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
index 50e4f50e87..41fd1f66f2 100644
--- a/misc/ruby-mode.el
+++ b/misc/ruby-mode.el
@@ -172,20 +172,14 @@ The variable ruby-indent-level controls the amount of indentation.
(defun ruby-indent-to (x)
(if x
(let (shift top beg)
- (and (< x 0)
- (error "invalid nest"))
+ (and (< x 0) (error "invalid nest"))
(setq shift (current-column))
(beginning-of-line)
(setq beg (point))
(back-to-indentation)
(setq top (current-column))
(skip-chars-backward " \t")
- (cond
- ((>= x shift)
- (setq shift 0))
- ((>= shift top)
- (setq shift (- shift top)))
- (t (setq shift 0)))
+ (if (>= shift top) (setq shift (- shift top)))
(if (and (bolp)
(= x top))
(move-to-column (+ x shift))
diff --git a/node.h b/node.h
index 4add37b47c..ea44a454d5 100644
--- a/node.h
+++ b/node.h
@@ -13,6 +13,10 @@
#ifndef NODE_H
#define NODE_H
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
enum node_type {
NODE_METHOD,
NODE_FBODY,
@@ -331,4 +335,8 @@ VALUE rb_gvar_get _((struct global_entry *));
VALUE rb_gvar_set _((struct global_entry *, VALUE));
VALUE rb_gvar_defined _((struct global_entry *));
+#if defined(__cplusplus)
+} /* extern "C" { */
+#endif
+
#endif
diff --git a/process.c b/process.c
index d5c2d5eb8a..57b4300ea4 100644
--- a/process.c
+++ b/process.c
@@ -644,7 +644,7 @@ rb_f_system(argc, argv)
fflush(stderr);
if (argc == 0) {
rb_last_status = INT2FIX(0);
- return INT2FIX(0);
+ rb_raise(rb_eArgError, "wrong # of arguments");
}
if (TYPE(argv[0]) == T_ARRAY) {
@@ -675,7 +675,7 @@ rb_f_system(argc, argv)
fflush(stderr);
if (argc == 0) {
rb_last_status = INT2FIX(0);
- return INT2FIX(0);
+ rb_raise(rb_eArgError, "wrong # of arguments");
}
if (TYPE(argv[0]) == T_ARRAY) {
diff --git a/string.c b/string.c
index af2db491d0..5fb4fdc0f1 100644
--- a/string.c
+++ b/string.c
@@ -2060,6 +2060,7 @@ rb_str_split_method(argc, argv, str)
if (!NIL_P(limit) && lim <= ++i) break;
}
end++;
+ if (ismbchar(*ptr)) ptr++;
}
}
}
diff --git a/time.c b/time.c
index dd22c499dd..4d18827597 100644
--- a/time.c
+++ b/time.c
@@ -152,13 +152,21 @@ rb_time_timeval(time)
}
static VALUE
-time_s_at(klass, time)
- VALUE klass, time;
+time_s_at(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
struct timeval tv;
- VALUE t;
+ VALUE time, t;
- tv = rb_time_timeval(time);
+ if (rb_scan_args(argc, argv, "11", &time, &t) == 2) {
+ tv.tv_sec = NUM2INT(time);
+ tv.tv_usec = NUM2INT(t);
+ }
+ else {
+ tv = rb_time_timeval(time);
+ }
t = time_new_internal(klass, tv.tv_sec, tv.tv_usec);
if (TYPE(time) == T_DATA) {
struct time_object *tobj, *tobj2;
@@ -978,7 +986,7 @@ Init_Time()
rb_define_singleton_method(rb_cTime, "now", time_s_now, 0);
rb_define_singleton_method(rb_cTime, "new", time_s_now, 0);
- rb_define_singleton_method(rb_cTime, "at", time_s_at, 1);
+ rb_define_singleton_method(rb_cTime, "at", time_s_at, -1);
rb_define_singleton_method(rb_cTime, "gm", time_s_timegm, -1);
rb_define_singleton_method(rb_cTime, "local", time_s_timelocal, -1);
rb_define_singleton_method(rb_cTime, "mktime", time_s_timelocal, -1);
diff --git a/win32/ruby.def b/win32/ruby.def
index 1c79697fd7..008452fa8d 100644
--- a/win32/ruby.def
+++ b/win32/ruby.def
@@ -31,6 +31,7 @@ EXPORTS
rb_eSystemCallError
rb_eZeroDivError
rb_mErrno
+ ruby_nerrs
;eval.c
rb_cProc
ruby_frame