((unsigned char) (Char) >= '0' && (unsigned char) (Char) <= '7')
#define ISSPACE(Char) (ISASCII (Char) && isspace (Char))
+#ifndef FNM_LEADING_DIR
+# include <fnmatch.h>
+#endif
+
#include "common.h"
union block *current_header; /* points to current archive header */
/* Valid header. We should decode next field (mode) first.
Ensure incoming names are null terminated. */
+ if (ending_file_option &&
+ fnmatch (ending_file_option, current_file_name,
+ FNM_LEADING_DIR) == 0) {
+ goto all_done;
+ }
+
/* FIXME: This is a quick kludge before 1.12 goes out. */
current_stat.st_mtime = TIME_FROM_OCT (current_header->header.mtime);
}
break;
}
+ all_done: ;
apply_delayed_set_stat ();
close_archive ();
}
else
{
- assign_string (¤t_file_name,
- (next_long_name ? next_long_name
- : current_header->header.name));
+ char *name = next_long_name;
+ struct posix_header *h = ¤t_header->header;
+ char namebuf[sizeof h->prefix + 1 + sizeof h->name + 1];
+
+ if (! name)
+ {
+ /* Accept file names as specified by POSIX.1-1996
+ section 10.1.1. */
+ char *np = namebuf;
+ if (h->prefix[0])
+ {
+ memcpy (np, h->prefix, sizeof h->prefix);
+ np[sizeof h->prefix] = '\0';
+ np += strlen (np);
+ *np++ = '/';
+ }
+ memcpy (np, h->name, sizeof h->name);
+ np[sizeof h->name] = '\0';
+ name = namebuf;
+ }
+
+ assign_string (¤t_file_name, name);
assign_string (¤t_link_name,
(next_long_link ? next_long_link
: current_header->header.linkname));