]> Dogcows Code - chaz/tar/blobdiff - src/names.c
Don't treat attempts to read an already read file list as fatal errors.
[chaz/tar] / src / names.c
index 4710848fa1be4e740630b2bc70da59e102577978..ccd016fa2a0c2a7ecc991ff156455878951317a5 100644 (file)
@@ -291,6 +291,7 @@ name_add_file (const char *name, int term)
   ep->type = NELT_FILE;
   ep->v.file.name = name;
   ep->v.file.term = term;
+  ep->v.file.fp = NULL;
 }
 \f
 /* Names from external name file.  */
@@ -324,7 +325,7 @@ struct file_id_list
 
 static struct file_id_list *file_id_list;
 
-static void
+static int
 add_file_id (const char *filename)
 {
   struct file_id_list *p;
@@ -335,14 +336,16 @@ add_file_id (const char *filename)
   for (p = file_id_list; p; p = p->next)
     if (p->ino == st.st_ino && p->dev == st.st_dev)
       {
-       FATAL_ERROR ((0, 0, _("%s: file list already read"),
-                     quotearg_colon (filename)));
+       ERROR ((0, 0, _("%s: file list already read"),
+               quotearg_colon (filename)));
+       return 1;
       }
   p = xmalloc (sizeof *p);
   p->next = file_id_list;
   p->ino = st.st_ino;
   p->dev = st.st_dev;
   file_id_list = p;
+  return 0;
 }
 \f
 enum read_file_list_state  /* Result of reading file name from the list file */
@@ -402,7 +405,7 @@ handle_option (const char *str)
   if (wordsplit (str, &ws, WRDSF_DEFFLAGS|WRDSF_DOOFFS))
     FATAL_ERROR ((0, 0, _("cannot split string '%s': %s"),
                  str, wordsplit_strerror (&ws)));
-  ws.ws_wordv[0] = "tar";
+  ws.ws_wordv[0] = program_invocation_short_name;
   more_options (ws.ws_wordc+ws.ws_offs, ws.ws_wordv);
   for (i = 0; i < ws.ws_wordc+ws.ws_offs; i++)
     ws.ws_wordv[i] = NULL;
@@ -414,8 +417,6 @@ handle_option (const char *str)
 static int
 read_next_name (struct name_elt *ent, struct name_elt *ret)
 {
-  enum read_file_list_state read_state;
-
   if (!ent->v.file.fp)
     {
       if (!strcmp (ent->v.file.name, "-"))
@@ -425,7 +426,8 @@ read_next_name (struct name_elt *ent, struct name_elt *ret)
        }
       else
        {
-         add_file_id (ent->v.file.name);
+         if (add_file_id (ent->v.file.name))
+           return 1;
          if ((ent->v.file.fp = fopen (ent->v.file.name, "r")) == NULL)
            open_fatal (ent->v.file.name);
        }
@@ -511,15 +513,14 @@ name_next_elt (int change_dirs)
       struct name_elt *ep;
 
       ep = &name_array[scanned];
-      if (ep->type == NELT_FMASK)
+
+      switch (ep->type)
        {
+       case NELT_FMASK:
          matching_flags = ep->v.matching_flags;
          ++scanned;
          continue;
-       }
-
-      switch (ep->type)
-       {
+         
        case NELT_FILE:
          if (read_next_name (ep, &entry) == 0)
            return &entry;
This page took 0.027652 seconds and 4 git commands to generate.