Description:
merge fix utf8
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r188:4805f3ab73c4 - - 2 files changed: 4 inserted, 2 deleted
@@ -102,36 +102,37 | |||||
|
102 |
|
102 | ||
|
103 | when "pas" |
|
103 | when "pas" |
|
104 | command = "#{PASCAL_COMPILER} #{params[:source_file]} -ooutpas #{PASCAL_OPTIONS}" |
|
104 | command = "#{PASCAL_COMPILER} #{params[:source_file]} -ooutpas #{PASCAL_OPTIONS}" |
|
105 | system(command,out: params[:message_file]) |
|
105 | system(command,out: params[:message_file]) |
|
106 | FileUtils.mv("output", params[:output_file]) |
|
106 | FileUtils.mv("output", params[:output_file]) |
|
107 |
|
107 | ||
|
108 | when "java" |
|
108 | when "java" |
|
109 | #rename the file to the public class name |
|
109 | #rename the file to the public class name |
|
110 |
|
110 | ||
|
111 | #get the class name |
|
111 | #get the class name |
|
112 | classname = 'DUMMY' |
|
112 | classname = 'DUMMY' |
|
113 | source = Array.new |
|
113 | source = Array.new |
|
114 | - File.foreach(params[:source_file]) do |line| |
|
114 | + File.foreach(params[:source_file],'r:UTF-8') do |line| |
|
|
115 | + line.encode!('UTF-8','UTF-8',invalid: :replace, replace: '') | ||
|
115 | md = /\s*public\s*class\s*(\w*)/.match(line) |
|
116 | md = /\s*public\s*class\s*(\w*)/.match(line) |
|
116 | classname=md[1] if md |
|
117 | classname=md[1] if md |
|
117 | source << line unless line =~ /\s*package\s*\w+\s*\;/ |
|
118 | source << line unless line =~ /\s*package\s*\w+\s*\;/ |
|
118 | end |
|
119 | end |
|
119 | File.open("#{classname}.java","w") do |file| |
|
120 | File.open("#{classname}.java","w") do |file| |
|
120 | source.each do |s| |
|
121 | source.each do |s| |
|
121 | file.puts s |
|
122 | file.puts s |
|
122 | end |
|
123 | end |
|
123 | end |
|
124 | end |
|
124 | #system("cp #{params[:source_file]} #{classname}.java") |
|
125 | #system("cp #{params[:source_file]} #{classname}.java") |
|
125 | - command = "#{JAVA_COMPILER} #{classname}.java" |
|
126 | + command = "#{JAVA_COMPILER} -encoding utf8 #{classname}.java" |
|
126 | system(command, err: params[:message_file]) |
|
127 | system(command, err: params[:message_file]) |
|
127 | if File.exists?(classname + ".class") |
|
128 | if File.exists?(classname + ".class") |
|
128 | File.open(params[:output_file],"w") {|file| file.write("#{classname}")} |
|
129 | File.open(params[:output_file],"w") {|file| file.write("#{classname}")} |
|
129 | end |
|
130 | end |
|
130 | if classname == 'DUMMY' |
|
131 | if classname == 'DUMMY' |
|
131 | File.open(params[:message_file],"w") {|file| file.write("Cannot find any public class in the source code\n")} |
|
132 | File.open(params[:message_file],"w") {|file| file.write("Cannot find any public class in the source code\n")} |
|
132 | end |
|
133 | end |
|
133 |
|
134 | ||
|
134 | when "ruby" |
|
135 | when "ruby" |
|
135 | command = "#{RUBY_INTERPRETER} -c #{params[:source_file]}" |
|
136 | command = "#{RUBY_INTERPRETER} -c #{params[:source_file]}" |
|
136 | if system(command, err: params[:message_file]) |
|
137 | if system(command, err: params[:message_file]) |
|
137 | File.open(params[:output_file],"w") do |out_file| |
|
138 | File.open(params[:output_file],"w") do |out_file| |
@@ -120,14 +120,15 | |||||
|
120 | result_file.close |
|
120 | result_file.close |
|
121 |
|
121 | ||
|
122 | comment_file = File.new("comment", "w") |
|
122 | comment_file = File.new("comment", "w") |
|
123 | comment_file.write "#{all_comment}\n" |
|
123 | comment_file.write "#{all_comment}\n" |
|
124 | comment_file.close |
|
124 | comment_file.close |
|
125 |
|
125 | ||
|
126 |
|
126 | ||
|
127 | File.open("run_stat","w") do |file| |
|
127 | File.open("run_stat","w") do |file| |
|
128 | file.puts max_runtime |
|
128 | file.puts max_runtime |
|
129 | file.puts peak_memory |
|
129 | file.puts peak_memory |
|
130 | end |
|
130 | end |
|
131 |
|
131 | ||
|
|
132 | + puts "#{all_score} #{all_comment}" | ||
|
132 | log "score = #{all_score}\ncomment = #{all_comment}" |
|
133 | log "score = #{all_score}\ncomment = #{all_comment}" |
|
133 | log "max_runtime = #{max_runtime}\npeak_memory = #{peak_memory}" |
|
134 | log "max_runtime = #{max_runtime}\npeak_memory = #{peak_memory}" |
You need to be logged in to leave comments.
Login now