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

Re: [PATCH v4 1/7] quote: remove leading space in sq_dequote_step

From
MNMoritz Neeb <lists@moritzneeb.de>
Date
Feb 29, 2016, 21:45 UTC
Message-ID
<56D4BC14.90301@moritzneeb.de>
In-Reply-To
<xmqqy4a39w8b.fsf@gitster.mtv.corp.google.com>
On 02/29/2016 08:01 PM, Junio C Hamano wrote:
Show 39 quoted lines
> Moritz Neeb <lists@moritzneeb.de> writes:
> 
>> Because sq_quote_argv adds a leading space (which is expected in trace.c),
>> sq_dequote_step should remove this space again, such that the operations
>> of quoting and dequoting are inverse of each other.
>>
>> This patch is preparing the way to remove some excessive trimming
>> operation in bisect in the following commit.
>>
>> Signed-off-by: Moritz Neeb <lists@moritzneeb.de>
>> ---
>>  quote.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/quote.c b/quote.c
>> index fe884d2..2714f27 100644
>> --- a/quote.c
>> +++ b/quote.c
>> @@ -63,6 +63,8 @@ static char *sq_dequote_step(char *arg, char **next)
>>  	char *src = arg;
>>  	char c;
>>  
>> +	if (*src == ' ')
>> +		src++;
>>  	if (*src != '\'')
>>  		return NULL;
>>  	for (;;) {
> 
> If we look at this "for (;;)" loop, we notice that (1) it accepts as
> many spaces as there are between two quoted strings, and (2) it does
> not limit it to SP but uses isspace().
> 
> I wonder if you would instead want
> 
> 	while (isspace(*src))
>         	src++;
> 
> to be consistent?
> 

My intention was to explicitly remove the space added by strbuf_addch(dst, ' ') in sq_quote_argv().

I think it would not make sense to remove more spaces, because for for sq_dequote() it is defined:

	This unwraps what sq_quote() produces in place, but returns
	NULL if the input does not look like what sq_quote would have
	produced.
I understand that this counts also for the sq_dequote_array*() family.
Thanks
Previous: Junio C HamanoNext: Moritz Neeb
Message 22 of 38 in “replacing strbuf_getline_lf() by strbuf_getline()”
  1. 0/7 replacing strbuf_getline_lf() by strbuf_getline()Moritz Neeb, Feb 28, 2016
  2. 1/7 quote: remove leading space in sq_dequote_stepMoritz Neeb, Feb 28, 2016
  3. 2/7 bisect: read bisect paths with strbuf_getline()Moritz Neeb, Feb 28, 2016
  4. Eric SunshineFeb 28, 2016
  5. Moritz NeebFeb 28, 2016
  6. 3/7 clean: read user input with strbuf_getline()Moritz Neeb, Feb 28, 2016
  7. Eric SunshineFeb 28, 2016
  8. Moritz NeebFeb 28, 2016
  9. 4/7 notes copy --stdin: split lines with string_list_split()Moritz Neeb, Feb 28, 2016
  10. Eric SunshineFeb 28, 2016
  11. Moritz NeebFeb 28, 2016
  12. Eric SunshineFeb 28, 2016
  13. 5/7 notes copy --stdin: read lines with strbuf_getline()Moritz Neeb, Feb 28, 2016
  14. 6/7 remote: read $GIT_DIR/branches/* with strbuf_getline()Moritz Neeb, Feb 28, 2016
  15. 7/7 wt-status: read rebase todolist with strbuf_getline()Moritz Neeb, Feb 28, 2016
  16. Eric SunshineFeb 28, 2016
  17. Moritz NeebFeb 28, 2016
  18. Moritz NeebFeb 28, 2016
  19. 0/7 replacing strbuf_getline_lf() by strbuf_getline()Moritz Neeb, Feb 29, 2016
  20. 1/7 quote: remove leading space in sq_dequote_stepMoritz Neeb, Feb 29, 2016
  21. Junio C HamanoFeb 29, 2016
  22. Moritz NeebFeb 29, 2016
  23. Moritz NeebFeb 29, 2016
  24. 2/7 bisect: read bisect paths with strbuf_getline()Moritz Neeb, Feb 29, 2016
  25. 3/7 clean: read user input with strbuf_getline()Moritz Neeb, Feb 29, 2016
  26. 5/7 notes copy --stdin: split lines with string_list_split()Moritz Neeb, Feb 29, 2016
  27. 6/7 remote: read $GIT_DIR/branches/* with strbuf_getline()Moritz Neeb, Feb 29, 2016
  28. 7/7 wt-status: read rebase todolist with strbuf_getline()Moritz Neeb, Feb 29, 2016
  29. 4/7 notes copy --stdin: read lines with strbuf_getline()Moritz Neeb, Feb 29, 2016
  30. Eric SunshineFeb 29, 2016
  31. Moritz NeebFeb 29, 2016
  32. Eric SunshineFeb 29, 2016
  33. Eric SunshineFeb 29, 2016
  34. Moritz NeebMar 9, 2016
  35. Junio C HamanoMar 9, 2016
  36. Moritz NeebMar 9, 2016
  37. Junio C HamanoMar 9, 2016
  38. Eric SunshineMar 9, 2016

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.