From a54b49f5a8858ae6603d0db56019adc3ce0dff90 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 5 Dec 2012 07:37:17 +0100 Subject: 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 --- src/main.cpp | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'src/main.cpp') 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); -- cgit v1.2.3