mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Moved the slash translation code around a bit more. Now ".//" comes out as
"" rather than ":". git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14832 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: unistd_translateu2a.c,v 1.4 2005-02-15 17:27:22 obarthel Exp $
|
* $Id: unistd_translateu2a.c,v 1.5 2005-02-16 14:48:17 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -111,6 +111,7 @@ __translate_unix_to_amiga_path_name(char const ** name_ptr,struct name_translati
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If the name was replaced, update the string length cached. */
|
||||||
if(name != (*name_ptr))
|
if(name != (*name_ptr))
|
||||||
{
|
{
|
||||||
D(("name after relative path replacement = '%s'",name));
|
D(("name after relative path replacement = '%s'",name));
|
||||||
@@ -118,30 +119,6 @@ __translate_unix_to_amiga_path_name(char const ** name_ptr,struct name_translati
|
|||||||
len = strlen(name);
|
len = strlen(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there are any, strip the trailing slashes ('foo/' -> 'foo'). A
|
|
||||||
leading '/' must be preserved, though ('///' -> '/'). */
|
|
||||||
if(len > 1)
|
|
||||||
{
|
|
||||||
size_t num_trailing_slashes = 0;
|
|
||||||
|
|
||||||
while((num_trailing_slashes < len - 1) && (name[len - (num_trailing_slashes + 1)] == '/'))
|
|
||||||
num_trailing_slashes++;
|
|
||||||
|
|
||||||
if(num_trailing_slashes > 0)
|
|
||||||
{
|
|
||||||
len -= num_trailing_slashes;
|
|
||||||
|
|
||||||
if(name != replace)
|
|
||||||
{
|
|
||||||
memmove(replace,name,len);
|
|
||||||
name = replace;
|
|
||||||
}
|
|
||||||
|
|
||||||
name[len] = '\0';
|
|
||||||
D(("name = '%s' (line %ld)",name,__LINE__));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If there are neighboring slashes, strip all but one
|
/* If there are neighboring slashes, strip all but one
|
||||||
('foo//bar' -> 'foo/bar'). The "//" pattern in a Unix
|
('foo//bar' -> 'foo/bar'). The "//" pattern in a Unix
|
||||||
file name is apparently harmless, but on AmigaDOS it
|
file name is apparently harmless, but on AmigaDOS it
|
||||||
@@ -194,15 +171,35 @@ __translate_unix_to_amiga_path_name(char const ** name_ptr,struct name_translati
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ditch all leading './' ('./foo' -> 'foo'). */
|
/* If there are any, strip the trailing slashes ('foo/' -> 'foo'). A
|
||||||
if(len >= 2 && strncmp(name,"./",2) == SAME)
|
leading '/' must be preserved, though ('///' -> '/'). */
|
||||||
|
if(len > 1)
|
||||||
{
|
{
|
||||||
do
|
size_t num_trailing_slashes = 0;
|
||||||
|
|
||||||
|
while((num_trailing_slashes < len - 1) && (name[len - (num_trailing_slashes + 1)] == '/'))
|
||||||
|
num_trailing_slashes++;
|
||||||
|
|
||||||
|
if(num_trailing_slashes > 0)
|
||||||
|
{
|
||||||
|
len -= num_trailing_slashes;
|
||||||
|
|
||||||
|
if(name != replace)
|
||||||
|
{
|
||||||
|
memmove(replace,name,len);
|
||||||
|
name = replace;
|
||||||
|
}
|
||||||
|
|
||||||
|
name[len] = '\0';
|
||||||
|
D(("name = '%s' (line %ld)",name,__LINE__));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ditch all leading './' ('./foo' -> 'foo'). */
|
||||||
|
while(len > 2 && name[0] == '.' && name[1] == '/')
|
||||||
{
|
{
|
||||||
name += 2;
|
name += 2;
|
||||||
len -= 2;
|
len -= 2;
|
||||||
}
|
|
||||||
while(len >= 2 && name[0] == '.' && name[1] == '/');
|
|
||||||
|
|
||||||
D(("name = '%s' (line %ld)",name,__LINE__));
|
D(("name = '%s' (line %ld)",name,__LINE__));
|
||||||
}
|
}
|
||||||
@@ -277,9 +274,9 @@ __translate_unix_to_amiga_path_name(char const ** name_ptr,struct name_translati
|
|||||||
nti->is_root = TRUE;
|
nti->is_root = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ok, so this is an absolute path. We first
|
/* Ok, so this is an absolute path. We begin by checking
|
||||||
check for a few special cases, the first
|
for a few special cases, the first being a reference
|
||||||
being a reference to "/tmp". */
|
to "/tmp". */
|
||||||
if((strncmp(name,"/tmp",4) == SAME) && (name[4] == '/' || len == 4))
|
if((strncmp(name,"/tmp",4) == SAME) && (name[4] == '/' || len == 4))
|
||||||
{
|
{
|
||||||
if(name[4] == '/')
|
if(name[4] == '/')
|
||||||
|
|||||||
Reference in New Issue
Block a user