Personal tools
You are here: Home Projects C++ Cfront releases Release 3.0.3 source libSC Path search.c
Document Actions

search.c

by Michael L Powell last modified 2007-01-26 03:24

Click here to get the file

Size 1.6 kB - File type text/plain

File contents

/*ident	"@(#)Path:search.c	3.1" */
/******************************************************************************
*
* C++ Standard Components, Release 3.0.
*
* Copyright (c) 1991, 1992 AT&T and Unix System Laboratories, Inc.
* Copyright (c) 1988, 1989, 1990 AT&T.  All Rights Reserved.
*
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T and Unix System
* Laboratories, Inc.  The copyright notice above does not evidence
* any actual or intended publication of such source code.
*
******************************************************************************/

#include "Pathlib.h"
#include <Search_path.h>

/* p is a (possibly empty) colon-separated list of file names
*/
void 
Search_path::build_from(const char * p)
{
	assert(length() == 0);
	char *q = strdup_ATTLC(p);
        char *b = q;
        for(char *e=strchr(b,':'); e?(*e=0,e):0; b=e+1, e=strchr(b,':'))
                put(b);
        put(b); // last segment
	free(q);
}

Search_path::Search_path()
{
}

Search_path::Search_path(const char * p)
{
	// I test for p being 0 to allow the client to say: Search_path(getenv("PATH"))
	// If getenv returns 0, the empty search path is constructed.
	if (p != 0)
		build_from(p);
}

Search_path::Search_path(const Search_path & pth) : List<Path> (pth)
{
}	

Search_path & Search_path::operator=(const Search_path & pth)
{
	List<Path>::operator=(pth);
	return *this;
}

Search_path::operator String() const
{
	String s;
	Listiter<Path> i(*(Search_path*)this);
	int first = 1;
	while (!i.at_end())
	{
		if (!first)
			s += ':';
		first = 0;
		s += (String)*(i.next());
	}
	return s;
}

Search_path::operator const char *() const
{
	return (String)*this;
}


« March 2024 »
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: