UserInterface/Fix_Path [ Functions ]

FUNCTION

Add a "./" to a path if it does not start with a "./" or does not contain a ":". If the path was "." just add a "/". Adding a "./" simplifies the creating of relative links during the generation process.

SYNOPSIS

static char        *Fix_Path(
    char *path )

INPUTS

RESULT

A pointer to a newly allocated string containing the path.

SOURCE

{
    char               *result = 0;

    if ( !PathBegin_Check( path ) )
    {
        char               *prefix = "./";

        if ( strcmp( path, "." ) == 0 )
        {
            result = RB_StrDup( prefix );
        }
        else
        {
            int                 l = strlen( path );

            l += strlen( prefix ) + 1;
            result = malloc( l );
            assert( result );
            result[0] = '\0';
            strcat( result, prefix );
            strcat( result, path );
        }
    }
    else
    {
        result = RB_StrDup( path );
    }
    return result;
}