From 6c7abcc75da8f667bf769bacff331e19d4a4dff2 Mon Sep 17 00:00:00 2001
From: David Macek <david.macek.0@gmail.com>
Date: Thu, 12 Feb 2015 13:04:15 +0100
Subject: [PATCH 3/3] Use FHS

---
 scite/src/SciTEIO.cxx    |  7 -------
 scite/win32/SciTEWin.cxx | 25 ++++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/scite/src/SciTEIO.cxx b/scite/src/SciTEIO.cxx
index 34abc6e..5da0040 100644
--- a/scite/src/SciTEIO.cxx
+++ b/scite/src/SciTEIO.cxx
@@ -52,14 +52,7 @@
 #include "SciTEBase.h"
 #include "Utf8_16.h"
 
-#if defined(GTK)
 const GUI::gui_char propUserFileName[] = GUI_TEXT(".SciTEUser.properties");
-#elif defined(__APPLE__)
-const GUI::gui_char propUserFileName[] = GUI_TEXT("SciTEUser.properties");
-#else
-// Windows
-const GUI::gui_char propUserFileName[] = GUI_TEXT("SciTEUser.properties");
-#endif
 const GUI::gui_char propGlobalFileName[] = GUI_TEXT("SciTEGlobal.properties");
 const GUI::gui_char propAbbrevFileName[] = GUI_TEXT("abbrev.properties");
 
diff --git a/scite/win32/SciTEWin.cxx b/scite/win32/SciTEWin.cxx
index 16c21a8..4929de9 100644
--- a/scite/win32/SciTEWin.cxx
+++ b/scite/win32/SciTEWin.cxx
@@ -551,7 +551,12 @@ FilePath GetSciTEPath(const FilePath &home) {
 		return {};
 	// Remove the SciTE.exe
 	const FilePath pathSciTE(path);
-	return pathSciTE.Directory();
+	// MSYS2: go to $(bindir)/../share/scite
+	const FilePath pathBin(pathSciTE.Directory());
+	const FilePath pathRoot(pathBin.Directory());
+	const FilePath pathShare(pathRoot, FilePath(GUI_TEXT("share")));
+	const FilePath pathShareSciTE(pathShare, FilePath(GUI_TEXT("scite")));
+	return pathShareSciTE;
 }
 
 }
@@ -547,7 +552,10 @@
 	if (!home) {
 		home = _wgetenv(GUI_TEXT("SciTE_HOME"));
 		if (!home) {
-			home = _wgetenv(GUI_TEXT("USERPROFILE"));
+			home = _wgetenv(GUI_TEXT("HOME"));
+			if (!home) {
+				home = _wgetenv(GUI_TEXT("USERPROFILE"));
+			}
 		}
 	}
 	return GetSciTEPath(home);
-- 
2.3.0
