Skip to content

Commit 169ff59

Browse files
committed
Preventing bug if liberace makes a library using new syntax
1 parent 178b8b4 commit 169ff59

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,13 +502,15 @@ impl Config {
502502
///
503503
/// # Panics
504504
///
505-
/// Panics if `output` is not formatted correctly or if one of the underlying
505+
/// Panics if `output` is not formatted correctly or if one of the underlying
506506
/// compiler commands fails. It can also panic if it fails reading file names
507507
/// or creating directories.
508508
pub fn compile(&self, output: &str) {
509-
let name_start = if output.starts_with("lib") { 3 } else { 0 };
510-
let name_end = if output.ends_with(".a") { output.len() - 2 } else { output.len() };
511-
let lib_name = &output[name_start..name_end];
509+
let lib_name = if output.starts_with("lib") && output.ends_with(".a") {
510+
&output[3..output.len() - 2]
511+
} else {
512+
&output
513+
};
512514
let dst = self.get_out_dir();
513515

514516
let mut objects = Vec::new();

0 commit comments

Comments
 (0)