scanclrmake/src/crparser.cxx
// ===========================================================================
// Interprets the given file name relative to the directory.
// If the file name is absolute, it remains unchanged.
// If the file name is relative, it is interpreted relative to the given
// directory.  The directory name should end in a separator character,
// i.e. \ or /
//
Interprets the given file name relative to the directory.
If the file name is absolute, it remains unchanged.
If the file name is relative, it is interpreted relative to the given
directory.  The directory name should end in a separator character,
i.e. \ or
Interprets the given file name relative to the directory . If the file name is absolute it remains unchanged . If the file name is relative it is interpreted relative to the given directory . The directory name should end in a separator character i . e . \ or
void CRParser::appendToDirectory(const string &dir, string &file)
{
    if (!isAbsolute(file.c_str())) {
	int dir_pos = dir.length() - 1; 
	for (;;) {
	    if (file[0] == '.' && file[1] == '.' && isPathSep(file[2])) {
		char tester = dir[dir_pos - 1];
		if (!isPathSep(tester) && tester != '.' && 
					!(tester == ':' && dir_pos == 2)) {
		    int pos;
		    for (pos = dir_pos - 1; pos >= 0; pos -= 1) {
			if (isPathSep(dir[pos])) {
			    break;
			}
		    }
		    if (pos >= 0) {
			dir_pos = pos;
			file = file.substr(3);
		    }
		}
	    }
	    else if (file[0] == '.' && isPathSep(file[1])) {
		file = file.substr(2);
	    }
	    else {
		break;
	    }
	}
	string t = dir;
	t.resize(dir_pos + 1);
	t.append(file);
	file = t;
    }
}
void CRParser :: appendToDirectory ( const string & dir , string & file ) { if ( ! isAbsolute ( file . c_str ( ) ) ) { int dir_pos = dir . length ( ) - 1 ; for ( ; ; ) { if ( file [ 0 ] == ' ' && file [ 1 ] == ' ' && isPathSep ( file [ 2 ] ) ) { char tester = dir [ dir_pos - 1 ] ; if ( ! isPathSep ( tester ) && tester != ' ' && ! ( tester == ' ' && dir_pos == 2 ) ) { int pos ; for ( pos = dir_pos - 1 ; pos >= 0 ; pos -= 1 ) { if ( isPathSep ( dir [ pos ] ) ) { break ; } } if ( pos >= 0 ) { dir_pos = pos ; file = file . substr ( 3 ) ; } } } else if ( file [ 0 ] == ' ' && isPathSep ( file [ 1 ] ) ) { file = file . substr ( 2 ) ; } else { break ; } } string t = dir ; t . resize ( dir_pos + 1 ) ; t . append ( file ) ; file = t ; } }
Interprets the given file name relative to the directory.
Interprets the given file name relative to the directory .
// Find initial occurrences of .. or . in the file name, and // eliminate them. // the separator // Here's a directory name to eliminate. // Directory name is located at pos+1 .. dir_pos-1.