1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

pass_block, etc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@74 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1998-02-16 06:05:46 +00:00
parent d18d1cea2e
commit b0edb6968f
5 changed files with 40 additions and 7 deletions

View file

@ -1,3 +1,11 @@
Mon Feb 16 14:38:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (f_pass_block): pass iterator block to other method.
* time.c (time_mon): now 1 for January and so on.
* time.c (time_year): year in 19xx (not + 1900 needed anymore).
Fri Feb 13 08:16:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y (parse_regx): handle \s before read_escape().

23
eval.c
View file

@ -3396,6 +3396,28 @@ f_send(argc, argv, recv)
return vid;
}
static VALUE
f_pass_block(argc, argv, recv)
int argc;
VALUE *argv;
VALUE recv;
{
VALUE vid;
if (argc == 0) ArgError("no iterator name given");
if (iterator_p())
ArgError("iterator block given to pass_block");
if (!f_iterator_p())
ArgError("pass_block called out of iterator");
vid = argv[0]; argc--; argv++;
PUSH_ITER(ITER_PRE);
vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, 1);
POP_ITER();
return vid;
}
#include <varargs.h>
VALUE
@ -4248,6 +4270,7 @@ Init_eval()
rb_define_global_function("global_variables", f_global_variables, 0);
rb_define_method(mKernel, "send", f_send, -1);
rb_define_method(mKernel, "pass_block", f_pass_block, -1);
rb_define_method(mKernel, "instance_eval", obj_instance_eval, 1);
rb_define_private_method(cModule, "append_features", mod_append_features, 1);

View file

@ -11,7 +11,7 @@ module ParseDate
def parsedate(date)
# ISO 8601?
if date =~ /(\d\d\d\d)-?(?:(\d\d)-?(\d\d)?)? *(?:(\d\d):(\d\d)(?::(\d\d))?)?/
if date =~ /^(\d\d\d\d)-?(?:(\d\d)-?(\d\d)?)? *(?:(\d\d):(\d\d)(?::(\d\d))?)?$/
return $1.to_i,
if $2 then $2.to_i else 1 end,
if $3 then $3.to_i else 1 end,
@ -25,7 +25,7 @@ module ParseDate
if date.sub!(/(#{DAYPAT})[a-z]*,?/i, ' ')
wday = DAYS[$1.downcase]
end
if date.sub!(/(\d+):(\d+)(?::(\d+))?\s*(am|pm)?\s*(?:\s+([a-z]{1,4}(?:\s+[a-z]{1,4})|[-+]\d{4}))?/i, ' ')
if date.sub!(/(\d+):(\d+)(?::(\d+))?\s*(am|pm)?\s*(?:\s+([a-z]{1,4}(?:\s+[a-z]{1,4})?|[-+]\d{4}))?/i, ' ')
hour = $1.to_i
min = $2.to_i
if $3

View file

@ -32,13 +32,15 @@ end
if ARGV.length == 0
user = ENV['USER']
else
user = ARGV[0]
file = user = ARGV[0]
ARGV.clear
end
file = ARGV[0]
[ENV['SPOOLDIR'], '/usr/spool', '/var/spool', '/usr', '/var'].each do |m|
break if File.exist? file = "#{m}/mail/#{user}"
if File.exist? f = "#{m}/mail/#{user}"
file = f
break
end
end
$outcount = 0;
@ -63,7 +65,7 @@ def fromout(date, from, subj)
end
from = from.kconv(lang).kjust(28)
subj = subj.kconv(lang).kjust(40)
printf "%02d/%02d/%02d [%s] %s\n",y,m,d,from,subj
printf "%02d/%02d/%02d [%s] %s\n",y%100,m,d,from,subj
$outcount += 1
end

View file

@ -323,7 +323,7 @@ EXPORTS
reg_regsub
rb_set_kcode
; ruby.c
rb_require_modules
ruby_require_modules
rb_load_file
ruby_script
ruby_prog_init