Description:
last commit is a dud...fixing it now.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r152:394121525814 - - 1 file changed: 1 inserted, 1 deleted
@@ -67,78 +67,78 | |||
|
67 | 67 | if FileTest.exists? params[:output_file] |
|
68 | 68 | FileUtils.rm(params[:output_file]) |
|
69 | 69 | end |
|
70 | 70 | if FileTest.exists? params[:message_file] |
|
71 | 71 | FileUtils.rm(params[:message_file]) |
|
72 | 72 | end |
|
73 | 73 | |
|
74 | 74 | # Check if the source file exists before attempt compiling. |
|
75 | 75 | if !FileTest.exists? params[:source_file] |
|
76 | 76 | talk("ERROR: The source file does not exist!") |
|
77 | 77 | open(params[:message_file],"w") do |f| |
|
78 | 78 | f.puts "ERROR: The source file did not exist." |
|
79 | 79 | end |
|
80 | 80 | exit(127) |
|
81 | 81 | end |
|
82 | 82 | |
|
83 | 83 | if params[:prog_lang]=='cpp' |
|
84 | 84 | params[:prog_lang] = 'c++' |
|
85 | 85 | end |
|
86 | 86 | |
|
87 | 87 | # Compile. |
|
88 | 88 | case params[:prog_lang] |
|
89 | 89 | |
|
90 | 90 | when "c" |
|
91 | 91 | command = "#{C_COMPILER} #{params[:source_file]} -o #{params[:output_file]} #{C_OPTIONS} 2> #{params[:message_file]}" |
|
92 | 92 | system(command) |
|
93 | 93 | |
|
94 | 94 | when "c++" |
|
95 | 95 | command = "#{CPLUSPLUS_COMPILER} #{params[:source_file]} -o #{params[:output_file]} #{CPLUSPLUS_OPTIONS} 2> #{params[:message_file]}" |
|
96 | 96 | system(command) |
|
97 | 97 | |
|
98 | 98 | when "pas" |
|
99 | 99 | command = "#{PASCAL_COMPILER} #{params[:source_file]} -ooutpas #{PASCAL_OPTIONS} > #{params[:message_file]}" |
|
100 | 100 | system(command) |
|
101 | 101 | FileUtils.mv("output", params[:output_file]) |
|
102 | 102 | |
|
103 | 103 | when "java" |
|
104 | 104 | #rename the file to the public class name |
|
105 | 105 | |
|
106 | 106 | #get the class name |
|
107 | 107 | classname = 'DUMMY' |
|
108 | 108 | File.foreach(params[:source_file]) do |line| |
|
109 | 109 | md = /\s*public\s*class\s*(\w*)/.match(line) |
|
110 | 110 | classname=md[1] if md |
|
111 | 111 | end |
|
112 | 112 | system("cp #{params[:source_file]} #{classname}.java") |
|
113 | 113 | command = "#{JAVA_COMPILER} #{classname}.java 2> #{params[:message_file]}" |
|
114 | 114 | system(command) |
|
115 |
- if File.exists?(classname + ".class") |
|
|
115 | + if File.exists?(classname + ".class") | |
|
116 | 116 | File.open(params[:output_file],"w") {|file| file.write("#!/bin/sh\n/usr/bin/java #{classname}\n")} |
|
117 | 117 | File.chmod(0755, params[:output_file]) |
|
118 | 118 | end |
|
119 | 119 | |
|
120 | 120 | when "ruby" |
|
121 | 121 | command = "#{RUBY_INTEPRETER} -c #{params[:source_file]} > #{params[:message_file]}" |
|
122 | 122 | system(command) |
|
123 | 123 | File.open(params[:output_file],"w") do |out_file| |
|
124 | 124 | out_file.puts "#!#{RUBY_INTEPRETER}" |
|
125 | 125 | File.open(params[:source_file],"r").each do |line| |
|
126 | 126 | out_file.print line |
|
127 | 127 | end |
|
128 | 128 | end |
|
129 | 129 | File.chmod(0755, params[:output_file]) |
|
130 | 130 | |
|
131 | 131 | else |
|
132 | 132 | talk("ERROR: Invalid language specified!") |
|
133 | 133 | open(params[:message_file],"w") do |f| |
|
134 | 134 | f.puts "ERROR: Invalid language specified!" |
|
135 | 135 | end |
|
136 | 136 | exit(127) |
|
137 | 137 | end |
|
138 | 138 | |
|
139 | 139 | # Report success or failure. |
|
140 | 140 | if FileTest.exists? params[:output_file] |
|
141 | 141 | talk "Compilation was successful!" |
|
142 | 142 | else |
|
143 | 143 | talk "ERROR: Something was wrong during the compilation!" |
|
144 | 144 | end |
You need to be logged in to leave comments.
Login now