From 4ddd4241a224f8a6b8be650fd8ff4e283d8191a7 Mon Sep 17 00:00:00 2001 From: Vseslav Kochenov Date: Sat, 3 Jun 2023 19:01:28 +0300 Subject: [PATCH] fix for cross-platform compatibility --- SnM/SnM_Notes.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SnM/SnM_Notes.cpp b/SnM/SnM_Notes.cpp index 4d4c276be..f623d9057 100644 --- a/SnM/SnM_Notes.cpp +++ b/SnM/SnM_Notes.cpp @@ -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) @@ -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)