tRemove strsep() usage to get item type - phroxy - Gopher to HTTP proxy
 (HTM) git clone git://git.z3bra.org/phroxy.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 6080677947fba31e72da83dd8a881de1e37daf15
 (DIR) parent b8839df0fea0cf644b2be9a9d9620e525ba39bd3
 (HTM) Author: Willy Goiffon <dev@z3bra.org>
       Date:   Mon, 14 Sep 2020 16:17:08 +0200
       
       Remove strsep() usage to get item type
       
       Using strsep() will overwrite the '/' between item type and path if it
       is present. However, we must request a file in gopher from the root
       directory, so we must keep this leading '/'.
       
       Diffstat:
         M phroxy.c                            |      11 ++++++-----
       
       1 file changed, 6 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/phroxy.c b/phroxy.c
       t@@ -343,7 +343,8 @@ phroxy(char *url)
        {
                int sock;
                size_t len;
       -        char *hole, *item, *path, *host, *port;
       +        char item;
       +        char *hole, *path, *host, *port;
                char *data = NULL, *srch = NULL;
        
                url++;
       t@@ -358,9 +359,9 @@ phroxy(char *url)
                if (!port)
                        port = "70";
        
       -        item = strsep(&url, "/");
       -        if (!item || !item[0] )
       -                item = "1";
       +        item = *url++;
       +        if (!item)
       +                item = '1';
        
                path = strsep(&url, "\0");
                if (!path)
       t@@ -378,7 +379,7 @@ phroxy(char *url)
                if (!data)
                        return 1;
        
       -        serveitem(*item, data, len);
       +        serveitem(item, data, len);
        
                return 0;
        }