delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/08/22/14:14:34

Message-Id: <199908221639.LAA14728@darwin.sfbr.org>
Date: Sun, 22 Aug 1999 11:39:32 -0500 (CDT)
From: Jeff Williams <jeffw AT darwin DOT sfbr DOT org>
Subject: patch for djtar.c
To: djgpp-workers AT delorie DOT com
Cc: jeffw AT darwin DOT sfbr DOT org
MIME-Version: 1.0
X-Mailer: dtmail 1.3.0 @(#)CDE Version 1.3.4 SunOS 5.7 sun4u sparc
Reply-To: djgpp-workers AT delorie DOT com

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.  I did all my testing on a SFN system; someone with
an LFN setup might want to make a quick check just for completeness.

jtw

*** djtar.c	Thu Jun  3 12:27:41 1999
--- djtar.c.new	Sun Aug 22 11:15:18 1999
***************
*** 99,104 ****
--- 99,105 ----
  
  FILE *change_file;
  
+ int n_changes = 0;
  int v_switch = 0;
  int dot_switch = 1;
  int text_unix = 0;
***************
*** 167,172 ****
--- 168,174 ----
    ch = (CHANGE *)malloc(sizeof(CHANGE));
    if (ch == 0)
      Fatal("Out of memory");
+   n_changes++;
    ch->next = change_root;
    change_root = ch;
    ch->old = strdup(fname);
***************
*** 547,553 ****
      setmode(fileno(stdout), O_TEXT);
      return 0;
    }
!   else
    {
      change_file = fopen("tarchange.lst", "w");
      if (change_file != (FILE *)0)
--- 549,555 ----
      setmode(fileno(stdout), O_TEXT);
      return 0;
    }
!   else if (n_changes)
    {
      change_file = fopen("tarchange.lst", "w");
      if (change_file != (FILE *)0)
***************
*** 559,562 ****
--- 561,566 ----
      else
        return 1;
    }
+   else
+     return 0;
  }


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019