diff --git a/stepmania/src/Font.cpp b/stepmania/src/Font.cpp index cc6fa1e07a..59fdf9eb06 100644 --- a/stepmania/src/Font.cpp +++ b/stepmania/src/Font.cpp @@ -343,17 +343,20 @@ CString Font::GetFontName(CString FileName) splitpath( FileName, sDir, sFName, sExt ); FileName = sFName; - /* If it ends in an extension, remove it. */ - if(regex("\\....", FileName)) + /* If it ends in an extension, remove it. XXX */ + static Regex drop_ext("\\...."); + if(drop_ext.Compare(FileName)) FileName.erase(FileName.size()-4); /* If it ends in a dimension spec, remove it. */ CStringArray mat; - if(regex("( [0-9]+x[0-9]+)$", FileName, mat)) + static Regex DimSpec("( [0-9]+x[0-9]+)$"); + if(DimSpec.Compare(FileName, mat)) FileName.erase(FileName.size()-mat[0].size()); /* If it ends in a page name, remove it. */ - if(regex("( \\[.+\\])$", FileName, mat)) + static Regex PageName("( \\[.+\\])$"); + if(PageName.Compare(FileName, mat)) FileName.erase(FileName.size()-mat[0].size()); TrimRight(FileName); @@ -366,6 +369,18 @@ CString Font::GetFontName(CString FileName) } +void Font::WeedFontNames(vector &v, const CString &FileName) +{ + CString FontName = Font::GetFontName(FileName); + /* Weed out false matches. (For example, this gets rid of "normal2" when + * we're really looking for "normal".) */ + for(unsigned i = 0; i < v.size(); ) { + if(FontName.CompareNoCase(Font::GetFontName(v[i]))) + v.erase(v.begin()+i); + else i++; + } +} + /* Given a file in a font, find all of the files for the font. * * Possibilities: @@ -541,7 +556,8 @@ void Font::LoadFontPageSettings(FontPageSettings &cfg, IniFile &ini, const CStri * range Unicode #3041-3094=0 */ vector matches; - bool match = regex("^RANGE ([A-Z\\-]+)( ?#([0-9A-F]+)-([0-9A-F]+))?$" , val, matches); + static Regex parse("^RANGE ([A-Z\\-]+)( ?#([0-9A-F]+)-([0-9A-F]+))?$"); + bool match = parse.Compare(val, matches); ASSERT(matches.size() == 4); /* 4 parens */ diff --git a/stepmania/src/Font.h b/stepmania/src/Font.h index 775efce89d..ab874438a1 100644 --- a/stepmania/src/Font.h +++ b/stepmania/src/Font.h @@ -132,6 +132,8 @@ public: static const longchar DEFAULT_GLYPH; static CString GetFontName(CString FileName); + /* Remove filenames in 'v' that aren't in the same font as "FileName". */ + static void WeedFontNames(vector &v, const CString &FileName); private: /* List of pages and fonts that we use (and are responsible for freeing). */ diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index faf9fdb1e0..4f6ed0f9bb 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -563,17 +563,18 @@ void Song::TidyUpData() struct TitleTrans { - CString TitleFrom, SubFrom, ArtistFrom, /* regex */ - TitleTo, SubTo, ArtistTo; /* plain text */ + Regex TitleFrom, SubFrom, ArtistFrom; + CString TitleTo, SubTo, ArtistTo; /* plain text */ + TitleTrans(CString tf, CString sf, CString af, CString tt, CString st, CString at): TitleFrom(tf), SubFrom(sf), ArtistFrom(af), TitleTo(tt), SubTo(st), ArtistTo(at) { } bool Matches(CString title, CString sub, CString artist) { - if(!TitleFrom.empty() && !regex(TitleFrom, title)) return false; /* no match */ - if(!SubFrom.empty() && !regex(SubFrom, sub)) return false; /* no match */ - if(!ArtistFrom.empty() && !regex(ArtistFrom, artist)) return false; /* no match */ + if(!TitleFrom.Compare(title)) return false; /* no match */ + if(!SubFrom.Compare(sub)) return false; /* no match */ + if(!ArtistFrom.Compare(artist)) return false; /* no match */ return true; }