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"
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)

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
*
@ -94,8 +94,12 @@ closedir(DIR * directory_pointer)
Remove((struct Node *)dh);
while((node = RemHead(&dh->dh_VolumeList)) != NULL)
free(node);
#if defined(UNIX_PATH_SEMANTICS)
{
while((node = RemHead((struct List *)&dh->dh_VolumeList)) != NULL)
free(node);
}
#endif /* UNIX_PATH_SEMANTICS */
PROFILE_OFF();
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
*
@ -54,9 +54,10 @@ struct DirectoryHandle
BPTR dh_DirLock;
struct FileInfoBlock dh_FileInfo;
struct dirent dh_DirectoryEntry;
int dh_Position;
struct Node * dh_VolumeNode;
struct List dh_VolumeList;
struct MinList dh_VolumeList;
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
*
@ -121,10 +121,10 @@ opendir(const char * path_name)
memset(dh,0,sizeof(*dh));
NewList(&dh->dh_VolumeList);
#if defined(UNIX_PATH_SEMANTICS)
{
NewList((struct List *)&dh->dh_VolumeList);
if(__unix_path_semantics)
{
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,
this is not the most sophisticated algorithm but then
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);
continue;
@ -180,14 +180,14 @@ opendir(const char * path_name)
D(("adding '%s'",node->ln_Name));
AddTail(&dh->dh_VolumeList,node);
AddTail((struct List *)&dh->dh_VolumeList,node);
}
}
UnLockDosList(LDF_VOLUMES|LDF_READ);
/* Bail out if we cannot present anything. */
if(IsListEmpty(&dh->dh_VolumeList))
if(IsListEmpty((struct List *)&dh->dh_VolumeList))
{
errno = ENOMEM;
goto out;
@ -254,8 +254,12 @@ opendir(const char * path_name)
{
SHOWMSG("ouch. cleaning up");
while((node = RemHead(&dh->dh_VolumeList)) != NULL)
free(node);
#if defined(UNIX_PATH_SEMANTICS)
{
while((node = RemHead((struct List *)&dh->dh_VolumeList)) != NULL)
free(node);
}
#endif /* UNIX_PATH_SEMANTICS */
PROFILE_OFF();
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
*
@ -93,8 +93,8 @@ readdir(DIR * directory_pointer)
assert( (((ULONG)name) & 3) == 0 );
if(dh->dh_VolumeNode == NULL && NOT IsListEmpty(&dh->dh_VolumeList))
dh->dh_VolumeNode = dh->dh_VolumeList.lh_Head;
if(dh->dh_VolumeNode == NULL && NOT IsListEmpty((struct List *)&dh->dh_VolumeList))
dh->dh_VolumeNode = (struct Node *)dh->dh_VolumeList.mlh_Head;
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
*
@ -42,7 +42,11 @@
/****************************************************************************/
/* This enables the legacy compatible 'struct AnchorPathOld'. */
#ifndef __amigaos4__
#define USE_OLD_ANCHORPATH
#endif /* USE_OLD_ANCHORPATH */
/****************************************************************************/
#if (INCLUDE_VERSION >= 50)
#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
*
@ -81,6 +81,13 @@ CLIB_DESTRUCTOR(__wildcard_expand_exit)
if(anchor != NULL)
{
MatchEnd(anchor);
#if defined(__amigaos4__)
{
FreeDosObject(DOS_ANCHORPATH,anchor);
}
#endif /* __amigaos4__ */
anchor = NULL;
}
@ -136,23 +143,45 @@ __wildcard_expand_init(void)
argc = __argc;
argv = __argv;
/* We need some extra room in this data structure as the buffer
* will be used to check if a string contains a pattern.
*/
ap = malloc(sizeof(*ap) + 2 * MAXPATHLEN);
if(ap == NULL)
#if defined(__amigaos4__)
{
error = ENOMEM;
goto out;
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
will be used to check if a string contains a pattern. */
ap = malloc(sizeof(*ap) + 2 * MAXPATHLEN);
if(ap == NULL)
{
error = ENOMEM;
goto out;
}
/* This has to be long-word aligned. */
assert( (((ULONG)ap) & 3) == 0 );
/* This has to be long-word aligned. */
assert( (((ULONG)ap) & 3) == 0 );
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;
memset(ap,0,sizeof(*ap));
/* The argument list will go in here. */
NewList((struct List *)&argument_list);
argument_list_size = 0;
@ -169,13 +198,6 @@ __wildcard_expand_init(void)
BOOL is_first = TRUE;
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);
while(TRUE)
@ -191,13 +213,6 @@ __wildcard_expand_init(void)
{
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);
}
else
@ -356,15 +371,23 @@ __wildcard_expand_init(void)
out:
anchor = NULL;
if(ap != NULL)
{
MatchEnd(ap);
free(ap);
#if defined(__amigaos4__)
{
FreeDosObject(DOS_ANCHORPATH,anchor);
}
#else
{
free(ap);
}
#endif /* __amigaos4__ */
}
anchor = NULL;
if(error != OK)
{
errno = error;