]> Dogcows Code - chaz/tar/blobdiff - src/names.c
(write_directory_file): Use sys_truncate
[chaz/tar] / src / names.c
index 5fdc43321a2eed92af7b445fb12d005def7b1d31..5cb1aa544a8588d20f12e75ea4c53e0eb330baba 100644 (file)
@@ -20,9 +20,7 @@
 #include "system.h"
 
 #include <fnmatch.h>
-#include <grp.h>
 #include <hash.h>
-#include <pwd.h>
 #include <quotearg.h>
 
 #include "common.h"
@@ -610,9 +608,11 @@ bool
 all_names_found (struct tar_stat_info *p)
 {
   struct name const *cursor;
-  size_t len = strlen (p->file_name);
-  if (occurrence_option == 0 || p->had_trailing_slash)
+  size_t len;
+
+  if (!p->file_name || occurrence_option == 0 || p->had_trailing_slash)
     return false;
+  len = strlen (p->file_name);
   for (cursor = namelist; cursor; cursor = cursor->next)
     {
       if (cursor->regexp
@@ -833,10 +833,7 @@ collect_and_sort_names (void)
 
       if (deref_stat (dereference_option, name->name, &statbuf) != 0)
        {
-         if (ignore_failed_read_option)
-           stat_warn (name->name);
-         else
-           stat_error (name->name);
+         stat_diag (name->name);
          continue;
        }
       if (S_ISDIR (statbuf.st_mode))
@@ -1024,9 +1021,14 @@ safer_name_suffix (char const *file_name, bool link_target)
 
       for (p = file_name + prefix_len; *p; )
        {
-         if (p[0] == '.' && p[1] == '.' && (ISSLASH (p[2]) || !p[2]))
-           prefix_len = p + 2 - file_name;
-
+         if (p[0] == '.')
+           {
+             if (p[1] == '.' && (ISSLASH (p[2]) || !p[2]))
+               prefix_len = p + 2 - file_name;
+             else if (ISSLASH (p[1]))
+               prefix_len = p + 1 - file_name;
+           }
+         
          do
            {
              char c = *p++;
@@ -1071,7 +1073,7 @@ safer_name_suffix (char const *file_name, bool link_target)
          WARN ((0, 0, _(diagnostic[link_target])));
        }
 
-      p = ".";
+      p = ISSLASH (file_name[strlen(file_name)-1]) ? "./" : ".";
     }
 
   return (char *) p;
This page took 0.025324 seconds and 4 git commands to generate.