From 1a9e56607eae2df2f4522b41294d94cb09fc4e5c Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Thu, 5 Feb 2015 10:11:42 +0100 Subject: ui-shared.c: Refactor add_clone_urls() Make use of strbuf_split_str() and strbuf lists to split clone URLs. Signed-off-by: Lukas Fleischer --- ui-shared.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'ui-shared.c') diff --git a/ui-shared.c b/ui-shared.c index d8cc4d7..1a84afc 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -751,31 +751,19 @@ void cgit_print_docend() static void add_clone_urls(void (*fn)(const char *), char *txt, char *suffix) { - struct strbuf buf = STRBUF_INIT; - char *h = txt, *t, c; + struct strbuf **url_list = strbuf_split_str(txt, ' ', 0); + int i; - while (h && *h) { - while (h && *h == ' ') - h++; - if (!*h) - break; - t = h; - while (t && *t && *t != ' ') - t++; - c = *t; - *t = 0; - - if (suffix && *suffix) { - strbuf_reset(&buf); - strbuf_addf(&buf, "%s/%s", h, suffix); - h = buf.buf; - } - fn(h); - *t = c; - h = t; + for (i = 0; url_list[i]; i++) { + strbuf_rtrim(url_list[i]); + if (url_list[i]->len == 0) + continue; + if (suffix && *suffix) + strbuf_addf(url_list[i], "/%s", suffix); + fn(url_list[i]->buf); } - strbuf_release(&buf); + strbuf_list_free(url_list); } void cgit_add_clone_urls(void (*fn)(const char *)) -- cgit 1.4.1 325d3914e75bd079ad8df31ca4f39197519386&follow=1'>commit diff
Commit message (Expand)Author
2020-02-11Support monochromatic terminalsJune McEnroe
2020-02-11Add .gz to chroot-man scriptJune McEnroe
2020-02-11Add -R restricted flagJune McEnroe
2020-02-11Add chroot targetJune McEnroe
2020-02-11Exit focus and paste modes on err exitJune McEnroe
2020-02-11Add startup GPLv3 note and URLJune McEnroe
2020-02-11Make sure -D_GNU_SOURCE ends up in CFLAGS on LinuxJune McEnroe
2020-02-11Add note about setting PKG_CONFIG_PATHJune McEnroe
2020-02-11Rename query ID on nick changeJune McEnroe
2020-02-11Call completeClear when closing a windowJune McEnroe
2020-02-11Don't insert color codes for non-mentionsJune McEnroe
2020-02-11Take first two words in colorMentionsJune McEnroe
2020-02-11Use time_t for save signatureJune McEnroe
2020-02-11Set self.nick to * initiallyJune McEnroe
2020-02-11Define ColorCap instead of hardcoding 100June McEnroe
2020-02-11Move hash to top of chat.hJune McEnroe
2020-02-11Move base64 out of chat.hJune McEnroe
2020-02-11Move XDG_SUBDIR out of chat.hJune McEnroe
2020-02-11Fix whois idle unit calculationJune McEnroe
2020-02-11Cast towupper to wchar_tJune McEnroe
2020-02-11Cast set but unused variables to voidJune McEnroe
2020-02-11Declare strlcatJune McEnroe
2020-02-11Check if VDSUSP existsJune McEnroe
2020-02-11Fix completeReplace iterationJune McEnroe
2020-02-11Use pkg(8) to configure on FreeBSDJune McEnroe
2020-02-11Remove legacy codeJune McEnroe
2020-02-11Add INSTALLING section to READMEJune McEnroe