[PATCH v4 02/12] ref-filter: use strbuf_split_str_omit_term()
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Jan 31, 2016, 17:42 UTC
- Message-ID
- <1454262176-6594-3-git-send-email-Karthik.188@gmail.com>
- In-Reply-To
- <1454262176-6594-1-git-send-email-Karthik.188@gmail.com>
Use the newly introduced strbuf_split_str_omit_term() rather than using strbuf_split_str() and manually removing the ',' terminator.
Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Karthik Nayak <Karthik.188@gmail.com> --- ref-filter.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/ref-filter.c b/ref-filter.c index f097176..38f38d4 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -892,18 +892,11 @@ static void populate_value(struct ref_array_item *ref) if (!valp) die(_("expected format: %%(align:<width>,<position>)")); - /* - * TODO: Implement a function similar to strbuf_split_str() - * which would omit the separator from the end of each value. - */ - s = to_free = strbuf_split_str(valp, ',', 0); + s = to_free = strbuf_split_str_omit_term(valp, ',', 0); align->position = ALIGN_LEFT; while (*s) { - /* Strip trailing comma */ - if (s[1]) - strbuf_setlen(s[0], s[0]->len - 1); if (!strtoul_ui(s[0]->buf, 10, (unsigned int *)&width)) ; else if (!strcmp(s[0]->buf, "left"))
-- 2.7.0