Ejemplo n.º 1
0
extern bool RcPass1IoInit( void )
/*******************************/
/* Open the two files for input and output. The input stream starts at the */
/* top   infilename   and continues as the directives in the file indicate */
/* Returns false if there is a problem opening one of the files. */
{
    bool        error;
    const char  *includepath = NULL;

    if( !CmdLineParms.IgnoreINCLUDE ) {
        if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN16 ) {
            includepath = RcGetEnv( "WINDOWS_INCLUDE" );
        } else if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
            includepath = RcGetEnv( "NT_INCLUDE" );
        } else if( CmdLineParms.TargetOS == RC_TARGET_OS_OS2 ) {
            includepath = RcGetEnv( "OS2_INCLUDE" );
        }
        if( includepath != NULL ) {
            PP_IncludePathAdd( includepath );
        }
        includepath = RcGetEnv( "INCLUDE" );
        if( includepath != NULL ) {
            PP_IncludePathAdd( includepath );
        }
    }
    if( !CmdLineParms.NoPreprocess ) {
        if( PreprocessInputFile() ) {
            return( false );
        }
    }
    RcIoTextInputInit();
    error = RcIoPushTextInputFile( CmdLineParms.InFileName );
    if( error )
        return( false );

    if( !CmdLineParms.PreprocessOnly ) {
        error = Pass1InitRes();
    }
    if( error )  {
        PP_FileFini();
        RcIoTextInputShutdown();
        return( false );
    }

    return( true );
}
Ejemplo n.º 2
0
static bool ScanOptionsArg( const char * arg )
/********************************************/
{
    bool        contok;
    size_t      len;

    contok = true;

    switch( tolower( *arg ) ) {
    case 'c':
        flags |= PPFLAG_KEEP_COMMENTS;
        break;
    case 'd':
        ++arg;
        defines = realloc( (void *)defines, ( numdefs + 1 ) * sizeof( char * ) );
        defines[numdefs++] = my_strdup( arg );
        break;
    case 'h':
        wcpp_quit( usageMsg, NULL );
        break;
    case 'i':
        {
            char    *p;

            ++arg;
            len = strlen( arg );
            p = malloc( len + 1 );
            scanString( p, arg, len );
            PP_IncludePathAdd( p );
            free( p );
        }
        break;
    case 'l':
        flags |= PPFLAG_EMIT_LINE;
        break;
    case 'o':
        ++arg;
        if( out_filename != NULL ) {
            free( out_filename );
        }
        len = strlen( arg );
        out_filename = malloc( len + 1 );
        scanString( out_filename, arg, len );
        break;
    case 'z':
        ++arg;
        if( tolower( arg[0] ) == 'k' ) {
            if( arg[1] == '0' && arg[2] == '\0' ) {
                flags |= PPFLAG_DB_KANJI;
                break;
            } else if( arg[1] == '1' && arg[2] == '\0' ) {
                flags |= PPFLAG_DB_CHINESE;
                break;
            } else if( arg[1] == '2' && arg[2] == '\0' ) {
                flags |= PPFLAG_DB_KOREAN;
                break;
            } else if( tolower( arg[1] ) == 'u' ) {
                if( arg[2] == '8' && arg[3] == '\0' ) {
                    flags |= PPFLAG_UTF8;
                    break;
                }
            }
        }
        // fall down
    default:
        wcpp_quit( usageMsg, "Incorrect option\n" );
        break;
    }
    return( contok );
} /* ScanOptionsArg */