mirror of
https://github.com/cc65/cc65.git
synced 2024-12-27 00:29:31 +00:00
PushSearchPath will add the path only if it's not already there.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4672 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
ebd679dd57
commit
9a6f97cfe1
@ -156,11 +156,25 @@ void AddSubSearchPathFromEnv (SearchPath* P, const char* EnvVar, const char* Sub
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PushSearchPath (SearchPath* P, const char* NewPath)
|
int PushSearchPath (SearchPath* P, const char* NewPath)
|
||||||
/* Add a new search path to the head of an existing search path list */
|
/* Add a new search path to the head of an existing search path list, provided
|
||||||
|
* that it's not already there. If the path is already at the first position,
|
||||||
|
* return zero, otherwise return a non zero value.
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
/* Insert a clean copy of the path at position 0 */
|
/* Generate a clean copy of NewPath */
|
||||||
CollInsert (P, CleanupPath (NewPath), 0);
|
char* Path = CleanupPath (NewPath);
|
||||||
|
|
||||||
|
/* If we have paths, check if Path is already at position zero */
|
||||||
|
if (CollCount (P) > 0 && strcmp (CollConstAt (P, 0), Path) == 0) {
|
||||||
|
/* Match. Delete the copy and return to the caller */
|
||||||
|
xfree (Path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Insert a clean copy of the path at position 0, return success */
|
||||||
|
CollInsert (P, Path, 0);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,8 +75,11 @@ 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);
|
int PushSearchPath (SearchPath* P, const char* NewPath);
|
||||||
/* Add a new search path to the head of an existing search path list */
|
/* Add a new search path to the head of an existing search path list, provided
|
||||||
|
* that it's not already there. If the path is already at the first position,
|
||||||
|
* return zero, otherwise return a non zero value.
|
||||||
|
*/
|
||||||
|
|
||||||
void PopSearchPath (SearchPath* P);
|
void PopSearchPath (SearchPath* P);
|
||||||
/* Remove a search path from the head of an existing search path list */
|
/* Remove a search path from the head of an existing search path list */
|
||||||
|
Loading…
Reference in New Issue
Block a user