Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new spawn API to fix broken Win32 ctags.exe command execution #372

Merged
merged 1 commit into from
Mar 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions geanyctags/src/geanyctags.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#endif


PLUGIN_VERSION_CHECK(211)
PLUGIN_VERSION_CHECK(226)
PLUGIN_SET_INFO("GeanyCtags",
_("Ctags generation and search plugin for geany projects"),
VERSION,
Expand Down Expand Up @@ -118,13 +118,14 @@ void plugin_help (void)
static void spawn_cmd(const gchar *cmd, const gchar *dir)
{
GError *error = NULL;
gchar **argv;
gchar **argv = NULL;
gchar *working_dir;
gchar *utf8_working_dir;
gchar *utf8_cmd_string;
gchar *out;
gint exitcode;
gboolean success;
GString *output;

#ifndef G_OS_WIN32
/* run within shell so we can use pipes */
Expand All @@ -133,13 +134,8 @@ static void spawn_cmd(const gchar *cmd, const gchar *dir)
argv[1] = g_strdup("-c");
argv[2] = g_strdup(cmd);
argv[3] = NULL;
#else
/* no shell on windows */
argv = g_new0(gchar *, 2);
argv[0] = g_strdup(cmd);
argv[1] = NULL;
#endif

utf8_cmd_string = utils_get_utf8_from_locale(cmd);
utf8_working_dir = g_strdup(dir);
working_dir = utils_get_locale_from_utf8(utf8_working_dir);
Expand All @@ -149,14 +145,16 @@ static void spawn_cmd(const gchar *cmd, const gchar *dir)
msgwin_msg_add(COLOR_BLUE, -1, NULL, _("%s (in directory: %s)"), utf8_cmd_string, utf8_working_dir);
g_free(utf8_working_dir);
g_free(utf8_cmd_string);


output = g_string_new(NULL);
#ifndef G_OS_WIN32
success = utils_spawn_sync(working_dir, argv, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, &out, &exitcode, &error);
success = spawn_sync(working_dir, NULL, argv, NULL,
NULL, NULL, output, &exitcode, &error);
#else
success = utils_spawn_sync(working_dir, argv, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, &out, NULL, &exitcode, &error);
success = spawn_sync(working_dir, cmd, NULL, NULL,
NULL, output, NULL, &exitcode, &error);
#endif
out = g_string_free(output, FALSE);
if (!success || exitcode != 0)
{
if (error != NULL)
Expand Down