Re: [PATCH v2 2/2] [GSOC] ref-filter: add %(raw) atom
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 1, 2021, 09:54 UTC
- Message-ID
- <xmqqa6o9ucyc.fsf@gitster.g>
- In-Reply-To
- <CAOLTT8REM7tF6ojdmnsJt7-RE6a8oX4RFXVcL215YnYTx6b62w@mail.gmail.com>
ZheNing Hu <adlternative@gmail.com> writes:
Show 6 quoted lines
>> ... because the host language may not support a NUL in the variables >> of its string type. >> > > I agree. But host language not only support NUL but also some Non-ASCII > character and Non-UTF-8 code:
Yup, rephase with "a NUL" with "arbitrary binary data" and you got what I meant. Thanks.
Show 12 quoted lines
>> > + const char *s = buf->buf;
>> > + size_t cur_len = 0;
>> > +
>> > + while ((cur_len != buf->len) && (isspace(*s) || *s == '\0')) {
>> > s++;
>> > + cur_len++;
>>
>> Is NUL treated the same as a whitespace letter for the purpose of
>> determining if a line is empty? WHY?
>
> Well, there seems to be no correction here. But is it true that memory
> like "\0abc" is considered empty?That sample has 'a' or 'b' or 'c' that are clearly not part of an "empty" string and irrelevant. After all, a string " abc" is not treated as empty in the original implementation, either.
You are treating a block of memory with e.g. " \000 " (SP NUL SP) as an "empty line" just like you do for " " (SP SP SP), but I think we should treat it more like " \001 " or " \007 ", i.e. not an empty string at all.