Permalink
Browse files

Add owl_argv_quote convenience function

Did we really never write this thing?
  • Loading branch information...
1 parent d953ede commit 7b89e8cbe6bf87b1f2950e4c4a73c77645eb5363 @davidben davidben committed Oct 1, 2011
Showing with 15 additions and 1 deletion.
  1. +15 −1 util.c
View
16 util.c
@@ -261,11 +261,25 @@ CALLER_OWN char *owl_string_build_quoted(const char *tmpl, ...)
* command-line. Result should be freed with g_free. */
CALLER_OWN char *owl_arg_quote(const char *arg)
{
- GString *buf = g_string_new("");;
+ GString *buf = g_string_new("");
owl_string_append_quoted_arg(buf, arg);
return g_string_free(buf, false);
}
+/* Returns a quoted version of argv. owl_parseline on the result should give
+ * back the input. */
+CALLER_OWN char *owl_argv_quote(int argc, const char *const *argv)
+{
+ int i;
+ GString *buf = g_string_new("");
+ for (i = 0; i < argc; i++) {
+ if (i > 0)
+ g_string_append_c(buf, ' ');
+ owl_string_append_quoted_arg(buf, argv[i]);
+ }
+ return g_string_free(buf, false);
+}
+
/* caller must free the return */
CALLER_OWN char *owl_util_format_minutes(int in)
{

0 comments on commit 7b89e8c

Please sign in to comment.