From 37c4eb123c9b2648abf06a8b4a45b12a37b12804 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 21 Sep 2015 09:12:29 +0200 Subject: [PATCH] Enhance bash auto-detection. --- PowerEditor/src/ScitillaComponent/Buffer.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index fa42d90ba..fdac986c7 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -1257,7 +1257,8 @@ LangType FileManager::detectLanguageFromTextBegining(const unsigned char *data, // it detectes xml, php and bash script file std::string xmlHeader = ""; // length : 6 std::string htmlHeader1 = ""; // length : 15 @@ -1272,8 +1273,13 @@ LangType FileManager::detectLanguageFromTextBegining(const unsigned char *data, std::string buf2Test = std::string((const char *)data + i, longestLength); - auto res = std::mismatch(bashHeader.begin(), bashHeader.end(), buf2Test.begin()); - if (res.first == bashHeader.end()) + auto res = std::mismatch(shebang1.begin(), shebang1.end(), buf2Test.begin()); + if (res.first == shebang1.end()) + { + return L_BASH; + } + res = std::mismatch(shebang2.begin(), shebang2.end(), buf2Test.begin()); + if (res.first == shebang2.end()) { return L_BASH; }