Example #1
0
static char *reduceToOneString( OPT_STRING **h )
{
    OPT_STRING *s;
    char *p;

    s = *h;
    if( s != NULL ) {
        if( s->data[0] != '\0' ) {
            *h = s->next;
            OPT_CLEAN_STRING( h );
	    /* HACK: Whoever wrote this assumed that strcpy() did a byte-by-byte copy.
	     *       GCC's version however may use DWORD-sized copies instead.
	     *       If source and dest overlap there is NO guarantee of data integrity.
	     *       To avoid corrupting the string, use memmove() instead.
	     *
	     *  NTS: So why can't we just go and return s->data instead of strcpy'ing
	     *       over the struct with it's own string data? Why this bizarre code
	     *       in the first place? --J.C. */
	    {
                int l = strlen(s->data)+1; /* string + NUL */
                p = (char *)s;
	        memmove(p,s->data,l);
	    }
        } else {
            OPT_CLEAN_STRING( h );
            p = NULL;
        }
    } else {
        p = NULL;
    }
    return( p );
}
Example #2
0
/*
 * Warn when one of /Ge and /Gs overrides the other.
 */
static void handle_stack_probes( OPT_STORAGE *cmdOpts, int x )
/************************************************************/
{
    static int          hasBeenCalled;
    static int          prevValue;

    x = x;
    if( cmdOpts->Gs_value != NULL ) {
        Warning( "Ignoring unsupported parameter '%s' to /Gs",
                 cmdOpts->Gs_value->data );
        OPT_CLEAN_STRING( &(cmdOpts->Gs_value) );
    }

    if( hasBeenCalled ) {
        if( prevValue == OPT_stack_probes_Ge ) {
            if( cmdOpts->stack_probes == OPT_stack_probes_Gs ) {
                Warning( "Overriding /Ge with /Gs" );
            }
        } else if( prevValue == OPT_stack_probes_Gs ) {
            if( cmdOpts->stack_probes == OPT_stack_probes_Ge ) {
                Warning( "Overriding /Gs with /Ge" );
            }
        }
    } else {
        hasBeenCalled = 1;
    }
    prevValue = cmdOpts->stack_probes;
}
Example #3
0
/*
 * Scan a pathname.  No leading whitespace is permitted.
 */
static int OPT_GET_PATH( OPT_STRING **p )
/***************************************/
{
    char *              filename;

    filename = CmdScanFileName();
    if( filename != NULL ) {
        add_string( p, filename );
    } else {
        OPT_CLEAN_STRING( p );
    }
    return( 1 );
}
Example #4
0
/*
 * Ensure that /Yc has no filename parameter.
 */
static void handle_precomp_headers( OPT_STORAGE *cmdOpts, int x )
/***************************************************************/
{
    x = x;
    if( cmdOpts->precomp_headers == OPT_precomp_headers_Yc ) {
        if( cmdOpts->Yc_value != NULL ) {
            Warning( "Ignoring unsupported parameter '%s' to /Yc",
                     cmdOpts->Yc_value->data );
            OPT_CLEAN_STRING( &(cmdOpts->Yc_value) );
        }
    } else if( cmdOpts->precomp_headers == OPT_precomp_headers_Yu ) {
        if( cmdOpts->Yu_value != NULL ) {
            Warning( "Ignoring unsupported parameter '%s' to /Yu",
                     cmdOpts->Yu_value->data );
            OPT_CLEAN_STRING( &(cmdOpts->Yu_value) );
        }
    } else if( cmdOpts->precomp_headers == OPT_precomp_headers_YX ) {
        if( cmdOpts->YX_value != NULL ) {
            Warning( "Ignoring unsupported parameter '%s' to /YX",
                     cmdOpts->YX_value->data );
            OPT_CLEAN_STRING( &(cmdOpts->YX_value) );
        }
    }
}
Example #5
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 #6
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 #7
0
bool OPT_GET_PATH_OPT           // PARSE: OPTIONAL PATH
    ( OPT_STRING **p )          // - target
{
    size_t len;
    char const *fname;

//    if( CmdPathDelim() || !CmdDelimitChar() ) {
    if( CmdRecogEquals() || !CmdDelimitChar() ) {
        // specified an '=' so accept -this-is-a-path-name.fil or /tmp/ack.tmp
        len = CmdScanFilename( &fname );
        if( len != 0 ) {
            addString( p, fname, len );
            StripQuotes( (*p)->data );
        } else {
            OPT_CLEAN_STRING( p );
        }
    }
    return( TRUE );
}
Example #8
0
bool OPT_GET_FILE_OPT           // PARSE: OPTIONAL FILE NAME
    ( OPT_STRING **p )          // - target
{
    size_t len;
    char const *fname;

    // handle leading option char specially
    if( CmdRecogEquals() || !CmdDelimitChar() ) {
        // specified an '=' so accept -this-is-a-file-name.fil or /tmp/ack.tmp
        len = CmdScanFilename( &fname );
        if( len != 0 ) {
            addString( p, fname, len );
            StripQuotes( (*p)->data );
        } else {
            OPT_CLEAN_STRING( p );
        }
    }
    return( TRUE );
}