summary refs log tree commit diff
path: root/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/parse.c b/parse.c
index b62ea8a..df416ac 100644
--- a/parse.c
+++ b/parse.c
@@ -10,16 +10,16 @@ int isurlch(char c) {
 }
 
 void parse_plain_url(struct doc *d, struct doc_line *l, size_t i) {
-	char url[l->len + 1];
 	size_t start = i - 1;
 	while (start > 0 && isalpha(l->txt[start])) start--;
 	if (!isalpha(l->txt[start])) start++;
 	size_t end = i + 3;
 	while (end < l->len && isurlch(l->txt[end])) end++;
 	if (end == i + 3) return;
-	size_t urln = end - start;
-	memcpy(url, &l->txt[start], urln);
-	url[urln] = 0;
+	strv_t url = {
+		&l->txt[start],
+		end - start
+	};
 	l->link = doc_add_link(d, url);
 }
 
@@ -75,8 +75,7 @@ int parse_gophermap_line(struct doc *d, strv_t ln) {
 		if (urln < sizeof url) url[urln++] = '/';
 		if (urln < sizeof url) url[urln++] = bits.item_type;
 		urln = scatss(url, urln, sizeof url, bits.sel);
-		url[urln] = 0;
-		doc_set_link(d, doc_add_link(d, url));
+		doc_set_link(d, doc_add_link(d, (strv_t) { url, urln }));
 	case 'i':
 		doc_add_text(d, bits.dstr);
 		doc_new_line(d);