Skip to content

Commit

Permalink
fix for cross-platform compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
RusAD32 committed Jun 3, 2023
1 parent 247f37d commit 4ddd424
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions SnM/SnM_Notes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1519,15 +1519,16 @@ void ImportSubTitleFile(COMMAND_T* _ct)
if (char* fn = BrowseForFiles(__LOCALIZE("S&M - Import subtitle file","sws_DLG_152"), g_lastImportSubFn, NULL, false, SNM_SUB_EXT_LIST))
{
lstrcpyn(g_lastImportSubFn, fn, sizeof(g_lastImportSubFn));
char* ext = strlwr(PathFindExtension(fn));
if (strcmp(ext, ".srt") == 0) {
char* ext = strrchr(fn, '.');

if (strcmp(ext, ".srt") == 0 || strcmp(ext, ".SRT") == 0) { // I don't know a cross-platform way to compare ignoring case in c++ so I'm checking only two cases
if (ImportSubRipFile(fn))
//JFB hard-coded undo label: _ct might be NULL (when called from a button)
// + avoid trailing "..." in undo point name (when called from an action)
Undo_OnStateChangeEx2(NULL, __LOCALIZE("Import subtitle file","sws_DLG_152"), UNDO_STATE_ALL, -1);
else
MessageBox(GetMainHwnd(), __LOCALIZE("Invalid subtitle file!","sws_DLG_152"), __LOCALIZE("S&M - Error","sws_DLG_152"), MB_OK);
} else if (strcmp(ext, ".ass") == 0) {
} else if (strcmp(ext, ".ass") == 0 || strcmp(ext, ".ASS") == 0) {
if (ImportAdvancedSubStationFile(fn))
//JFB hard-coded undo label: _ct might be NULL (when called from a button)
// + avoid trailing "..." in undo point name (when called from an action)
Expand Down Expand Up @@ -1985,16 +1986,16 @@ void NotesWnd::OnDroppedFiles(HDROP _h) {
for (int i=0; i < iFiles; i++)
{
int n = DragQueryFile(_h, i, fn, sizeof(fn));
char* ext = strlwr(PathFindExtension(fn));
char* ext = strrchr(fn, '.');

if (strcmp(ext, ".srt") == 0) {
if (strcmp(ext, ".srt") == 0 || strcmp(ext, ".SRT") == 0) {
if (ImportSubRipFile(fn))
//JFB hard-coded undo label: _ct might be NULL (when called from a button)
// + avoid trailing "..." in undo point name (when called from an action)
Undo_OnStateChangeEx2(NULL, __LOCALIZE("Import subtitle file","sws_DLG_152"), UNDO_STATE_ALL, -1);
else
MessageBox(GetMainHwnd(), __LOCALIZE("Invalid subtitle file!","sws_DLG_152"), __LOCALIZE("S&M - Error","sws_DLG_152"), MB_OK);
} else if (strcmp(ext, ".ass") == 0) {
} else if (strcmp(ext, ".ass") == 0 || strcmp(ext, ".ASS") == 0) {
if (ImportAdvancedSubStationFile(fn))
//JFB hard-coded undo label: _ct might be NULL (when called from a button)
// + avoid trailing "..." in undo point name (when called from an action)
Expand Down

0 comments on commit 4ddd424

Please sign in to comment.