git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-10-04 04:51:08 +00:00
Родитель d426749ff0
Коммит 758cb647c7
20 изменённых файлов: 125 добавлений и 65 удалений

Просмотреть файл

@ -1,3 +1,25 @@
Mon Oct 4 12:42:32 1999 Kazuhiko Izawa <izawa@erec.che.tohoku.ac.jp>
* pack.c (pack_unpack): % in printf format should be %%.
Mon Oct 4 10:01:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* variable.c (rb_obj_instance_variables): should always return
array for all object can have instance variables now.
Mon Oct 4 00:08:34 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* pack.c (OFF16): need to adjust pointer address to pack/unpack on
64bit machines.
Sun Oct 03 03:05:59 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
* time.c (time_arg): mktime y2k problem.
Sun Sep 26 16:54:45 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
* parse.y (here_document): `\r' handling for here documents.
Wed Sep 22 09:20:11 1999 Masahiro Tomita <tommy@tmtm.org>
* ext/socket/socket.c: SOCKS5 support.

Просмотреть файл

@ -38,7 +38,7 @@ LIBRUBY_ALIASES= @LIBRUBY_ALIASES@
LIBRUBY = @LIBRUBY@
LIBRUBYARG = @LIBRUBYARG@
EXTOBJS =
EXTOBJS = dmyext.@OBJEXT@
MAINOBJ = main.@OBJEXT@
@ -83,20 +83,20 @@ OBJS = array.@OBJEXT@ \
all: miniruby$(EXEEXT) rbconfig.rb
@./miniruby$(EXEEXT) -Xext extmk.rb @EXTSTATIC@
miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) dmyext.@OBJEXT@
miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) $(EXTOBJS)
@rm -f $@
$(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) dmyext.@OBJEXT@ $(LIBRUBY_A) $(LIBS) -o $@
$(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY_A) $(LIBS) -o $@
$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS)
@rm -f $@
$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
$(LIBRUBY_A): $(OBJS) dmyext.@OBJEXT@
@AR@ rcu $@ $(OBJS) dmyext.@OBJEXT@
$(LIBRUBY_A): $(OBJS)
@AR@ rcu $@ $(OBJS)
@-@RANLIB@ $@ 2> /dev/null || true
$(LIBRUBY_SO): $(OBJS) dmyext.@OBJEXT@
$(LDSHARED) $(DLDFLAGS) $(SOLIBS) $(OBJS) dmyext.@OBJEXT@ -o $@
$(LIBRUBY_SO): $(OBJS)
$(LDSHARED) $(DLDFLAGS) $(SOLIBS) $(OBJS) -o $@
@-./miniruby -e 'ARGV.each{|link| File.delete link if File.exist? link; \
File.symlink "$(LIBRUBY_SO)", link}' \
$(LIBRUBY_ALIASES) || true

Просмотреть файл

@ -893,7 +893,6 @@ Calls the function func1, supplying func2 as the block. func1 will be
called with the argument arg1. func2 receives the value from yield as
the first argument, arg2 as the second argument.
VALUE rb_yield(VALUE val)
Evaluates the block with value val.
@ -942,10 +941,14 @@ exception handling nor ensure execution will be done.
The embedding API are below (not needed for extension libraries):
void ruby_init(int argc, char **argv, char **envp)
void ruby_init()
Initializes the interpreter.
void ruby_options(int argc, char **argv)
Process command line arguments for the interpreter.
void ruby_run()
Starts execution of the interpreter.

Просмотреть файл

@ -245,8 +245,8 @@ Ruby
クラスやモジュールを他のクラスの内部にネストして定義する時に
は以下の関数を使います.
VALUE rb_define_class(VALUE outer, char *name, VALUE super)
VALUE rb_define_module(VALUE outer, char *name)
VALUE rb_define_class_under(VALUE outer, char *name, VALUE super)
VALUE rb_define_module_under(VALUE outer, char *name)
2.1.2 メソッド/特異メソッド定義
@ -1099,10 +1099,14 @@ void rb_bug(char *fmt, ...)
Rubyをアプリケーションに埋め込む場合には以下のインタフェース
を使う.通常の拡張ライブラリには必要ない.
void ruby_init(int argc, char **argv, char **envp)
void ruby_init()
Rubyインタプリタの初期化を行なう
void ruby_options(int argc, char **argv)
Rubyインタプリタのコマンドライン引数の処理を行なう
void ruby_run()
Rubyインタプリタを実行する

Просмотреть файл

@ -136,7 +136,7 @@ UNIX
* 配布条件
RubyはフリーソフトウェアですGPL(the GNU General Public
Licence)または以下に示す条件でRubyを再配布できますGPLにつ
License)または以下に示す条件でRubyを再配布できますGPLにつ
いてはCOPYINGファイルを参照して下さい
1. 複製は制限なく自由です.

1
ToDo
Просмотреть файл

@ -15,6 +15,7 @@ Language Spec.
Hacking Interpreter
* RUBYOPT environment variable
* non-blocking open (e.g. named pipe) for thread
* avoid blocking with gethostbyname/gethostbyaddr
* objectify interpreters

5
eval.c
Просмотреть файл

@ -1185,9 +1185,9 @@ rb_eval_string_wrap(str, state)
POP_CLASS();
if (state) {
*state = status;
if (status) {
JUMP_TAG(status);
}
else if (status) {
JUMP_TAG(status);
}
return val;
}
@ -6414,7 +6414,6 @@ rb_thread_schedule()
fd_set readfds;
struct timeval delay_tv, *delay_ptr;
double delay, now; /* OK */
int n, max;
do {

Просмотреть файл

@ -10,7 +10,7 @@
#undef getc
#undef ungetc
#define getc(f) (input_ctr>i_len?-1:input[input_ctr++])
#define getc(f) (input_ctr<i_len?input[input_ctr++]:-1)
#define ungetc(c,f) input_ctr--
#undef putchar

Просмотреть файл

@ -1826,6 +1826,7 @@ reinit()
file_out = FALSE;
add_cr = FALSE;
del_cr = FALSE;
line = 0;
}
#ifndef PERL_XS

Просмотреть файл

@ -67,6 +67,10 @@
#include <stddef.h>
#include <ctype.h>
#ifdef SOCKS5
#include <socks.h>
#endif
#include "config.h"
#include "addrinfo.h"
#include "sockport.h"

Просмотреть файл

@ -56,6 +56,10 @@
#include <string.h>
#include <stddef.h>
#ifdef SOCKS5
#include <socks.h>
#endif
#include "config.h"
#include "addrinfo.h"
#include "sockport.h"

Просмотреть файл

@ -780,6 +780,20 @@ socks_s_open(class, host, serv)
Check_SafeStr(host);
return open_inet(class, host, serv, INET_SOCKS);
}
#ifdef SOCKS5
static VALUE
socks_s_close(sock)
VALUE sock;
{
OpenFile *fptr;
GetOpenFile(sock, fptr);
shutdown(fileno(fptr->f), 2);
shutdown(fileno(fptr->f2), 2);
return rb_io_close(sock);
}
#endif
#endif
/*
@ -1876,6 +1890,9 @@ Init_socket()
rb_define_global_const("SOCKSsocket", rb_cSOCKSSocket);
rb_define_singleton_method(rb_cSOCKSSocket, "open", socks_s_open, 2);
rb_define_singleton_method(rb_cSOCKSSocket, "new", socks_s_open, 2);
#ifdef SOCKS5
rb_define_method(rb_cSOCKSSocket, "close", socks_s_close, 0);
#endif
#endif
rb_cTCPServer = rb_define_class("TCPServer", rb_cTCPSocket);

Просмотреть файл

@ -576,12 +576,11 @@ An end of a defun is found by moving forward from the beginning of one."
(defun ruby-reindent-then-newline-and-indent ()
(interactive "*")
(save-excursion
(delete-region (point) (progn (skip-chars-backward " \t") (point))))
(newline)
(save-excursion
(forward-line -1)
(indent-according-to-mode))
(end-of-line 0)
(indent-according-to-mode)
(delete-region (point) (progn (skip-chars-backward " \t") (point))))
(indent-according-to-mode))
(fset 'ruby-encomment-region (symbol-function 'comment-region))

Просмотреть файл

@ -108,6 +108,8 @@ and source-file directory for your debugger."
(gud-def gud-print "p %e" "\C-p" "Evaluate ruby expression at point.")
(setq comint-prompt-regexp "^(rdb:-) ")
(if (boundp 'comint-last-output-start)
(set-marker comint-last-output-start (point)))
(set (make-local-variable 'paragraph-start) comint-prompt-regexp)
(run-hooks 'rubydb-mode-hook)
)

Просмотреть файл

@ -425,6 +425,7 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
*/
off = -(daylight ? timezone : altzone) / 60;
#else /* !HAVE_TZNAME */
gettimeofday(&tv, &zone);
off = -zone.tz_minuteswest;
#endif /* !HAVE_TZNAME */
#endif /* !HAVE_TM_ZONE */

69
pack.c
Просмотреть файл

@ -23,10 +23,19 @@
#ifdef NATINT_PACK
# define NATINT_LEN(type,len) (natint?sizeof(type):(len))
# ifndef WORDS_BIGENDIAN
# define OFF16(p) ((char*)(p) + (natint?(sizeof(short) - 2):0))
# define OFF32(p) ((char*)(p) + (natint?(sizeof(long) - 4):0))
# endif
#else
# define NATINT_LEN(type,len) sizeof(type)
#endif
#ifndef OFF16
# define OFF16(p) (char*)(p)
# define OFF32(p) (char*)(p)
#endif
#define define_swapx(x, xtype) \
static xtype \
TOKEN_PASTE(swap,x)(z) \
@ -546,7 +555,7 @@ pack_pack(ary, fmt)
else {
s = NUM2INT(from);
}
rb_str_cat(res, (char*)&s, NATINT_LEN(short,2));
rb_str_cat(res, OFF16(&s), NATINT_LEN(short,2));
}
break;
@ -574,7 +583,7 @@ pack_pack(ary, fmt)
else {
l = NUM2ULONG(from);
}
rb_str_cat(res, (char*)&l, NATINT_LEN(long,4));
rb_str_cat(res, OFF32(&l), NATINT_LEN(long,4));
}
break;
@ -588,7 +597,7 @@ pack_pack(ary, fmt)
s = NUM2INT(from);
}
s = htons(s);
rb_str_cat(res, (char*)&s, NATINT_LEN(short,2));
rb_str_cat(res, OFF16(&s), NATINT_LEN(short,2));
}
break;
@ -602,7 +611,7 @@ pack_pack(ary, fmt)
l = NUM2ULONG(from);
}
l = htonl(l);
rb_str_cat(res, (char*)&l, NATINT_LEN(long,4));
rb_str_cat(res, OFF32(&l), NATINT_LEN(long,4));
}
break;
@ -616,7 +625,7 @@ pack_pack(ary, fmt)
s = NUM2INT(from);
}
s = htovs(s);
rb_str_cat(res, (char*)&s, NATINT_LEN(short,2));
rb_str_cat(res, OFF16(&s), NATINT_LEN(short,2));
}
break;
@ -630,7 +639,7 @@ pack_pack(ary, fmt)
l = NUM2ULONG(from);
}
l = htovl(l);
rb_str_cat(res, (char*)&l, NATINT_LEN(long,4));
rb_str_cat(res, OFF32(&l), NATINT_LEN(long,4));
}
break;
@ -783,7 +792,7 @@ pack_pack(ary, fmt)
break;
case '%':
rb_raise(rb_eArgError, "% may only be used in unpack");
rb_raise(rb_eArgError, "%% is not supported");
break;
case 'U':
@ -1062,7 +1071,7 @@ pack_unpack(str, fmt)
switch (type) {
case '%':
rb_raise(rb_eArgError, "% is not supported(yet)");
rb_raise(rb_eArgError, "%% is not supported");
break;
case 'A':
@ -1204,8 +1213,8 @@ pack_unpack(str, fmt)
case 's':
PACK_LENGTH_ADJUST(short,2);
while (len-- > 0) {
short tmp;
memcpy(&tmp, s, NATINT_LEN(short,2));
short tmp = 0;
memcpy(OFF16(&tmp), s, NATINT_LEN(short,2));
s += NATINT_LEN(short,2);
rb_ary_push(ary, INT2FIX(tmp));
}
@ -1215,8 +1224,8 @@ pack_unpack(str, fmt)
case 'S':
PACK_LENGTH_ADJUST(unsigned short,2);
while (len-- > 0) {
unsigned short tmp;
memcpy(&tmp, s, NATINT_LEN(unsigned short,2));
unsigned short tmp = 0;
memcpy(OFF16(&tmp), s, NATINT_LEN(unsigned short,2));
s += NATINT_LEN(unsigned short,2);
rb_ary_push(ary, INT2FIX(tmp));
}
@ -1248,8 +1257,8 @@ pack_unpack(str, fmt)
case 'l':
PACK_LENGTH_ADJUST(long,4);
while (len-- > 0) {
long tmp;
memcpy(&tmp, s, NATINT_LEN(long,4));
long tmp = 0;
memcpy(OFF32(&tmp), s, NATINT_LEN(long,4));
s += NATINT_LEN(long,4);
rb_ary_push(ary, rb_int2inum(tmp));
}
@ -1259,8 +1268,8 @@ pack_unpack(str, fmt)
case 'L':
PACK_LENGTH_ADJUST(unsigned long,4);
while (len-- > 0) {
unsigned long tmp;
memcpy(&tmp, s, NATINT_LEN(unsigned long,4));
unsigned long tmp = 0;
memcpy(OFF32(&tmp), s, NATINT_LEN(unsigned long,4));
s += NATINT_LEN(unsigned long,4);
rb_ary_push(ary, rb_uint2inum(tmp));
}
@ -1270,11 +1279,10 @@ pack_unpack(str, fmt)
case 'n':
PACK_LENGTH_ADJUST(unsigned short,2);
while (len-- > 0) {
unsigned short tmp;
memcpy(&tmp, s, NATINT_LEN(unsigned short,2));
unsigned short tmp = 0;
memcpy(OFF16(&tmp), s, NATINT_LEN(unsigned short,2));
s += NATINT_LEN(unsigned short,2);
tmp = ntohs(tmp);
rb_ary_push(ary, rb_uint2inum(tmp));
rb_ary_push(ary, rb_uint2inum(ntohs(tmp)));
}
PACK_ITEM_ADJUST();
break;
@ -1282,11 +1290,10 @@ pack_unpack(str, fmt)
case 'N':
PACK_LENGTH_ADJUST(unsigned long,4);
while (len-- > 0) {
unsigned long tmp;
memcpy(&tmp, s, NATINT_LEN(unsigned long,4));
unsigned long tmp = 0;
memcpy(OFF32(&tmp), s, NATINT_LEN(unsigned long,4));
s += NATINT_LEN(unsigned long,4);
tmp = ntohl(tmp);
rb_ary_push(ary, rb_uint2inum(tmp));
rb_ary_push(ary, rb_uint2inum(ntohl(tmp)));
}
PACK_ITEM_ADJUST();
break;
@ -1294,11 +1301,10 @@ pack_unpack(str, fmt)
case 'v':
PACK_LENGTH_ADJUST(unsigned short,2);
while (len-- > 0) {
unsigned short tmp;
memcpy(&tmp, s, NATINT_LEN(unsigned short,2));
unsigned short tmp = 0;
memcpy(OFF16(&tmp), s, NATINT_LEN(unsigned short,2));
s += NATINT_LEN(unsigned short,2);
tmp = vtohs(tmp);
rb_ary_push(ary, rb_uint2inum(tmp));
rb_ary_push(ary, rb_uint2inum(vtohs(tmp)));
}
PACK_ITEM_ADJUST();
break;
@ -1306,11 +1312,10 @@ pack_unpack(str, fmt)
case 'V':
PACK_LENGTH_ADJUST(unsigned long,4);
while (len-- > 0) {
unsigned long tmp;
memcpy(&tmp, s, NATINT_LEN(long,4));
unsigned long tmp = 0;
memcpy(OFF32(&tmp), s, NATINT_LEN(long,4));
s += NATINT_LEN(long,4);
tmp = vtohl(tmp);
rb_ary_push(ary, rb_uint2inum(tmp));
rb_ary_push(ary, rb_uint2inum(vtohl(tmp)));
}
PACK_ITEM_ADJUST();
break;

Просмотреть файл

@ -2387,7 +2387,7 @@ here_document(term, indent)
p++;
}
}
if (strncmp(eos, p, len) == 0 && p[len] == '\n') {
if (strncmp(eos, p, len) == 0 && (p[len] == '\n' || p[len] == '\r')) {
break;
}

Просмотреть файл

@ -2877,7 +2877,7 @@ re_compile_fastmap(bufp)
break;
}
for (j = 0,c = 0;j < (int)size; j++) {
int cc = EXTRACT_MBC(&p[j*8]);
unsigned int cc = EXTRACT_MBC(&p[j*8]);
beg = WC2MBC1ST(cc);
while (c < beg) {
if (ismbchar(c))

2
time.c
Просмотреть файл

@ -208,7 +208,7 @@ time_arg(argc, argv, tm)
}
tm->tm_year = obj2long(v[0]);
if (0 < tm->tm_year && tm->tm_year < 69) tm->tm_year += 100;
if (0 <= tm->tm_year && tm->tm_year < 69) tm->tm_year += 100;
if (tm->tm_year >= 1900) tm->tm_year -= 1900;
if (NIL_P(v[1])) {
tm->tm_mon = 0;

Просмотреть файл

@ -916,7 +916,7 @@ VALUE
rb_obj_instance_variables(obj)
VALUE obj;
{
VALUE ary;
VALUE ary = rb_ary_new();
if (!FL_TEST(obj, FL_TAINT) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't get metainfo");
@ -924,25 +924,23 @@ rb_obj_instance_variables(obj)
case T_OBJECT:
case T_CLASS:
case T_MODULE:
ary = rb_ary_new();
if (ROBJECT(obj)->iv_tbl) {
st_foreach(ROBJECT(obj)->iv_tbl, ivar_i, ary);
}
return ary;
break;
default:
if (!generic_iv_tbl) return Qnil;
if (!generic_iv_tbl) break;
if (FL_TEST(obj, FL_EXIVAR) || rb_special_const_p(obj)) {
st_table *tbl;
if (st_lookup(generic_iv_tbl, obj, &tbl)) {
ary = rb_ary_new();
st_foreach(tbl, ivar_i, ary);
}
}
break;
}
return ary;
}
}
}
return Qnil;
}
VALUE
rb_obj_remove_instance_variable(obj, name)