]> Sergey Matveev's repositories - nnn.git/commitdiff
Code reduction
authorArun Prakash Jana <engineerarun@gmail.com>
Wed, 22 Jul 2020 14:49:38 +0000 (20:19 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Wed, 22 Jul 2020 14:49:38 +0000 (20:19 +0530)
src/nnn.c

index 567eb92add98de9ac0e2d090be45461e8e225ef7..dbcd7a3eace1ad33db6fab0e6ff499074056ddc5 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -4017,17 +4017,10 @@ static bool remote_mount(char *newpath)
                return FALSE;
        }
 
-       /* Convert "Host" to "Host:" */
-       size_t len = xstrlen(tmp);
-       bool path = FALSE;
-
-       for (size_t count = 0; count < len; ++count)
-               if (tmp[count] == ':') {
-                       tmp[count] = '\0';
-                       len = count;
-                       path = TRUE;
-                       break;
-               }
+       char *div = strchr(tmp, ':');
+
+       if (div)
+               *div = '\0';
 
        /* Create the mount point */
        mkpath(cfgpath, toks[TOK_MNT], mntpath);
@@ -4037,10 +4030,12 @@ static bool remote_mount(char *newpath)
                return FALSE;
        }
 
-       tmp[len] = ':';
-
-       if (!path) /* Append ':' at the end */
+       if (!div) { /* Convert "host" to "host:" */
+               size_t len = xstrlen(tmp);
+               tmp[len] = ':';
                tmp[len + 1] = '\0';
+       } else
+               *div = ':';
 
        /* Connect to remote */
        if (opt == 's') {