aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/functions.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-06 15:30:47 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-06 15:30:47 -0600
commitcffe9f4085cf28e9a1e62346cfb31ed0470a49ff (patch)
tree7bfd667b0c1952275ff478afc3bcad0a0c0dbf53 /src/makefile/functions.rs
parentccd9a6560c34690af803ef4dae2e53621ae608c1 (diff)
downloadmakers-cffe9f4085cf28e9a1e62346cfb31ed0470a49ff.tar.gz
makers-cffe9f4085cf28e9a1e62346cfb31ed0470a49ff.zip
appease our wire lord and savior
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()
)?,