www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2011/02/19/16:40:04

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
X-Authenticated: #27081556
X-Provags-ID: V01U2FsdGVkX1/UzRFcZyvUnQmeYE6au7p8FzkhNS7Q9u1bmw3gfD
AS12L+d5zjN6z4
From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
To: djgpp-workers AT delorie DOT com
Subject: djtar fails if empty line in fnchange.lst
Date: Sat, 19 Feb 2011 22:13:52 +0100
User-Agent: KMail/1.9.10
MIME-Version: 1.0
Message-Id: <201102192213.52351.juan.guerrero@gmx.de>
X-Y-GMX-Trusted: 0
Reply-To: djgpp-workers AT delorie DOT com

Using djtar I observed that if a filename change file contains an empty line
the extraction of the file named in the previous line is skipped.  E.g.:

  /dir/foobar1.txt  /dir/fb1.txt

  /dir/foobar2.txt  /dir/fb2.txt
  /dir/foobar3.txt  /dir/fb3.txt

in this case the file foobar1.txt would not be extracted as fb1.txt but
its extraction simply skipped.  If the empty line between foobar1.txt and
foobar2.txt is removed all 3 files will be extracted and renamed according
to the specification given above.  I assume that this behaviour is not
intentional.  Any objections if the changes are commited.

Regards,
Juan M. Guerrero




diff -aprNU5 djgpp.orig/src/docs/kb/wc204.txi djgpp/src/docs/kb/wc204.txi
--- djgpp.orig/src/docs/kb/wc204.txi	2010-06-08 02:04:12 +0000
+++ djgpp/src/docs/kb/wc204.txi	2011-02-19 21:36:42 +0000
@@ -1193,5 +1193,10 @@ with other C compilers.
 @findex realpath AT r{, and POSIX.1-2008 compliance}
 If the pointer that shall point to the buffer that shall contain the resolved
 path is a @code{NULL} pointer, then @code{realpath} will call @code{malloc} to allocate
 a buffer of @code{PATH_MAX} bytes to store the resolved path name and return this
 pointer to the caller.
+
+@pindex djtar AT r{, and empty lines in the filename change file}
+@code{djtar} now ignores empty lines in filename change files instead
+of skipping the extraction of the file named in the line before the
+empty line.
diff -aprNU5 djgpp.orig/src/utils/djtar/djtar.c djgpp/src/utils/djtar/djtar.c
--- djgpp.orig/src/utils/djtar/djtar.c	2011-02-17 11:32:32 +0000
+++ djgpp/src/utils/djtar/djtar.c	2011-02-19 21:28:16 +0000
@@ -101,31 +101,34 @@ static void
 DoNameChanges(char *fname)
 {
   struct skip_dir_list * new_entry; 
   FILE *f = fopen(fname, "r");
   char from[PATH_MAX], to[PATH_MAX];
-  char line[PATH_MAX*2 + 10];
+  char line[PATH_MAX * 2 + 10];
   if (f == 0)
   {
     perror(fname);
     exit(1);
   }
   while (1)
   {
     fgets(line, sizeof(line), f);
     if (feof(f))
       break;
-    to[0] = 0;
+    from[0] = to[0] = 0;
     sscanf(line, "%s %s", from, to);
-    if (to[0])
-      store_entry(from, to);
-    else
+    if (from[0])
     {
-      new_entry = xmalloc(sizeof(struct skip_dir_list));
-      new_entry->skip_dir = xstrdup(from);
-      new_entry->next = skip_dirs;
-      skip_dirs = new_entry;
+      if (to[0])
+        store_entry(from, to);
+      else
+      {
+        new_entry = xmalloc(sizeof(struct skip_dir_list));
+        new_entry->skip_dir = xstrdup(from);
+        new_entry->next = skip_dirs;
+        skip_dirs = new_entry;
+      }
     }
   }
   fclose(f);
 }
 

- Raw text -


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