Exemplo n.º 1
0
/*
 * Parse the /link option.
 */
static int parse_link( OPT_STRING **p )
/*************************************/
{
    char *              str;
    int                 gotOne = 0;

    if( !CmdScanRecogChar( ' ' )  &&  !CmdScanRecogChar( '\t' ) ) {
        FatalError( "Whitespace required after /link" );
        return( 0 );
    }
    for( ;; ) {
        CmdScanWhitespace();
        str = CmdScanString();
        if( str == NULL ) {
            if( !gotOne ) {
                FatalError( "/link requires at least one argument" );
                return( 0 );
            } else {
                break;
            }
        }
        add_string( p, str );
        gotOne = 1;
    }
    return( 1 );
}
Exemplo n.º 2
0
/*
 * Parse the /D option.
 */
static int parse_D( OPT_STRING **p )
/**********************************/
{
    char *              str;
    char *              eq;

    p = p;
    CmdScanWhitespace();
    str = CmdScanString();
    if( str == NULL ) {
        FatalError( "/D requires an argument" );
        return( 0 );
    }
    for( ;; ) {                 /* convert all '#' chars to '=' chars */
        eq = strchr( str, '#' );
        if( eq == NULL )  break;
        *eq = '=';
    }
    if( DefineMacro( str ) ) {
        return( 1 );
    } else {
        Warning( "Ignoring invalid macro definition '%s'", str );
        return( 0 );
    }
}
Exemplo n.º 3
0
/*
 * Parse the /Tp option.
 */
static int parse_Tp( OPT_STRING **p )
/***********************************/
{
    CmdScanWhitespace();
    if( OPT_GET_FILE( p ) ) {
        AddFile( TYPE_CPP_FILE, (*p)->data );
        return( 1 );
    } else {
        FatalError( "/Tp requires an argument" );
        return( 0 );
    }
}
Exemplo n.º 4
0
/*
 * Parse the command string contained in the current context.
 */
void CmdStringParse( OPT_STORAGE *cmdOpts, int *itemsParsed )
/***********************************************************/
{
    int                 ch;
    char *              filename;

    for( ;; ) {
        /*** Find the start of the next item ***/
        CmdScanWhitespace();
        ch = GetCharContext();
        if( ch == '\0' )  break;
        MarkPosContext();               /* mark start of switch */

        /*** Handle switches, command files, and input files ***/
        if( ch == '-'  ||  ch == '/' ) {        /* switch */
            if( OPT_PROCESS( cmdOpts ) != 0 ) {
                cmd_line_error();
            }
        } else if( ch == '@' ) {                /* command file */
            filename = CmdScanFileNameWithoutQuotes();
            PushContext();
            if( OpenFileContext( filename ) ) {
                FatalError( "Cannot open '%s'.", filename );
            }
            FreeMem( filename );
            CmdStringParse( cmdOpts, itemsParsed );
            PopContext();
        } else if( ch == '"' ) {                /* quoted option or file name */
            ch = GetCharContext();
            if( ch == '-' ) {
                Quoted = 1;
                if( OPT_PROCESS( cmdOpts ) != 0 ) {
                    cmd_line_error();
                }
            } else {
                UngetCharContext();
                UngetCharContext();
                filename = CmdScanFileName();
                AddFile( TYPE_DEFAULT_FILE, filename );
                FreeMem( filename );
            }                
        } else {                                /* input file */
            UngetCharContext();
            filename = CmdScanFileName();
            AddFile( TYPE_DEFAULT_FILE, filename );
            FreeMem( filename );
        }
        (*itemsParsed)++;
    }
    CloseContext();
}
Exemplo n.º 5
0
/*
 * Parse the /o option.
 */
static int parse_o( OPT_STRING **p )
/**********************************/
{
    char *              str;

    CmdScanWhitespace();
    str = CmdScanString();
    if( str == NULL ) {
        FatalError( "/o requires an argument" );
        return( 0 );
    }
    add_string( p, str );
    return( 1 );
}
Exemplo n.º 6
0
/*
 * Parse the /V option.
 */
static int parse_V( OPT_STRING **p )
/**********************************/
{
    char *              str;

    p = p;
    CmdScanWhitespace();
    str = CmdScanString();
    if( str == NULL ) {
        FatalError( "/V requires an argument" );
        return( 0 );
    }
    /* it's unsupported, so just skip over it; error msg will come later */
    return( 1 );
}
Exemplo n.º 7
0
/*
 * Parse the /U option.
 */
static int parse_U( OPT_STRING **p )
/**********************************/
{
    char *              str;

    p = p;
    CmdScanWhitespace();
    str = CmdScanString();
    if( str == NULL ) {
        FatalError( "/U requires an argument" );
        return( 0 );
    }
    UndefineMacro( str );
    return( 1 );
}
Exemplo n.º 8
0
/*
 * For the /optName option, read in :string and store the string into the
 * given OPT_STRING.  If onlyOne is non-zero, any previous string in p will
 * be deleted.  If quote is non-zero, make sure the string is quoted.
 * Use quote if there aren't any quotes already.
 */
static int do_string_parse( OPT_STRING **p, char *optName, bool onlyOne,
                            char quote )
/**********************************************************************/
{
    char *              str;

    CmdScanWhitespace();
    str = CmdScanString();
    if( str == NULL ) {
        FatalError( "/%s option requires a filename", optName );
        return( 0 );
    }
    if( onlyOne ) OPT_CLEAN_STRING( p );
    add_string( p, str, quote );
    return( 1 );
}
Exemplo n.º 9
0
/*
 * Parse the command string contained in the current context.
 */
void CmdStringParse( OPT_STORAGE *cmdOpts, int *itemsParsed )
/***********************************************************/
{
    char                ch;
    char *              filename;
    char *              str;

    for( ;; ) {
        /*** Find the start of the next item ***/
        CmdScanWhitespace();
        ch = GetCharContext();
        if( ch == '\0' )  break;
        MarkPosContext();               /* mark start of switch */

        /*** Handle switches, command files, and input files ***/
        if( ch == '-'  ||  ch == '/' ) {        /* switch */
            if( OPT_PROCESS( cmdOpts ) ) {
                /*
                 * Switch didn't match, if user entered empty switch,
                 * just be silent like MS's nmake does.
                 */

                ch = GetCharContext();
                if( ch != '\0' && !isspace( ch ) ) {
                    cmd_line_error();
                }
            }
        } else if( ch == '@' ) {                /* command file */
            filename = CmdScanFileNameWithoutQuotes();
            PushContext();
            if( OpenFileContext( filename ) ) {
                FatalError( "Cannot open '%s'.", filename );
            }
            FreeMem( filename );
            CmdStringParse( cmdOpts, itemsParsed );
            PopContext();
        } else {                                /* targets and macros */
            UngetCharContext();
            str = CmdScanString();
            add_string( &(cmdOpts->t010101010101_value), str, '\0' );
            cmdOpts->t010101010101 = 1;
        }
        (*itemsParsed)++;
    }
    CloseContext();
}