class C::Preprocessor
Public Instance Methods
preprocess(text)
click to toggle source
# File lib/cstub.rb, line 9 def preprocess(text) filename = nil Tempfile.open(['cast-preprocessor-input.', '.c'], File.expand_path(pwd || '.')) do |file| filename = file.path file.puts text end output = `#{full_command(filename)}` if $? == 0 return output else raise Error, output end end
shellquote(arg)
click to toggle source
# File lib/cstub.rb, line 22 def shellquote(arg) if arg !~ /[\"\'\\$&<>|\s()]/ return arg else arg.gsub!(/([\"\\$&<>|])/, '\\\\\\1') return "\"#{arg}\"" end end