]> Dogcows Code - chaz/tar/blobdiff - src/names.c
(names_done): New function.
[chaz/tar] / src / names.c
index ee68749bb921be22ce3b13bcfeb3a4e8be8be205..41d3476ec6cb05428c5e719e4edfe9155cbd5638 100644 (file)
@@ -595,6 +595,17 @@ name_match (const char *path)
     }
 }
 
+/* Returns true if all names from the namelist were processed */
+bool
+names_done ()
+{
+  struct name const *cursor;
+  for (cursor = namelist; cursor; cursor = cursor->next)
+    if (!cursor->found && !cursor->fake)
+      return false;
+  return true;
+}
+
 /* Print the names of things in the namelist that were not matched.  */
 void
 names_notfound (void)
@@ -1043,21 +1054,29 @@ safer_name_suffix (char const *file_name, bool link_target)
   return (char *) p;
 }
 \f
-char const *
-cut_path_elements (char const *file_name, size_t num)
+/* Return the size of the prefix of FILE_NAME that is removed after
+   stripping NUM leading path name components.  NUM must be
+   positive.  */
+
+size_t
+stripped_prefix_len (char const *file_name, size_t num)
 {
-  char const *p = file_name;
-  if (ISSLASH (*p))
+  char const *p = file_name + FILESYSTEM_PREFIX_LEN (file_name);
+  while (ISSLASH (*p))
     p++;
-  for (; *p; p++)
+  while (*p)
     {
-      if (ISSLASH (*p))
+      bool slash = ISSLASH (*p);
+      p++;
+      if (slash)
        {
          if (--num == 0)
-           return p + 1;
+           return p - file_name;
+         while (ISSLASH (*p))
+           p++;
        }
     }
-  return NULL;
+  return -1;
 }
 \f
 /* Return nonzero if NAME contains ".." as a path name component.  */
This page took 0.022744 seconds and 4 git commands to generate.