8000 * ricsin/ricsin.rb: moved from tool/ricsin.rb. · documenting-ruby/ruby@173cd72 · GitHub
[go: up one dir, main page]

Skip to content

Commit 173cd72

Browse files
committed
* ricsin/ricsin.rb: moved from tool/ricsin.rb.
* ricsin/ricsin.rb: fix to skip string and comment while preprocessing C source. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ricsin@19515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent e15aeda commit 173cd72

File tree

4 files changed

+30
-179
lines changed

4 files changed

+30
-179
lines changed

ricsin/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Wed Sep 24 14:47:29 2008 Koichi Sasada <ko1@atdot.net>
2+
3+
* ricsin/ricsin.rb: moved from tool/ricsin.rb.
4+
5+
* ricsin/ricsin.rb: fix to skip string and comment
6+
while preprocessing C source.

ricsin/Makefile

Lines changed: 0 additions & 173 deletions
This file was deleted.

tool/ricsin.rb renamed to ricsin/ricsin.rb

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,25 @@ def generate_dll
8484
}
8585
end
8686

87+
Str = /("[^\\"]*(?:\\.[^\\"]*)*")/m
88+
Com = /(\/\*.*?\*\/)/m
89+
Oth = /([\w\W]+?(?=[\"\/]|\z))/m
90+
CProg = /\G(?:#{Str}|#{Com}|#{Oth})/m
91+
8792
def preprocess_c src
88-
src.gsub(/\$(\w+)\b/){
89-
# @ids[$~.to_s] = $1
90-
"RGV(#{$1})"
91-
}.gsub(/\@(\w+)\b/){
92-
@ids[$~.to_s] = $1
93-
"RIV(#{$1})"
93+
ret = ''
94+
src.scan(CProg){|str, comm, body|
95+
ret << str if str
96+
ret << comm if comm
97+
ret << body.gsub(/\$(\w+)\b/){
98+
# @ids[$~.to_s] = $1
99+
"RGV(#{$1})"
100+
}.gsub(/\@(\w+)\b/){
101+
@ids[$~.to_s] = $1
102+
"RIV(#{$1})"
103+
} if body
94104
}
105+
ret
95106
end
96107

97108
def csrc_function name, params, src, pre_csrc, fastcall = true

ricsin/t.rcb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2+
$foo = 42
3+
p __C__('return $foo; /* $foo */')
4+
5+
6+
__END__
7+
18
p __C__('return INT2FIX(42);')
29

310
__END__

0 commit comments

Comments
 (0)
0