Skip to content

Commit e18ae11

Browse files
committed
Fix language issue with preproc
1 parent ffc5749 commit e18ae11

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/main.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,14 @@ fn act_on_file(language: Option<LANG>, path: PathBuf, cfg: Config) -> std::io::R
116116
};
117117
action::<Count>(&language, source, &path, pr, cfg)
118118
} else if cfg.preproc_lock.is_some() {
119-
if language == LANG::Cpp {
120-
let source = read_file_with_eol(&path)?;
121-
preprocess(
122-
&PreprocParser::new(source, &path, None),
123-
&path,
124-
cfg.preproc_lock.unwrap().clone(),
125-
);
119+
if let Some(language) = guess_language(&source, &path).0 {
120+
if language == LANG::Cpp {
121+
preprocess(
122+
&PreprocParser::new(source, &path, None),
123+
&path,
124+
cfg.preproc_lock.unwrap().clone(),
125+
);
126+
}
126127
}
127128
Ok(())
128129
} else {

0 commit comments

Comments
 (0)