1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- We now allocate the AnchorPath used in the unistd_wildcard_expand.c

code. Also, the contents of the AnchorPath structure are no longer
  modified between calls. MatchEnd() has to be sufficient.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14822 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2005-02-03 12:14:55 +00:00
parent 50b8b623cc
commit 3548d3cf7e
7 changed files with 87 additions and 46 deletions

View File

@@ -14,6 +14,11 @@
modified unless the library is built with the "CHECK_FOR_NULL_POINTERS" modified unless the library is built with the "CHECK_FOR_NULL_POINTERS"
option. option.
- We now allocate the AnchorPath used in the unistd_wildcard_expand.c
code. Also, the contents of the AnchorPath structure are no longer
modified between calls. MatchEnd() has to be sufficient.
c.lib 1.187 (29.1.2005) c.lib 1.187 (29.1.2005)

View File

@@ -1,5 +1,5 @@
/* /*
* $Id: dirent_closedir.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ * $Id: dirent_closedir.c,v 1.4 2005-02-03 12:14:55 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@@ -94,8 +94,12 @@ closedir(DIR * directory_pointer)
Remove((struct Node *)dh); Remove((struct Node *)dh);
while((node = RemHead(&dh->dh_VolumeList)) != NULL) #if defined(UNIX_PATH_SEMANTICS)
{
while((node = RemHead((struct List *)&dh->dh_VolumeList)) != NULL)
free(node); free(node);
}
#endif /* UNIX_PATH_SEMANTICS */
PROFILE_OFF(); PROFILE_OFF();
UnLock(dh->dh_DirLock); UnLock(dh->dh_DirLock);

View File

@@ -1,5 +1,5 @@
/* /*
* $Id: dirent_headers.h,v 1.3 2005-01-02 09:07:07 obarthel Exp $ * $Id: dirent_headers.h,v 1.4 2005-02-03 12:14:55 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@@ -54,9 +54,10 @@ struct DirectoryHandle
BPTR dh_DirLock; BPTR dh_DirLock;
struct FileInfoBlock dh_FileInfo; struct FileInfoBlock dh_FileInfo;
struct dirent dh_DirectoryEntry; struct dirent dh_DirectoryEntry;
int dh_Position; int dh_Position;
struct Node * dh_VolumeNode; struct Node * dh_VolumeNode;
struct List dh_VolumeList; struct MinList dh_VolumeList;
BOOL dh_ScanVolumeList; BOOL dh_ScanVolumeList;
}; };

View File

@@ -1,5 +1,5 @@
/* /*
* $Id: dirent_opendir.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ * $Id: dirent_opendir.c,v 1.4 2005-02-03 12:14:55 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@@ -121,10 +121,10 @@ opendir(const char * path_name)
memset(dh,0,sizeof(*dh)); memset(dh,0,sizeof(*dh));
NewList(&dh->dh_VolumeList);
#if defined(UNIX_PATH_SEMANTICS) #if defined(UNIX_PATH_SEMANTICS)
{ {
NewList((struct List *)&dh->dh_VolumeList);
if(__unix_path_semantics) if(__unix_path_semantics)
{ {
if(__translate_unix_to_amiga_path_name(&path_name,&path_name_nti) != 0) if(__translate_unix_to_amiga_path_name(&path_name,&path_name_nti) != 0)
@@ -172,7 +172,7 @@ opendir(const char * path_name)
/* Check if the name is already on the list. Mind you, /* Check if the name is already on the list. Mind you,
this is not the most sophisticated algorithm but then this is not the most sophisticated algorithm but then
the number of volumes should be small. */ the number of volumes should be small. */
if(find_by_name(&dh->dh_VolumeList,node->ln_Name) != NULL) if(find_by_name((struct List *)&dh->dh_VolumeList,node->ln_Name) != NULL)
{ {
free(node); free(node);
continue; continue;
@@ -180,14 +180,14 @@ opendir(const char * path_name)
D(("adding '%s'",node->ln_Name)); D(("adding '%s'",node->ln_Name));
AddTail(&dh->dh_VolumeList,node); AddTail((struct List *)&dh->dh_VolumeList,node);
} }
} }
UnLockDosList(LDF_VOLUMES|LDF_READ); UnLockDosList(LDF_VOLUMES|LDF_READ);
/* Bail out if we cannot present anything. */ /* Bail out if we cannot present anything. */
if(IsListEmpty(&dh->dh_VolumeList)) if(IsListEmpty((struct List *)&dh->dh_VolumeList))
{ {
errno = ENOMEM; errno = ENOMEM;
goto out; goto out;
@@ -254,8 +254,12 @@ opendir(const char * path_name)
{ {
SHOWMSG("ouch. cleaning up"); SHOWMSG("ouch. cleaning up");
while((node = RemHead(&dh->dh_VolumeList)) != NULL) #if defined(UNIX_PATH_SEMANTICS)
{
while((node = RemHead((struct List *)&dh->dh_VolumeList)) != NULL)
free(node); free(node);
}
#endif /* UNIX_PATH_SEMANTICS */
PROFILE_OFF(); PROFILE_OFF();
UnLock(dh->dh_DirLock); UnLock(dh->dh_DirLock);

View File

@@ -1,5 +1,5 @@
/* /*
* $Id: dirent_readdir.c,v 1.5 2005-01-09 15:58:02 obarthel Exp $ * $Id: dirent_readdir.c,v 1.6 2005-02-03 12:14:55 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@@ -93,8 +93,8 @@ readdir(DIR * directory_pointer)
assert( (((ULONG)name) & 3) == 0 ); assert( (((ULONG)name) & 3) == 0 );
if(dh->dh_VolumeNode == NULL && NOT IsListEmpty(&dh->dh_VolumeList)) if(dh->dh_VolumeNode == NULL && NOT IsListEmpty((struct List *)&dh->dh_VolumeList))
dh->dh_VolumeNode = dh->dh_VolumeList.lh_Head; dh->dh_VolumeNode = (struct Node *)dh->dh_VolumeList.mlh_Head;
strcpy(name,"\1:"); /* BSTR for ":" */ strcpy(name,"\1:"); /* BSTR for ":" */

View File

@@ -1,5 +1,5 @@
/* /*
* $Id: stdlib_headers.h,v 1.6 2005-01-02 09:07:18 obarthel Exp $ * $Id: stdlib_headers.h,v 1.7 2005-02-03 12:14:55 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@@ -42,7 +42,11 @@
/****************************************************************************/ /****************************************************************************/
/* This enables the legacy compatible 'struct AnchorPathOld'. */ /* This enables the legacy compatible 'struct AnchorPathOld'. */
#ifndef __amigaos4__
#define USE_OLD_ANCHORPATH #define USE_OLD_ANCHORPATH
#endif /* USE_OLD_ANCHORPATH */
/****************************************************************************/
#if (INCLUDE_VERSION >= 50) #if (INCLUDE_VERSION >= 50)
#include <dos/anchorpath.h> #include <dos/anchorpath.h>

View File

@@ -1,5 +1,5 @@
/* /*
* $Id: unistd_wildcard_expand.c,v 1.4 2005-01-02 09:07:19 obarthel Exp $ * $Id: unistd_wildcard_expand.c,v 1.5 2005-02-03 12:14:55 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@@ -81,6 +81,13 @@ CLIB_DESTRUCTOR(__wildcard_expand_exit)
if(anchor != NULL) if(anchor != NULL)
{ {
MatchEnd(anchor); MatchEnd(anchor);
#if defined(__amigaos4__)
{
FreeDosObject(DOS_ANCHORPATH,anchor);
}
#endif /* __amigaos4__ */
anchor = NULL; anchor = NULL;
} }
@@ -136,9 +143,23 @@ __wildcard_expand_init(void)
argc = __argc; argc = __argc;
argv = __argv; argv = __argv;
#if defined(__amigaos4__)
{
ap = AllocDosObjectTags(DOS_ANCHORPATH,
ADO_Strlen, 2 * MAXPATHLEN,
ADO_Mask, (__check_abort_enabled) ? SIGBREAKF_CTRL_C : 0,
TAG_END);
if(ap == NULL)
{
error = ENOMEM;
goto out;
}
}
#else
{
/* We need some extra room in this data structure as the buffer /* We need some extra room in this data structure as the buffer
* will be used to check if a string contains a pattern. will be used to check if a string contains a pattern. */
*/
ap = malloc(sizeof(*ap) + 2 * MAXPATHLEN); ap = malloc(sizeof(*ap) + 2 * MAXPATHLEN);
if(ap == NULL) if(ap == NULL)
{ {
@@ -149,10 +170,18 @@ __wildcard_expand_init(void)
/* This has to be long-word aligned. */ /* This has to be long-word aligned. */
assert( (((ULONG)ap) & 3) == 0 ); assert( (((ULONG)ap) & 3) == 0 );
anchor = ap;
memset(ap,0,sizeof(*ap)); memset(ap,0,sizeof(*ap));
ap->ap_Strlen = MAXPATHLEN;
if(__check_abort_enabled)
ap->ap_BreakBits = SIGBREAKF_CTRL_C;
}
#endif /* __amigaos4__ */
/* This may have to be cleaned up later. */
anchor = ap;
/* The argument list will go in here. */ /* The argument list will go in here. */
NewList((struct List *)&argument_list); NewList((struct List *)&argument_list);
argument_list_size = 0; argument_list_size = 0;
@@ -169,13 +198,6 @@ __wildcard_expand_init(void)
BOOL is_first = TRUE; BOOL is_first = TRUE;
LONG rc; LONG rc;
memset(ap,0,sizeof(*ap));
ap->ap_Strlen = MAXPATHLEN;
if(__check_abort_enabled)
ap->ap_BreakBits = SIGBREAKF_CTRL_C;
rc = MatchFirst(argv[i],ap); rc = MatchFirst(argv[i],ap);
while(TRUE) while(TRUE)
@@ -191,13 +213,6 @@ __wildcard_expand_init(void)
{ {
MatchEnd(ap); MatchEnd(ap);
memset(ap,0,sizeof(*ap));
ap->ap_Strlen = MAXPATHLEN;
if(__check_abort_enabled)
ap->ap_BreakBits = SIGBREAKF_CTRL_C;
rc = MatchFirst(argv[i],ap); rc = MatchFirst(argv[i],ap);
} }
else else
@@ -356,14 +371,22 @@ __wildcard_expand_init(void)
out: out:
anchor = NULL;
if(ap != NULL) if(ap != NULL)
{ {
MatchEnd(ap); MatchEnd(ap);
#if defined(__amigaos4__)
{
FreeDosObject(DOS_ANCHORPATH,anchor);
}
#else
{
free(ap); free(ap);
} }
#endif /* __amigaos4__ */
}
anchor = NULL;
if(error != OK) if(error != OK)
{ {