зеркало из https://github.com/github/ruby.git
19991012
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
758cb647c7
Коммит
be1fea072c
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
Mon Oct 11 17:42:25 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||||
|
|
||||||
|
* parse.y (rb_intern): should generate distinct ID_ATTRSET symbols
|
||||||
|
for the name with multiple `='s at the end.
|
||||||
|
|
||||||
|
* Makefile.in (CPPFLAGS): separate cpp flags from CFLAGS.
|
||||||
|
|
||||||
|
Mon Oct 11 07:27:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
|
* eval.c (rb_eval): should not execute the `else' clause on the
|
||||||
|
case the exceptions are handled by the `rescue' clause.
|
||||||
|
|
||||||
|
* signal.c (Init_signal): ignore SIGPIPE by default.
|
||||||
|
|
||||||
Mon Oct 4 12:42:32 1999 Kazuhiko Izawa <izawa@erec.che.tohoku.ac.jp>
|
Mon Oct 4 12:42:32 1999 Kazuhiko Izawa <izawa@erec.che.tohoku.ac.jp>
|
||||||
|
|
||||||
* pack.c (pack_unpack): % in printf format should be %%.
|
* pack.c (pack_unpack): % in printf format should be %%.
|
||||||
|
|
17
Makefile.in
17
Makefile.in
|
@ -12,7 +12,8 @@ AUTOCONF = autoconf
|
||||||
@SET_MAKE@
|
@SET_MAKE@
|
||||||
|
|
||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
CFLAGS = @CFLAGS@ -I. -I@srcdir@ -I@includedir@
|
CFLAGS = @CFLAGS@
|
||||||
|
CPPFLAGS = -I. -I@srcdir@ -I@includedir@
|
||||||
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
|
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
|
||||||
XLDFLAGS = @XLDFLAGS@
|
XLDFLAGS = @XLDFLAGS@
|
||||||
EXTLIBS =
|
EXTLIBS =
|
||||||
|
@ -38,7 +39,7 @@ LIBRUBY_ALIASES= @LIBRUBY_ALIASES@
|
||||||
LIBRUBY = @LIBRUBY@
|
LIBRUBY = @LIBRUBY@
|
||||||
LIBRUBYARG = @LIBRUBYARG@
|
LIBRUBYARG = @LIBRUBYARG@
|
||||||
|
|
||||||
EXTOBJS = dmyext.@OBJEXT@
|
EXTOBJS =
|
||||||
|
|
||||||
MAINOBJ = main.@OBJEXT@
|
MAINOBJ = main.@OBJEXT@
|
||||||
|
|
||||||
|
@ -83,20 +84,20 @@ OBJS = array.@OBJEXT@ \
|
||||||
all: miniruby$(EXEEXT) rbconfig.rb
|
all: miniruby$(EXEEXT) rbconfig.rb
|
||||||
@./miniruby$(EXEEXT) -Xext extmk.rb @EXTSTATIC@
|
@./miniruby$(EXEEXT) -Xext extmk.rb @EXTSTATIC@
|
||||||
|
|
||||||
miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) $(EXTOBJS)
|
miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) dmyext.@OBJEXT@
|
||||||
@rm -f $@
|
@rm -f $@
|
||||||
$(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY_A) $(LIBS) -o $@
|
$(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) dmyext.@OBJEXT@ $(LIBRUBY_A) $(LIBS) -o $@
|
||||||
|
|
||||||
$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS)
|
$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS)
|
||||||
@rm -f $@
|
@rm -f $@
|
||||||
$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
|
$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
|
||||||
|
|
||||||
$(LIBRUBY_A): $(OBJS)
|
$(LIBRUBY_A): $(OBJS) dmyext.@OBJEXT@
|
||||||
@AR@ rcu $@ $(OBJS)
|
@AR@ rcu $@ $(OBJS) dmyext.@OBJEXT@
|
||||||
@-@RANLIB@ $@ 2> /dev/null || true
|
@-@RANLIB@ $@ 2> /dev/null || true
|
||||||
|
|
||||||
$(LIBRUBY_SO): $(OBJS)
|
$(LIBRUBY_SO): $(OBJS) dmyext.@OBJEXT@
|
||||||
$(LDSHARED) $(DLDFLAGS) $(SOLIBS) $(OBJS) -o $@
|
$(LDSHARED) $(DLDFLAGS) $(SOLIBS) $(OBJS) dmyext.@OBJEXT@ -o $@
|
||||||
@-./miniruby -e 'ARGV.each{|link| File.delete link if File.exist? link; \
|
@-./miniruby -e 'ARGV.each{|link| File.delete link if File.exist? link; \
|
||||||
File.symlink "$(LIBRUBY_SO)", link}' \
|
File.symlink "$(LIBRUBY_SO)", link}' \
|
||||||
$(LIBRUBY_ALIASES) || true
|
$(LIBRUBY_ALIASES) || true
|
||||||
|
|
|
@ -874,6 +874,10 @@ Returns the name corresponding ID.
|
||||||
|
|
||||||
Returns the name of the class.
|
Returns the name of the class.
|
||||||
|
|
||||||
|
int rb_respond_to(VALUE object, ID id)
|
||||||
|
|
||||||
|
Returns true if the object reponds to the message specified by id.
|
||||||
|
|
||||||
** Instance Variables
|
** Instance Variables
|
||||||
|
|
||||||
VALUE rb_iv_get(VALUE obj, char *name)
|
VALUE rb_iv_get(VALUE obj, char *name)
|
||||||
|
|
|
@ -1013,7 +1013,7 @@ VALUE rb_funcall2(VALUE recv, ID mid, int argc, VALUE *argv)
|
||||||
|
|
||||||
VALUE rb_eval_string(char *str)
|
VALUE rb_eval_string(char *str)
|
||||||
|
|
||||||
文字列をRubyとスクリプトしてコンパイル・実行する.
|
文字列をRubyスクリプトとしてコンパイル・実行する.
|
||||||
|
|
||||||
ID rb_intern(char *name)
|
ID rb_intern(char *name)
|
||||||
|
|
||||||
|
@ -1028,6 +1028,10 @@ char *rb_class2name(VALUE class)
|
||||||
classの名前を返す(デバッグ用).classが名前を持たない時には,
|
classの名前を返す(デバッグ用).classが名前を持たない時には,
|
||||||
祖先を遡って名前を持つクラスの名前を返す.
|
祖先を遡って名前を持つクラスの名前を返す.
|
||||||
|
|
||||||
|
int rb_respond_to(VALUE obj, ID id)
|
||||||
|
|
||||||
|
objがidで示されるメソッドを持つかどうかを返す。
|
||||||
|
|
||||||
** インスタンス変数
|
** インスタンス変数
|
||||||
|
|
||||||
VALUE rb_iv_get(VALUE obj, char *name)
|
VALUE rb_iv_get(VALUE obj, char *name)
|
||||||
|
|
3
ToDo
3
ToDo
|
@ -15,6 +15,7 @@ Language Spec.
|
||||||
|
|
||||||
Hacking Interpreter
|
Hacking Interpreter
|
||||||
|
|
||||||
|
* hash[key] = nil may not remove entry; hashes may have nil as the value.
|
||||||
* RUBYOPT environment variable
|
* RUBYOPT environment variable
|
||||||
* non-blocking open (e.g. named pipe) for thread
|
* non-blocking open (e.g. named pipe) for thread
|
||||||
* avoid blocking with gethostbyname/gethostbyaddr
|
* avoid blocking with gethostbyname/gethostbyaddr
|
||||||
|
@ -26,6 +27,7 @@ Hacking Interpreter
|
||||||
|
|
||||||
Standard Libraries
|
Standard Libraries
|
||||||
|
|
||||||
|
* Array#{first,last,at}
|
||||||
* Struct::new([name,]member,...) ??
|
* Struct::new([name,]member,...) ??
|
||||||
* String#scanf(?)
|
* String#scanf(?)
|
||||||
* Object#fmt(?)
|
* Object#fmt(?)
|
||||||
|
@ -44,7 +46,6 @@ Extension Libraries
|
||||||
|
|
||||||
Ruby Libraries
|
Ruby Libraries
|
||||||
|
|
||||||
* net/pop.rb net/smtp.rb
|
|
||||||
* httplib.rb, urllib.rb, nttplib.rb, etc.
|
* httplib.rb, urllib.rb, nttplib.rb, etc.
|
||||||
* format like perl's
|
* format like perl's
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
/* define RUBY_USE_EUC/SJIS for default kanji-code */
|
/* define RUBY_USE_EUC/SJIS for default kanji-code */
|
||||||
#ifndef DEFAULT_KCODE
|
#ifndef DEFAULT_KCODE
|
||||||
#if defined(MSDOS) || defined(__CYGWIN32__) || defined(__human68k__) || defined(__MACOS__) || defined(__EMX__) || defined(OS2)
|
#if defined(MSDOS) || defined(__CYGWIN32__) || defined(__human68k__) || defined(__MACOS__) || defined(__EMX__) || defined(OS2) || defined(NT)
|
||||||
#define DEFAULT_KCODE KCODE_SJIS
|
#define DEFAULT_KCODE KCODE_SJIS
|
||||||
#else
|
#else
|
||||||
#define DEFAULT_KCODE KCODE_EUC
|
#define DEFAULT_KCODE KCODE_EUC
|
||||||
|
|
2
error.c
2
error.c
|
@ -330,7 +330,7 @@ exc_inspect(exc)
|
||||||
str = rb_str_new2("#<");
|
str = rb_str_new2("#<");
|
||||||
klass = rb_class_path(klass);
|
klass = rb_class_path(klass);
|
||||||
rb_str_concat(str, klass);
|
rb_str_concat(str, klass);
|
||||||
rb_str_cat(str, ":", 1);
|
rb_str_cat(str, ": ", 2);
|
||||||
rb_str_concat(str, exc);
|
rb_str_concat(str, exc);
|
||||||
rb_str_cat(str, ">", 1);
|
rb_str_cat(str, ">", 1);
|
||||||
|
|
||||||
|
|
8
eval.c
8
eval.c
|
@ -2084,10 +2084,12 @@ rb_eval(self, node)
|
||||||
resq = resq->nd_head; /* next rescue */
|
resq = resq->nd_head; /* next rescue */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state) JUMP_TAG(state);
|
else if (node->nd_else) { /* else clause given */
|
||||||
if (node->nd_else) { /* no exception raised, else clause given */
|
if (!state) { /* no exception raised */
|
||||||
result = rb_eval(self, node->nd_else);
|
result = rb_eval(self, node->nd_else);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (state) JUMP_TAG(state);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,8 @@ EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
have_header("sys/sysctl.h")
|
have_header("sys/sysctl.h")
|
||||||
|
have_header("netinet/tcp.h")
|
||||||
|
have_header("netinet/udp.h")
|
||||||
|
|
||||||
$getaddr_info_ok = false
|
$getaddr_info_ok = false
|
||||||
if try_run(<<EOF)
|
if try_run(<<EOF)
|
||||||
|
|
|
@ -16,6 +16,12 @@
|
||||||
#ifndef NT
|
#ifndef NT
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#ifdef NETINET_TCP
|
||||||
|
# include <netinet/tcp.h>
|
||||||
|
#endif
|
||||||
|
#ifdef NETINET_UDP
|
||||||
|
# include <netinet/udp.h>
|
||||||
|
#endif
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
16
file.c
16
file.c
|
@ -1521,20 +1521,20 @@ rb_f_test(argc, argv)
|
||||||
case '-':
|
case '-':
|
||||||
if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino)
|
if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino)
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
break;
|
return Qfalse;
|
||||||
|
|
||||||
case '=':
|
case '=':
|
||||||
if (st1.st_mtime == st2.st_mtime) return Qtrue;
|
if (st1.st_mtime == st2.st_mtime) return Qtrue;
|
||||||
break;
|
return Qfalse;
|
||||||
|
|
||||||
case '>':
|
case '>':
|
||||||
if (st1.st_mtime > st2.st_mtime) return Qtrue;
|
if (st1.st_mtime > st2.st_mtime) return Qtrue;
|
||||||
break;
|
return Qfalse;
|
||||||
|
|
||||||
case '<':
|
case '<':
|
||||||
if (st1.st_mtime < st2.st_mtime) return Qtrue;
|
if (st1.st_mtime < st2.st_mtime) return Qtrue;
|
||||||
break;
|
return Qfalse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* unknown command */
|
/* unknown command */
|
||||||
rb_raise(rb_eArgError, "unknown command ?%c", cmd);
|
rb_raise(rb_eArgError, "unknown command ?%c", cmd);
|
||||||
|
|
1
gc.c
1
gc.c
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
************************************************/
|
************************************************/
|
||||||
|
|
||||||
#define RUBY_NO_INLINE
|
|
||||||
#include "ruby.h"
|
#include "ruby.h"
|
||||||
#include "rubysig.h"
|
#include "rubysig.h"
|
||||||
#include "st.h"
|
#include "st.h"
|
||||||
|
|
1
hash.c
1
hash.c
|
@ -264,6 +264,7 @@ rb_hash_s_create(argc, argv, klass)
|
||||||
hash = rb_hash_new2(klass);
|
hash = rb_hash_new2(klass);
|
||||||
|
|
||||||
for (i=0; i<argc; i+=2) {
|
for (i=0; i<argc; i+=2) {
|
||||||
|
if (NIL_P(argv[i+1])) continue;
|
||||||
st_insert(RHASH(hash)->tbl, argv[i], argv[i+1]);
|
st_insert(RHASH(hash)->tbl, argv[i], argv[i+1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,17 @@ class CGI < SimpleDelegator
|
||||||
LF = "\012"
|
LF = "\012"
|
||||||
EOL = CR + LF
|
EOL = CR + LF
|
||||||
|
|
||||||
|
RFC822_DAYS = %w[ Sun Mon Tue Wed Thu Fri Sat ]
|
||||||
|
RFC822_MONTHS = %w[ Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ]
|
||||||
|
|
||||||
|
# make rfc1123 date string
|
||||||
|
def rfc1123_date(time)
|
||||||
|
t = time.clone.gmtime
|
||||||
|
return format("%s, %.2d %s %d %.2d:%.2d:%.2d GMT",
|
||||||
|
RFC822_DAYS[t.wday], t.day, RFC822_MONTHS[t.month-1], t.year,
|
||||||
|
t.hour, t.min, t.sec)
|
||||||
|
end
|
||||||
|
|
||||||
# escape url encode
|
# escape url encode
|
||||||
def escape(str)
|
def escape(str)
|
||||||
str.gsub(/[^a-zA-Z0-9_\-.]/n){ sprintf("%%%02X", $&.unpack("C")[0]) }
|
str.gsub(/[^a-zA-Z0-9_\-.]/n){ sprintf("%%%02X", $&.unpack("C")[0]) }
|
||||||
|
@ -132,7 +143,7 @@ class CGI < SimpleDelegator
|
||||||
str.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<")
|
str.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<")
|
||||||
end
|
end
|
||||||
|
|
||||||
module_function :escape, :unescape, :escapeHTML
|
module_function :escape, :unescape, :escapeHTML, :rfc1123_date
|
||||||
|
|
||||||
# offline mode. read name=value pairs on standard input.
|
# offline mode. read name=value pairs on standard input.
|
||||||
def read_from_cmdline
|
def read_from_cmdline
|
||||||
|
@ -160,7 +171,7 @@ class CGI < SimpleDelegator
|
||||||
input.read(Integer(ENV['CONTENT_LENGTH'])) or ""
|
input.read(Integer(ENV['CONTENT_LENGTH'])) or ""
|
||||||
else
|
else
|
||||||
read_from_cmdline
|
read_from_cmdline
|
||||||
end.split(/&/).each do |x|
|
end.split(/[&;]/).each do |x|
|
||||||
key, val = x.split(/=/,2).collect{|x|unescape(x)}
|
key, val = x.split(/=/,2).collect{|x|unescape(x)}
|
||||||
if @inputs.include?(key)
|
if @inputs.include?(key)
|
||||||
@inputs[key] += "\0" + (val or "")
|
@inputs[key] += "\0" + (val or "")
|
||||||
|
@ -201,7 +212,7 @@ class CGI < SimpleDelegator
|
||||||
"Set-Cookie: " + options['name'] + '=' + escape(options['value']) +
|
"Set-Cookie: " + options['name'] + '=' + escape(options['value']) +
|
||||||
(options['domain'] ? '; domain=' + options['domain'] : '') +
|
(options['domain'] ? '; domain=' + options['domain'] : '') +
|
||||||
(options['path'] ? '; path=' + options['path'] : '') +
|
(options['path'] ? '; path=' + options['path'] : '') +
|
||||||
(options['expires'] ? '; expires=' + options['expires'].strftime("%a, %d %b %Y %X %Z") : '') +
|
(options['expires'] ? '; expires=' + rfc1123_date(options['expires']) : '') +
|
||||||
(options['secure'] ? '; secure' : '')
|
(options['secure'] ? '; secure' : '')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -218,7 +229,7 @@ class CGI < SimpleDelegator
|
||||||
else
|
else
|
||||||
if options.delete("nph") or (ENV['SERVER_SOFTWARE'] =~ /IIS/)
|
if options.delete("nph") or (ENV['SERVER_SOFTWARE'] =~ /IIS/)
|
||||||
[(ENV['SERVER_PROTOCOL'] or "HTTP/1.0") + " 200 OK",
|
[(ENV['SERVER_PROTOCOL'] or "HTTP/1.0") + " 200 OK",
|
||||||
"Date: " + Time.now.gmtime.strftime("%a, %d %b %Y %X %Z"),
|
"Date: " + rfc1123_date(Time.now),
|
||||||
"Server: " + (ENV['SERVER_SOFTWARE'] or ""),
|
"Server: " + (ENV['SERVER_SOFTWARE'] or ""),
|
||||||
"Connection: close"] +
|
"Connection: close"] +
|
||||||
(options.empty? ? ["Content-Type: text/html"] : options)
|
(options.empty? ? ["Content-Type: text/html"] : options)
|
||||||
|
|
100
lib/matrix.rb
100
lib/matrix.rb
|
@ -1,8 +1,9 @@
|
||||||
|
#!/usr/local/bin/ruby
|
||||||
#
|
#
|
||||||
# matrix.rb -
|
# matrix.rb -
|
||||||
# $Release Version: 1.0$
|
# $Release Version: 1.0$
|
||||||
# $Revision: 1.9 $
|
# $Revision: 1.11 $
|
||||||
# $Date: 1999/08/24 10:25:00 $
|
# $Date: 1999/10/06 11:01:53 $
|
||||||
# Original Version from Smalltalk-80 version
|
# Original Version from Smalltalk-80 version
|
||||||
# on July 23, 1985 at 8:37:17 am
|
# on July 23, 1985 at 8:37:17 am
|
||||||
# by Keiju ISHITSUKA
|
# by Keiju ISHITSUKA
|
||||||
|
@ -38,7 +39,7 @@
|
||||||
# creates a matrix where `rows' indicates rows.
|
# creates a matrix where `rows' indicates rows.
|
||||||
# `rows' is an array of arrays,
|
# `rows' is an array of arrays,
|
||||||
# e.g, Matrix[[11, 12], [21, 22]]
|
# e.g, Matrix[[11, 12], [21, 22]]
|
||||||
# Matrix.rows(rows, copy = true)
|
# Matrix.rows(rows, copy = TRUE)
|
||||||
# creates a matrix where `rows' indicates rows.
|
# creates a matrix where `rows' indicates rows.
|
||||||
# if optional argument `copy' is false, use the array as
|
# if optional argument `copy' is false, use the array as
|
||||||
# internal structure of the metrix without copying.
|
# internal structure of the metrix without copying.
|
||||||
|
@ -144,7 +145,7 @@
|
||||||
#
|
#
|
||||||
# INSTANCE CREATION:
|
# INSTANCE CREATION:
|
||||||
# Vector.[](*array)
|
# Vector.[](*array)
|
||||||
# Vector.elements(array, copy = true)
|
# Vector.elements(array, copy = TRUE)
|
||||||
# ACCSESSING:
|
# ACCSESSING:
|
||||||
# [](i)
|
# [](i)
|
||||||
# size
|
# size
|
||||||
|
@ -185,7 +186,7 @@ module ExceptionForMatrix
|
||||||
end
|
end
|
||||||
|
|
||||||
class Matrix
|
class Matrix
|
||||||
@RCS_ID='-$Id: matrix.rb,v 1.8 1999/02/17 12:34:19 keiju Exp keiju $-'
|
@RCS_ID='-$Id: matrix.rb,v 1.11 1999/10/06 11:01:53 keiju Exp keiju $-'
|
||||||
|
|
||||||
# extend Exception2MessageMapper
|
# extend Exception2MessageMapper
|
||||||
include ExceptionForMatrix
|
include ExceptionForMatrix
|
||||||
|
@ -194,10 +195,10 @@ class Matrix
|
||||||
private_class_method :new
|
private_class_method :new
|
||||||
|
|
||||||
def Matrix.[](*rows)
|
def Matrix.[](*rows)
|
||||||
new(:init_rows, rows, false)
|
new(:init_rows, rows, FALSE)
|
||||||
end
|
end
|
||||||
|
|
||||||
def Matrix.rows(rows, copy = true)
|
def Matrix.rows(rows, copy = TRUE)
|
||||||
new(:init_rows, rows, copy)
|
new(:init_rows, rows, copy)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -209,7 +210,7 @@ class Matrix
|
||||||
columns[j][i]
|
columns[j][i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Matrix.rows(rows, false)
|
Matrix.rows(rows, FALSE)
|
||||||
end
|
end
|
||||||
|
|
||||||
def Matrix.diagonal(*values)
|
def Matrix.diagonal(*values)
|
||||||
|
@ -220,7 +221,8 @@ class Matrix
|
||||||
row[j] = values[j]
|
row[j] = values[j]
|
||||||
row
|
row
|
||||||
}
|
}
|
||||||
rows(rows, false)
|
self
|
||||||
|
rows(rows, FALSE)
|
||||||
end
|
end
|
||||||
|
|
||||||
def Matrix.scalar(n, value)
|
def Matrix.scalar(n, value)
|
||||||
|
@ -242,11 +244,11 @@ class Matrix
|
||||||
def Matrix.row_vector(row)
|
def Matrix.row_vector(row)
|
||||||
case row
|
case row
|
||||||
when Vector
|
when Vector
|
||||||
Matrix.rows([row.to_a], false)
|
Matrix.rows([row.to_a], FALSE)
|
||||||
when Array
|
when Array
|
||||||
Matrix.rows([row.dup], false)
|
Matrix.rows([row.dup], FALSE)
|
||||||
else
|
else
|
||||||
Matrix.row([[row]], false)
|
Matrix.row([[row]], FALSE)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -311,13 +313,13 @@ class Matrix
|
||||||
|i|
|
|i|
|
||||||
@rows[i][j]
|
@rows[i][j]
|
||||||
}
|
}
|
||||||
Vector.elements(col, false)
|
Vector.elements(col, FALSE)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def collect
|
def collect
|
||||||
rows = @rows.collect{|row| row.collect{|e| yield e}}
|
rows = @rows.collect{|row| row.collect{|e| yield e}}
|
||||||
Matrix.rows(rows, false)
|
Matrix.rows(rows, FALSE)
|
||||||
end
|
end
|
||||||
alias map collect
|
alias map collect
|
||||||
|
|
||||||
|
@ -345,7 +347,7 @@ class Matrix
|
||||||
|row|
|
|row|
|
||||||
row[from_col, size_col]
|
row[from_col, size_col]
|
||||||
}
|
}
|
||||||
Matrix.rows(rows, false)
|
Matrix.rows(rows, FALSE)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TESTING
|
# TESTING
|
||||||
|
@ -363,20 +365,20 @@ class Matrix
|
||||||
|
|
||||||
# COMPARING
|
# COMPARING
|
||||||
def ==(other)
|
def ==(other)
|
||||||
return false unless Matrix === other
|
return FALSE unless Matrix === other
|
||||||
|
|
||||||
other.compare_by_row_vectors(@rows)
|
other.compare_by_row_vectors(@rows)
|
||||||
end
|
end
|
||||||
alias eql? ==
|
alias eql? ==
|
||||||
|
|
||||||
def compare_by_row_vectors(rows)
|
def compare_by_row_vectors(rows)
|
||||||
return false unless @rows.size == rows.size
|
return FALSE unless @rows.size == rows.size
|
||||||
|
|
||||||
0.upto(@rows.size - 1) do
|
0.upto(@rows.size - 1) do
|
||||||
|i|
|
|i|
|
||||||
return false unless @rows[i] == rows[i]
|
return FALSE unless @rows[i] == rows[i]
|
||||||
end
|
end
|
||||||
true
|
TRUE
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone
|
def clone
|
||||||
|
@ -405,7 +407,7 @@ class Matrix
|
||||||
e * m
|
e * m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Matrix.rows(rows, false)
|
return Matrix.rows(rows, FALSE)
|
||||||
when Vector
|
when Vector
|
||||||
m = Matrix.column_vector(m)
|
m = Matrix.column_vector(m)
|
||||||
r = self * m
|
r = self * m
|
||||||
|
@ -425,7 +427,7 @@ class Matrix
|
||||||
vij
|
vij
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Matrix.rows(rows, false)
|
return Matrix.rows(rows, FALSE)
|
||||||
else
|
else
|
||||||
x, y = m.coerce(self)
|
x, y = m.coerce(self)
|
||||||
return x * y
|
return x * y
|
||||||
|
@ -453,7 +455,7 @@ class Matrix
|
||||||
self[i, j] + m[i, j]
|
self[i, j] + m[i, j]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Matrix.rows(rows, false)
|
Matrix.rows(rows, FALSE)
|
||||||
end
|
end
|
||||||
|
|
||||||
def -(m)
|
def -(m)
|
||||||
|
@ -477,7 +479,7 @@ class Matrix
|
||||||
self[i, j] - m[i, j]
|
self[i, j] - m[i, j]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Matrix.rows(rows, false)
|
Matrix.rows(rows, FALSE)
|
||||||
end
|
end
|
||||||
|
|
||||||
def /(other)
|
def /(other)
|
||||||
|
@ -490,7 +492,7 @@ class Matrix
|
||||||
e / other
|
e / other
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Matrix.rows(rows, false)
|
return Matrix.rows(rows, FALSE)
|
||||||
when Matrix
|
when Matrix
|
||||||
return self * other.inverse
|
return self * other.inverse
|
||||||
else
|
else
|
||||||
|
@ -619,17 +621,36 @@ class Matrix
|
||||||
k = 0
|
k = 0
|
||||||
begin
|
begin
|
||||||
if (akk = a[k][k]) == 0
|
if (akk = a[k][k]) == 0
|
||||||
i = -1
|
i = k
|
||||||
nothing = false
|
exists = true
|
||||||
begin
|
begin
|
||||||
if (i += 1) > column_size - 1
|
if (i += 1) > column_size - 1
|
||||||
nothing = true
|
exists = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end while a[i][k] == 0
|
end while a[i][k] == 0
|
||||||
next if nothing
|
if exists
|
||||||
a[i], a[k] = a[k], a[i]
|
a[i], a[k] = a[k], a[i]
|
||||||
akk = a[k][k]
|
akk = a[k][k]
|
||||||
|
else
|
||||||
|
i = k
|
||||||
|
exists = true
|
||||||
|
begin
|
||||||
|
if (i += 1) > row_size - 1
|
||||||
|
exists = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end while a[k][i] == 0
|
||||||
|
if exists
|
||||||
|
k.upto(column_size - 1) do
|
||||||
|
|j|
|
||||||
|
a[j][k], a[j][i] = a[j][i], a[j][k]
|
||||||
|
end
|
||||||
|
akk = a[k][k]
|
||||||
|
else
|
||||||
|
next
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
(k + 1).upto(row_size - 1) do
|
(k + 1).upto(row_size - 1) do
|
||||||
|i|
|
|i|
|
||||||
|
@ -806,10 +827,10 @@ class Vector
|
||||||
|
|
||||||
private_class_method :new
|
private_class_method :new
|
||||||
def Vector.[](*array)
|
def Vector.[](*array)
|
||||||
new(:init_elements, array, copy = false)
|
new(:init_elements, array, copy = FALSE)
|
||||||
end
|
end
|
||||||
|
|
||||||
def Vector.elements(array, copy = true)
|
def Vector.elements(array, copy = TRUE)
|
||||||
new(:init_elements, array, copy)
|
new(:init_elements, array, copy)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -854,7 +875,7 @@ class Vector
|
||||||
|
|
||||||
# COMPARING
|
# COMPARING
|
||||||
def ==(other)
|
def ==(other)
|
||||||
return false unless Vector === other
|
return FALSE unless Vector === other
|
||||||
|
|
||||||
other.compare_by(@elements)
|
other.compare_by(@elements)
|
||||||
end
|
end
|
||||||
|
@ -874,11 +895,11 @@ class Vector
|
||||||
|
|
||||||
# ARITHMETIC
|
# ARITHMETIC
|
||||||
|
|
||||||
def *(x) # is matrix or number
|
def *(x) "is matrix or number"
|
||||||
case x
|
case x
|
||||||
when Numeric
|
when Numeric
|
||||||
els = @elements.collect{|e| e * x}
|
els = @elements.collect{|e| e * x}
|
||||||
Vector.elements(els, false)
|
Vector.elements(els, FALSE)
|
||||||
when Matrix
|
when Matrix
|
||||||
self.covector * x
|
self.covector * x
|
||||||
else
|
else
|
||||||
|
@ -895,7 +916,7 @@ class Vector
|
||||||
|v1, v2|
|
|v1, v2|
|
||||||
v1 + v2
|
v1 + v2
|
||||||
}
|
}
|
||||||
Vector.elements(els, false)
|
Vector.elements(els, FALSE)
|
||||||
when Matrix
|
when Matrix
|
||||||
Matrix.column_vector(self) + v
|
Matrix.column_vector(self) + v
|
||||||
else
|
else
|
||||||
|
@ -912,7 +933,7 @@ class Vector
|
||||||
|v1, v2|
|
|v1, v2|
|
||||||
v1 - v2
|
v1 - v2
|
||||||
}
|
}
|
||||||
Vector.elements(els, false)
|
Vector.elements(els, FALSE)
|
||||||
when Matrix
|
when Matrix
|
||||||
Matrix.column_vector(self) - v
|
Matrix.column_vector(self) - v
|
||||||
else
|
else
|
||||||
|
@ -939,7 +960,7 @@ class Vector
|
||||||
|v|
|
|v|
|
||||||
yield v
|
yield v
|
||||||
}
|
}
|
||||||
Vector.elements(els, false)
|
Vector.elements(els, FALSE)
|
||||||
end
|
end
|
||||||
alias map collect
|
alias map collect
|
||||||
|
|
||||||
|
@ -948,7 +969,7 @@ class Vector
|
||||||
|v1, v2|
|
|v1, v2|
|
||||||
yield v1, v2
|
yield v1, v2
|
||||||
}
|
}
|
||||||
Vector.elements(els, false)
|
Vector.elements(els, FALSE)
|
||||||
end
|
end
|
||||||
|
|
||||||
def r
|
def r
|
||||||
|
@ -999,4 +1020,3 @@ class Vector
|
||||||
str = "Vector"+@elements.inspect
|
str = "Vector"+@elements.inspect
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
=begin
|
=begin
|
||||||
$Date: 1999/09/21 21:24:07 $
|
$Date: 1999/10/04 22:51:26 $
|
||||||
|
|
||||||
== SIMPLE TELNET CLIANT LIBRARY
|
== SIMPLE TELNET CLIANT LIBRARY
|
||||||
|
|
||||||
telnet.rb
|
telnet.rb
|
||||||
|
|
||||||
Version 0.50
|
Version 1.00
|
||||||
|
|
||||||
Wakou Aoyama <wakou@fsinet.or.jp>
|
Wakou Aoyama <wakou@fsinet.or.jp>
|
||||||
|
|
||||||
|
@ -155,6 +155,15 @@ of cource, set sync=true or flush is necessary.
|
||||||
|
|
||||||
== HISTORY
|
== HISTORY
|
||||||
|
|
||||||
|
=== Version 1.00
|
||||||
|
|
||||||
|
1999/10/04 22:51:26
|
||||||
|
|
||||||
|
- bug fix: waitfor(preprocess) method
|
||||||
|
thanks to Shin-ichiro Hara <sinara@blade.nagaokaut.ac.jp>
|
||||||
|
- add simple support for AO, DM, IP, NOP, SB, SE
|
||||||
|
- COUTION! TimeOut --> TimeoutError
|
||||||
|
|
||||||
=== Version 0.50
|
=== Version 0.50
|
||||||
|
|
||||||
1999/09/21 21:24:07
|
1999/09/21 21:24:07
|
||||||
|
@ -331,7 +340,6 @@ require "socket"
|
||||||
require "delegate"
|
require "delegate"
|
||||||
require "thread"
|
require "thread"
|
||||||
require "timeout"
|
require "timeout"
|
||||||
TimeOut = TimeoutError
|
|
||||||
|
|
||||||
class Telnet < SimpleDelegator
|
class Telnet < SimpleDelegator
|
||||||
|
|
||||||
|
@ -405,8 +413,8 @@ class Telnet < SimpleDelegator
|
||||||
EOL = CR + LF
|
EOL = CR + LF
|
||||||
v = $-v
|
v = $-v
|
||||||
$-v = false
|
$-v = false
|
||||||
VERSION = "0.50"
|
VERSION = "1.00"
|
||||||
RELEASE_DATE = "$Date: 1999/09/21 21:24:07 $"
|
RELEASE_DATE = "$Date: 1999/10/04 22:51:26 $"
|
||||||
$-v = v
|
$-v = v
|
||||||
|
|
||||||
def initialize(options)
|
def initialize(options)
|
||||||
|
@ -456,7 +464,7 @@ $-v = v
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
rescue TimeoutError
|
rescue TimeoutError
|
||||||
raise TimeOut, "timed-out; opening of the host"
|
raise TimeoutError, "timed-out; opening of the host"
|
||||||
rescue
|
rescue
|
||||||
@log.write($!.to_s + "\n") if @options.key?("Output_log")
|
@log.write($!.to_s + "\n") if @options.key?("Output_log")
|
||||||
@dumplog.write($!.to_s + "\n") if @options.key?("Dump_log")
|
@dumplog.write($!.to_s + "\n") if @options.key?("Dump_log")
|
||||||
|
@ -502,10 +510,10 @@ $-v = v
|
||||||
str.gsub!(/#{EOL}/no, "\n") unless @options["Binmode"]
|
str.gsub!(/#{EOL}/no, "\n") unless @options["Binmode"]
|
||||||
|
|
||||||
str.gsub!(/#{IAC}(
|
str.gsub!(/#{IAC}(
|
||||||
#{IAC}|
|
[#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]|
|
||||||
#{AYT}|
|
|
||||||
[#{DO}#{DONT}#{WILL}#{WONT}]
|
[#{DO}#{DONT}#{WILL}#{WONT}]
|
||||||
[#{OPT_BINARY}-#{OPT_NEW_ENVIRON}#{OPT_EXOPL}]
|
[#{OPT_BINARY}-#{OPT_NEW_ENVIRON}#{OPT_EXOPL}]|
|
||||||
|
#{SB}[^#{IAC}]*#{IAC}#{SE}
|
||||||
)/xno){
|
)/xno){
|
||||||
if IAC == $1 # handle escaped IAC characters
|
if IAC == $1 # handle escaped IAC characters
|
||||||
IAC
|
IAC
|
||||||
|
@ -539,6 +547,8 @@ $-v = v
|
||||||
self.write(IAC + DONT + OPT_SGA)
|
self.write(IAC + DONT + OPT_SGA)
|
||||||
end
|
end
|
||||||
''
|
''
|
||||||
|
else
|
||||||
|
''
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +561,7 @@ $-v = v
|
||||||
|
|
||||||
if options.kind_of?(Hash)
|
if options.kind_of?(Hash)
|
||||||
prompt = if options.key?("Match")
|
prompt = if options.key?("Match")
|
||||||
options["Match"]
|
options["Match"]
|
||||||
elsif options.key?("Prompt")
|
elsif options.key?("Prompt")
|
||||||
options["Prompt"]
|
options["Prompt"]
|
||||||
elsif options.key?("String")
|
elsif options.key?("String")
|
||||||
|
@ -569,24 +579,30 @@ $-v = v
|
||||||
|
|
||||||
line = ''
|
line = ''
|
||||||
buf = ''
|
buf = ''
|
||||||
|
rest = ''
|
||||||
until(prompt === line and not IO::select([@sock], nil, nil, waittime))
|
until(prompt === line and not IO::select([@sock], nil, nil, waittime))
|
||||||
unless IO::select([@sock], nil, nil, time_out)
|
unless IO::select([@sock], nil, nil, time_out)
|
||||||
raise TimeOut, "timed-out; wait for the next data"
|
raise TimeoutError, "timed-out; wait for the next data"
|
||||||
end
|
end
|
||||||
begin
|
begin
|
||||||
c = @sock.sysread(1024 * 1024)
|
c = @sock.sysread(1024 * 1024)
|
||||||
@dumplog.print(c) if @options.key?("Dump_log")
|
@dumplog.print(c) if @options.key?("Dump_log")
|
||||||
buf.concat c
|
|
||||||
if @options["Telnetmode"]
|
if @options["Telnetmode"]
|
||||||
buf = preprocess(buf)
|
if Integer(c.rindex(/#{IAC}#{SE}/no)) <
|
||||||
if /#{IAC}.?\z/no === buf
|
Integer(c.rindex(/#{IAC}#{SB}/no))
|
||||||
next
|
buf = preprocess(rest + c[0 ... c.rindex(/#{IAC}#{SB}/no)])
|
||||||
end
|
rest = c[c.rindex(/#{IAC}#{SB}/no) .. -1]
|
||||||
end
|
elsif pt = c.rindex(/#{IAC}[^#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]?\z/no)
|
||||||
|
buf = preprocess(rest + c[0 ... pt])
|
||||||
|
rest = c[pt .. -1]
|
||||||
|
else
|
||||||
|
buf = preprocess(c)
|
||||||
|
rest = ''
|
||||||
|
end
|
||||||
|
end
|
||||||
@log.print(buf) if @options.key?("Output_log")
|
@log.print(buf) if @options.key?("Output_log")
|
||||||
yield buf if iterator?
|
|
||||||
line.concat(buf)
|
line.concat(buf)
|
||||||
buf = ''
|
yield buf if iterator?
|
||||||
rescue EOFError # End of file reached
|
rescue EOFError # End of file reached
|
||||||
if line == ''
|
if line == ''
|
||||||
line = nil
|
line = nil
|
||||||
|
|
4
parse.y
4
parse.y
|
@ -4420,11 +4420,11 @@ rb_intern(name)
|
||||||
strncpy(buf, name, last);
|
strncpy(buf, name, last);
|
||||||
buf[last] = '\0';
|
buf[last] = '\0';
|
||||||
id = rb_intern(buf);
|
id = rb_intern(buf);
|
||||||
if (id > LAST_TOKEN) {
|
if (id > LAST_TOKEN && !is_attrset_id(id)) {
|
||||||
id = rb_id_attrset(id);
|
id = rb_id_attrset(id);
|
||||||
goto id_regist;
|
goto id_regist;
|
||||||
}
|
}
|
||||||
id |= ID_ATTRSET;
|
id = ID_ATTRSET;
|
||||||
}
|
}
|
||||||
else if (ISUPPER(name[0])) {
|
else if (ISUPPER(name[0])) {
|
||||||
id = ID_CONST;
|
id = ID_CONST;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#! /usr/bin/ruby -Ke
|
||||||
|
|
||||||
class Board
|
class Board
|
||||||
def clr
|
def clr
|
||||||
print "\e[2J"
|
print "\e[2J"
|
||||||
|
|
26
signal.c
26
signal.c
|
@ -294,6 +294,13 @@ posix_signal(signum, handler)
|
||||||
sigact.sa_handler = handler;
|
sigact.sa_handler = handler;
|
||||||
sigemptyset(&sigact.sa_mask);
|
sigemptyset(&sigact.sa_mask);
|
||||||
sigact.sa_flags = 0;
|
sigact.sa_flags = 0;
|
||||||
|
#ifdef SA_RESTART
|
||||||
|
sigact.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */
|
||||||
|
#endif
|
||||||
|
#ifdef SA_NOCLDWAIT
|
||||||
|
if (signum == SIGCHLD && handler == (RETSIGTYPE)SIG_IGN)
|
||||||
|
sigact.sa_flags |= SA_NOCLDWAIT;
|
||||||
|
#endif
|
||||||
sigaction(signum, &sigact, 0);
|
sigaction(signum, &sigact, 0);
|
||||||
}
|
}
|
||||||
#define ruby_signal(sig,handle) posix_signal((sig),(handle))
|
#define ruby_signal(sig,handle) posix_signal((sig),(handle))
|
||||||
|
@ -313,9 +320,6 @@ signal_exec(sig)
|
||||||
#ifndef NT
|
#ifndef NT
|
||||||
case SIGHUP:
|
case SIGHUP:
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGPIPE
|
|
||||||
case SIGPIPE:
|
|
||||||
#endif
|
|
||||||
#ifdef SIGQUIT
|
#ifdef SIGQUIT
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
#endif
|
#endif
|
||||||
|
@ -345,7 +349,7 @@ sighandle(sig)
|
||||||
rb_bug("trap_handler: Bad signal %d", sig);
|
rb_bug("trap_handler: Bad signal %d", sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL)
|
#if !defined(BSD_SIGNAL)
|
||||||
ruby_signal(sig, sighandle);
|
ruby_signal(sig, sighandle);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -508,9 +512,6 @@ trap(arg)
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGUSR2
|
#ifdef SIGUSR2
|
||||||
case SIGUSR2:
|
case SIGUSR2:
|
||||||
#endif
|
|
||||||
#ifdef SIGPIPE
|
|
||||||
case SIGPIPE:
|
|
||||||
#endif
|
#endif
|
||||||
func = sighandle;
|
func = sighandle;
|
||||||
break;
|
break;
|
||||||
|
@ -523,6 +524,11 @@ trap(arg)
|
||||||
case SIGSEGV:
|
case SIGSEGV:
|
||||||
func = sigsegv;
|
func = sigsegv;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef SIGPIPE
|
||||||
|
case SIGPIPE:
|
||||||
|
func = SIG_IGN;
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -614,9 +620,6 @@ Init_signal()
|
||||||
#ifndef NT
|
#ifndef NT
|
||||||
ruby_signal(SIGHUP, sighandle);
|
ruby_signal(SIGHUP, sighandle);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGPIPE
|
|
||||||
ruby_signal(SIGPIPE, sighandle);
|
|
||||||
#endif
|
|
||||||
#ifdef SIGQUIT
|
#ifdef SIGQUIT
|
||||||
ruby_signal(SIGQUIT, sighandle);
|
ruby_signal(SIGQUIT, sighandle);
|
||||||
#endif
|
#endif
|
||||||
|
@ -636,5 +639,8 @@ Init_signal()
|
||||||
#ifdef SIGSEGV
|
#ifdef SIGSEGV
|
||||||
ruby_signal(SIGSEGV, sigsegv);
|
ruby_signal(SIGSEGV, sigsegv);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef SIGPIPE
|
||||||
|
ruby_signal(SIGPIPE, SIG_IGN);
|
||||||
|
#endif
|
||||||
#endif /* MACOS_UNUSE_SIGNAL */
|
#endif /* MACOS_UNUSE_SIGNAL */
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче