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/branches/ruby_1_4@564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-11-17 07:30:37 +00:00
parent aa6ca26e8b
commit b1d45b805c
7 changed files with 45 additions and 19 deletions

View file

@ -89,6 +89,7 @@ lib/Env.rb
lib/README lib/README
lib/base64.rb lib/base64.rb
lib/cgi.rb lib/cgi.rb
lib/cgi/session.rb
lib/cgi-lib.rb lib/cgi-lib.rb
lib/complex.rb lib/complex.rb
lib/date.rb lib/date.rb

View file

@ -78,6 +78,16 @@ class PStore
begin begin
@transaction = true @transaction = true
value = file = nil value = file = nil
lock = @filename + ".lock"
loop do
begin
File::symlink("pstore::#$$", lock)
break
rescue Errno::EEXIST
rescue
sleep 1
end
end
begin begin
File::open(@filename, "r") do |file| File::open(@filename, "r") do |file|
@table = Marshal.load(file) @table = Marshal.load(file)
@ -112,6 +122,7 @@ class PStore
ensure ensure
@table = nil @table = nil
@transaction = false @transaction = false
File::unlink(lock)
end end
value value
end end

View file

@ -14,6 +14,7 @@ module Singleton
def Singleton.append_features(klass) def Singleton.append_features(klass)
klass.private_class_method(:new) klass.private_class_method(:new)
klass.instance_eval %{ klass.instance_eval %{
@__instance__ = nil
def instance def instance
unless @__instance__ unless @__instance__
@__instance__ = new @__instance__ = new

27
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; extern int ruby_in_compile;
static void static void
@ -260,10 +275,7 @@ static VALUE
rb_reg_source(re) rb_reg_source(re)
VALUE re; VALUE re;
{ {
VALUE str = rb_str_new(0,0); return rb_str_new(RREGEXP(re)->str,RREGEXP(re)->len);
rb_reg_expr_str(str, RREGEXP(re)->str,RREGEXP(re)->len);
return str;
} }
static VALUE static VALUE
@ -538,6 +550,7 @@ rb_reg_search(reg, str, pos, reverse)
} }
result = re_search(RREGEXP(reg)->ptr,RSTRING(str)->ptr,RSTRING(str)->len, result = re_search(RREGEXP(reg)->ptr,RSTRING(str)->ptr,RSTRING(str)->len,
pos, range, regs); pos, range, regs);
if (FL_TEST(reg, KCODE_FIXED)) if (FL_TEST(reg, KCODE_FIXED))
kcode_reset_option(); kcode_reset_option();
@ -710,7 +723,7 @@ static VALUE
match_string(match) match_string(match)
VALUE match; VALUE match;
{ {
return rb_str_dup(RMATCH(match)->str); return RMATCH(match)->str; /* str is frozen */
} }
VALUE rb_cRegexp; VALUE rb_cRegexp;
@ -1263,7 +1276,9 @@ Init_Regexp()
rb_global_variable(&reg_cache); rb_global_variable(&reg_cache);
rb_global_variable(&matchcache); rb_global_variable(&matchcache);
rb_cMatch = rb_define_class("MatchingData", rb_cData); rb_cMatch = rb_define_class("MatchingData", rb_cObject);
rb_undef_method(CLASS_OF(rb_cMatch), "new");
rb_define_method(rb_cMatch, "clone", match_clone, 0); rb_define_method(rb_cMatch, "clone", match_clone, 0);
rb_define_method(rb_cMatch, "size", match_size, 0); rb_define_method(rb_cMatch, "size", match_size, 0);
rb_define_method(rb_cMatch, "length", match_size, 0); rb_define_method(rb_cMatch, "length", match_size, 0);

3
re.h
View file

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

View file

@ -112,9 +112,10 @@ rb_str_new4(orig)
str->ptr = RSTRING(orig)->ptr; str->ptr = RSTRING(orig)->ptr;
RSTRING(orig)->orig = (VALUE)str; RSTRING(orig)->orig = (VALUE)str;
str->orig = 0; str->orig = 0;
if (FL_TEST(str, FL_TAINT)) { if (FL_TEST(orig, FL_TAINT)) {
FL_SET(str, FL_TAINT); FL_SET(str, FL_TAINT);
} }
FL_SET(str, STR_FREEZE);
return (VALUE)str; return (VALUE)str;
} }
} }
@ -1111,7 +1112,7 @@ rb_str_gsub_bang(argc, argv, str)
* Always consume at least one character of the input string * Always consume at least one character of the input string
* in order to prevent infinite loops. * 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)) { if (RSTRING(str)->len > END(0)) {
memcpy(bp, RSTRING(str)->ptr+END(0), len); memcpy(bp, RSTRING(str)->ptr+END(0), len);
bp += len; bp += len;
@ -1344,12 +1345,6 @@ rb_str_inspect(str)
*b++ = *p++; *b++ = *p++;
} }
} }
#if 0
else if ((c & 0x80) && rb_kcode() != MBCTYPE_EUC) {
CHECK(1);
*b++ = c;
}
#endif
else if (c == '"'|| c == '\\') { else if (c == '"'|| c == '\\') {
CHECK(2); CHECK(2);
*b++ = '\\'; *b++ = '\\';
@ -2084,11 +2079,11 @@ rb_str_split_method(argc, argv, str)
regs = RMATCH(rb_backref_get())->regs; regs = RMATCH(rb_backref_get())->regs;
if (start == end && BEG(0) == END(0)) { if (start == end && BEG(0) == END(0)) {
if (last_null == 1) { 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; beg = start;
} }
else { else {
start += mbclen(RSTRING(str)->ptr[start]); start += mbclen2(RSTRING(str)->ptr[start],spat);
last_null = 1; last_null = 1;
continue; continue;
} }
@ -2398,7 +2393,7 @@ scan_once(str, pat, start)
/* /*
* Always consume at least one character of the input string * 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 { else {
*start = END(0); *start = END(0);

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.4.3" #define RUBY_VERSION "1.4.3"
#define RUBY_RELEASE_DATE "1999-10-12" #define RUBY_RELEASE_DATE "1999-11-17"
#define RUBY_VERSION_CODE 143 #define RUBY_VERSION_CODE 143
#define RUBY_RELEASE_CODE 19991012 #define RUBY_RELEASE_CODE 19991117