aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/functions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/makefile/functions.rs')
-rw-r--r--src/makefile/functions.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/makefile/functions.rs b/src/makefile/functions.rs
index a16c268..e6efd1c 100644
--- a/src/makefile/functions.rs
+++ b/src/makefile/functions.rs
@@ -219,7 +219,11 @@ mod text {
let n = macros.expand(n)?;
let n: usize = n.parse().wrap_err("while calling `word`")?;
let text = macros.expand(text)?;
- Ok(text.split_whitespace().nth(n + 1).unwrap_or("").to_owned())
+ Ok(text
+ .split_whitespace()
+ .nth(n.saturating_add(1))
+ .unwrap_or("")
+ .to_owned())
}
pub fn words(macros: &MacroSet, words: &TokenString) -> Result<String> {
@@ -655,7 +659,7 @@ mod test {
&[
TokenString::text(""),
TokenString::text("yeet"),
- "$(error fail)".parse().unwrap()
+ "$(error fail)".parse()?
],
&MacroSet::new()
)?,
@@ -681,7 +685,7 @@ mod test {
&[
TokenString::text("maybe"),
TokenString::text(""),
- "$(error fail)".parse().unwrap()
+ "$(error fail)".parse()?
],
&MacroSet::new()
)?,