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@557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-11-04 08:39:57 +00:00
parent 0d684beafb
commit a9e9697994
16 changed files with 2126 additions and 80 deletions

View file

@ -1,3 +1,21 @@
Wed Nov 3 08:52:57 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
* io.c (Init_IO): forgot to use INT2FIX() around SEEK_SET, etc.
Wed Nov 3 00:25:20 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* string.c (rb_str_split_method): use mbclen2() to handle kcode
option of regexp objects.
Mon Nov 1 14:22:15 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
* eval.c (rb_eval): reduce recursive calls to rb_eval()
case of ||= and &&= .
Sun Oct 31 13:12:42 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
* regex.c (re_compile_pattern): wrong [\W] match.
Fri Oct 29 16:57:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* ext/nkf/lib/kconv.rb: new String methods (kconv, tojis, toeuc,

View file

@ -26,8 +26,11 @@
int sys_nerr = 256;
#endif
#if defined __CYGWIN__ && defined _sys_nerr
#define sys_nerr _sys_nerr
#if defined __CYGWIN__
# include <cygwin/version.h>
# if (CYGWIN_VERSION_API_MAJOR > 0) || (CYGWIN_VERSION_API_MINOR >= 8)
# define sys_nerr _sys_nerr
# endif
#endif
int ruby_nerrs;
@ -442,7 +445,7 @@ static const syserr_index_entry syserr_index[]= {
static VALUE *syserr_list;
#endif
#ifndef NT
#if !defined NT && !defined sys_nerr
extern int sys_nerr;
#endif

23
eval.c
View file

@ -1771,7 +1771,7 @@ rb_eval(self, node)
/* nodes for speed-up(literal match) */
case NODE_MATCH2:
result = rb_reg_match(rb_eval(self,node->nd_recv),
rb_eval(self,node->nd_value));
rb_eval(self,node->nd_value));
break;
/* nodes for speed-up(literal match) */
@ -1841,7 +1841,12 @@ rb_eval(self, node)
{
VALUE val;
val = rb_eval(self, node->nd_head);
if (node->nd_head) {
val = rb_eval(self, node->nd_head);
}
else {
val = Qtrue;
}
node = node->nd_body;
while (node) {
NODE *tag;
@ -2334,17 +2339,15 @@ rb_eval(self, node)
case NODE_OP_ASGN_AND:
result = rb_eval(self, node->nd_head);
if (RTEST(result)) {
result = rb_eval(self, node->nd_value);
}
break;
if (!RTEST(result)) break;
node = node->nd_value;
goto again;
case NODE_OP_ASGN_OR:
result = rb_eval(self, node->nd_head);
if (!RTEST(result)) {
result = rb_eval(self, node->nd_value);
}
break;
if (RTEST(result)) break;
node = node->nd_value;
goto again;
case NODE_MASGN:
result = massign(self, node, rb_eval(self, node->nd_value),0);

View file

@ -72,12 +72,16 @@ fdbm_s_open(argc, argv, klass)
Check_SafeStr(file);
dbm = 0;
if (mode >= 0)
if (mode >= 0) {
dbm = dbm_open(RSTRING(file)->ptr, O_RDWR|O_CREAT, mode);
if (!dbm)
}
if (!dbm) {
mode = 0666;
dbm = dbm_open(RSTRING(file)->ptr, O_RDWR, mode);
if (!dbm)
}
if (!dbm) {
dbm = dbm_open(RSTRING(file)->ptr, O_RDONLY, mode);
}
if (!dbm) {
if (mode == -1) return Qnil;

View file

@ -21,6 +21,7 @@ def find_tcl(tcllib)
find_library(tcllib, func, *paths)
else
find_library("tcl", func, *paths) or
find_library("tcl8.2", func, *paths) or
find_library("tcl8.0", func, *paths) or
find_library("tcl7.6", func, *paths)
end
@ -33,6 +34,7 @@ def find_tk(tklib)
find_library(tklib, func, *paths)
else
find_library("tk", func, *paths) or
find_library("tk8.2", func, *paths) or
find_library("tk8.0", func, *paths) or
find_library("tk4.2", func, *paths)
end

View file

@ -667,7 +667,20 @@ class TkFont
alias measure_core measure_core_tk8x
alias metrics_core metrics_core_tk8x
when /^8\.1/
when /^8\.[12]/
alias create_latinfont create_latinfont_tk8x
alias create_kanjifont create_kanjifont_tk81
alias create_compoundfont create_compoundfont_tk81
alias actual_core actual_core_tk8x
alias configure_core configure_core_tk8x
alias configinfo_core configinfo_core_tk8x
alias delete_core delete_core_tk8x
alias latin_replace_core latin_replace_core_tk8x
alias kanji_replace_core kanji_replace_core_tk81
alias measure_core measure_core_tk8x
alias metrics_core metrics_core_tk8x
when /^8\.*/
alias create_latinfont create_latinfont_tk8x
alias create_kanjifont create_kanjifont_tk81
alias create_compoundfont create_compoundfont_tk81

View file

@ -210,6 +210,12 @@ VALUE rb_Array _((VALUE));
/* parse.y */
extern int ruby_sourceline;
extern char *ruby_sourcefile;
#define yyparse rb_yyparse
#define yylex rb_yylex
#define yyerror rb_yyerror
#define yylval rb_yylval
#define yychar rb_yychar
#define yydebug rb_yydebug
int yyparse _((void));
ID rb_id_attrset _((ID));
void rb_parser_append_print _((void));

6
io.c
View file

@ -3254,9 +3254,9 @@ Init_IO()
rb_define_method(rb_cIO, "flush", rb_io_flush, 0);
rb_define_method(rb_cIO, "tell", rb_io_tell, 0);
rb_define_method(rb_cIO, "seek", rb_io_seek, 2);
rb_define_const(rb_cIO, "SEEK_SET", SEEK_SET);
rb_define_const(rb_cIO, "SEEK_CUR", SEEK_CUR);
rb_define_const(rb_cIO, "SEEK_END", SEEK_END);
rb_define_const(rb_cIO, "SEEK_SET", INT2FIX(SEEK_SET));
rb_define_const(rb_cIO, "SEEK_CUR", INT2FIX(SEEK_CUR));
rb_define_const(rb_cIO, "SEEK_END", INT2FIX(SEEK_END));
rb_define_method(rb_cIO, "rewind", rb_io_rewind, 0);
rb_define_method(rb_cIO, "pos", rb_io_tell, 0);
rb_define_method(rb_cIO, "pos=", rb_io_set_pos, 1);

1949
lib/cgi.rb Normal file

File diff suppressed because it is too large Load diff

View file

@ -4,58 +4,82 @@ $vsave, $VERBOSE = $VERBOSE, FALSE
class String
printf STDERR, "feel free for some warnings:\n" if $VERBOSE
def jlength
self.split(//).length
end
PATTERN_SJIS = '[\x81-\x9f\xe0-\xef][\x40-\x7e\x80-\xfc]'
PATTERN_EUC = '[\xa1-\xfe][\xa1-\xfe]'
PATTERN_UTF8 = '[\xc0-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf][\x80-\xbf]'
alias original_succ succ
private :original_succ
RE_SJIS = Regexp.new(PATTERN_SJIS, 'n')
RE_EUC = Regexp.new(PATTERN_EUC, 'n')
RE_UTF8 = Regexp.new(PATTERN_UTF8, 'n')
SUCC = {}
SUCC['s'] = Hash.new(1)
for i in 0 .. 0x3f
SUCC['s'][i.chr] = 0x40 - i
end
SUCC['s']["\x7e"] = 0x80 - 0x7e
SUCC['s']["\xfd"] = 0x100 - 0xfd
SUCC['s']["\xfe"] = 0x100 - 0xfe
SUCC['s']["\xff"] = 0x100 - 0xff
SUCC['e'] = Hash.new(1)
for i in 0 .. 0xa0
SUCC['e'][i.chr] = 0xa1 - i
end
SUCC['e']["\xfe"] = 2
SUCC['u'] = Hash.new(1)
for i in 0 .. 0x7f
SUCC['u'][i.chr] = 0x80 - i
end
SUCC['u']["\xbf"] = 0x100 - 0xbf
def mbchar?
case $KCODE[0]
when ?s, ?S
self =~ /[\x81-\x9f\xe0-\xef][\x40-\x7e\x80-\xfc]/n
self =~ RE_SJIS
when ?e, ?E
self =~ /[\xa1-\xfe][\xa1-\xfe]/n
self =~ RE_EUC
when ?u, ?U
self =~ RE_UTF8
else
false
nil
end
end
def end_regexp
case $KCODE[0]
when ?s, ?S
/#{PATTERN_SJIS}$/o
when ?e, ?E
/#{PATTERN_EUC}$/o
when ?u, ?U
/#{PATTERN_UTF8}$/o
else
/.$/o
end
end
alias original_succ! succ!
private :original_succ!
alias original_succ succ
private :original_succ
def succ!
reg = end_regexp
if self =~ reg
succ_table = SUCC[$KCODE[0,1].downcase]
begin
self[-1] += succ_table[self[-1]]
self[-2] += 1 if self[-1] == 0
end while self !~ reg
self
else
original_succ!
end
end
def succ
if self[-2] and self[-2, 2].mbchar?
s = self.dup
s[-1] += 1
s[-1] += 1 unless s[-2, 2].mbchar?
return s
else
original_succ
end
end
def upto(to)
return if self > to
curr = self
tail = self[-2..-1]
if tail.length == 2 and tail =~ /^.$/ then
if self[0..-2] == to[0..-2]
first = self[-2].chr
for c in self[-1] .. to[-1]
if (first+c.chr).mbchar?
yield self[0..-2]+c.chr
end
end
end
else
loop do
yield curr
return if curr == to
curr = curr.succ
return if curr.length > to.length
end
end
return nil
(str = self.dup).succ! or str
end
private
@ -159,9 +183,24 @@ class String
(str = self.dup).chop! or str
end
def jlength
self.gsub(/[^\Wa-zA-Z_\d]/, ' ').length
end
alias jsize jlength
def jcount(str)
self.delete("^#{str}").jlength
end
def each_char
if iterator?
scan(/./) do |x|
yield x
end
else
scan(/./)
end
end
end
$VERBOSE = $vsave

16
re.c
View file

@ -182,6 +182,21 @@ kcode_reset_option()
}
}
int
rb_mbclen2(c, re)
unsigned char c;
VALUE re;
{
int len;
if (!FL_TEST(re, KCODE_FIXED))
return mbclen(c);
kcode_set_option(re);
len = mbclen(c);
kcode_reset_option();
return len;
}
extern int ruby_in_compile;
static void
@ -538,6 +553,7 @@ rb_reg_search(reg, str, pos, reverse)
}
result = re_search(RREGEXP(reg)->ptr,RSTRING(str)->ptr,RSTRING(str)->len,
pos, range, regs);
if (FL_TEST(reg, KCODE_FIXED))
kcode_reset_option();

3
re.h
View file

@ -36,4 +36,7 @@ VALUE rb_reg_regsub _((VALUE, VALUE, struct re_registers *));
int rb_kcode _((void));
extern int ruby_ignorecase;
int rb_mbclen2 _((unsigned char, VALUE));
#define mbclen2(c,re) rb_mbclen2((c),(re))
#endif

View file

@ -1406,7 +1406,8 @@ re_compile_pattern(pattern, size, bufp)
case 'W':
for (c = 0; c < (1 << BYTEWIDTH); c++) {
if (SYNTAX(c) != Sword &&
(current_mbctype || SYNTAX(c) != Sword2))
(current_mbctype && !re_mbctab[c] ||
!current_mbctype && SYNTAX(c) != Sword2))
SET_LIST_BIT(c);
}
last = -1;

View file

@ -757,6 +757,7 @@ rb_str_upto(beg, end, excl)
int excl;
{
VALUE current;
ID succ = rb_intern("succ");
if (TYPE(end) != T_STRING) end = rb_str_to_str(end);
@ -764,7 +765,7 @@ rb_str_upto(beg, end, excl)
while (rb_str_cmp(current, end) <= 0) {
rb_yield(current);
if (!excl && rb_str_equal(current, end)) break;
current = rb_str_succ(current);
current = rb_funcall(current, succ, 0, 0);
if (excl && rb_str_equal(current, end)) break;
if (RSTRING(current)->len > RSTRING(end)->len)
break;
@ -1110,7 +1111,7 @@ rb_str_gsub_bang(argc, argv, str)
* Always consume at least one character of the input string
* in order to prevent infinite loops.
*/
len = mbclen(RSTRING(str)->ptr[END(0)]);
len = mbclen2(RSTRING(str)->ptr[END(0)], pat);
if (RSTRING(str)->len > END(0)) {
memcpy(bp, RSTRING(str)->ptr+END(0), len);
bp += len;
@ -1342,12 +1343,6 @@ rb_str_inspect(str)
*b++ = *p++;
}
}
#if 0
else if ((c & 0x80) && rb_kcode() != MBCTYPE_EUC) {
CHECK(1);
*b++ = c;
}
#endif
else if (c == '"'|| c == '\\') {
CHECK(2);
*b++ = '\\';
@ -2074,11 +2069,11 @@ rb_str_split_method(argc, argv, str)
regs = RMATCH(rb_backref_get())->regs;
if (start == end && BEG(0) == END(0)) {
if (last_null == 1) {
rb_ary_push(result, rb_str_substr(str, beg, mbclen(RSTRING(str)->ptr[beg])));
rb_ary_push(result, rb_str_substr(str, beg, mbclen2(RSTRING(str)->ptr[beg],spat)));
beg = start;
}
else {
start += mbclen(RSTRING(str)->ptr[start]);
start += mbclen2(RSTRING(str)->ptr[start],spat);
last_null = 1;
continue;
}
@ -2384,7 +2379,7 @@ scan_once(str, pat, start)
/*
* Always consume at least one character of the input string
*/
*start = END(0)+mbclen(RSTRING(str)->ptr[END(0)]);
*start = END(0)+mbclen2(RSTRING(str)->ptr[END(0)],pat);
}
else {
*start = END(0);

View file

@ -19,7 +19,7 @@ LDFLAGS = $(CFLAGS) -Fm
XLDFLAGS =
#EXTLIBS =
LIBS = advapi32.lib wsock32.lib $(EXTLIBS)
MISSING = crypt.obj alloca.obj win32.obj fnmatch.obj isinf.obj isnan.obj
MISSING = crypt.obj alloca.obj win32.obj isinf.obj isnan.obj
LDSHARED =
DLDFLAGS =
SOLIBS =
@ -166,9 +166,6 @@ isinf.obj: missing/isinf.c
isnan.obj: missing/isnan.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c missing/isnan.c
fnmatch.obj: missing/fnmatch.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c missing/fnmatch.c
memcmp.obj: missing/memcmp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c missing/memcmp.c

View file

@ -99,8 +99,6 @@ EXPORTS
definekey
encrypt
crypt
;missing/fnmatch.c
fnmatch
;missing/isinf.c
isinf
;missing/isnan.c
@ -452,7 +450,6 @@ EXPORTS
rb_get_kcode
rb_set_kcode
;ruby.c
ruby_require_libraries
rb_load_file
ruby_script
ruby_prog_init