Mail Archives: djgpp-workers/1999/08/25/10:32:52
On Sun, 22 Aug 1999, Jeff Williams wrote:
> Attached below is my patch for djtar.c (made against the latest CVS
> version: 12662 Jun 3 12:27 djtar.c), to prevent an empty `tarchange.lst'
> file from being left behind if no name changes are made during file
> extraction.
>
> I added a counter (`n_changes') and increment it every time a new
> change entry is requested. At the end, a change file is written only
> if n_changes > 0.
Thanks!
However, there's no need to introduce a special variable, since DJTAR
already knows whether it did any file-name changes. Here's a change
that I checked in today:
*** src/utils/djtar/djtar.c~0 Thu Jun 3 20:27:42 1999
--- src/utils/djtar/djtar.c Tue Aug 24 16:03:00 1999
*************** typedef struct CHANGE {
*** 123,128 ****
--- 123,134 ----
CHANGE *change_root = 0;
+ static int
+ any_changes_done(void)
+ {
+ return change_root != NULL;
+ }
+
static void
dump_changes(void)
{
*************** main(int argc, char **argv)
*** 547,562 ****
setmode(fileno(stdout), O_TEXT);
return 0;
}
! else
{
change_file = fopen("tarchange.lst", "w");
if (change_file != (FILE *)0)
{
dump_changes();
fclose(change_file);
- return 0;
}
else
return 1;
}
}
--- 553,568 ----
setmode(fileno(stdout), O_TEXT);
return 0;
}
! else if (any_changes_done())
{
change_file = fopen("tarchange.lst", "w");
if (change_file != (FILE *)0)
{
dump_changes();
fclose(change_file);
}
else
return 1;
}
+ return 0;
}
- Raw text -