patch-sacc.c - pkgsrc-localpatches - leot's pkgsrc LOCALPATCHES
(HTM) hg clone https://bitbucket.org/iamleot/pkgsrc-localpatches
(DIR) Log
(DIR) Files
(DIR) Refs
---
patch-sacc.c
---
1 $NetBSD$
2
3 According RFC 1436:
4
5 > [...] If there are yet other tab delimited fields, the basic
6 > Gopher client should ignore them. [...]
7
8 In order to do that:
9
10 - Change the behaviour of invaliditem() to consider an item with more than 3
11 tabs valid.
12 - Adjust the 2nd argument of pickfield() as a string of possible separator, if
13 more than 3 tabs are present the separator at the right of the port can also
14 be a `\t', not just a `\r'.
15 - In molditem() ignore any possible extra characters.
16
17 --- sacc.c.orig 2018-02-24 15:24:43.000000000 +0000
18 +++ sacc.c
19 @@ -259,11 +259,11 @@ displaytextitem(Item *item)
20 }
21
22 static char *
23 -pickfield(char **raw, char sep)
24 +pickfield(char **raw, const char *sep)
25 {
26 char *c, *f = *raw;
27
28 - for (c = *raw; *c && *c != sep; ++c)
29 + for (c = *raw; *c && strchr(sep, *c) == NULL; ++c)
30 ;
31
32 *c = '\0';
33 @@ -285,7 +285,7 @@ invaliditem(char *raw)
34 if (c)
35 *raw++ = '\0';
36
37 - return (tabs == 3) ? NULL : raw;
38 + return (tabs >= 3) ? NULL : raw;
39 }
40
41 static void
42 @@ -303,10 +303,12 @@ molditem(Item *item, char **raw)
43 }
44
45 item->type = *raw[0]++;
46 - item->username = pickfield(raw, '\t');
47 - item->selector = pickfield(raw, '\t');
48 - item->host = pickfield(raw, '\t');
49 - item->port = pickfield(raw, '\r');
50 + item->username = pickfield(raw, "\t");
51 + item->selector = pickfield(raw, "\t");
52 + item->host = pickfield(raw, "\t");
53 + item->port = pickfield(raw, "\t\r");
54 + while (*raw[0] != '\0')
55 + ++*raw;
56 if (!*raw[0])
57 ++*raw;
58 }