コード例 #1
0
ファイル: leadbyte.c プロジェクト: ABratovic/open-watcom-v2
void SetNativeLeadBytes( void ) {
/*********************************/
    CPINFO      info;
    unsigned    i;

    GetCPInfo( CP_ACP, &info );
    i = 0;
    while( info.LeadByte[i] != 0 && info.LeadByte[i+1] != 0 ) {
        SetMBRange( info.LeadByte[i], info.LeadByte[i+1], 1 );
        i += 2;
    }
}
コード例 #2
0
static bool ScanOptionsArg( const char * arg )
/********************************************/
{
    bool        contok;
    ExtraRes    *resfile;
    FRStrings   *frStrings;
    char        *temp=NULL;
    char        *p;
    char        *delims = ",";
    size_t      findlen = 0;
//    size_t      replen = 0;

    contok = true;

    switch( tolower( *arg ) ) {
    case '\0':
        RcError( ERR_NO_OPT_SPECIFIED );
        contok = false;
        break;
    case 'a':
        arg++;
        if( tolower( *arg ) == 'd' ) {
            CmdLineParms.GenAutoDep = TRUE;
        } else if( tolower( *arg ) == 'p' ) {
            arg++;
            if( *arg == '=' ) arg++;
            if( scanString( CmdLineParms.PrependString, arg, _MAX_PATH  ) ) {
                RcError( ERR_UNMATCHED_QUOTE_ON_CMD_LINE );
            }
            CmdLineParms.Prepend = TRUE;
            break;
        } else {
            RcError( ERR_UNKNOWN_MULT_OPTION, arg - 1 );
            contok = FALSE;
        }
        break;
    case '3':
        arg++;
        switch( tolower( *arg ) ) {
        case '0':
            CmdLineParms.VersionStamp = VERSION_30_STAMP;
            break;
        case '1':
            CmdLineParms.VersionStamp = VERSION_31_STAMP;
            break;
        default:
            RcError( ERR_UNKNOWN_MULT_OPTION, arg - 1 );
            contok = FALSE;
            break;
        }
        break;
    case 'b':
        arg++;
        if( tolower( *arg ) == 't' ) {
            arg++;
            if( *arg == '=' ) arg++;
            if( stricmp( arg, "windows" ) == 0 || stricmp( arg, "win" ) == 0 ) {
                CmdLineParms.TargetOS = RC_TARGET_OS_WIN16;
            } else if( stricmp( arg, "nt" ) == 0 ) {
                CmdLineParms.TargetOS = RC_TARGET_OS_WIN32;
            } else if( stricmp( arg, "os2" ) == 0 ) {
                CmdLineParms.TargetOS = RC_TARGET_OS_OS2;
            } else {
                RcError( ERR_UNKNOWN_TARGET_OS, arg );
                contok = FALSE;
            }
        } else {
            RcError( ERR_UNKNOWN_MULT_OPTION, arg - 1 );
            contok = FALSE;
        }
        break;
    case 'c':
        arg++;
        if( *arg == '=' ) arg++;
        if( scanString( CmdLineParms.CodePageFile, arg, _MAX_PATH  ) ) {
            RcError( ERR_UNMATCHED_QUOTE_ON_CMD_LINE );
        }
        break;
    case 'd':
        /* temporary until preprocessing done inline */
        /* -1 to get the '-' or '/' as well */
        /* the cast is so the argument won't be const */
        RcAddCPPArg( (char *)arg - 1 );
        break;
    case 'f':
        arg++;
        switch( tolower( *arg ) ) {
        case 'o':
            arg++;
            if( *arg == '=' ) arg++;
            if( scanString( CmdLineParms.OutResFileName, arg, _MAX_PATH  ) ) {
                RcError( ERR_UNMATCHED_QUOTE_ON_CMD_LINE );
            }
            break;
        case 'r':
            arg++;
            if( *arg == '=' ) arg++;
            resfile = RcMemMalloc( sizeof( ExtraRes ) );
            if( scanString( resfile->name, arg, _MAX_PATH  ) ) {
                RcError( ERR_UNMATCHED_QUOTE_ON_CMD_LINE );
                RcMemFree( resfile );
            } else {
                resfile->next = CmdLineParms.ExtraResFiles;
                CmdLineParms.ExtraResFiles = resfile;
            }
            break;
        case 'e':
            arg++;
            if( *arg == '=' ) arg++;
            if( scanString( CmdLineParms.OutExeFileName, arg, _MAX_PATH  ) ) {
                RcError( ERR_UNMATCHED_QUOTE_ON_CMD_LINE );
            }
            break;
        default:
            RcError( ERR_UNKNOWN_MULT_OPTION, arg - 1 );
            contok = FALSE;
            break;
        }
        break;
    case 'g':
        arg++;
        if( *arg == '=' ) arg++;
        temp = RcMemMalloc( strlen( arg ) + 1 );
        if( scanString( temp, arg, _MAX_PATH  ) ) {
            RcError( ERR_UNMATCHED_QUOTE_ON_CMD_LINE );
        }
        frStrings = RcMemMalloc( sizeof( FRStrings ) + strlen( arg ) + 2 );
        p = strtok( temp, delims );
        if( p != NULL ) {
            findlen = strlen( p );
            strcpy( frStrings->buf, p );
            frStrings->findString = frStrings->buf;
        } else {
            RcError( ERR_SYNTAX_STR, "/g=" );
            contok = FALSE;
        }
        p = strtok( NULL, delims );
        if( p != NULL ) {
//            replen = strlen( p );
            strcpy( &frStrings->buf[findlen+1], p );
            frStrings->replaceString = &frStrings->buf[findlen+1];
        } else {
            RcError( ERR_SYNTAX_STR, frStrings->findString  );
            contok = FALSE;
        }
        frStrings->next = CmdLineParms.FindReplaceStrings;
        CmdLineParms.FindReplaceStrings = frStrings;
        CmdLineParms.FindAndReplace = TRUE;
        RcMemFree( temp );
        break;
    case 'i':
        arg++;
        if( *arg == '=' )
            arg++;
        temp = RcMemMalloc( _MAX_PATH );
        if( scanString( temp, arg, _MAX_PATH  ) ) {
            RcError( ERR_UNMATCHED_QUOTE_ON_CMD_LINE );
        }
        PP_AddIncludePath( temp );
        RcMemFree( temp );
        break;
    case 'o':
        CmdLineParms.PreprocessOnly = TRUE;
        break;
    case 's':
        arg++;
        switch( tolower( *arg ) ) {
        case '0':
            CmdLineParms.SegmentSorting = SEG_SORT_NONE;
            break;
        case '1':
            CmdLineParms.SegmentSorting = SEG_SORT_PRELOAD_ONLY;
            break;
        case '2':
            CmdLineParms.SegmentSorting = SEG_SORT_MANY;
            break;
        }
        break;
    case 'w':
        arg++;
        if( *arg == 'r' ) {
//          CmdLineParms.WritableRes = TRUE;
        }
        break;
#if defined(YYDEBUG) || defined(SCANDEBUG)
    case 'v':
        arg++;
        switch( tolower( *arg ) ) {
    #if defined(YYDEBUG)
        case '1':
            CmdLineParms.DebugParser = 1;
            break;
    #endif
    #if defined(YYDEBUG) && defined(SCANDEBUG)
        case '2':
            CmdLineParms.DebugParser = 1;
            CmdLineParms.DebugScanner = 1;
            break;
        case '3':
            CmdLineParms.DebugScanner = 1;
            break;
    #endif
    #if defined(SCANDEBUG)
        default:
            CmdLineParms.DebugScanner = 1;
            break;
    #endif
        }
        break;
#endif
    case 'x':
        arg++;
        if( tolower( *arg ) == 'b' ) {
            CmdLineParms.NoTargetDefine = TRUE;
        } else if( tolower( *arg ) == 'c' ) {
            CmdLineParms.IgnoreCWD = TRUE;
        } else {
            CmdLineParms.IgnoreINCLUDE = TRUE;
        }
        break;
    case 'z':
        arg++;
        switch( tolower( *arg ) ) {
        case 'm':
            CmdLineParms.MSResFormat = TRUE;
            break;
        case 'n':
            CmdLineParms.NoPreprocess = TRUE;
            break;
        /*
            Lead-byte and trail-byte ranges for code pages used in Far East
            editions of Windows 95.

                        Character           Code    Lead-Byte   Trail-Byte
        Language        Set Name            Page    Ranges      Ranges

        Chinese
        (Simplified)    GB 2312-80          CP 936  0xA1-0xFE   0xA1-0xFE

        Chinese
        (Traditional)   Big-5               CP 950  0x81-0xFE   0x40-0x7E
                                                                0xA1-0xFE

        Japanese        Shift-JIS (Japan
                        Industry Standard)  CP 932  0x81-0x9F   0x40-0xFC
                                                    0xE0-0xFC   (except 0x7F)

        Korean
        (Wansung)       KS C-5601-1987      CP 949  0x81-0xFE   0x41-0x5A
                                                                0x61-0x7A
                                                                0x81-0xFE

        Korean
        (Johab)         KS C-5601-1992      CP 1361 0x84-0xD3   0x41-0x7E
                                                    0xD8        0x81-0xFE
                                                    0xD9-0xDE   (Government
                                                    0xE0-0xF9   standard:
                                                                0x31-0x7E
                                                                0x41-0xFE)
        */
        case 'k':
            arg++;
            switch( tolower( *arg ) ) {
            case '1':
                SetMBRange( 0x81, 0xfe, 1 );
                CmdLineParms.MBCharSupport = DB_TRADITIONAL_CHINESE;
                break;
            case '2':
                SetMBRange( 0x81, 0xfe, 1 );
                CmdLineParms.MBCharSupport = DB_WANSUNG_KOREAN;
                break;
            case '3':
                SetMBRange( 0xA1, 0xfe, 1 );
                CmdLineParms.MBCharSupport = DB_SIMPLIFIED_CHINESE;
                break;
            case '0':
            case ' ':
            case '\0':
                SetMBRange( 0x81, 0x9f, 1 );
                SetMBRange( 0xe0, 0xfc, 1 );
                CmdLineParms.MBCharSupport = DB_KANJI;
                break;
            case 'u':
                if( arg[1] == '8' ) {
                    arg++;
                    SetMBRange( 0xc0, 0xdf, 1 );
                    SetMBRange( 0xe0, 0xef, 2 );
                    SetMBRange( 0xf0, 0xf7, 3 );
                    SetMBRange( 0xf8, 0xfb, 4 );
                    SetMBRange( 0xfc, 0xfd, 5 );
                    CmdLineParms.MBCharSupport = MB_UTF8;
                    break;
                }
                // fall down
            default:
                RcError( ERR_UNKNOWN_MULT_OPTION, arg - 2 );
                contok = FALSE;
                break;
            }
            break;
        default:
            RcError( ERR_UNKNOWN_MULT_OPTION, arg - 1 );
            contok = FALSE;
            break;
        }
        break;
    default:            /* option that could have others with it */
        contok = ScanMultiOptArg( arg ) && contok;
        break;
    }
    return( contok );
} /* ScanOptionsArg */