git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/4] quote: implement "sq_dequote_many" to unwrap many args in one string

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 30, 2009, 06:45 UTC
Message-ID
<7vocvjjyqa.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20090329114444.5579813c.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
Show 6 quoted lines
> @@ -92,6 +92,8 @@ char *sq_dequote(char *arg)
>  		switch (*++src) {
>  		case '\0':
>  			*dst = 0;
> +			if (next)
> +				*next = 0;
	*next = NULL;
>  			return arg;
>  		case '\\':
>  			c = *++src;
Show 10 quoted lines
> diff --git a/quote.h b/quote.h
> index c5eea6f..c2f98e7 100644
> --- a/quote.h
> +++ b/quote.h
> @@ -39,6 +39,14 @@ extern void sq_quote_argv(struct strbuf *, const char **argv, size_t maxlen);
>   */
>  extern char *sq_dequote(char *);
>  
> +/*
> + * Same as the above, but can unwraps many arguments in the same string
"can unwrap"
Show 9 quoted lines
> + * separated by space. "next" is changed to point to the next argument
> + * that should be passed as first parameter. When there are no more
> + * arguments to be dequoted, then "next" is changed to point to NULL.
> + */
> +extern char *sq_dequote_many(char *arg, char **next);
> +
>  extern int unquote_c_style(struct strbuf *, const char *quoted, const char **endp);
>  extern size_t quote_c_style(const char *name, struct strbuf *, FILE *, int no_dq);
>  extern void quote_two_c_style(struct strbuf *, const char *, const char *, int);

I think dequote_many() is misnamed, as it only does one but has a slightly more helpful interface than the bare sq_dequote() when the caller is willing to dequote many. It probably should be called dequote_step().

But do not send in replacements just yet.
Previous: Christian CouderNext: Christian Couder
Message 2 of 4 in “quote: implement "sq_dequote_many" to unwrap many args in one string”
  1. 1/4 quote: implement "sq_dequote_many" to unwrap many args in one stringChristian Couder, Mar 29, 2009
  2. Junio C HamanoMar 30, 2009
  3. Christian CouderMar 31, 2009
  4. Junio C HamanoMar 31, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.