Permalink
Browse files

* random.c: replace with Mersenne Twister RNG.

* eval.c (jump_tag_but_local_jump): preserve retval in
  LocalJumpError exceptions.

* parse.y (command): no more check for "super outside of method".

* eval.c (rb_mod_define_method): should set last_class and
  last_func in the block->frame.

* eval.c (error_handle): should handle TAG_THROW as well.

* parse.y (yylex): new decimal notation '0d4567'.

* parse.y (yylex): new octal notation '0o777'.

* parse.y (string_content): every string_content node should
  return string only.  use NODE_EVSTR to coercing.

* eval.c (rb_eval): NODE_EVSTR support.

* re.c (rb_reg_quote): avoid unnecessary string allocation.

* string.c (get_pat): quote metachracters before compiling a
  string into a regex.

* string.c (rb_str_split_m): special treatment of strings of size
  1, but AWK emulation.  now uses get_pat().

* string.c (rb_str_match_m): quote metacharacters.

* string.c (rb_str_match2): ditto.

* ext/socket/socket.c (sock_addrinfo): make all 3 versions of
  getaddrinfo happy.  [ruby-core:00184]


git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent bb1c035 commit c932081ea8f9d106e8b87c938412654b3381cf09 matz committed Jul 26, 2002
Showing with 462 additions and 207 deletions.
  1. +52 −0 ChangeLog
  2. +47 −0 LEGAL
  3. +1 −0 ToDo
  4. +3 −7 bignum.c
  5. +28 −4 eval.c
  6. +1 −1 gc.c
  7. +1 −1 intern.h
  8. +1 −1 node.h
  9. +2 −1 numeric.c
  10. +50 −28 parse.y
  11. +155 −80 random.c
  12. +46 −14 re.c
  13. +1 −0 re.h
  14. +74 −70 string.c
View
@@ -1,3 +1,7 @@
+Fri Jul 26 14:31:06 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * random.c: replace with Mersenne Twister RNG.
+
Fri Jul 26 12:14:48 2002 Minero Aoki <aamine@loveruby.net>
* parse.y (yylex): modify to accept a code like "m (a){...}".
@@ -22,6 +26,24 @@ Thu Jul 25 09:05:02 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* misc/ruby-mode.el (ruby-move-to-block): skips RD style comments.
+Wed Jul 24 09:47:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (jump_tag_but_local_jump): preserve retval in
+ LocalJumpError exceptions.
+
+ * parse.y (command): no more check for "super outside of method".
+
+ * eval.c (rb_mod_define_method): should set last_class and
+ last_func in the block->frame.
+
+Mon Jul 22 17:23:00 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (error_handle): should handle TAG_THROW as well.
+
+Fri Jul 19 10:52:32 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): new decimal notation '0d4567'.
+
Thu Jul 18 11:52:02 2002 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/ftp.rb (set_socket): new method.
@@ -30,6 +52,17 @@ Thu Jul 18 06:51:24 2002 Minero Aoki <aamine@loveruby.net>
* parse.y (yylex): fix typo.
+Wed Jul 17 18:41:28 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): new octal notation '0o777'.
+
+Mon Jul 15 18:36:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (string_content): every string_content node should
+ return string only. use NODE_EVSTR to coercing.
+
+ * eval.c (rb_eval): NODE_EVSTR support.
+
Mon Jul 15 10:35:35 2002 Minero Aoki <aamine@loveruby.net>
* parse.y (heredoc_identifier): fix typo.
@@ -61,6 +94,20 @@ Fri Jul 12 00:02:50 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* ext/stringio/stringio.c (strio_gets_internal): fixed for record
separator longer than 1.
+Thu Jul 11 17:59:20 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_quote): avoid unnecessary string allocation.
+
+ * string.c (get_pat): quote metachracters before compiling a
+ string into a regex.
+
+ * string.c (rb_str_split_m): special treatment of strings of size
+ 1, but AWK emulation. now uses get_pat().
+
+ * string.c (rb_str_match_m): quote metacharacters.
+
+ * string.c (rb_str_match2): ditto.
+
Thu Jul 11 12:59:23 2002 Shugo Maeda <shugo@ruby-lang.org>
* lib/resolv.rb: untaint strings read from /etc/hosts and
@@ -256,6 +303,11 @@ Sun Jun 23 00:19:10 2002 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date.rb, lib/date/format.rb, sample/cal.rb, sample/goodfriday.rb:
updated to the new version (based on date2 3.3).
+Sat Jun 22 14:41:33 2002 Guy Decoux <ts@moulon.inra.fr>
+
+ * ext/socket/socket.c (sock_addrinfo): make all 3 versions of
+ getaddrinfo happy. [ruby-core:00184]
+
Fri Jun 21 18:49:58 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (yylex): __END__ should not be effective within
View
47 LEGAL
@@ -83,6 +83,53 @@ win32/win32.[ch]:
You may distribute under the terms of either the GNU General Public
License or the Artistic License, as specified in the perl README file.
+random.c
+
+ This file is under the new-style BSD license.
+
+ A C-program for MT19937, with initialization improved 2002/2/10.
+ Coded by Takuji Nishimura and Makoto Matsumoto.
+ This is a faster version by taking Shawn Cokus's optimization,
+ Matthe Bellew's simplification, Isaku Wada's real version.
+
+ Before using, initialize the state by using init_genrand(seed)
+ or init_by_array(init_key, key_length).
+
+ Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The names of its contributors may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+ Any feedback is very welcome.
+ http://www.math.keio.ac.jp/matumoto/emt.html
+ email: matumoto@math.keio.ac.jp
+
st.[ch]:
x68/*:
missing/alloca.c:
View
1 ToDo
@@ -78,6 +78,7 @@ Standard Libraries
- Hash::new{default}
- hash etc. should handle self referenceing array/hash
- Array#select(n1,n2...) works like Array#indexes(n1,n2...)
+- use Mersenne Twister RNG for random.
* String#scanf(?)
* Object#fmt(?)
* Time::strptime
View
@@ -1675,22 +1675,18 @@ rb_big_abs(x)
return x;
}
-/* !!!warnig!!!!
- this is not really a random number!!
-*/
-
VALUE
-rb_big_rand(max, rand)
+rb_big_rand(max, rand_buf)
VALUE max;
- double rand;
+ double *rand_buf;
{
VALUE v;
long len;
len = RBIGNUM(max)->len;
v = bignew(len,1);
while (len--) {
- BDIGITS(v)[len] = ((BDIGIT)~0) * rand;
+ BDIGITS(v)[len] = ((BDIGIT)~0) * rand_buf[len];
}
return rb_big_modulo((VALUE)v, max);
View
32 eval.c
@@ -1141,6 +1141,17 @@ error_handle(ex)
fprintf(stderr, ": retry outside of rescue clause\n");
ex = 1;
break;
+ case TAG_THROW:
+ if (prot_tag && prot_tag->frame && prot_tag->frame->file) {
+ fprintf(stderr, "%s:%d: uncaught throw\n",
+ prot_tag->frame->file, prot_tag->frame->line);
+ }
+ else {
+ error_pos();
+ fprintf(stderr, ": unexpected throw\n");
+ }
+ ex = 1;
+ break;
case TAG_RAISE:
case TAG_FATAL:
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
@@ -1354,17 +1365,21 @@ static void
jump_tag_but_local_jump(state)
int state;
{
+ VALUE val;
+
+ if (prot_tag) val = prot_tag->retval;
+ else val = Qnil;
switch (state) {
case 0:
break;
case TAG_RETURN:
- localjump_error("unexpected return", Qnil);
+ localjump_error("unexpected return", val);
break;
case TAG_NEXT:
- localjump_error("unexpected next", Qnil);
+ localjump_error("unexpected next", val);
break;
case TAG_BREAK:
- localjump_error("unexpected break", Qnil);
+ localjump_error("unexpected break", val);
break;
case TAG_REDO:
localjump_error("unexpected redo", Qnil);
@@ -1412,7 +1427,6 @@ rb_eval_cmd(cmd, arg, tcheck)
if ((state = EXEC_TAG()) == 0) {
val = eval(ruby_top_self, cmd, Qnil, 0, 0);
}
-
if (ruby_scope->flags & SCOPE_DONT_RECYCLE)
scope_dup(saved_scope);
ruby_scope = saved_scope;
@@ -3059,6 +3073,10 @@ rb_eval(self, n)
result = rb_str_new3(node->nd_lit);
break;
+ case NODE_EVSTR:
+ result = rb_obj_as_string(rb_eval(self, node->nd_body));
+ break;
+
case NODE_DSTR:
case NODE_DXSTR:
case NODE_DREGX:
@@ -7102,6 +7120,12 @@ rb_mod_define_method(argc, argv, mod)
node = NEW_DMETHOD(method_unbind(body));
}
else if (RDATA(body)->dmark == (RUBY_DATA_FUNC)blk_mark) {
+ struct BLOCK *block;
+
+ body = bind_clone(body);
+ Data_Get_Struct(body, struct BLOCK, block);
+ block->frame.last_func = id;
+ block->frame.last_class = mod;
node = NEW_BMETHOD(body);
}
else {
View
2 gc.c
@@ -651,7 +651,6 @@ rb_gc_mark_children(ptr)
case NODE_ARRAY:
case NODE_DSTR:
case NODE_DXSTR:
- case NODE_EVSTR:
case NODE_DREGX:
case NODE_DREGX_ONCE:
case NODE_FBODY:
@@ -697,6 +696,7 @@ rb_gc_mark_children(ptr)
case NODE_MODULE:
case NODE_COLON3:
case NODE_OPT_N:
+ case NODE_EVSTR:
rb_gc_mark((VALUE)obj->as.node.u2.node);
break;
View
@@ -89,7 +89,7 @@ VALUE rb_big_and _((VALUE, VALUE));
VALUE rb_big_or _((VALUE, VALUE));
VALUE rb_big_xor _((VALUE, VALUE));
VALUE rb_big_lshift _((VALUE, VALUE));
-VALUE rb_big_rand _((VALUE, double));
+VALUE rb_big_rand _((VALUE, double*));
/* class.c */
VALUE rb_class_boot _((VALUE));
VALUE rb_class_new _((VALUE));
View
2 node.h
@@ -294,7 +294,7 @@ typedef struct RNode {
#define NEW_DSTR(s) rb_node_newnode(NODE_DSTR,s,0,0)
#define NEW_XSTR(s) rb_node_newnode(NODE_XSTR,s,0,0)
#define NEW_DXSTR(s) rb_node_newnode(NODE_DXSTR,s,0,0)
-#define NEW_EVSTR(s,l) rb_node_newnode(NODE_EVSTR,rb_str_new(s,l),0,0)
+#define NEW_EVSTR(n) rb_node_newnode(NODE_EVSTR,0,(n),0)
#define NEW_CALL(r,m,a) rb_node_newnode(NODE_CALL,r,m,a)
#define NEW_FCALL(m,a) rb_node_newnode(NODE_FCALL,0,m,a)
#define NEW_VCALL(m) rb_node_newnode(NODE_VCALL,0,m,0)
View
@@ -861,6 +861,7 @@ rb_num2long(val)
case T_BIGNUM:
return rb_big2long(val);
+#if 0
case T_STRING:
rb_raise(rb_eTypeError, "no implicit conversion to integer from string");
return Qnil; /* not reached */
@@ -869,7 +870,7 @@ rb_num2long(val)
case T_FALSE:
rb_raise(rb_eTypeError, "no implicit conversion to integer from boolean");
return Qnil; /* not reached */
-
+#endif
default:
val = rb_to_int(val);
return NUM2LONG(val);
Oops, something went wrong.

0 comments on commit c932081

Please sign in to comment.