X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Flist.c;h=2cf3c1000aae33f9f09aec7f7629466275a99b12;hb=1fef6258aa492f84ea63c1eea3e1e0e9c40c81bb;hp=59374ff8cbaf6fdb4943511f49e20ea0abdf01b5;hpb=f29b54b2377e4c5eee21863bc58a183f077217d7;p=chaz%2Ftar diff --git a/src/list.c b/src/list.c index 59374ff..2cf3c10 100644 --- a/src/list.c +++ b/src/list.c @@ -903,6 +903,8 @@ print_header (off_t block_ordinal) { char modes[11]; char const *time_stamp; + char *temp_name; + /* These hold formatted ints. */ char uform[UINTMAX_STRSIZE_BOUND], gform[UINTMAX_STRSIZE_BOUND]; char *user, *group; @@ -922,10 +924,22 @@ print_header (off_t block_ordinal) STRINGIFY_BIGINT (block_ordinal, buf)); } + if (current_trailing_slash) + { + temp_name = xmalloc (strlen (current_file_name) + 2); + strcpy (temp_name, current_file_name); + strcat (temp_name, "/"); + } + else + { + temp_name = xmalloc (strlen (current_file_name) + 1); + strcpy (temp_name, current_file_name); + } + if (verbose_option <= 1) { /* Just the fax, mam. */ - fprintf (stdlis, "%s\n", quotearg (current_file_name)); + fprintf (stdlis, "%s\n", quotearg (temp_name)); } else { @@ -956,7 +970,7 @@ print_header (off_t block_ordinal) case REGTYPE: case AREGTYPE: modes[0] = '-'; - if (current_file_name[strlen (current_file_name) - 1] == '/') + if (temp_name[strlen (temp_name) - 1] == '/') modes[0] = 'd'; break; case LNKTYPE: @@ -1070,7 +1084,7 @@ print_header (off_t block_ordinal) fprintf (stdlis, "%s %s/%s %*s%s %s", modes, user, group, ugswidth - pad, "", size, time_stamp); - fprintf (stdlis, " %s", quotearg (current_file_name)); + fprintf (stdlis, " %s", quotearg (temp_name)); switch (current_header->header.typeflag) { @@ -1129,6 +1143,7 @@ print_header (off_t block_ordinal) break; } } + free (temp_name); fflush (stdlis); }