Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Enrico Tröger enrico.troeger@uvena.de Date: Sun, 13 Nov 2016 13:55:42 UTC Commit: f1f577ea72352b4d6010f87cd8097179d0642d54 https://github.com/geany/geany/commit/f1f577ea72352b4d6010f87cd8097179d0642d...
Log Message: ----------- spawn: Don't depend on utils.h, and fix locale compat on Windows
utils_get_utf8_from_locale() is actually a no-op on Windows, so use the GLib conversion directly. We really mean locale here, not "filename encoding".
Modified Paths: -------------- src/Makefile.am src/build.c src/geany-run-helper src/geany-run-helper.bat src/spawn.c src/win32.c src/win32.h
Modified: src/Makefile.am 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -186,9 +186,9 @@ CLEANFILES += signallist.i
# install the run script if MINGW -pkglibexec_SCRIPTS = geany-run-helper.bat +dist_pkglibexec_SCRIPTS = geany-run-helper.bat else -pkglibexec_SCRIPTS = geany-run-helper +dist_pkglibexec_SCRIPTS = geany-run-helper endif
# Ubuntu ld has a bug so that libtool sees /usr/local/lib as a system path so
Modified: src/build.c 6 lines changed, 5 insertions(+), 1 deletions(-) =================================================================== @@ -826,16 +826,20 @@ static gchar *prepare_run_cmd(GeanyDocument *doc, gchar **working_dir, guint cmd #endif
gchar *helper = g_build_filename(utils_resource_dir(RESOURCE_DIR_LIBEXEC), "geany-run-helper", NULL); + gchar *arg_directory = NULL;
/* escape helper appropriately */ #ifdef G_OS_WIN32 /* FIXME: check the Windows rules, but it should not matter too much here as \es and "es are not * allowed in paths anyway */ SETPTR(helper, g_strdup_printf(""%s"", helper)); + SETPTR(arg_directory, g_strdup_printf(""%s"", *working_dir)); #else SETPTR(helper, g_shell_quote(helper)); + SETPTR(arg_directory, g_shell_quote(*working_dir)); #endif - run_cmd = g_strdup_printf("%s %d %s", helper, autoclose ? 1 : 0, cmd_string); + run_cmd = g_strdup_printf("%s %s %d %s", helper, arg_directory, autoclose ? 1 : 0, cmd_string); + g_free(arg_directory); g_free(helper);
utils_free_pointers(3, cmd_string_utf8, working_dir_utf8, cmd_string, NULL);
Modified: src/geany-run-helper 5 lines changed, 4 insertions(+), 1 deletions(-) =================================================================== @@ -1,6 +1,9 @@ #!/bin/sh -# USAGE: geany-run-helper AUTOCLOSE COMMAND... +# USAGE: geany-run-helper DIRECTORY AUTOCLOSE COMMAND...
+# OSX resets the current directory, so check it back +cd "$1" +shift # save autoclose option and remove it autoclose=$1 shift
Modified: src/geany-run-helper.bat 5 lines changed, 4 insertions(+), 1 deletions(-) =================================================================== @@ -1,5 +1,8 @@ -REM USAGE: geany-run-helper AUTOCLOSE COMMAND... +REM USAGE: geany-run-helper DIRECTORY AUTOCLOSE COMMAND...
+REM unnecessary, but we get the directory +cd %1 +shift REM save autoclose option and remove it set autoclose=%1 shift
Modified: src/spawn.c 18 lines changed, 13 insertions(+), 5 deletions(-) =================================================================== @@ -67,7 +67,6 @@ #else # include "support.h" #endif -#include "utils.h"
#if ! GLIB_CHECK_VERSION(2, 31, 20) && ! defined(G_SPAWN_ERROR_TOO_BIG) # define G_SPAWN_ERROR_TOO_BIG G_SPAWN_ERROR_2BIG @@ -575,8 +574,9 @@ static gboolean spawn_async_with_pipes(const gchar *working_directory, const gch // FIXME: remove this and rely on UTF-8 input if (! g_utf8_validate(*envp, -1, NULL)) { - tmp = utils_get_utf8_from_locale(*envp); - *envp = tmp; + tmp = g_locale_to_utf8(*envp, -1, NULL, NULL, NULL); + if (tmp) + *envp = tmp; } /* TODO: better error message */ w_entry = g_utf8_to_utf16(*envp, -1, NULL, &w_entry_len, error); @@ -603,7 +603,11 @@ static gboolean spawn_async_with_pipes(const gchar *working_directory, const gch
// FIXME: remove this and rely on UTF-8 input if (! g_utf8_validate(working_directory, -1, NULL)) - utf8_working_directory = tmp = utils_get_utf8_from_locale(working_directory); + { + tmp = g_locale_to_utf8(working_directory, -1, NULL, NULL, NULL); + if (tmp) + utf8_working_directory = tmp; + } else utf8_working_directory = working_directory;
@@ -628,7 +632,11 @@ static gboolean spawn_async_with_pipes(const gchar *working_directory, const gch
// FIXME: remove this and rely on UTF-8 input if (! g_utf8_validate(command->str, -1, NULL)) - utf8_cmd = tmp = utils_get_utf8_from_locale(command->str); + { + tmp = g_locale_to_utf8(command->str, -1, NULL, NULL, NULL); + if (tmp) + utf8_cmd = tmp; + } else utf8_cmd = command->str;
Modified: src/win32.c 0 lines changed, 0 insertions(+), 0 deletions(-) =================================================================== No diff available, check online
Modified: src/win32.h 0 lines changed, 0 insertions(+), 0 deletions(-) =================================================================== No diff available, check online
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).