From 387a8888ee338bbe4628640cd4cd72037ac57032 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 16 May 2011 14:33:22 -0700 Subject: [PATCH] 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. --- src/comp/driver/rustc.rs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index d9d5633d05dc..6dd57ac02325 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -166,26 +166,31 @@ options: } fn get_os(str triple) -> session::os { - if (_str::find(triple, "win32") > 0 || - _str::find(triple, "mingw32") > 0 ) { + if (_str::find(triple, "win32") >= 0 || + _str::find(triple, "mingw32") >= 0 ) { ret session::os_win32; - } else if (_str::find(triple, "darwin") > 0) { ret session::os_macos; } - else if (_str::find(triple, "linux") > 0) { ret session::os_linux; } + } else if (_str::find(triple, "darwin") >= 0) { ret session::os_macos; } + else if (_str::find(triple, "linux") >= 0) { ret session::os_linux; } + else { log_err "Unknown operating system!"; fail; } } fn get_arch(str triple) -> session::arch { - if (_str::find(triple, "i386") > 0 || - _str::find(triple, "i486") > 0 || - _str::find(triple, "i586") > 0 || - _str::find(triple, "i686") > 0 || - _str::find(triple, "i786") > 0 ) { + if (_str::find(triple, "i386") >= 0 || + _str::find(triple, "i486") >= 0 || + _str::find(triple, "i586") >= 0 || + _str::find(triple, "i686") >= 0 || + _str::find(triple, "i786") >= 0 ) { ret session::arch_x86; - } else if (_str::find(triple, "x86_64") > 0) { + } else if (_str::find(triple, "x86_64") >= 0) { ret session::arch_x64; - } else if (_str::find(triple, "arm") > 0 || - _str::find(triple, "xscale") > 0 ) { + } else if (_str::find(triple, "arm") >= 0 || + _str::find(triple, "xscale") >= 0 ) { ret session::arch_arm; } + else { + log_err ("Unknown architecture! " + triple); + fail; + } } fn get_default_sysroot(str binary) -> str {