Skip to content

Commit c404fb2

Browse files
committed
3
1 parent 380b448 commit c404fb2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

libc-test/build.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,21 @@ fn process_semver_file<W: Write, P: AsRef<Path>>(output: &mut W, path: &mut Path
129129
};
130130
let input = BufReader::new(input_file);
131131

132-
write!(output, "// Source: {}.\n", path.display()).unwrap();
133-
output.write(b"use libc::{\n").unwrap();
132+
writeln!(output, "// Source: {}.", path.display()).unwrap();
133+
output.write_all(b"use libc::{\n").unwrap();
134134
for line in input.lines() {
135135
let line = line.unwrap().into_bytes();
136136
match line.first() {
137137
// Ignore comments and empty lines.
138138
Some(b'#') | None => continue,
139139
_ => {
140-
output.write(b" ").unwrap();
141-
output.write(&line).unwrap();
142-
output.write(b",\n").unwrap();
140+
output.write_all(b" ").unwrap();
141+
output.write_all(&line).unwrap();
142+
output.write_all(b",\n").unwrap();
143143
}
144144
}
145145
}
146-
output.write(b"};\n\n").unwrap();
146+
output.write_all(b"};\n\n").unwrap();
147147
path.pop();
148148
}
149149

@@ -158,21 +158,21 @@ fn main() {
158158

159159
// FIXME(ctest): ctest cannot parse `crate::` in paths, so replace them with `::`
160160
let re = regex::bytes::Regex::new(r"(?-u:\b)crate::").unwrap();
161-
copy_dir_hotfix(Path::new("../src"), &hotfix_dir, &re);
161+
copy_dir_hotfix(Path::new("../src"), &hotfix_dir, &re, b"::");
162162

163163
do_cc();
164164
do_ctest();
165165
do_semver();
166166
}
167167

168-
fn copy_dir_hotfix(src: &Path, dst: &Path, regex: &regex::bytes::Regex) {
169-
std::fs::create_dir(dst).unwrap();
168+
fn copy_dir_hotfix(src: &Path, dst: &Path, regex: &regex::bytes::Regex, replace: &[u8]) {
169+
std::fs::create_dir(&dst).unwrap();
170170
for entry in src.read_dir().unwrap() {
171171
let entry = entry.unwrap();
172172
let src_path = entry.path();
173173
let dst_path = dst.join(entry.file_name());
174174
if entry.file_type().unwrap().is_dir() {
175-
copy_dir_hotfix(&src_path, &dst_path, regex);
175+
copy_dir_hotfix(&src_path, &dst_path, regex, replace);
176176
} else {
177177
// Replace "crate::" with "::"
178178
let src_data = std::fs::read(&src_path).unwrap();

0 commit comments

Comments
 (0)