mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 01:29:41 +01:00
Update langtool to latest Rust edition, run clippy fix
This commit is contained in:
1 parent
5a572879a4
commit
48e414fd0e
4 files changed
+41
-42
No files matched your search
Generated
+8
-8
@@ -54,9 +54,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.40"
|
||||
version = "4.5.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f"
|
||||
checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@@ -64,9 +64,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.40"
|
||||
version = "4.5.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e"
|
||||
checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@@ -76,9 +76,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.40"
|
||||
version = "4.5.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce"
|
||||
checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
@@ -149,9 +149,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.103"
|
||||
version = "2.0.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4307e30089d6fd6aff212f2da3a1f9e32f3223b1f010fb09b7c95f90f3ca1e8"
|
||||
checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
authors = ["Henrik Rydgård <hrydgard@gmail.com>"]
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
name = "langtool"
|
||||
version = "0.1.0"
|
||||
|
||||
|
||||
+27
-28
@@ -125,7 +125,7 @@ fn print_keys_if_not_in(
|
||||
if !keys.is_empty() {
|
||||
println!("{} ({})", reference_section.name, header);
|
||||
for key in &keys {
|
||||
println!("- {}", key);
|
||||
println!("- {key}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,13 +139,13 @@ fn move_key(target_ini: &mut IniFile, old: &str, new: &str, key: &str) -> io::Re
|
||||
if let Some(new_section) = target_ini.get_section_mut(new) {
|
||||
new_section.insert_line_if_missing(&line);
|
||||
} else {
|
||||
println!("No new section {}", new);
|
||||
println!("No new section {new}");
|
||||
}
|
||||
} else {
|
||||
println!("No key {} in section {}", key, old);
|
||||
println!("No key {key} in section {old}");
|
||||
}
|
||||
} else {
|
||||
println!("No old section {}", old);
|
||||
println!("No old section {old}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -156,13 +156,13 @@ fn copy_key(target_ini: &mut IniFile, old: &str, new: &str, key: &str) -> io::Re
|
||||
if let Some(new_section) = target_ini.get_section_mut(new) {
|
||||
new_section.insert_line_if_missing(&line);
|
||||
} else {
|
||||
println!("No new section {}", new);
|
||||
println!("No new section {new}");
|
||||
}
|
||||
} else {
|
||||
println!("No key {} in section {}", key, old);
|
||||
println!("No key {key} in section {old}");
|
||||
}
|
||||
} else {
|
||||
println!("No old section {}", old);
|
||||
println!("No old section {old}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -171,16 +171,16 @@ fn remove_key(target_ini: &mut IniFile, section: &str, key: &str) -> io::Result<
|
||||
if let Some(old_section) = target_ini.get_section_mut(section) {
|
||||
old_section.remove_line(key);
|
||||
} else {
|
||||
println!("No section {}", section);
|
||||
println!("No section {section}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn add_new_key(target_ini: &mut IniFile, section: &str, key: &str, value: &str) -> io::Result<()> {
|
||||
if let Some(section) = target_ini.get_section_mut(section) {
|
||||
section.insert_line_if_missing(&format!("{} = {}", key, value));
|
||||
section.insert_line_if_missing(&format!("{key} = {value}"));
|
||||
} else {
|
||||
println!("No section {}", section);
|
||||
println!("No section {section}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -189,7 +189,7 @@ fn rename_key(target_ini: &mut IniFile, section: &str, old: &str, new: &str) ->
|
||||
if let Some(section) = target_ini.get_section_mut(section) {
|
||||
section.rename_key(old, new);
|
||||
} else {
|
||||
println!("No section {}", section);
|
||||
println!("No section {section}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -198,7 +198,7 @@ fn dupe_key(target_ini: &mut IniFile, section: &str, old: &str, new: &str) -> io
|
||||
if let Some(section) = target_ini.get_section_mut(section) {
|
||||
section.dupe_key(old, new);
|
||||
} else {
|
||||
println!("No section {}", section);
|
||||
println!("No section {section}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -207,7 +207,7 @@ fn sort_section(target_ini: &mut IniFile, section: &str) -> io::Result<()> {
|
||||
if let Some(section) = target_ini.get_section_mut(section) {
|
||||
section.sort();
|
||||
} else {
|
||||
println!("No section {}", section);
|
||||
println!("No section {section}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -225,7 +225,7 @@ fn main() {
|
||||
let reference_ini_filename = "en_US.ini";
|
||||
|
||||
let mut reference_ini =
|
||||
IniFile::parse(&format!("{}/{}", root, reference_ini_filename)).unwrap();
|
||||
IniFile::parse(&format!("{root}/{reference_ini_filename}")).unwrap();
|
||||
|
||||
if filenames.is_empty() {
|
||||
// Grab them all.
|
||||
@@ -254,10 +254,10 @@ fn main() {
|
||||
if let Some(single_section) = single_ini.get_section("Single") {
|
||||
single_ini_section = Some(single_section.clone());
|
||||
} else {
|
||||
println!("No section {} in {}", section, filename);
|
||||
println!("No section {section} in {filename}");
|
||||
}
|
||||
} else {
|
||||
println!("Failed to parse {}", filename);
|
||||
println!("Failed to parse {filename}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -268,9 +268,9 @@ fn main() {
|
||||
// Get this from cargo run for some reason.
|
||||
continue;
|
||||
}
|
||||
let target_ini_filename = format!("{}/{}", root, filename);
|
||||
let target_ini_filename = format!("{root}/{filename}");
|
||||
if opt.verbose {
|
||||
println!("Langtool processing {}", target_ini_filename);
|
||||
println!("Langtool processing {target_ini_filename}");
|
||||
}
|
||||
|
||||
let mut target_ini = IniFile::parse(&target_ini_filename).unwrap();
|
||||
@@ -287,7 +287,7 @@ fn main() {
|
||||
Command::RemoveUnknownLines {} => {
|
||||
deal_with_unknown_lines(reference_ini, &mut target_ini, true).unwrap();
|
||||
}
|
||||
Command::GetNewKeys {} => {
|
||||
Command::GetNewKeys => {
|
||||
print_keys_if_not_in(reference_ini, &mut target_ini, &target_ini_filename).unwrap();
|
||||
}
|
||||
Command::SortSection { ref section } => sort_section(&mut target_ini, section).unwrap(),
|
||||
@@ -340,28 +340,27 @@ fn main() {
|
||||
} => {
|
||||
let lang_id = filename.strip_suffix(".ini").unwrap();
|
||||
if let Some(single_section) = &single_ini_section {
|
||||
if let Some(target_section) = target_ini.get_section_mut(§ion) {
|
||||
if let Some(single_line) = single_section.get_line(&lang_id) {
|
||||
if let Some(target_section) = target_ini.get_section_mut(section) {
|
||||
if let Some(single_line) = single_section.get_line(lang_id) {
|
||||
if let Some(value) = line_value(&single_line) {
|
||||
println!(
|
||||
"Inserting value {} for key {} in section {} in {}",
|
||||
value, key, section, target_ini_filename
|
||||
"Inserting value {value} for key {key} in section {section} in {target_ini_filename}"
|
||||
);
|
||||
if !target_section
|
||||
.insert_line_if_missing(&format!("{} = {}", key, value))
|
||||
.insert_line_if_missing(&format!("{key} = {value}"))
|
||||
{
|
||||
// Didn't insert it, so it exists. We need to replace it.
|
||||
target_section.set_value(key, value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
println!("No lang_id {} in single section", lang_id);
|
||||
println!("No lang_id {lang_id} in single section");
|
||||
}
|
||||
} else {
|
||||
println!("No section {} in {}", section, target_ini_filename);
|
||||
println!("No section {section} in {target_ini_filename}");
|
||||
}
|
||||
} else {
|
||||
println!("No section {} in {}", section, filename);
|
||||
println!("No section {section} in {filename}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -371,7 +370,7 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
println!("Langtool processing {}", reference_ini_filename);
|
||||
println!("Langtool processing {reference_ini_filename}");
|
||||
|
||||
// Some commands also apply to the reference ini.
|
||||
match opt.cmd {
|
||||
|
||||
@@ -10,7 +10,7 @@ pub struct Section {
|
||||
pub lines: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn line_value<'a>(line: &'a str) -> Option<&'a str> {
|
||||
pub fn line_value(line: &str) -> Option<&str> {
|
||||
let line = line.trim();
|
||||
if let Some(pos) = line.find(" =") {
|
||||
let value = &line[pos + 2..];
|
||||
@@ -105,7 +105,7 @@ impl Section {
|
||||
return true;
|
||||
}
|
||||
|
||||
println!("failed to insert {}", line);
|
||||
println!("failed to insert {line}");
|
||||
true
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ impl Section {
|
||||
let mut right_part = line.strip_prefix(&prefix).unwrap().to_string();
|
||||
if right_part.trim() == old.trim() {
|
||||
// Was still untranslated - replace the translation too.
|
||||
right_part = format!(" {}", new);
|
||||
right_part = format!(" {new}");
|
||||
}
|
||||
let line = new.to_owned() + " =" + &right_part;
|
||||
self.insert_line_if_missing(&line);
|
||||
@@ -145,7 +145,7 @@ impl Section {
|
||||
let mut right_part = line.strip_prefix(&prefix).unwrap().to_string();
|
||||
if right_part.trim() == old.trim() {
|
||||
// Was still untranslated - replace the translation too.
|
||||
right_part = format!(" {}", new);
|
||||
right_part = format!(" {new}");
|
||||
}
|
||||
let line = new.to_owned() + " =" + &right_part;
|
||||
self.insert_line_if_missing(&line);
|
||||
@@ -238,7 +238,7 @@ impl Section {
|
||||
}
|
||||
|
||||
if let Some(found_index) = found_index {
|
||||
self.lines[found_index] = format!("{} = {}", key, value);
|
||||
self.lines[found_index] = format!("{key} = {value}");
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
||||
Reference in new issue
Block a user