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);