s3-clitar: Improve readabilty of fix_unix_path().
authorAndreas Schneider <asn@samba.org>
Mon, 17 Feb 2014 10:32:14 +0000 (11:32 +0100)
committerAndreas Schneider <asn@samba.org>
Wed, 19 Feb 2014 17:22:30 +0000 (18:22 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
source3/client/clitar.c

index 8dd69d34335c885b46d9a838f79fb33ebad814c3..bad7eac4ad85a79efd74df20fc5fb7cc3ab4896f 100644 (file)
@@ -1662,39 +1662,42 @@ static int max_token (const char *str)
  * @path: path to convert
  * @removeprefix: if true, remove leading ./ or /.
  */
-static char *fix_unix_path (char *path, bool removeprefix)
+static char *fix_unix_path (char *path, bool do_remove_prefix)
 {
     char *from = path, *to = path;
 
-    if (!path || !*path)
+    if (path == NULL || path[0] == '\0') {
         return path;
+    }
 
     /* remove prefix:
      * ./path => path
      *  /path => path
      */
-    if (removeprefix) {
+    if (do_remove_prefix) {
         /* /path */
         if (path[0] == '/' || path[0] == '\\') {
             from += 1;
         }
 
         /* ./path */
-        if (path[1] && path[0] == '.' && (path[1] == '/' || path[1] == '\\')) {
+        if (path[1] != '\0' && path[0] == '.' && (path[1] == '/' || path[1] == '\\')) {
             from += 2;
         }
     }
 
     /* replace / with \ */
-    while (*from) {
-        if (*from == '/') {
-            *to = '\\';
+    while (from[0] != '\0') {
+        if (from[0] == '/') {
+            to[0] = '\\';
         } else {
-            *to = *from;
+            to[0] = from[0];
         }
-        from++; to++;
+
+        from++;
+        to++;
     }
-    *to = 0;
+    to[0] = '\0';
 
     return path;
 }