Re: [PATCH v2 3/7] string-list: unify string_list_split* functions
- From
shejialuo <shejialuo@gmail.com>
- Date
- Aug 1, 2025, 03:00 UTC
- Message-ID
- <aIwtzHdDQPzl56KU@mbp>
- In-Reply-To
- <20250731224607.3942417-4-gitster@pobox.com>
On Thu, Jul 31, 2025 at 03:46:02PM -0700, Junio C Hamano wrote:
[snip]
> +/* > + * append a substring [p..end] to list; return number of things it > + * appended to the list. > + */
In the following function, we would always return 1. So, I guess in the following commits, there would be a case where we won't append the string. And it is, in [PATCH v2 6/7], we would simply skip and return 0.
And I have a design question, should we make "append_one" pure? It would simply attend a string where start is `p` and end is `end`? Let's see in the later patches whether we could do this.
Show 14 quoted lines
> +static int append_one(struct string_list *list,
> + const char *p, const char *end,
> + int in_place)
> +{
> + if (!end)
> + end = p + strlen(p);
> +
> + if (in_place) {
> + *((char *)end) = '\0';
> + string_list_append(list, p);
> + } else {
> + string_list_append_nodup(list, xmemdupz(p, end - p));
> + }
> + return 1;Thanks, Jialuo