Skip to content

Commit 387a888

Browse files
committed
Fix get_os and get_arch
get_os and get_arch were failing to return a value in the error case; they were also assuming that strings are indexed from 1. No idea how they ever worked, but anyway, fixed.
1 parent b42bb2c commit 387a888

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/comp/driver/rustc.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,26 +166,31 @@ options:
166166
}
167167

168168
fn get_os(str triple) -> session::os {
169-
if (_str::find(triple, "win32") > 0 ||
170-
_str::find(triple, "mingw32") > 0 ) {
169+
if (_str::find(triple, "win32") >= 0 ||
170+
_str::find(triple, "mingw32") >= 0 ) {
171171
ret session::os_win32;
172-
} else if (_str::find(triple, "darwin") > 0) { ret session::os_macos; }
173-
else if (_str::find(triple, "linux") > 0) { ret session::os_linux; }
172+
} else if (_str::find(triple, "darwin") >= 0) { ret session::os_macos; }
173+
else if (_str::find(triple, "linux") >= 0) { ret session::os_linux; }
174+
else { log_err "Unknown operating system!"; fail; }
174175
}
175176

176177
fn get_arch(str triple) -> session::arch {
177-
if (_str::find(triple, "i386") > 0 ||
178-
_str::find(triple, "i486") > 0 ||
179-
_str::find(triple, "i586") > 0 ||
180-
_str::find(triple, "i686") > 0 ||
181-
_str::find(triple, "i786") > 0 ) {
178+
if (_str::find(triple, "i386") >= 0 ||
179+
_str::find(triple, "i486") >= 0 ||
180+
_str::find(triple, "i586") >= 0 ||
181+
_str::find(triple, "i686") >= 0 ||
182+
_str::find(triple, "i786") >= 0 ) {
182183
ret session::arch_x86;
183-
} else if (_str::find(triple, "x86_64") > 0) {
184+
} else if (_str::find(triple, "x86_64") >= 0) {
184185
ret session::arch_x64;
185-
} else if (_str::find(triple, "arm") > 0 ||
186-
_str::find(triple, "xscale") > 0 ) {
186+
} else if (_str::find(triple, "arm") >= 0 ||
187+
_str::find(triple, "xscale") >= 0 ) {
187188
ret session::arch_arm;
188189
}
190+
else {
191+
log_err ("Unknown architecture! " + triple);
192+
fail;
193+
}
189194
}
190195

191196
fn get_default_sysroot(str binary) -> str {

0 commit comments

Comments
 (0)