summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sample')
-rw-r--r--sample/fib.py10
-rw-r--r--sample/fib.scm4
-rw-r--r--sample/from.rb29
-rw-r--r--sample/io.rb44
-rw-r--r--sample/rbc.rb207
-rw-r--r--sample/ruby-mode.el66
-rw-r--r--sample/test.rb10
-rw-r--r--sample/tkfrom.rb40
8 files changed, 234 insertions, 176 deletions
diff --git a/sample/fib.py b/sample/fib.py
new file mode 100644
index 0000000000..8318021d24
--- /dev/null
+++ b/sample/fib.py
@@ -0,0 +1,10 @@
+# calculate Fibonacci(20)
+# for benchmark
+def fib(n):
+ if n<2:
+ return n
+ else:
+ return fib(n-2)+fib(n-1)
+
+print fib(20)
+
diff --git a/sample/fib.scm b/sample/fib.scm
index 8eba75bb9e..5c2b86e656 100644
--- a/sample/fib.scm
+++ b/sample/fib.scm
@@ -3,4 +3,6 @@
n
(+ (fib (- n 2)) (fib (- n 1)))))
-(fib 20)
+(display (fib 20))
+(newline)
+
diff --git a/sample/from.rb b/sample/from.rb
index d39bb70084..0a83f081f1 100644
--- a/sample/from.rb
+++ b/sample/from.rb
@@ -9,8 +9,6 @@ include Kconv
class String
- public :kconv
-
def kconv(code = Kconv::EUC)
Kconv.kconv(self, code, Kconv::AUTO)
end
@@ -34,11 +32,15 @@ end
if ARGV.length == 0
user = ENV['USER']
else
- user = ARGV[0]
+ file = user = ARGV[0]
+ ARGV.clear
end
[ENV['SPOOLDIR'], '/usr/spool', '/var/spool', '/usr', '/var'].each do |m|
- break if File.exist? ARGV[0] = "#{m}/mail/#{user}"
+ if File.exist? f = "#{m}/mail/#{user}"
+ file = f
+ break
+ end
end
$outcount = 0;
@@ -63,18 +65,23 @@ def fromout(date, from, subj)
end
from = from.kconv(lang).kjust(28)
subj = subj.kconv(lang).kjust(40)
- printf "%02d/%02d/%02d [%s] %s\n",y,m,d,from,subj
+ printf "%02d/%02d/%02d [%s] %s\n",y%100,m,d,from,subj
$outcount += 1
end
-for file in ARGV
- next if !File.exist?(file)
+if File.exist?(file)
+ atime = File.atime(file)
+ mtime = File.mtime(file)
f = open(file, "r")
- while !f.eof?
- mail = Mail.new(f)
- fromout mail.header['Date'], mail.header['From'], mail.header['Subject']
+ begin
+ until f.eof?
+ mail = Mail.new(f)
+ fromout mail.header['Date'],mail.header['From'],mail.header['Subject']
+ end
+ ensure
+ f.close
+ File.utime(atime, mtime, file)
end
- f.close
end
if $outcount == 0
diff --git a/sample/io.rb b/sample/io.rb
deleted file mode 100644
index 0b38d2112d..0000000000
--- a/sample/io.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# IO test
-# usage: ruby io.rb file..
-
-home = ENV["HOME"]
-home.sub("m", "&&")
-print(home, "\n")
-print(home.reverse, "\n")
-
-if File.s("io.rb")
- print(File.s("io.rb"), ": io.rb\n")
-end
-
-$/="f\n"
-for i in "abc\n\ndef\nghi\n"
- print("tt: ", i)
-end
-
-printf("%s:(%d)%s\n", $0, ARGV.length, ARGV[0])
-passwd = open(ARGV[0], "r")
-#printf("%s", passwd.find{i|i =~ /\*/})
-
-n = 1
-for i in passwd #.grep(/^\*/)
- printf("%6d: %s", n, i)
- n = n + 1;
-end
-
-fp = open("|-", "r")
-
-if fp == nil
- for i in 1..5
- print(i, "\n")
- end
-else
- for line in fp
- print(line)
- end
-end
-
-def printUsage()
- if $USAGE
- apply($USAGE);
- end
-end
diff --git a/sample/rbc.rb b/sample/rbc.rb
index 88a5b2d069..e09dae6069 100644
--- a/sample/rbc.rb
+++ b/sample/rbc.rb
@@ -1,9 +1,9 @@
#!/usr/local/bin/ruby
#
# rbc.rb -
-# $Release Version: 0.6 $
-# $Revision: 1.2 $
-# $Date: 1997/11/27 13:46:06 $
+# $Release Version: 0.8 $
+# $Revision: 1.7 $
+# $Date: 1998/02/27 03:45:51 $
# by Keiju ISHITSUKA(Nippon Rational Inc.)
#
# --
@@ -12,8 +12,9 @@
# rbc.rb [options] file_name opts
# options:
# -d デバッグモード(利用しない方が良いでしょう)
+# -f ~/.irbrc を読み込まない.
# -m bcモード(分数, 行列の計算ができます)
-# -r load-module ruby -r と同じ
+# -r load-module ruby -r と同じ.
# --inspect 結果出力にinspectを用いる(bcモード以外はデ
# フォルト).
# --noinspect 結果出力にinspectを用いない.
@@ -32,25 +33,25 @@ require "e2mmap.rb"
$stdout.sync = TRUE
module BC_APPLICATION__
- RCS_ID='-$Header: /home/keiju/var/src/var.lib/ruby/ruby/RCS/rbc.rb,v 1.2 1997/11/27 13:46:06 keiju Exp keiju $-'
+ RCS_ID='-$Id: rbc.rb,v 1.7 1998/02/27 03:45:51 keiju Exp keiju $-'
extend Exception2MessageMapper
def_exception :UnrecognizedSwitch, "Unrecognized switch: %s"
- $DEBUG = FALSE
- $INSPECT = nil
-
CONFIG = {}
CONFIG[0] = $0
CONFIG[:USE_READLINE] = TRUE
CONFIG[:LOAD_MODULES] = []
CONFIG[:INSPECT] = nil
CONFIG[:TRACE_LOAD] = TRUE
+ CONFIG[:RC] = TRUE
+
+ CONFIG[:DEBUG] = FALSE
while opt = ARGV.shift
case opt
when "-d"
- $DEBUG = TRUE
+ CONFIG[:DEBUG] = TRUE
when "-m"
CONFIG[:INSPECT] = FALSE if CONFIG[:INSPECT].nil?
require "mathn.rb"
@@ -58,6 +59,9 @@ module BC_APPLICATION__
when "-r"
opt = ARGV.shift
CONFIG[:LOAD_MODULES].push opt if opt
+ when "-f"
+ opt = ARGV.shift
+ CONFIG[:RC] = FALSE
when "--inspect"
CONFIG[:INSPECT] = TRUE
when "--noinspect"
@@ -66,7 +70,7 @@ module BC_APPLICATION__
CONFIG[:USE_READLINE] = FALSE
when /^-/
# print UnrecognizedSwitch.inspect, "\n"
- BC.fail UnrecognizedSwitch, opt
+ BC_APPLICATION__.fail UnrecognizedSwitch, opt
else
CONFIG[:USE_READLINE] = FALSE
$0 = opt
@@ -104,7 +108,7 @@ module BC_APPLICATION__
line = line + l
lex(l) if l != "\n"
- print @quoted.inspect, "\n" if $DEBUG
+ print @quoted.inspect, "\n" if CONFIG[:DEBUG]
if @ltype
@io.prompt = format(PROMPTs, @indent, @ltype)
next
@@ -120,9 +124,9 @@ module BC_APPLICATION__
if line != "\n"
begin
if CONFIG[:INSPECT]
- print (cont._=eval(line, bind)).inspect, "\n"
+ print((cont._=eval(line, bind)).inspect, "\n")
else
- print (cont._=eval(line, bind)), "\n"
+ print((cont._=eval(line, bind)), "\n")
end
rescue
# $! = 'exception raised' unless $!
@@ -182,7 +186,8 @@ module BC_APPLICATION__
"case", "class", "def", "do", "for", "if",
"module", "unless", "until", "while", "begin" #, "when"
]
- DEINDENT_CLAUSE = ["end"]
+ DEINDENT_CLAUSE = ["end" #, "when"
+ ]
PARCENT_LTYPE = {
"q" => "\'",
@@ -197,7 +202,7 @@ module BC_APPLICATION__
"<" => ">",
"(" => ")"
}
-
+
def lex_init()
@OP = Trie.new
@OP.def_rules("\0", "\004", "\032"){}
@@ -211,7 +216,7 @@ module BC_APPLICATION__
identify_comment(rests)
end
@OP.def_rule("\n") do
- print "\\n\n" if $DEBUG
+ print "\\n\n" if CONFIG[:DEBUG]
if @lex_state == EXPR_BEG || @lex_state == EXPR_FNAME
@continue = TRUE
else
@@ -220,9 +225,9 @@ module BC_APPLICATION__
end
@OP.def_rules("*", "*=", "**=", "**") {@lex_state = EXPR_BEG}
@OP.def_rules("!", "!=", "!~") {@lex_state = EXPR_BEG}
- @OP.def_rules("=", "==", "===", "=~", "=>") {@lex_state = EXPR_BEG}
- @OP.def_rules("<", "<=", "<=>", "<<", "<=") {@lex_state = EXPR_BEG}
- @OP.def_rules(">", ">=", ">>", ">=") {@lex_state = EXPR_BEG}
+ @OP.def_rules("=", "==", "===", "=~", "<=>") {@lex_state = EXPR_BEG}
+ @OP.def_rules("<", "<=", "<<") {@lex_state = EXPR_BEG}
+ @OP.def_rules(">", ">=", ">>") {@lex_state = EXPR_BEG}
@OP.def_rules("'", '"') do
|op, rests|
@ltype = op
@@ -268,10 +273,14 @@ module BC_APPLICATION__
if rests[0] =~ /[0-9]/
rests.unshift op
identify_number(rests)
+ else
+ # obj.if などの対応
+ identify_identifier(rests, TRUE)
+ @lex_state = EXPR_ARG
end
end
@OP.def_rules("..", "...") {@lex_state = EXPR_BEG}
-
+
lex_int2
end
@@ -280,8 +289,12 @@ module BC_APPLICATION__
@lex_state = EXPR_END
@indent -= 1
end
- @OP.def_rule(":") {}
- @OP.def_rule("::") {@lex_state = EXPR_BEG}
+ @OP.def_rule(":") {|op,rests|
+ identify_identifier(rests, TRUE)
+ }
+ @OP.def_rule("::") {|op,rests|
+ identify_identifier(rests, TRUE);
+ }
@OP.def_rule("/") do
|op, rests|
if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
@@ -343,16 +356,26 @@ module BC_APPLICATION__
identify_identifier(rests)
end
end
+ @OP.def_rule("def", proc{|op, chrs| /\s/ =~ chrs[0]}) do
+ |op, rests|
+ @indent += 1
+ @lex_state = EXPR_END
+ until rests[0] == "\n" or rests[0] == ";"
+ rests.shift
+ end
+ end
@OP.def_rule("") do
|op, rests|
- printf "match: start %s: %s", op, rests.inspect if $DEBUG
+ printf "MATCH: start %s: %s\n", op, rests.inspect if CONFIG[:DEBUG]
if rests[0] =~ /[0-9]/
identify_number(rests)
elsif rests[0] =~ /[\w_]/
identify_identifier(rests)
end
- printf "match: end %s: %s", op, rests.inspect if $DEBUG
+ printf "MATCH: end %s: %s\n", op, rests.inspect if CONFIG[:DEBUG]
end
+
+ p @OP if CONFIG[:DEBUG]
end
def lex(l)
@@ -380,9 +403,9 @@ module BC_APPLICATION__
until chrs.empty?
@space_seen = FALSE
- printf "perse: %s\n", chrs.join("") if $DEBUG
+ printf "perse: %s\n", chrs.join("") if CONFIG[:DEBUG]
@OP.match(chrs)
- printf "lex_state: %s continue: %s\n", @lex_state.id2name, @continue if $DEBUG
+ printf "lex_state: %s continue: %s\n", @lex_state.id2name, @continue if CONFIG[:DEBUG]
end
end
@@ -421,11 +444,11 @@ module BC_APPLICATION__
end
end
- def identify_identifier(chrs)
+ def identify_identifier(chrs, escaped = FALSE)
token = ""
- token.concat chrs.shift if chrs[0] =~ /[$@]/
+ token.concat chrs.shift if chrs[0] =~ /[$@]/ or escaped
while (ch = chrs.shift) =~ /\w|_/
- print ":", ch, ":" if $DEBUG
+ print ":", ch, ":" if CONFIG[:DEBUG]
token.concat ch
end
chrs.unshift ch
@@ -436,12 +459,12 @@ module BC_APPLICATION__
end
# fix token
- if token =~ /^[$@]/
+ if token =~ /^[$@]/ or escaped
@lex_state = EXPR_END
return
end
- print token, "\n" if $DEBUG
+ print token, "\n" if CONFIG[:DEBUG]
if state = CLAUSE_STATE_TRANS[token]
if @lex_state != EXPR_BEG and token =~ /^(if|unless|while|until)/
# 修飾子
@@ -624,14 +647,9 @@ module BC_APPLICATION__
@preproc = preproc
@postproc = postproc
end
-
- def preproc(p)
- @preproc = p
- end
-
- def postproc(p)
- @postproc = p
- end
+
+ attr :preproc, TRUE
+ attr :postproc, TRUE
def search(chrs, opt = nil)
return self if chrs.empty?
@@ -649,10 +667,29 @@ module BC_APPLICATION__
end
def create_subnode(chrs, preproc = nil, postproc = nil)
+ if chrs.empty?
+ if @postproc
+ p node
+ Trie.fail ErrNodeAlreadyExists
+ else
+ print "Warn: change abstruct node to real node\n" if CONFIG[:DEBUG]
+ @preproc = preproc
+ @postproc = postproc
+ end
+ return self
+ end
+
ch = chrs.shift
if node = @Tree[ch]
if chrs.empty?
- Trie.fail ErrNodeAlreadyExists
+ if node.postproc
+ p node
+ Trie.fail ErrNodeAlreadyExists
+ else
+ print "Warn: change abstruct node to real node\n" if CONFIG[:DEBUG]
+ node.preproc = preproc
+ node.postproc = postproc
+ end
else
node.create_subnode(chrs, preproc, postproc)
end
@@ -669,10 +706,10 @@ module BC_APPLICATION__
end
def match(chrs, op = "")
- print "match: ", chrs, ":", op, "\n" if $DEBUG
+ print "match>: ", chrs, "op:", op, "\n" if CONFIG[:DEBUG]
if chrs.empty?
if @preproc.nil? || @preproc.call(op, chrs)
- printf "op1: %s\n", op if $DEBUG
+ printf "op1: %s\n", op if CONFIG[:DEBUG]
@postproc.call(op, chrs)
""
else
@@ -683,23 +720,23 @@ module BC_APPLICATION__
if node = @Tree[ch]
if ret = node.match(chrs, op+ch)
return ch+ret
- elsif @postproc and @preproc.nil? || @preproc.call(op, chrs)
- chrs.unshift ch
- printf "op2: %s\n", op if $DEBUG
- @postproc.call(op, chrs)
- return ""
else
chrs.unshift ch
- return nil
+ if @postproc and @preproc.nil? || @preproc.call(op, chrs)
+ printf "op2: %s\n", op.inspect if CONFIG[:DEBUG]
+ @postproc.call(op, chrs)
+ return ""
+ else
+ return nil
+ end
end
else
+ chrs.unshift ch
if @postproc and @preproc.nil? || @preproc.call(op, chrs)
- printf "op3: %s\n", op if $DEBUG
- chrs.unshift ch
+ printf "op3: %s\n", op if CONFIG[:DEBUG]
@postproc.call(op, chrs)
return ""
else
- chrs.unshift ch
return nil
end
end
@@ -712,14 +749,9 @@ module BC_APPLICATION__
end
def def_rule(token, preproc = nil, postproc = nil)
- node = search(token, :CREATE)
-# print node.inspect, "\n" if $DEBUG
- node.preproc(preproc)
- if iterator?
- node.postproc(proc)
- elsif postproc
- node.postproc(postproc)
- end
+# print node.inspect, "\n" if CONFIG[:DEBUG]
+ postproc = proc if iterator?
+ node = create(token, preproc, postproc)
end
def def_rules(*tokens)
@@ -731,24 +763,28 @@ module BC_APPLICATION__
end
end
- def preporc(token)
+ def preporc(token, proc)
node = search(token)
- node.preproc proc
+ node.preproc=proc
end
def postproc(token)
- node = search(token)
- node.postproc proc
+ node = search(token, proc)
+ node.postproc=proc
end
- def search(token, opt = nil)
- @head.search(token.split(//), opt)
+ def search(token)
+ @head.search(token.split(//))
+ end
+
+ def create(token, preproc = nil, postproc = nil)
+ @head.create_subnode(token.split(//), preproc, postproc)
end
def match(token)
token = token.split(//) if token.kind_of?(String)
ret = @head.match(token)
- printf "match end: %s:%s", ret, token.inspect if $DEBUG
+ printf "match end: %s:%s", ret, token.inspect if CONFIG[:DEBUG]
ret
end
@@ -845,17 +881,18 @@ module BC_APPLICATION__
case file_name
when /\.rb$/
if load_sub(file_name)
- $:.push file_name
+ $".push file_name
return true
end
when /\.(so|o|sl)$/
- require_org(file_name)
+ rbc_require_org(file_name)
end
if load_sub(f = file_name + ".rb")
- $:.push f
+ $".push f
+ return true
end
- require(file_name)
+ rbc_require_org(file_name)
end
def load_sub(fn)
@@ -878,15 +915,30 @@ module BC_APPLICATION__
if opt
CONFIG[:INSPECT] = opt
else
- CONFIG[:INSPECT] = !$INSPECT
+ CONFIG[:INSPECT] = !CONFIG[:INSPECT]
end
- print "Switch to#{unless $INSPECT; ' non';end} inspect mode.\n"
- $INSPECT
+ print "Switch to#{unless CONFIG[:INSPECT]; ' non';end} inspect mode.\n"
+ CONFIG[:INSPECT]
end
- def run
- CONFIG[:BIND] = proc
+ def run(bind)
+ CONFIG[:BIND] = bind
+ if CONFIG[:RC]
+ rc = File.expand_path("~/.irbrc")
+ if File.exists?(rc)
+ begin
+ load rc
+ rescue
+ print "load error: #{rc}\n"
+ print $!.type, ": ", $!, "\n"
+ for err in $@[0, $@.size - 2]
+ print "\t", err, "\n"
+ end
+ end
+ end
+ end
+
if CONFIG[:TRACE_LOAD]
trace_load true
end
@@ -898,7 +950,7 @@ module BC_APPLICATION__
print $@[0], ":", $!.type, ": ", $!, "\n"
end
end
-
+
if !$0.equal?(CONFIG[0])
io = FileInputMethod.new($0)
elsif defined? Readline
@@ -959,4 +1011,5 @@ module BC_APPLICATION__
end
extend BC_APPLICATION__::CONTEXT
-run{}
+run(binding)
+
diff --git a/sample/ruby-mode.el b/sample/ruby-mode.el
index 0f56477ea0..0d94df0fc8 100644
--- a/sample/ruby-mode.el
+++ b/sample/ruby-mode.el
@@ -2,11 +2,16 @@
;;; ruby-mode.el -
;;;
;;; $Author$
-;;; Time-stamp: <97/03/21 01:16:05 matz>
+;;; $Date$
;;; created at: Fri Feb 4 14:49:13 JST 1994
;;;
-(defconst ruby-mode-version "1.0.7")
+(defconst ruby-mode-revision "$Revision$")
+
+(defconst ruby-mode-version
+ (progn
+ (string-match "[0-9.]+" ruby-mode-revision)
+ (substring ruby-mode-revision (match-beginning 0) (match-end 0))))
(defconst ruby-block-beg-re
"class\\|module\\|def\\|if\\|unless\\|case\\|while\\|until\\|for\\|begin\\|do"
@@ -31,7 +36,7 @@
(defconst ruby-block-end-re "end")
(defconst ruby-delimiter
- (concat "[?$/%(){}#\"'`]\\|\\[\\|\\]\\|\\<\\("
+ (concat "[?$/%(){}#\"'`.:]\\|\\[\\|\\]\\|\\<\\("
ruby-block-beg-re
"\\|" ruby-block-end-re
"\\)\\>\\|^=begin")
@@ -79,8 +84,8 @@
(modify-syntax-entry ?\` "\"" ruby-mode-syntax-table)
(modify-syntax-entry ?# "<" ruby-mode-syntax-table)
(modify-syntax-entry ?\n ">" ruby-mode-syntax-table)
- (modify-syntax-entry ?\\ "'" ruby-mode-syntax-table)
- (modify-syntax-entry ?$ "/" ruby-mode-syntax-table)
+ (modify-syntax-entry ?\\ "\\" ruby-mode-syntax-table)
+ (modify-syntax-entry ?$ "." ruby-mode-syntax-table)
(modify-syntax-entry ?? "_" ruby-mode-syntax-table)
(modify-syntax-entry ?_ "_" ruby-mode-syntax-table)
(modify-syntax-entry ?< "." ruby-mode-syntax-table)
@@ -229,7 +234,7 @@ The variable ruby-indent-level controls the amount of indentation.
(setq w (char-after (point)))
(cond
((and (not (eobp))
- (re-search-forward (format "[^\\]%c" w) indent-point t))
+ (re-search-forward (format "[^\\]\\(\\\\\\\\\\)*%c" w) indent-point t))
nil)
(t
(setq in-string (point))
@@ -271,7 +276,7 @@ The variable ruby-indent-level controls the amount of indentation.
((looking-at "\\$") ;skip $char
(goto-char pnt)
(forward-char 1))
- ((looking-at "#") ;skip comment
+ ((looking-at "#") ;skip comment
(forward-line 1)
(goto-char (point))
)
@@ -310,29 +315,41 @@ The variable ruby-indent-level controls the amount of indentation.
(setq nest (cdr nest))
(setq depth (1- depth)))
(goto-char pnt))
+ ((looking-at "def\\s *[^\n;]*\\(\\|$\\)")
+ (if (or (bolp)
+ (progn
+ (forward-char -1)
+ (not (eq ?_ (char-after (point))))))
+ (progn
+ (setq nest (cons (cons nil pnt) nest))
+ (setq depth (1+ depth))))
+ (goto-char (match-end 0)))
((looking-at ruby-block-beg-re)
(and
(or (bolp)
(progn
(forward-char -1)
(not (eq ?_ (char-after (point))))))
- (progn
- (goto-char pnt)
- (setq w (char-after (point)))
- (and (not (eq ?_ w))
- (not (eq ?! w))
- (not (eq ?? w))))
+ (goto-char pnt)
+ (setq w (char-after (point)))
+ (not (eq ?_ w))
+ (not (eq ?! w))
+ (not (eq ?? w))
(progn
(goto-char (match-beginning 0))
(if (looking-at ruby-modifier-re)
(ruby-expr-beg)
t))
- (progn
- (setq nest (cons (cons nil pnt) nest))
- (setq depth (1+ depth))))
- (if (looking-at "def\\s *[/`]")
- (goto-char (match-end 0))
- (goto-char pnt)))
+ (goto-char pnt)
+ (setq nest (cons (cons nil pnt) nest))
+ (setq depth (1+ depth)))
+ (goto-char pnt))
+ ((looking-at ":\\([a-zA-Z_][a-zA-Z_0-9]*\\)?")
+ (goto-char (match-end 0)))
+ ((or (looking-at "\\.\\.\\.?")
+ (looking-at "\\.[0-9]+")
+ (looking-at "\\.[a-zA-Z_0-9]+"))
+ (goto-char (match-end 0)))
((looking-at "^=begin")
(if (re-search-forward "^=end" indent-point t)
(forward-line 1)
@@ -583,7 +600,7 @@ An end of a defun is found by moving forward from the beginning of one."
(defvar ruby-font-lock-keywords
(list
(cons (concat
- "\\(^\\|[^_]\\)\\b\\("
+ "\\(^\\|[^_:.]\\|\\.\\.\\)\\b\\("
(mapconcat
'identity
'("alias"
@@ -632,10 +649,10 @@ An end of a defun is found by moving forward from the beginning of one."
'("\\(^\\|[^_]\\)\\b\\([A-Z]+[a-zA-Z0-9_]*\\)"
2 font-lock-type-face)
;; functions
- '("^\\s *def[ \t]+.*$"
- 0 font-lock-function-name-face))
+ '("^\\s *def[ \t]+[^ \t(]*"
+ 0 font-lock-function-name-face t))
"*Additional expressions to highlight in ruby mode.")
- (if (and (>= (string-to-int emacs-version) 20)
+ (if (and (>= (string-to-int emacs-version) 19)
(not (featurep 'xemacs)))
(add-hook
'ruby-mode-hook
@@ -645,5 +662,4 @@ An end of a defun is found by moving forward from the beginning of one."
'((ruby-font-lock-keywords) nil nil ((?\_ . "w"))))))
(add-hook 'ruby-mode-hook
(lambda ()
- (setq font-lock-keywords ruby-font-lock-keywords)
- (font-lock-mode 1))))))
+ (setq font-lock-keywords ruby-font-lock-keywords))))))
diff --git a/sample/test.rb b/sample/test.rb
index 0a9d41c2ed..e413ada27a 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -120,7 +120,7 @@ $bad = false
tmp = open("while_tmp", "r")
while tmp.gets()
if gsub!('vt100', 'VT100')
- gsub!('VT100', 'Vt100')
+ p gsub!('VT100', 'Vt100')
redo;
end
$bad = 1 if /vt100/;
@@ -766,6 +766,14 @@ ok(done)
File.unlink "script_tmp" or `/bin/rm -f "script_tmp"`
File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"`
+$bad = false
+for script in Dir["{lib,sample}/*.rb"]
+ unless `./ruby -c #{script}` == "Syntax OK\n"
+ $bad = true
+ end
+end
+ok(!$bad)
+
check "const"
TEST1 = 1
TEST2 = 2
diff --git a/sample/tkfrom.rb b/sample/tkfrom.rb
index b0ef8995ca..ba0e547799 100644
--- a/sample/tkfrom.rb
+++ b/sample/tkfrom.rb
@@ -94,25 +94,31 @@ root.bind "space", proc{exit}
$outcount = 0;
for file in ARGV
- next if !File.exist?(file)
+ next if File.exist?(file)
+ atime = File.atime(file)
+ mtime = File.mtime(file)
f = open(file, "r")
- while !f.eof
- mail = Mail.new(f)
- date = mail.header['Date']
- next if !date
- from = mail.header['From']
- subj = mail.header['Subject']
- y = m = d = 0
- y, m, d = parsedate(date) if date
- from = "sombody@somewhere" if ! from
- subj = "(nil)" if ! subj
- from = decode_b(from)
- subj = decode_b(subj)
- list.insert 'end', format('%-02d/%02d/%02d [%-28.28s] %s',y,m,d,from,subj)
- $outcount += 1
+ begin
+ until f.eof
+ mail = Mail.new(f)
+ date = mail.header['Date']
+ next unless date
+ from = mail.header['From']
+ subj = mail.header['Subject']
+ y = m = d = 0
+ y, m, d = parsedate(date) if date
+ from = "sombody@somewhere" unless from
+ subj = "(nil)" unless subj
+ from = decode_b(from)
+ subj = decode_b(subj)
+ list.insert 'end', format('%-02d/%02d/%02d [%-28.28s] %s',y,m,d,from,subj)
+ $outcount += 1
+ end
+ ensure
+ f.close
+ File.utime(atime, mtime, file)
+ list.see 'end'
end
- f.close
- list.see 'end'
end
limit = 10000