From: Sergey Poznyakoff Date: Fri, 16 Aug 2013 12:17:22 +0000 (+0300) Subject: Don't treat attempts to read an already read file list as fatal errors. X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Ftar;a=commitdiff_plain;h=077d7bceff9f28209972325097509d7ae775c1f0 Don't treat attempts to read an already read file list as fatal errors. * src/names.c (add_file_id): Report error and return 1 if the file has already been read. (read_next_name): Don't try to open file if add_file_id returns 1. (name_next_elt): Simplify conditional. --- diff --git a/src/names.c b/src/names.c index e3fbf7b..ccd016f 100644 --- a/src/names.c +++ b/src/names.c @@ -325,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; @@ -336,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; } enum read_file_list_state /* Result of reading file name from the list file */ @@ -424,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); }