[gnome-builder/wip/gtk4-port] libide/threading: add shell parse helper for argv
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/threading: add shell parse helper for argv
- Date: Thu, 26 May 2022 03:37:17 +0000 (UTC)
commit 30e801c843f673b18e0f4f1cb1248f0030716aef
Author: Christian Hergert <chergert redhat com>
Date: Wed May 25 17:13:34 2022 -0700
libide/threading: add shell parse helper for argv
src/libide/threading/ide-subprocess-launcher.c | 19 +++++++++++++++++++
src/libide/threading/ide-subprocess-launcher.h | 3 +++
2 files changed, 22 insertions(+)
---
diff --git a/src/libide/threading/ide-subprocess-launcher.c b/src/libide/threading/ide-subprocess-launcher.c
index 450182761..ffa3c9208 100644
--- a/src/libide/threading/ide-subprocess-launcher.c
+++ b/src/libide/threading/ide-subprocess-launcher.c
@@ -1256,3 +1256,22 @@ ide_subprocess_launcher_push_argv_format (IdeSubprocessLauncher *self,
ide_subprocess_launcher_push_argv (self, arg);
}
+
+void
+ide_subprocess_launcher_push_argv_parsed (IdeSubprocessLauncher *self,
+ const char *args_to_parse)
+{
+ g_return_if_fail (IDE_IS_SUBPROCESS_LAUNCHER (self));
+
+ if (!ide_str_empty0 (args_to_parse))
+ {
+ g_autoptr(GError) error = NULL;
+ g_auto(GStrv) argv = NULL;
+ int argc;
+
+ if (!g_shell_parse_argv (args_to_parse, &argc, &argv, &error))
+ g_warning ("Failed to parse args: %s", error->message);
+ else
+ ide_subprocess_launcher_push_args (self, (const char * const *)argv);
+ }
+}
diff --git a/src/libide/threading/ide-subprocess-launcher.h b/src/libide/threading/ide-subprocess-launcher.h
index 7aad02a34..65fdd14cd 100644
--- a/src/libide/threading/ide-subprocess-launcher.h
+++ b/src/libide/threading/ide-subprocess-launcher.h
@@ -113,6 +113,9 @@ IDE_AVAILABLE_IN_3_32
void ide_subprocess_launcher_push_argv (IdeSubprocessLauncher *self,
const gchar *argv);
IDE_AVAILABLE_IN_ALL
+void ide_subprocess_launcher_push_argv_parsed (IdeSubprocessLauncher *self,
+ const char *args_to_parse);
+IDE_AVAILABLE_IN_ALL
void ide_subprocess_launcher_push_argv_format (IdeSubprocessLauncher *self,
const char *format,
...) G_GNUC_PRINTF (2, 3);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]