delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/08/25/10:32:52

Date: Wed, 25 Aug 1999 12:22:15 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Jeff Williams <jeffw AT darwin DOT sfbr DOT org>
cc: djgpp-workers AT delorie DOT com
Subject: Re: patch for djtar.c
In-Reply-To: <199908221639.LAA14728@darwin.sfbr.org>
Message-ID: <Pine.SUN.3.91.990825122115.2834H-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


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