aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-12-05 07:37:17 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-12-05 07:37:17 +0100
commita54b49f5a8858ae6603d0db56019adc3ce0dff90 (patch)
tree40894af980f74648a43d5c322e4501b3a400c4cd /src/main.cpp
parent29d54a4b19caf94b2efd2bd537e8c24f70e9520b (diff)
downloadsciteco-a54b49f5a8858ae6603d0db56019adc3ce0dff90.tar.gz
windows compatibility changes
* respect executable extensions * do not use weak symbols which appear to be broken on MinGW. Instead, the generated symbol constants contain constructor functions initializing the corresponding objects. Constructor priorities are used to ensure that the initialization takes place after the dummy (NULL) initialization. * do not change the working dir (causes trouble when sciteco gets passed relative paths but the exe is not in the current dir) instead look for teco.ini in program's directory
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp28
1 files changed, 7 insertions, 21 deletions
diff --git a/src/main.cpp b/src/main.cpp
index c93e542..2adb505 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -85,32 +85,22 @@ Interface::process_notify(SCNotification *notify)
#ifdef G_OS_WIN32
/*
- * keep program self-contained under Windows
- * (look for profile in current directory)
+ * Keep program self-contained under Windows
+ * (look for profile in program's directory)
*/
static inline gchar *
-get_teco_ini(void)
-{
- return g_strdup(INI_FILE);
-}
-
-/*
- * Windows sometimes sets the current working directory to very obscure
- * paths when opening files in the Explorer, but we have to read the
- * teco.ini from the directory where our binary resides.
- */
-static inline void
-fix_cwd(const gchar *program)
+get_teco_ini(const gchar *program)
{
gchar *bin_dir = g_path_get_dirname(program);
- g_chdir(bin_dir);
+ gchar *ini = g_build_filename(bin_dir, INI_FILE, NULL);
g_free(bin_dir);
+ return ini;
}
#else
static inline gchar *
-get_teco_ini(void)
+get_teco_ini(const gchar *program __attribute__((unused)))
{
const gchar *home;
@@ -122,8 +112,6 @@ get_teco_ini(void)
return g_build_filename(home, INI_FILE, NULL);
}
-static inline void fix_cwd(const gchar *program __attribute__((unused))) {}
-
#endif /* !G_OS_WIN32 */
static inline void
@@ -158,7 +146,7 @@ process_options(int &argc, char **&argv)
exit(EXIT_FAILURE);
}
} else {
- mung_file = get_teco_ini();
+ mung_file = get_teco_ini(argv[0]);
}
interface.parse_args(argc, argv);
@@ -172,8 +160,6 @@ main(int argc, char **argv)
static GotoTable cmdline_goto_table;
static QRegisterTable local_qregs;
- fix_cwd(argv[0]);
-
process_options(argc, argv);
interface.ssm(SCI_SETCARETSTYLE, CARETSTYLE_BLOCK);