Skip to content

Commit

Permalink
langtool: Update, fix clippy warnings, just because
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Mar 12, 2023
1 parent 25fbfd7 commit ddab8fc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
16 changes: 8 additions & 8 deletions Tools/langtool/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tools/langtool/Cargo.toml
Expand Up @@ -5,4 +5,4 @@ name = "langtool"
version = "0.1.0"

[dependencies]
structopt = "0.3"
structopt = "0.3.26"
12 changes: 6 additions & 6 deletions Tools/langtool/src/main.rs
Expand Up @@ -100,7 +100,7 @@ fn move_key(target_ini: &mut IniFile, old: &str, new: &str, key: &str) -> io::Re

fn remove_key(target_ini: &mut IniFile, section: &str, key: &str) -> io::Result<()> {
if let Some(old_section) = target_ini.get_section_mut(section) {
let _ = old_section.remove_line(key);
old_section.remove_line(key);
} else {
println!("No section {}", section);
}
Expand All @@ -109,7 +109,7 @@ fn remove_key(target_ini: &mut IniFile, section: &str, key: &str) -> io::Result<

fn add_new_key(target_ini: &mut IniFile, section: &str, key: &str) -> io::Result<()> {
if let Some(section) = target_ini.get_section_mut(section) {
let _ = section.insert_line_if_missing(&format!("{} = {}", key, key));
section.insert_line_if_missing(&format!("{} = {}", key, key));
} else {
println!("No section {}", section);
}
Expand All @@ -118,7 +118,7 @@ fn add_new_key(target_ini: &mut IniFile, section: &str, key: &str) -> io::Result

fn rename_key(target_ini: &mut IniFile, section: &str, old: &str, new: &str) -> io::Result<()> {
if let Some(section) = target_ini.get_section_mut(section) {
let _ = section.rename_key(old, new);
section.rename_key(old, new);
} else {
println!("No section {}", section);
}
Expand Down Expand Up @@ -178,13 +178,13 @@ fn main() {

match opt.cmd {
Command::CopyMissingLines {} => {
copy_missing_lines(&reference_ini, &mut target_ini).unwrap();
copy_missing_lines(reference_ini, &mut target_ini).unwrap();
}
Command::CommentUnknownLines {} => {
deal_with_unknown_lines(&reference_ini, &mut target_ini, false).unwrap();
deal_with_unknown_lines(reference_ini, &mut target_ini, false).unwrap();
}
Command::RemoveUnknownLines {} => {
deal_with_unknown_lines(&reference_ini, &mut target_ini, true).unwrap();
deal_with_unknown_lines(reference_ini, &mut target_ini, true).unwrap();
}
Command::SortSection { ref section } => sort_section(&mut target_ini, section).unwrap(),
Command::RenameKey {
Expand Down
10 changes: 4 additions & 6 deletions Tools/langtool/src/section.rs
Expand Up @@ -20,7 +20,7 @@ impl Section {
continue;
};

if prefix.eq_ignore_ascii_case(&key) {
if prefix.eq_ignore_ascii_case(key) {
remove_index = Some(index);
break;
}
Expand Down Expand Up @@ -140,11 +140,9 @@ impl Section {
if prefix.starts_with("Font") || prefix.starts_with('#') {
return true;
}
if !other.lines.iter().any(|line| line.starts_with(prefix)) {
false
} else {
true
}

// keeps the line if this expression returns true.
other.lines.iter().any(|line| line.starts_with(prefix))
});
}
}

0 comments on commit ddab8fc

Please sign in to comment.