mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Documented __strip_double_slash() and plugged in a memmove()
in place of the copying loop. - Modified __translate_unix_to_amiga_path_name() and __translate_amiga_to_unix_path_name() to not to call strlen() on the results of __strip_double_slash(). git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14951 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -15,6 +15,13 @@
|
||||
|
||||
- Added %D, %e, %F, %g, %G and %h for strftime(); repaired %I.
|
||||
|
||||
- Documented __strip_double_slash() and plugged in a memmove()
|
||||
in place of the copying loop.
|
||||
|
||||
- Modified __translate_unix_to_amiga_path_name() and
|
||||
__translate_amiga_to_unix_path_name() to not to call strlen()
|
||||
on the results of __strip_double_slash().
|
||||
|
||||
|
||||
c.lib 1.192 (12.5.2005)
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd_headers.h,v 1.7 2005-03-18 12:38:25 obarthel Exp $
|
||||
* $Id: unistd_headers.h,v 1.8 2005-05-15 12:32:58 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -90,7 +90,7 @@ extern BOOL NOCOMMON __unix_path_semantics;
|
||||
/****************************************************************************/
|
||||
|
||||
extern int __set_current_path(const char * path_name);
|
||||
extern void __strip_double_slash(char * file_name,int len);
|
||||
extern int __strip_double_slash(char * file_name,int len);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd_strip_double_slash.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $
|
||||
* $Id: unistd_strip_double_slash.c,v 1.3 2005-05-15 12:32:59 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -40,48 +40,56 @@
|
||||
/* Remove '//' from an AmigaDOS path name. For example, "volume:one/two//three"
|
||||
is equivalent to "volume:one/three" and the following function removes the
|
||||
redundant part of the path. */
|
||||
void
|
||||
int
|
||||
__strip_double_slash(char * file_name,int len)
|
||||
{
|
||||
int start,delta,position,i;
|
||||
|
||||
assert( file_name != NULL && len > 0 );
|
||||
int position;
|
||||
|
||||
position = len;
|
||||
|
||||
while(len > 1)
|
||||
{
|
||||
position--;
|
||||
|
||||
/* Stop when we hit the volume name or the first character of the name. */
|
||||
if((position == 0) || (file_name[position] == ':') || (file_name[position - 1] == ':'))
|
||||
break;
|
||||
|
||||
if((position > 1) && (file_name[position] == '/') && (file_name[position - 1] == '/') && (file_name[position - 2] != ':') && (file_name[position - 2] != '/'))
|
||||
/* Do we have a // embedded in the file_name? That // must stand alone
|
||||
between directory names and not in front of a volume name or
|
||||
yet another /. */
|
||||
if((position > 1) && (file_name[position] == '/' && file_name[position - 1] == '/') && (file_name[position - 2] != ':' && file_name[position - 2] != '/'))
|
||||
{
|
||||
int start,delta;
|
||||
|
||||
start = position;
|
||||
|
||||
/* Back up behind the //. */
|
||||
position -= 2;
|
||||
|
||||
/* Find the spot where the previous directory or volume
|
||||
name begins. */
|
||||
while((position > 0) && (file_name[position] != ':') && (file_name[position] != '/'))
|
||||
position--;
|
||||
|
||||
/* Don't move too far. */
|
||||
if((file_name[position] == ':') || (file_name[position] == '/'))
|
||||
position++;
|
||||
|
||||
i = position;
|
||||
delta = start - position + 1;
|
||||
/* Find out how long the directory name is that
|
||||
we are going to remove now. */
|
||||
delta = start - position + 1;
|
||||
|
||||
/* Remove the file_name part; we copy one more byte than
|
||||
necessary to account for the NUL at the end. */
|
||||
len -= delta;
|
||||
|
||||
while(i < len)
|
||||
{
|
||||
file_name[i] = file_name[i + delta];
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
file_name[len] = '\0';
|
||||
memmove(&file_name[position],&file_name[position + delta],len - position + 1);
|
||||
|
||||
/* The string is shorter, and here we go again... */
|
||||
position = len;
|
||||
}
|
||||
}
|
||||
|
||||
return(len);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd_translatea2u.c,v 1.5 2005-04-24 08:46:37 obarthel Exp $
|
||||
* $Id: unistd_translatea2u.c,v 1.6 2005-05-15 12:32:59 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -89,9 +89,7 @@ __translate_amiga_to_unix_path_name(char const ** name_ptr,struct name_translati
|
||||
strcpy(local_replacement,name);
|
||||
name = local_replacement;
|
||||
|
||||
__strip_double_slash(name,len);
|
||||
|
||||
len = strlen(name);
|
||||
len = __strip_double_slash(name,len);
|
||||
}
|
||||
|
||||
/* The empty string corresponds to the current
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd_translateu2a.c,v 1.8 2005-04-24 08:46:37 obarthel Exp $
|
||||
* $Id: unistd_translateu2a.c,v 1.9 2005-05-15 12:32:59 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -524,8 +524,7 @@ __translate_unix_to_amiga_path_name(char const ** name_ptr,struct name_translati
|
||||
name = replace;
|
||||
}
|
||||
|
||||
__strip_double_slash(name,len);
|
||||
len = strlen(name);
|
||||
len = __strip_double_slash(name,len);
|
||||
|
||||
D(("name = '%s' (line %ld)",name,__LINE__));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user