delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/11/28/22:20:06

Date: Mon, 28 Nov 1994 20:49:48 +0100
From: terra AT diku DOT dk
To: dj AT ctron DOT com
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: djtarx and file names with multiple dots

This patch allows djtarx to easily handle file names having
more than one dot in them.

Using the option "-." (dash dot) causes the second and subsequent
dots to be changed to dashes; an initial dot is changed to an
underscore.

This problem arises with tar files created on (e.g.) Unix file
systems.  Such a file might contain "emacs-19.28.90/" which is
invalid under dos.  Changing it into "emacs-19.28-90/" solves
the problem.

Morten Welinder
terra AT diku DOT dk




*** save/djtarx.c	Mon Jun 27 00:08:18 1994
--- djtarx.c	Mon Nov 28 18:57:30 1994
***************
*** 90,93 ****
--- 90,94 ----
  
  int v_switch = 0;
+ int dot_switch = 0;
  
  main(int argc, char **argv)
***************
*** 96,100 ****
    if (argc < 2)
    {
!     fprintf(stderr, "djtarx [-n changeFile] [-v] tarfile . . .\n");
      exit(1);
    }
--- 97,101 ----
    if (argc < 2)
    {
!     fprintf(stderr, "djtarx [-n changeFile] [-v] [-.] tarfile . . .\n");
      exit(1);
    }
***************
*** 110,113 ****
--- 111,117 ----
          v_switch = 1;
          break;
+       case '.':
+         dot_switch = 1;
+         break;
      }
      i++;
***************
*** 118,121 ****
--- 122,126 ----
    dump_changes();
    fclose(change_file);
+   return 0;
  }
  
***************
*** 270,273 ****
--- 275,307 ----
      sscanf(header.otime, "%lo", &ftime);
      changed_name = get_entry(header.name);
+     if (dot_switch)
+       {
+ 	char *p = changed_name;
+ 	int state = 0;
+ 	/* 0 = start of item
+ 	   1 = before dot (not counting initial dot), but not first char
+ 	   2 = after first dot */
+ 
+ 	/* ".gdbinit" -> "_gdbinit"
+ 	   "emacs-19.28.90/ChangeLog" -> "emacs-19.28-90/ChangeLog"
+ 	   */
+ 	while (*p)
+ 	  {
+ 	    switch (*p++)
+ 	      {
+ 	      case '/':
+ 	      case '\\':
+ 		state = 0;
+ 		break;
+ 	      case '.':
+ 		p[-1] = "_.-"[state];
+ 		if (state < 2) state++;
+ 		break;
+ 	      default:
+ 		if (state == 0) state = 1;
+ 	      }
+ 	  }
+       }
+ 
      if (v_switch)
        printf("%08lx %6lo ", posn, perm);
--
-------------------------------------------------------------------------
For information on the free Republic of Macedonia connect to the WWW link
http://ASUdesign.eas.asu.edu/places/Macedonia/republic/
-------------------------------------------Morten Welinder, terra AT diku DOT dk

- Raw text -


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