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".master
parent
1d5d4e278a
commit
f1f577ea72
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue