Skip to content

Commit d124b82

Browse files
committed
use lossy conversion when reading file to parse points
1 parent 3b241fb commit d124b82

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

tmc-langs-framework/src/command.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ impl TmcCommand {
5858

5959
// starts executing the command
6060
let mut popen = exec.popen().map_err(|e| popen_to_tmc_err(cmd.clone(), e))?;
61-
log::debug!("here {:?} {:?}", popen.stdin, stdin);
6261
let stdin_handle = spawn_writer(popen.stdin.take(), stdin);
6362
let stdout_handle = spawn_reader(popen.stdout.take());
6463
let stderr_handle = spawn_reader(popen.stderr.take());

tmc-langs-framework/src/file_util.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ pub fn read_file_to_string<P: AsRef<Path>>(path: P) -> Result<String, FileIo> {
4848
Ok(s)
4949
}
5050

51+
pub fn read_file_to_string_lossy<P: AsRef<Path>>(path: P) -> Result<String, FileIo> {
52+
let path = path.as_ref();
53+
let bytes = read_file(path)?;
54+
let s = String::from_utf8_lossy(&bytes).into_owned();
55+
Ok(s)
56+
}
57+
5158
pub fn create_file<P: AsRef<Path>>(path: P) -> Result<File, FileIo> {
5259
let path = path.as_ref();
5360
if let Some(parent) = path.parent() {

tmc-langs-framework/src/plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ pub trait LanguagePlugin {
424424
let entry = entry?;
425425
if entry.path().is_file() {
426426
log::trace!("parsing points from {}", entry.path().display());
427-
let file_contents = file_util::read_file_to_string(entry.path())?;
427+
let file_contents = file_util::read_file_to_string_lossy(entry.path())?;
428428

429429
// reads any character
430430
let etc_parser = combinator::value(Parse::Other, character::complete::anychar);

0 commit comments

Comments
 (0)