mirror of
https://github.com/cc65/cc65.git
synced 2024-09-10 15:57:30 +00:00
New functions PushSearchPath and PopSearchPath.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4671 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
64b597017a
commit
ebd679dd57
@ -57,29 +57,36 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void Add (SearchPath* P, const char* New)
|
static char* CleanupPath (const char* Path)
|
||||||
/* Cleanup a new search path and add it to the list */
|
/* Prepare and return a clean copy of Path */
|
||||||
{
|
{
|
||||||
unsigned NewLen;
|
unsigned Len;
|
||||||
char* NewPath;
|
char* NewPath;
|
||||||
|
|
||||||
/* Get the length of the new path */
|
/* Get the length of the path */
|
||||||
NewLen = strlen (New);
|
Len = strlen (Path);
|
||||||
|
|
||||||
/* Check for a trailing path separator and remove it */
|
/* Check for a trailing path separator and remove it */
|
||||||
if (NewLen > 0 && (New[NewLen-1] == '\\' || New[NewLen-1] == '/')) {
|
if (Len > 0 && (Path[Len-1] == '\\' || Path[Len-1] == '/')) {
|
||||||
--NewLen;
|
--Len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate memory for the new string */
|
/* Allocate memory for the new string */
|
||||||
NewPath = (char*) xmalloc (NewLen + 1);
|
NewPath = (char*) xmalloc (Len + 1);
|
||||||
|
|
||||||
/* Copy the path and terminate it */
|
/* Copy the path and terminate it, then return the copy */
|
||||||
memcpy (NewPath, New, NewLen);
|
memcpy (NewPath, Path, Len);
|
||||||
NewPath [NewLen] = '\0';
|
NewPath [Len] = '\0';
|
||||||
|
return NewPath;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add the path to the collection */
|
|
||||||
CollAppend (P, NewPath);
|
|
||||||
|
static void Add (SearchPath* P, const char* New)
|
||||||
|
/* Cleanup a new search path and add it to the list */
|
||||||
|
{
|
||||||
|
/* Add a clean copy of the path to the collection */
|
||||||
|
CollAppend (P, CleanupPath (New));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -149,6 +156,25 @@ void AddSubSearchPathFromEnv (SearchPath* P, const char* EnvVar, const char* Sub
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PushSearchPath (SearchPath* P, const char* NewPath)
|
||||||
|
/* Add a new search path to the head of an existing search path list */
|
||||||
|
{
|
||||||
|
/* Insert a clean copy of the path at position 0 */
|
||||||
|
CollInsert (P, CleanupPath (NewPath), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PopSearchPath (SearchPath* P)
|
||||||
|
/* Remove a search path from the head of an existing search path list */
|
||||||
|
{
|
||||||
|
/* Remove the path at position 0 */
|
||||||
|
xfree (CollAt (P, 0));
|
||||||
|
CollDelete (P, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ForgetSearchPath (SearchPath* P)
|
void ForgetSearchPath (SearchPath* P)
|
||||||
/* Forget all search paths in the given list */
|
/* Forget all search paths in the given list */
|
||||||
{
|
{
|
||||||
|
@ -75,6 +75,12 @@ void AddSubSearchPathFromEnv (SearchPath* P, const char* EnvVar, const char* Sub
|
|||||||
* the environment variable value.
|
* the environment variable value.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void PushSearchPath (SearchPath* P, const char* NewPath);
|
||||||
|
/* Add a new search path to the head of an existing search path list */
|
||||||
|
|
||||||
|
void PopSearchPath (SearchPath* P);
|
||||||
|
/* Remove a search path from the head of an existing search path list */
|
||||||
|
|
||||||
void ForgetSearchPath (SearchPath* P);
|
void ForgetSearchPath (SearchPath* P);
|
||||||
/* Forget all search paths in the given list */
|
/* Forget all search paths in the given list */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user