home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / programm / utility / diff115.zoo / diff / fixupname.c < prev    next >
C/C++ Source or Header  |  1991-08-29  |  687b  |  33 lines

  1. /* Fix unix pathname for AmigaDOS [":/" --> ":", "/blah" --> ":bla"] */
  2. char *fixupname(name)
  3. char *name;
  4. {
  5.   register char *s, *d;
  6.   char * buffer;
  7.   char *xmalloc();
  8.  
  9.   buffer = xmalloc(256);
  10.   s = name;
  11.   d = buffer;
  12.  
  13.   if (*s == '/') { /* Fix leading slash (root dir) */
  14.     *d++ = ':';
  15.     s++;
  16.   }
  17.   else if (*s == '.') { /* fix leading "./" (Current dir) */
  18.     if (*(s+1L) == '/') { s++; s++; }; /* Leave it out */
  19.   };
  20.  
  21.   /* And now try to handle volume names correctly */
  22.   while ((*s != '\0') && (*s != ':')) *d++ = *s++;
  23.  
  24.   if (*s != '\0') {
  25.     *d++ = *s++; /* copy ":" */
  26.     if (*s == '/') s++;
  27.     while (*s != '\0') *d++ = *s++;
  28.   };
  29.  
  30.   *d = '\0';
  31.   return(buffer);  
  32. }
  33.