summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-13 09:51:02 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-13 09:51:02 +0000
commit1b47fa1097c709be518a5071a7ec0e5271d45a00 (patch)
tree62f7220ccb1211efc9e1bc9b69c28448173c03bf /lib
parent1c940e6cdd3e59430d57a42a9d5989bc5ad85270 (diff)
2000-06-13
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/jcode.rb16
-rw-r--r--lib/pstore.rb4
2 files changed, 10 insertions, 10 deletions
diff --git a/lib/jcode.rb b/lib/jcode.rb
index 92b9284471..608c97206e 100644
--- a/lib/jcode.rb
+++ b/lib/jcode.rb
@@ -84,10 +84,6 @@ class String
h
end
- def bsquote(str)
- str.gsub(/\\/, '\\\\\\\\')
- end
-
HashCache = {}
TrPatternCache = {}
DeletePatternCache = {}
@@ -98,7 +94,7 @@ class String
def tr!(from, to)
return self.delete!(from) if to.length == 0
- pattern = TrPatternCache[from] ||= /[#{bsquote(from)}]/
+ pattern = TrPatternCache[from] ||= /[#{Regexp::quote(from)}]/
if from[0] == ?^
last = /.$/.match(to)[0]
self.gsub!(pattern, last)
@@ -113,7 +109,7 @@ class String
end
def delete!(del)
- self.gsub!(DeletePatternCache[del] ||= /[#{bsquote(del)}]+/, '')
+ self.gsub!(DeletePatternCache[del] ||= /[#{Regexp::quote(del)}]+/, '')
end
def delete(del)
@@ -123,7 +119,7 @@ class String
def squeeze!(del=nil)
pattern =
if del
- SqueezePatternCache[del] ||= /([#{bsquote(del)}])\1+/
+ SqueezePatternCache[del] ||= /([#{Regexp::quote(del)}])\1+/
else
/(.|\n)\1+/
end
@@ -137,7 +133,7 @@ class String
def tr_s!(from, to)
return self.delete!(from) if to.length == 0
- pattern = SqueezePatternCache[from] ||= /([#{bsquote(from)}])\1+"/
+ pattern = SqueezePatternCache[from] ||= /([#{Regexp::quote(from)}])\1+"/
if from[0] == ?^
last = /.$/.match(to)[0]
self.gsub!(pattern, last)
@@ -163,5 +159,9 @@ class String
self.delete("^#{str}").jlength
end
+ def each_char(&block)
+ scan(/.|\n/, &block)
+ end
end
+
$VERBOSE = $vsave
diff --git a/lib/pstore.rb b/lib/pstore.rb
index 97b3794326..eb65aabc8d 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -88,14 +88,14 @@ class PStore
file = File::open(@filename, "r+")
orig = true
else
+ @table = {}
file = File::open(@filename, "w+")
+ Marshal::dump(@table, file)
end
file.flock(File::LOCK_EX)
if orig
File::copy @filename, backup
@table = Marshal::load(file)
- else
- @table = {}
end
begin
catch(:pstore_abort_transaction) do