www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/03/19/10:32:59

From: "Juan Manuel Guerrero" <ST001906 AT HRZ1 DOT HRZ DOT TU-Darmstadt DOT De>
Organization: Darmstadt University of Technology
To: djgpp-workers AT delorie DOT com
Date: Mon, 19 Mar 2001 16:32:04 +0200
MIME-Version: 1.0
Subject: Small bugfix for tar-1.12a
X-mailer: Pegasus Mail for Windows (v2.54DE)
Message-ID: <50F387E4047@HRZ1.hrz.tu-darmstadt.de>
Reply-To: djgpp-workers AT delorie DOT com

I do not know if this is already known but
if tar is invoked as:
  tar -cvf foobar.tar --name-prefix=c:/foo/  z:/bar
both path strings, c:/foo and z:/bar will be concatenated
together like this:
  foo/z:/bar
instead of:
  foo/bar
as it should be. From both path strings, the drive spec
and the leading slash should be removed before concatenating
them . If no name-prefix is given at all the drive spec and
first slash will be removed from
  z:/bar
in the correct way.
The patch below documents/fixes the issue.

Regards,
Guerrero, Juan Manuel


diff -acprNC5 tar-1.12a.orig/src/create.c tar-1.12a/src/create.c
*** tar-1.12a.orig/src/create.c	Sat Mar  7 18:01:42 1998
--- tar-1.12a/src/create.c	Mon Mar 19 16:09:42 2001
*************** start_header (const char *name, struct s
*** 140,149 ****
--- 140,155 ----
    union block *header;
    char *prefixed_name;
  
    if (name_prefix_option)
      {
+ #if DOSWIN
+       /* Remove drive spec and first slash from path name
+          before concatenating prefix and path name. */
+       if (name[0] >= 'A' && name[0] <= 'z' && name[1] == ':')
+         name = (name[2] == '/') ? name + 3 : name + 2;
+ #endif /* DOSWIN */
        prefixed_name = (char *)
  	xmalloc (strlen (name_prefix_option) + strlen (name) + 1);
        strcpy (stpcpy (prefixed_name, name_prefix_option), name);
        name = prefixed_name;
      }

- Raw text -


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