Fix crash on Windows | resolves #37

This commit is contained in:
Greg 2019-06-18 14:49:23 -04:00
parent 61d678c1d2
commit 4982a6645c
No known key found for this signature in database
GPG key ID: 2E44FAEEDC94B1E2

View file

@ -47,20 +47,20 @@ impl Replacer {
match c {
'c' => {
regex.case_insensitive(false);
}
},
'i' => {
regex.case_insensitive(true);
}
},
'm' => {
regex.multi_line(true);
}
},
'w' => {
regex = regex::bytes::RegexBuilder::new(&format!(
"\\b{}\\b",
look_for
));
}
_ => {}
},
_ => {},
};
}
};
@ -110,6 +110,9 @@ impl Replacer {
mmap_target.deref_mut().write_all(&replaced)?;
mmap_target.flush()?;
drop(source);
drop(mmap_source);
target.persist(path)?;
Ok(())
}
@ -128,7 +131,7 @@ impl Replacer {
handle.write_all(&self.replace(&buffer))?;
}
Ok(())
}
},
(Source::Files(paths), true) => {
use rayon::prelude::*;
@ -137,7 +140,7 @@ impl Replacer {
.map(|p| self.replace_file(p).map_err(Error::log))
.collect::<Vec<Result<()>>>();
Ok(())
}
},
(Source::Files(paths), false) => {
let stdout = std::io::stdout();
let mut handle = stdout.lock();
@ -152,7 +155,7 @@ impl Replacer {
})
.collect::<Result<Vec<()>>>()?;
Ok(())
}
},
}
}
}