Fixed some pedant issues.
I need to fix the last two by splitting up encode into multiple functions (probably a good thing) and apparently changing the lazy static macro
This commit is contained in:
39
src/files.rs
39
src/files.rs
@@ -41,9 +41,9 @@ pub fn watch_files(file_list: &[PathBuf]) -> u8
|
||||
return 0
|
||||
}
|
||||
},
|
||||
Err(e) =>
|
||||
Err(error) =>
|
||||
{
|
||||
println!("watch error: {:?}", e);
|
||||
println!("watch error: {error:?}");
|
||||
return 1
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ pub fn read_file(file_name: &str, depth: u8) ->
|
||||
Vec<PathBuf>,
|
||||
)
|
||||
{
|
||||
if let Ok(file_contents) = fs::read_to_string(format!("root/{}",file_name))
|
||||
if let Ok(file_contents) = fs::read_to_string(format!("root/{file_name}"))
|
||||
{
|
||||
let (bytes, file_list) = encode_npon(file_contents.as_str(), depth);
|
||||
return (bytes, file_list)
|
||||
@@ -108,10 +108,7 @@ fn encode_npon(file_contents: &str, depth: u8) ->
|
||||
_ => bytes.push(character), // Otherwise just push the character
|
||||
}
|
||||
backslash_flag = false;
|
||||
continue
|
||||
}
|
||||
backslash_flag = false;
|
||||
//print!("{} ", character);
|
||||
match flag
|
||||
{
|
||||
0 =>
|
||||
@@ -137,7 +134,6 @@ fn encode_npon(file_contents: &str, depth: u8) ->
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
continue
|
||||
},
|
||||
1 => // in a string
|
||||
{
|
||||
@@ -155,7 +151,6 @@ fn encode_npon(file_contents: &str, depth: u8) ->
|
||||
},
|
||||
_ => temp_string.push(character),
|
||||
}
|
||||
continue
|
||||
},
|
||||
2 => // in a name
|
||||
{
|
||||
@@ -174,30 +169,24 @@ fn encode_npon(file_contents: &str, depth: u8) ->
|
||||
},
|
||||
_ => temp_string.push(character),
|
||||
}
|
||||
continue
|
||||
},
|
||||
3 => // in import
|
||||
{
|
||||
match character
|
||||
if character == 58
|
||||
{
|
||||
58 =>
|
||||
file_list.push(ROOT_DIR.join(&file_contents[index_flag..index]));
|
||||
let (new_bytes, mut new_file_list) = read_file
|
||||
(
|
||||
&file_contents[index_flag..index],
|
||||
depth+1
|
||||
);
|
||||
file_list.append(&mut new_file_list);
|
||||
for byte in &new_bytes
|
||||
{
|
||||
file_list.push(ROOT_DIR.join(&file_contents[index_flag..index]));
|
||||
let (new_bytes, mut new_file_list) = read_file
|
||||
(
|
||||
&file_contents[index_flag..index],
|
||||
depth+1
|
||||
);
|
||||
file_list.append(&mut new_file_list);
|
||||
for byte in new_bytes.iter()
|
||||
{
|
||||
bytes.push(*byte);
|
||||
}
|
||||
flag = 0;
|
||||
bytes.push(*byte);
|
||||
}
|
||||
_ => (),
|
||||
flag = 0;
|
||||
}
|
||||
continue
|
||||
},
|
||||
_ => println!("ERROR: Invalid flag code or 'null'"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user