diff options
Diffstat (limited to 'support/pkgcheck/src/utils.rs')
-rw-r--r-- | support/pkgcheck/src/utils.rs | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/support/pkgcheck/src/utils.rs b/support/pkgcheck/src/utils.rs index 2dedc94ecd..a8f2d56c0f 100644 --- a/support/pkgcheck/src/utils.rs +++ b/support/pkgcheck/src/utils.rs @@ -17,8 +17,8 @@ use std::fs; #[derive(Debug, Clone, PartialEq, Eq)] pub enum CheckType { - TDS, - PACKAGE, + Tds, + Package, } pub struct Utils { @@ -38,7 +38,7 @@ impl Utils { return false; } if fsize > 40 * 1024 * 1024 { - if self.kind == CheckType::PACKAGE { + if self.kind == CheckType::Package { w0005!(dir_entry_str, fsize / 1024 / 1024); } else { w0006!(dir_entry_str, fsize / 1024 / 1024); @@ -102,10 +102,10 @@ impl Utils { pub fn check_for_hidden_file(&self, entry: &str, dir_entry_str: &str) { if entry.starts_with('.') { match self.kind { - CheckType::PACKAGE => { + CheckType::Package => { e0007!(dir_entry_str); } - CheckType::TDS => { + CheckType::Tds => { e0007t!(dir_entry_str); } } @@ -123,10 +123,10 @@ impl Utils { //if fname.map(|s| s.starts_with('.')).unwrap_or(false) { if fname.starts_with('.') { match self.kind { - CheckType::PACKAGE => { + CheckType::Package => { e0006!(dir_entry_str); } - CheckType::TDS => { + CheckType::Tds => { e0006t!(dir_entry_str); } } @@ -140,10 +140,10 @@ impl Utils { if RE.is_match(dir_entry_str) { match self.kind { - CheckType::PACKAGE => { + CheckType::Package => { e0008!(dir_entry_str); } - CheckType::TDS => { + CheckType::Tds => { e0008t!(dir_entry_str); } } @@ -156,10 +156,10 @@ impl Utils { Ok(contents) => { if contents.count() == 0 { match self.kind { - CheckType::PACKAGE => { + CheckType::Package => { e0004!(dir_entry_display); } - CheckType::TDS => { + CheckType::Tds => { // Note: Karl Berry recommended to issue a warning only // as an empty directory in a TDS zip archive // - is automatically deleted before including @@ -176,10 +176,10 @@ impl Utils { } } -pub fn temp_file_endings() -> Vec<(&'static str, &'static str)> { +pub fn temp_file_endings() -> Vec<(String, String)> { // https://github.com/github/gitignore/blob/master/TeX.gitignore // http://hopf.math.purdue.edu/doc/html/suffixes.html - vec![ + let v = vec![ ("-blx.aux", "bibliography auxiliary file"), ("-blx.bib", "bibliography auxiliary file"), (".4ct", "htlatex related"), @@ -212,6 +212,7 @@ pub fn temp_file_endings() -> Vec<(&'static str, &'static str)> { (".gls", "glossary related"), (".glsdefs", "glossaries related"), (".gtex", "generated by gregoriotex"), + (".hd", ""), (".idv", "htlatex related"), (".idx", "makeidx related"), (".ilg", "makeidx related"), @@ -250,6 +251,7 @@ pub fn temp_file_endings() -> Vec<(&'static str, &'static str)> { (".synctex(busy)", "synctex related"), (".synctex.gz", "synctex related"), (".synctex.gz(busy)", "synctex related"), + (".tpt", ""), (".tdo", "generated by todonotes (list of todos)"), (".thm", "amsthm related"), (".tmb", "generated by thumbs package"), @@ -267,7 +269,9 @@ pub fn temp_file_endings() -> Vec<(&'static str, &'static str)> { (".xref", "htlatex related"), ("~", "a file name ending with ~ (tilde) is temporary anyway"), // ( ".lyx~", "LyX related backup file" ), - ] + ]; + + v.into_iter().map(|(i, j)| (i.to_string(), j.to_string())).collect() } pub fn regex_temporary_file_endings() -> Regex { @@ -280,7 +284,7 @@ pub fn regex_temporary_file_endings() -> Regex { } else { rv.push('|'); } - let px = str::replace(p, ".", "\\."); + let px = str::replace(&p, ".", "\\."); rv.push_str(&px); } @@ -452,12 +456,13 @@ fn test_dirname() { #[allow(dead_code)] pub fn dirname(entry: &str) -> Option<&str> { - if entry.ends_with('/') { + if let Some(stripped) = entry.strip_suffix('/') { if entry.len() == 1 { return Some(entry); } - return Some(&entry[..entry.len() - 1]); + return Some(stripped) } + let pos = entry.rfind('/'); match pos { None => None, |