1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-07-10 04:49:24 +00:00
parent 3043170b14
commit c67a74570d
22 changed files with 560 additions and 440 deletions

View file

@ -1,3 +1,28 @@
Mon Jul 10 09:07:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* error.c (rb_bug): print version number and such too.
Sat Jul 8 23:08:40 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (rb_thread_start_0): should copy previous scopes to
prevent rb_gc_force_recylce().
Fri Jul 7 23:36:36 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
* ext/socket/addrinfo.h: move IN_EXPERIMENTAL and IN_LOOPBACKNET
definitions to ext/socket/sockport.h.
* ext/socket/extconf.rb: add getservbyport() and arpa/inet.h check.
* ext/socket/getaddrinfo.c (getaddrinfo): SOCK_RAW may not be
defined (ex. BeOS, Palm OS 2.x or before).
* ext/socket/getnameinfo.c (getnameinfo): getservbyport() may not
exist (ex. BeOS, Palm OS).
* ext/socket/sockport.h: add IN_EXPERIMENTAL, IN_CLASSA_NSHIFT,
IN_LOOPBACKNET, AF_UNSPEC, PF_UNSPEC and PF_INET.
Fri Jul 7 03:30:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y (aref_args): should allow Hash[:a=>2] etc.

View file

@ -150,6 +150,15 @@ interpreter. Useful functions are listed below (not all):
Creates a new Ruby string from C string. This is equivalent to
rb_str_new(ptr, strlen(ptr)).
rb_tainted_str_new(char *ptr, int len)
Creates a new tainted Ruby string. Strings from external data
should be tainted.
rb_tainted_str_new2(char *ptr)
Creates a new tainted Ruby string from C string.
rb_str_cat(VALUE str, char *ptr, int len)
Appends len bytes data from ptr to the Ruby string.
@ -266,6 +275,9 @@ in Kernel module, can be defined using:
void rb_define_global_function(char *name, VALUE (*func)(), int argc)
To define alias to the method,
void rb_define_alias(VALUE module, const char* new, const char* old);
2.1.3 Constant definition

View file

@ -180,6 +180,16 @@ Ruby
Cの文字列からRubyの文字列を生成するこの関数の機能は
rb_str_new(ptr, strlen(ptr))と同等である.
rb_tainted_str_new(char *ptr, int len)
汚染マークが付加された新しいRubyの文字列を生成する外部
からのデータに基づく文字列には汚染マークが付加されるべき
である.
rb_tainted_str_new2(char *ptr)
Cの文字列から汚染マークが付加されたRubyの文字列を生成する
rb_str_cat(VALUE str, char *ptr, int len)
Rubyの文字列strにlenバイトの文字列ptrを追加する
@ -307,6 +317,10 @@ private
void rb_define_global_function(char *name, VALUE (*func)(), int argc)
メソッドの別名を定義するための関数は以下の通りです。
void rb_define_alias(VALUE module, const char* new, const char* old);
2.1.3 定数定義
拡張ライブラリが必要な定数はあらかじめ定義しておいた方が良い

View file

@ -159,6 +159,7 @@ rb_bug(fmt, va_alist)
va_init_list(args, fmt);
err_print(buf, args);
va_end(args);
ruby_show_version();
abort();
}

10
eval.c
View file

@ -778,6 +778,9 @@ static VALUE ruby_wrapper; /* security wrapper */
ruby_scope = _scope; \
scope_vmode = SCOPE_PUBLIC;
typedef struct thread * rb_thread_t;
static rb_thread_t curr_thread = 0;
#define SCOPE_DONT_RECYCLE FL_USER2
#define POP_SCOPE() \
if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE)) {\
@ -6315,7 +6318,7 @@ enum thread_status {
/* +infty, for this purpose */
#define DELAY_INFTY 1E30
typedef struct thread * rb_thread_t;
/* typedef struct thread * rb_thread_t; */
struct thread {
struct thread *next, *prev;
@ -6372,7 +6375,7 @@ struct thread {
#define THREAD_RAISED 0x200
static rb_thread_t main_thread;
static rb_thread_t curr_thread = 0;
/*static rb_thread_t curr_thread = 0;*/
#define FOREACH_THREAD_FROM(f,x) x = f; do { x = x->next;
#define END_FOREACH_FROM(f,x) } while (x != f)
@ -7513,6 +7516,9 @@ rb_thread_start_0(fn, arg, th)
}
#endif
if (ruby_block) { /* should nail down higher scopes */
blk_copy_prev(ruby_block);
}
scope_dup(ruby_scope);
FL_SET(ruby_scope, SCOPE_SHARED);
if (THREAD_SAVE_CONTEXT(curr_thread)) {

View file

@ -127,11 +127,6 @@
#define NI_NUMERICSERV 0x00000008
#define NI_DGRAM 0x00000010
#ifdef NT
#define IN_EXPERIMENTAL(x) 0
#define IN_LOOPBACKNET 0
#endif
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
int ai_family; /* PF_xxx */

View file

@ -306,6 +306,8 @@ else
$objs += ["getnameinfo.#{$OBJEXT}"]
have_func("inet_ntop") or have_func("inet_ntoa")
have_func("inet_pton") or have_func("inet_aton")
have_func("getservbyport")
have_header("arpa/inet.h")
have_header("arpa/nameser.h")
have_header("resolv.h")
end

View file

@ -42,9 +42,15 @@
#include <sys/types.h>
#ifndef NT
#include <sys/param.h>
#include <sys/socket.h>
#if defined(__BEOS__)
# include <net/socket.h>
#else
# include <sys/socket.h>
#endif
#include <netinet/in.h>
#if defined(HAVE_ARPA_INET_H)
#include <arpa/inet.h>
#endif
#if defined(HAVE_ARPA_NAMESER_H)
#include <arpa/nameser.h>
#endif
@ -330,12 +336,16 @@ getaddrinfo(hostname, servname, hints, res)
pai->ai_socktype = SOCK_STREAM;
break;
default:
#if defined(SOCK_RAW)
pai->ai_socktype = SOCK_RAW;
#endif
break;
}
break;
#if defined(SOCK_RAW)
case SOCK_RAW:
break;
#endif
case SOCK_DGRAM:
if (pai->ai_protocol != IPPROTO_UDP &&
pai->ai_protocol != ANY)

View file

@ -37,9 +37,15 @@
#include "config.h"
#include <sys/types.h>
#ifndef NT
#include <sys/socket.h>
#if defined(__BEOS__)
# include <net/socket.h>
#else
# include <sys/socket.h>
#endif
#include <netinet/in.h>
#if defined(HAVE_ARPA_INET_H)
#include <arpa/inet.h>
#endif
#if defined(HAVE_ARPA_NAMESER_H)
#include <arpa/nameser.h>
#endif
@ -178,6 +184,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
return ENI_MEMORY;
strcpy(serv, numserv);
} else {
#if defined(HAVE_GETSERVBYPORT)
sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp");
if (sp) {
if (strlen(sp->s_name) > servlen)
@ -185,6 +192,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
strcpy(serv, sp->s_name);
} else
return ENI_NOSERVNAME;
#else
return ENI_NOSERVNAME;
#endif
}
switch (sa->sa_family) {

View file

@ -21,7 +21,11 @@
#endif
#ifndef NT
#include <sys/socket.h>
#if defined(__BEOS__)
# include <net/socket.h>
#else
# include <sys/socket.h>
#endif
#include <netinet/in.h>
#ifdef HAVE_NETINET_TCP_H
# include <netinet/tcp.h>

View file

@ -45,4 +45,28 @@
# define IN_MULTICAST(i) IN_CLASSD(i)
#endif
#ifndef IN_EXPERIMENTAL
# define IN_EXPERIMENTAL(i) ((((long)(i)) & 0xe0000000) == 0xe0000000)
#endif
#ifndef IN_CLASSA_NSHIFT
# define IN_CLASSA_NSHIFT 24
#endif
#ifndef IN_LOOPBACKNET
# define IN_LOOPBACKNET 127
#endif
#ifndef AF_UNSPEC
# define AF_UNSPEC 0
#endif
#ifndef PF_UNSPEC
# define PF_UNSPEC AF_UNSPEC
#endif
#ifndef PF_INET
# define PF_INET AF_INET
#endif
#endif

View file

@ -1,8 +1,8 @@
#
# Date.rb -
# $Release Version: $
# $Revision: 1.1.1.2 $
# $Date: 1999/01/20 04:59:35 $
# $Revision: 1.2 $
# $Date: 2000/07/06 07:21:23 $
# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
#
# --
@ -168,12 +168,10 @@ class Date
m = Date.daylist(@year)
if @month < 1 || @month > 12
raise ArgumentError, "argument(month) out of range."
return nil
end
if @year == 1752 && @month == 9
if @day >= 3 && @day <= 13
raise ArgumentError, "argument(1752/09/3-13) out of range."
return nil
end
d = 30
else
@ -181,7 +179,6 @@ class Date
end
if @day < 1 || @day > d
raise ArgumentError, "argument(day) out of range."
return nil
end
return self
end
@ -299,4 +296,3 @@ def Date.jan1!(y)
end
return (d % 7)
end

View file

@ -147,7 +147,7 @@ class Date
def new3(y=-4712, m=1, d=1, sg=ITALY)
unless jd = exist3?(y, m, d, sg)
fail ArgumentError, 'invalid date'
raise ArgumentError, 'invalid date'
end
new(jd, sg)
end
@ -169,7 +169,7 @@ class Date
def new2(y=-4712, d=1, sg=ITALY)
unless jd = exist2?(y, d, sg)
fail ArgumentError, 'invalid date'
raise ArgumentError, 'invalid date'
end
new(jd, sg)
end
@ -189,7 +189,7 @@ class Date
def neww(y=1582, w=41, d=5, sg=ITALY)
unless jd = existw?(y, w, d, sg)
fail ArgumentError, 'invalid date'
raise ArgumentError, 'invalid date'
end
new(jd, sg)
end
@ -280,7 +280,7 @@ class Date
case n
when Numeric; return type.new(@rjd + n, @sg)
end
fail TypeError, 'expected numeric'
raise TypeError, 'expected numeric'
end
def - (x)
@ -288,7 +288,7 @@ class Date
when Numeric; return type.new(@rjd - x, @sg)
when Date; return @rjd - x.rjd
end
fail TypeError, 'expected numeric or date'
raise TypeError, 'expected numeric or date'
end
def <=> (other)
@ -296,7 +296,7 @@ class Date
when Numeric; return @rjd <=> other
when Date; return @rjd <=> other.rjd
end
fail TypeError, 'expected numeric or date'
raise TypeError, 'expected numeric or date'
end
def === (other)
@ -304,7 +304,7 @@ class Date
when Numeric; return jd == other
when Date; return jd == other.jd
end
fail TypeError, 'expected numeric or date'
raise TypeError, 'expected numeric or date'
end
def >> (n)

View file

@ -1,6 +1,6 @@
# jcode.rb - ruby code to handle japanese (EUC/SJIS) string
$vsave, $VERBOSE = $VERBOSE, FALSE
$vsave, $VERBOSE = $VERBOSE, false
class String
printf STDERR, "feel free for some warnings:\n" if $VERBOSE

View file

@ -37,7 +37,7 @@
# creates a matrix where `rows' indicates rows.
# `rows' is an array of arrays,
# e.g, Matrix[[11, 12], [21, 22]]
# Matrix.rows(rows, copy = TRUE)
# Matrix.rows(rows, copy = true)
# creates a matrix where `rows' indicates rows.
# if optional argument `copy' is false, use the array as
# internal structure of the metrix without copying.
@ -143,7 +143,7 @@
#
# INSTANCE CREATION:
# Vector.[](*array)
# Vector.elements(array, copy = TRUE)
# Vector.elements(array, copy = true)
# ACCSESSING:
# [](i)
# size
@ -193,10 +193,10 @@ class Matrix
private_class_method :new
def Matrix.[](*rows)
new(:init_rows, rows, FALSE)
new(:init_rows, rows, false)
end
def Matrix.rows(rows, copy = TRUE)
def Matrix.rows(rows, copy = true)
new(:init_rows, rows, copy)
end
@ -208,7 +208,7 @@ class Matrix
columns[j][i]
}
}
Matrix.rows(rows, FALSE)
Matrix.rows(rows, false)
end
def Matrix.diagonal(*values)
@ -220,7 +220,7 @@ class Matrix
row
}
self
rows(rows, FALSE)
rows(rows, false)
end
def Matrix.scalar(n, value)
@ -242,11 +242,11 @@ class Matrix
def Matrix.row_vector(row)
case row
when Vector
Matrix.rows([row.to_a], FALSE)
Matrix.rows([row.to_a], false)
when Array
Matrix.rows([row.dup], FALSE)
Matrix.rows([row.dup], false)
else
Matrix.row([[row]], FALSE)
Matrix.row([[row]], false)
end
end
@ -311,13 +311,13 @@ class Matrix
|i|
@rows[i][j]
}
Vector.elements(col, FALSE)
Vector.elements(col, false)
end
end
def collect
rows = @rows.collect{|row| row.collect{|e| yield e}}
Matrix.rows(rows, FALSE)
Matrix.rows(rows, false)
end
alias map collect
@ -345,7 +345,7 @@ class Matrix
|row|
row[from_col, size_col]
}
Matrix.rows(rows, FALSE)
Matrix.rows(rows, false)
end
# TESTING
@ -363,20 +363,20 @@ class Matrix
# COMPARING
def ==(other)
return FALSE unless Matrix === other
return false unless Matrix === other
other.compare_by_row_vectors(@rows)
end
alias eql? ==
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
|i|
return FALSE unless @rows[i] == rows[i]
return false unless @rows[i] == rows[i]
end
TRUE
true
end
def clone
@ -405,7 +405,7 @@ class Matrix
e * m
}
}
return Matrix.rows(rows, FALSE)
return Matrix.rows(rows, false)
when Vector
m = Matrix.column_vector(m)
r = self * m
@ -425,7 +425,7 @@ class Matrix
vij
}
}
return Matrix.rows(rows, FALSE)
return Matrix.rows(rows, false)
else
x, y = m.coerce(self)
return x * y
@ -453,7 +453,7 @@ class Matrix
self[i, j] + m[i, j]
}
}
Matrix.rows(rows, FALSE)
Matrix.rows(rows, false)
end
def -(m)
@ -477,7 +477,7 @@ class Matrix
self[i, j] - m[i, j]
}
}
Matrix.rows(rows, FALSE)
Matrix.rows(rows, false)
end
def /(other)
@ -490,7 +490,7 @@ class Matrix
e / other
}
}
return Matrix.rows(rows, FALSE)
return Matrix.rows(rows, false)
when Matrix
return self * other.inverse
else
@ -825,10 +825,10 @@ class Vector
private_class_method :new
def Vector.[](*array)
new(:init_elements, array, copy = FALSE)
new(:init_elements, array, copy = false)
end
def Vector.elements(array, copy = TRUE)
def Vector.elements(array, copy = true)
new(:init_elements, array, copy)
end
@ -873,7 +873,7 @@ class Vector
# COMPARING
def ==(other)
return FALSE unless Vector === other
return false unless Vector === other
other.compare_by(@elements)
end
@ -897,7 +897,7 @@ class Vector
case x
when Numeric
els = @elements.collect{|e| e * x}
Vector.elements(els, FALSE)
Vector.elements(els, false)
when Matrix
self.covector * x
else
@ -914,7 +914,7 @@ class Vector
|v1, v2|
v1 + v2
}
Vector.elements(els, FALSE)
Vector.elements(els, false)
when Matrix
Matrix.column_vector(self) + v
else
@ -931,7 +931,7 @@ class Vector
|v1, v2|
v1 - v2
}
Vector.elements(els, FALSE)
Vector.elements(els, false)
when Matrix
Matrix.column_vector(self) - v
else
@ -958,7 +958,7 @@ class Vector
|v|
yield v
}
Vector.elements(els, FALSE)
Vector.elements(els, false)
end
alias map collect
@ -967,7 +967,7 @@ class Vector
|v1, v2|
yield v1, v2
}
Vector.elements(els, FALSE)
Vector.elements(els, false)
end
def r

View file

@ -377,7 +377,7 @@ module Net
end
end
def putbinaryfile(localfile, remotefile, blocksize, callback = nil)
def putbinaryfile(localfile, remotefile, blocksize = 4096, callback = nil)
if iterator?
callback = Proc.new
end
@ -635,7 +635,7 @@ module Net
host = (@sock.peeraddr())[3]
return host, port
end
private :parse228
private :parse229
def parse257(resp)
if resp[0, 3] != "257"

View file

@ -17,10 +17,10 @@ class Tracer
@RCS_ID='-$Id: tracer.rb,v 1.8 1998/05/19 03:42:49 keiju Exp keiju $-'
class << self
attr :verbose, TRUE
attr :verbose, true
alias verbose? verbose
end
verbose = TRUE
verbose = true
MY_FILE_NAME = caller(0)[0].scan(/^(.*):[0-9]+$/)[0][0]
@ -114,14 +114,14 @@ class Tracer
return unless p.call event, file, line, id, binding
end
Thread.critical = TRUE
Thread.critical = true
printf("#%d:%s:%d:%s: %s",
get_thread_no,
file,
line,
EVENT_SYMBOL[event],
get_line(file, line))
Thread.critical = FALSE
Thread.critical = false
end
Single = new

View file

@ -19,18 +19,24 @@ class WeakRef<Delegator
ID_MAP = {} # obj -> [ref,...]
ID_REV_MAP = {} # ref -> obj
ObjectSpace.add_finalizer(lambda{|id|
rids = ID_MAP[id]
if rids
for rid in rids
ID_REV_MAP[rid] = nil
__old_status = Thread.critical
Thread.critical = true
begin
rids = ID_MAP[id]
if rids
for rid in rids
ID_REV_MAP[rid] = nil
end
ID_MAP[id] = nil
end
ID_MAP[id] = nil
end
rid = ID_REV_MAP[id]
if rid
ID_REV_MAP[id] = nil
ID_MAP[rid].delete(id)
ID_MAP[rid] = nil if ID_MAP[rid].empty?
rid = ID_REV_MAP[id]
if rid
ID_REV_MAP[id] = nil
ID_MAP[rid].delete(id)
ID_MAP[rid] = nil if ID_MAP[rid].empty?
end
ensure
Thread.critical = __old_status
end
})

View file

@ -11,6 +11,20 @@
#
#
# probably based on:
#
# Newsgroups: comp.sources.misc,de.comp.sources.os9
# From: fkk@stasys.sta.sub.org (Frank Kaefer)
# Subject: v41i126: br - Biorhythm v3.0, Part01/01
# Message-ID: <1994Feb1.070616.15982@sparky.sterling.com>
# Sender: kent@sparky.sterling.com (Kent Landfield)
# Organization: Sterling Software
# Date: Tue, 1 Feb 1994 07:06:16 GMT
#
# Posting-number: Volume 41, Issue 126
# Archive-name: br/part01
# Environment: basic, dos, os9
include Math
require "date.rb"
require "parsearg.rb"

View file

@ -1,4 +1,4 @@
#! /usr/local/bin/ruby
#! /usr/bin/env ruby
# cal.rb: Written by Tadayoshi Funaba 1998-2000
# $Id: cal.rb,v 1.10 2000/05/20 02:09:47 tadf Exp $

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.4"
#define RUBY_RELEASE_DATE "2000-07-06"
#define RUBY_RELEASE_DATE "2000-07-10"
#define RUBY_VERSION_CODE 154
#define RUBY_RELEASE_CODE 20000706
#define RUBY_RELEASE_CODE 20000710