aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c32
1 files changed, 10 insertions, 22 deletions
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()
751 751
752static void add_clone_urls(void (*fn)(const char *), char *txt, char *suffix) 752static void add_clone_urls(void (*fn)(const char *), char *txt, char *suffix)
753{ 753{
754 struct strbuf buf = STRBUF_INIT; 754 struct strbuf **url_list = strbuf_split_str(txt, ' ', 0);
755 char *h = txt, *t, c; 755 int i;
756 756
757 while (h && *h) { 757 for (i = 0; url_list[i]; i++) {
758 while (h && *h == ' ') 758 strbuf_rtrim(url_list[i]);
759 h++; 759 if (url_list[i]->len == 0)
760 if (!*h) 760 continue;
761 break; 761 if (suffix && *suffix)
762 t = h; 762 strbuf_addf(url_list[i], "/%s", suffix);
763 while (t && *t && *t != ' ') 763 fn(url_list[i]->buf);
764 t++;
765 c = *t;
766 *t = 0;
767
768 if (suffix && *suffix) {
769 strbuf_reset(&buf);
770 strbuf_addf(&buf, "%s/%s", h, suffix);
771 h = buf.buf;
772 }
773 fn(h);
774 *t = c;
775 h = t;
776 } 764 }
777 765
778 strbuf_release(&buf); 766 strbuf_list_free(url_list);
779} 767}
780 768
781void cgit_add_clone_urls(void (*fn)(const char *)) 769void cgit_add_clone_urls(void (*fn)(const char *))