From 169ff59e04274ca4329306520a300969d2517c6a Mon Sep 17 00:00:00 2001 From: Andy Gauge Date: Wed, 19 Jul 2017 09:20:19 -0700 Subject: [PATCH] Preventing bug if liberace makes a library using new syntax --- src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a0e178d..52b244b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -502,13 +502,15 @@ impl Config { /// /// # Panics /// - /// Panics if `output` is not formatted correctly or if one of the underlying + /// Panics if `output` is not formatted correctly or if one of the underlying /// compiler commands fails. It can also panic if it fails reading file names /// or creating directories. pub fn compile(&self, output: &str) { - let name_start = if output.starts_with("lib") { 3 } else { 0 }; - let name_end = if output.ends_with(".a") { output.len() - 2 } else { output.len() }; - let lib_name = &output[name_start..name_end]; + let lib_name = if output.starts_with("lib") && output.ends_with(".a") { + &output[3..output.len() - 2] + } else { + &output + }; let dst = self.get_out_dir(); let mut objects = Vec::new();