tTidied up use of g_strsplit. - vaccinewars - be a doctor and try to vaccinate the world
 (HTM) git clone git://src.adamsgaard.dk/vaccinewars
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 44e6a55ab0b831534dfadabe338e04b90ec8a7e0
 (DIR) parent 0879e757649f4d5d80f54ba4bf94682ac15f0b07
 (HTM) Author: Ben Webb <ben@salilab.org>
       Date:   Mon, 25 Mar 2002 16:47:39 +0000
       
       Tidied up use of g_strsplit.
       
       
       Diffstat:
         M src/network.c                       |      32 ++++++++++++++++---------------
       
       1 file changed, 17 insertions(+), 15 deletions(-)
       ---
 (DIR) diff --git a/src/network.c b/src/network.c
       t@@ -74,6 +74,20 @@ static gboolean StartConnect(int *fd, gchar *RemoteHost,
                                     unsigned RemotePort, gboolean *doneOK,
                                     LastError **error);
        
       +/*
       + * g_strsplit from GLIB1 behaves differently to GLIB2, so we use this
       + * wrapper function to give the GLIB2 behaviour in all circumstances.
       + */
       +static gchar **my_strsplit(const gchar *string, const gchar *delim,
       +                           gint max_tokens)
       +{
       +#ifdef HAVE_GLIB2
       +  return g_strsplit(string, delim, max_tokens);
       +#else
       +  return g_strsplit(string, delim, max_tokens - 1);
       +#endif
       +}
       +
        #ifdef CYGWIN
        
        void StartNetworking()
       t@@ -1334,11 +1348,7 @@ static void StartHttpAuth(HttpConnection *conn, gboolean proxy,
          if (!conn->authfunc)
            return;
        
       -#ifdef HAVE_GLIB2
       -  split = g_strsplit(header, " ", 2);
       -#else
       -  split = g_strsplit(header, " ", 1);
       -#endif
       +  split = my_strsplit(header, " ", 2);
        
          if (split[0] && split[1] && g_strcasecmp(split[0], "Basic") == 0 &&
              g_strncasecmp(split[1], "realm=", 6) == 0 && strlen(split[1]) > 6) {
       t@@ -1359,11 +1369,7 @@ static void ParseHtmlHeader(gchar *line, HttpConnection *conn,
          gchar **split, *host, *query;
          unsigned port;
        
       -#ifdef HAVE_GLIB2
       -  split = g_strsplit(line, " ", 2);
       -#else
       -  split = g_strsplit(line, " ", 1);
       -#endif
       +  split = my_strsplit(line, " ", 2);
          if (split[0] && split[1]) {
            if (g_strcasecmp(split[0], "Location:") == 0 &&
                (conn->StatusCode == HEC_MOVETEMP
       t@@ -1401,11 +1407,7 @@ gchar *ReadHttpResponse(HttpConnection *conn, gboolean *doneOK)
            switch (conn->Status) {
            case HS_CONNECTING:        /* OK, we should have the HTTP status line */
              conn->Status = HS_READHEADERS;
       -#ifdef HAVE_GLIB2
       -      split = g_strsplit(msg, " ", 3);
       -#else
       -      split = g_strsplit(msg, " ", 2);
       -#endif
       +      split = my_strsplit(msg, " ", 3);
              if (split[0] && split[1]) {
                conn->StatusCode = atoi(split[1]);
              } else {