[gnome-builder/wip/gtk4-port] libide/threading: add helper to append argv with printf format
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/threading: add helper to append argv with printf format
- Date: Wed, 25 May 2022 20:26:26 +0000 (UTC)
commit 6b026c5c12b7b3d7fdf184b5873436ef57e10a3e
Author: Christian Hergert <chergert redhat com>
Date: Wed May 25 12:27:54 2022 -0700
libide/threading: add helper to append argv with printf format
src/libide/threading/ide-subprocess-launcher.c | 31 ++++++++++++++++++++++++++
src/libide/threading/ide-subprocess-launcher.h | 4 ++++
2 files changed, 35 insertions(+)
---
diff --git a/src/libide/threading/ide-subprocess-launcher.c b/src/libide/threading/ide-subprocess-launcher.c
index f73329e40..450182761 100644
--- a/src/libide/threading/ide-subprocess-launcher.c
+++ b/src/libide/threading/ide-subprocess-launcher.c
@@ -1225,3 +1225,34 @@ ide_subprocess_launcher_join_args_for_sh_c (IdeSubprocessLauncher *self,
g_ptr_array_add (priv->argv, g_string_free (g_steal_pointer (&str), FALSE));
g_ptr_array_add (priv->argv, NULL);
}
+
+/**
+ * ide_subprocess_launcher_push_argv_format: (skip)
+ * @self: a #IdeSubprocessLauncher
+ * @format: a printf-style format string
+ *
+ * Convenience function which allows combining a g_strdup_printf() and
+ * call to ide_subprocess_launcher_push_argv() into one call.
+ *
+ * @format is used to build the argument string which is added using
+ * ide_subprocess_launcher_push_argv() and then freed.
+ */
+void
+ide_subprocess_launcher_push_argv_format (IdeSubprocessLauncher *self,
+ const char *format,
+ ...)
+{
+ g_autofree char *arg = NULL;
+ va_list args;
+
+ g_return_if_fail (IDE_IS_SUBPROCESS_LAUNCHER (self));
+ g_return_if_fail (format != NULL);
+
+ va_start (args, format);
+ arg = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ g_return_if_fail (arg != NULL);
+
+ ide_subprocess_launcher_push_argv (self, arg);
+}
diff --git a/src/libide/threading/ide-subprocess-launcher.h b/src/libide/threading/ide-subprocess-launcher.h
index d674aaf1b..7aad02a34 100644
--- a/src/libide/threading/ide-subprocess-launcher.h
+++ b/src/libide/threading/ide-subprocess-launcher.h
@@ -112,6 +112,10 @@ void ide_subprocess_launcher_push_args (IdeSubproce
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_format (IdeSubprocessLauncher *self,
+ const char *format,
+ ...) G_GNUC_PRINTF (2, 3);
IDE_AVAILABLE_IN_3_32
gchar *ide_subprocess_launcher_pop_argv (IdeSubprocessLauncher *self)
G_GNUC_WARN_UNUSED_RESULT;
IDE_AVAILABLE_IN_3_32
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]