Example #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 );
}
Example #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 );
    }
}
Example #3
0
/*
 * Gripe about a command line error.
 */
static void cmd_line_error( void )
/********************************/
{
    char *              str;

    GoToMarkContext();
    str = CmdScanString();
    Warning( "Ignoring invalid option '%s'", str );
}
Example #4
0
/*
 * Parse the /Gs option.
 */
static int parse_Gs( OPT_STRING **p )
/***********************************/
{
    char *              str;

    str = CmdScanString();
    if( str != NULL ) {
        add_string( p, str );
    }
    return( 1 );
}
Example #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 );
}
Example #6
0
/*
 * Scan a filename without quotes.  No leading whitespace is allowed.  Returns a pointer
 * to newly allocated memory containing the filename string.  If leading
 * whitespace is found, returns NULL.
 */
char *CmdScanFileNameWithoutQuotes( void )
/***************************/
{
    char *              str;
    char *              newstr;

    str = CmdScanString();
    if( str != NULL ) {
        newstr = PathConvertWithoutQuotes( str );
        FreeMem( str );
    } else {
        newstr = NULL;
    }
    return( newstr );
}
Example #7
0
/*
 * Scan a filename.  No leading whitespace is allowed.  Returns a pointer
 * to newly allocated memory containing the filename string.  If filename
 * contained a quote character, returned string contains quotes. If leading
 * whitespace is found, returns NULL.
 */
char *CmdScanFileName( void )
/***************************/
{
    char *              str;
    char *              newstr;

    str = CmdScanString();
    if( str != NULL ) {
        newstr = PathConvert( str, '"' );
        FreeMem( str );
    } else {
        newstr = NULL;
    }
    return( newstr );
}
Example #8
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 );
}
Example #9
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 );
}
Example #10
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 );
}
Example #11
0
/*
 * Parse the /Fm option.
 */
static int parse_Fm( OPT_STRING **p )
/***********************************/
{
    char *              str;

    str = CmdScanString();
    if( str == NULL ) {
        OPT_CLEAN_STRING( p );
    } else {
        if( *p != NULL ) {
            Warning( "Overriding /Fm%s with /Fm%s", (*p)->data, str );
        }
        add_string( p, str );
    }
    return( 1 );
}
Example #12
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();
}
Example #13
0
/*
 * Parse the /passwopts option.
 */
static int parse_passwopts( OPT_STRING **p )
{
    char *str;
    char *src;
    char *dst;

    if( !CmdScanRecogChar( ':' ) )
    {
        FatalError("/passwopts:{argument} requires an argument");
        return 0;
    }

    str = CmdScanString();
    if (str == NULL)
    {
        FatalError("/passwopts requires an argument");
        return 0;
    }

    /*
     * If quoted, stip out the quote characters.
     */
    if (*str == '\"')
    {
        for (dst = str, src = str + 1; *src && (*src != '\"'); )
        {
            *dst++ = *src++;
        }

        if (*src != '\"')
        {
            FatalError("/passwopts argument is missing closing quote");
            return 0;
        }

        *dst = 0x00;
    }

    add_string(p, str, '\0');
    return 1;
} /* parse_passwopts() */