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

Re: [PATCH 1/1] quote: handle null and empty strings in sq_quote_buf_pretty()

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 20, 2019, 20:32 UTC
Message-ID
<xmqqpnkztw6y.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<9d2685bdb2e193986bec8cad88795963977d41fe.1566329700.git.gitgitgadget@gmail.com>
"Garima Singh via GitGitGadget" <gitgitgadget@gmail.com> writes:
> +	/*
> +	 * In case of null or empty tokens, add a '' to ensure we 
> +	 * don't inadvertently drop those tokens
> +	 */
A good comment.
> +	if (!src || !*src) {

I think a caller that passes src==NULL deserves a BUG, or just a normal segfault. The condition here should just be "if (!*src)" instead.

> +		strbuf_addstr(dst, "''");
> +		return;
> +	}
Otherwise, the fix itself is good.
Thanks.
>  	for (p = src; *p; p++) {
>  		if (!isalpha(*p) && !isdigit(*p) && !strchr(ok_punct, *p)) {
>  			sq_quote_buf(dst, src);
Previous: Junio C HamanoNext: Garima Singh via GitGitGadget
Message 5 of 19 in “quote: handle null and empty strings in sq_quote_buf_pretty()”
  1. 0/1 quote: handle null and empty strings in sq_quote_buf_pretty()Garima Singh via GitGitGadget, Aug 20, 2019
  2. 1/1 quote: handle null and empty strings in sq_quote_buf_pretty()Garima Singh via GitGitGadget, Aug 20, 2019
  3. Junio C HamanoAug 20, 2019
  4. Junio C HamanoAug 21, 2019
  5. Junio C HamanoAug 20, 2019
  6. 0/1 quote: handle null and empty strings in sq_quote_buf_pretty()Garima Singh via GitGitGadget, Aug 26, 2019
  7. 1/1 quote: handle null and empty strings in sq_quote_buf_pretty()Garima Singh via GitGitGadget, Aug 26, 2019
  8. Garima SinghAug 26, 2019
  9. Junio C HamanoAug 26, 2019
  10. 0/1 quote: handle null and empty strings in sq_quote_buf_pretty()Garima Singh via GitGitGadget, Oct 7, 2019
  11. 1/1 quote: handle numm and empty strings in sq_quote_buf_prettyGarima Singh via GitGitGadget, Oct 7, 2019
  12. Garima SinghOct 7, 2019
  13. Eric SunshineOct 7, 2019
  14. Garima SinghOct 7, 2019
  15. 0/1 quote: handle null and empty strings in sq_quote_buf_pretty()Garima Singh via GitGitGadget, Oct 7, 2019
  16. 1/1 sq_quote_buf_pretty: don't drop empty argumentsGarima Singh via GitGitGadget, Oct 7, 2019
  17. Junio C HamanoOct 8, 2019
  18. 0/1 quote: handle null and empty strings in sq_quote_buf_pretty()Garima Singh via GitGitGadget, Oct 8, 2019
  19. 1/1 sq_quote_buf_pretty: don't drop empty argumentsGarima Singh via GitGitGadget, Oct 8, 2019

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.