sfeed_gopher: add some comments and simplify printing non-gopher URLs - sfeed - RSS and Atom parser
 (HTM) git clone git://git.codemadness.org/sfeed
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 558184631531ba033e2dc17ca928ca4d9beebb66
 (DIR) parent 416c898b677fbf56161623ca1eab6fed6e614a4a
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sun, 21 Sep 2025 14:29:01 +0200
       
       sfeed_gopher: add some comments and simplify printing non-gopher URLs
       
       If the item link is not a gopher:// URL then just use the text from sfeed(5)
       FeedLink field (do not format the parsed version).
       
       Diffstat:
         M sfeed_gopher.c                      |      27 ++++++++++++++++-----------
       
       1 file changed, 16 insertions(+), 11 deletions(-)
       ---
 (DIR) diff --git a/sfeed_gopher.c b/sfeed_gopher.c
       @@ -66,11 +66,11 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f)
                                    uri_parse(fields[FieldLink], &u) != -1) {
                                        itemhost = u.host;
                                        itemport = u.port[0] ? u.port : "70";
       -                                itemtype = '1';
       +                                itemtype = '1'; /* directory */
                                        itempath = u.path;
                                        itemquery = u.query;
                                        itemfragment = u.fragment;
       -
       +                                /* use the gopher type from the path if it is set */
                                        if (itempath[0] == '/') {
                                                itempath++;
                                                if (*itempath) {
       @@ -99,16 +99,21 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f)
        
                        gophertext(fpitems, fields[FieldTitle]);
                        fputs("\t", fpitems);
       -                if (itemtype == 'h' && fields[FieldLink] == itempath)
       +                /* Prefix non-gopher URLs with "URL:" using the h type.
       +                   This gopher extension is commonly used to link to external URLs */
       +                if (itemtype == 'h' && fields[FieldLink] == itempath) {
                                fputs("URL:", fpitems);
       -                gophertext(fpitems, itempath);
       -                if (itemquery[0]) {
       -                        fputs("?", fpitems);
       -                        gophertext(fpitems, itemquery);
       -                }
       -                if (itemfragment[0]) {
       -                        fputs("#", fpitems);
       -                        gophertext(fpitems, itemfragment);
       +                        gophertext(fpitems, fields[FieldLink]);
       +                } else {
       +                        gophertext(fpitems, itempath);
       +                        if (itemquery[0]) {
       +                                fputs("?", fpitems);
       +                                gophertext(fpitems, itemquery);
       +                        }
       +                        if (itemfragment[0]) {
       +                                fputs("#", fpitems);
       +                                gophertext(fpitems, itemfragment);
       +                        }
                        }
                        fprintf(fpitems, "\t%s\t%s\r\n", itemhost, itemport);
                }