Changeset 80 in dev for ProjectEditor/SubOperation.cpp


Ignore:
Timestamp:
Mar 26, 2007, 6:33:06 AM (17 years ago)
Author:
dai_9181
Message:

TheText用のリソースを追加。
単語単位での検索を可能にした。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ProjectEditor/SubOperation.cpp

    r69 r80  
    183183}
    184184
    185 char *ComparisonString(char *str1,char *str2,BOOL bBigSmall){
    186     int i,i2,i3,len1,len2;
    187     len1=lstrlen(str1);
    188     len2=lstrlen(str2);
    189     for(i=0;i<len1-len2+1;i++){
    190         for(i2=0,i3=i;i2<len2;i2++,i3++){
    191             if(bBigSmall){
    192                 if(str1[i3]!=str2[i2]) break;
     185char *ComparisonString( char *str1, char *str2, bool isBigSmall, bool isWordUnit ){
     186    char *temp1 = (char *)malloc( lstrlen( str1 ) +1 );
     187    char *temp2 = (char *)malloc( lstrlen( str2 ) +1 );
     188
     189    lstrcpy( temp1, str1 );
     190    lstrcpy( temp2, str2 );
     191
     192    if( isBigSmall == false ){
     193        // 大文字小文字を区別しない場合
     194        // すべて大文字にしておく
     195        CharUpper( temp1 );
     196        CharUpper( temp2 );
     197    }
     198
     199    int len2 = lstrlen( temp2 );
     200
     201    const char *temp3 = strstr( temp1, temp2 );
     202    while( temp3 ){
     203        if( isWordUnit ){
     204            int pos = (int)temp3 - (int)temp1;
     205            if( pos == 0 ){
     206                if( !IsVariableChar( temp1[len2] ) ){
     207                        break;
     208                }
    193209            }
    194210            else{
    195                 if((char)CharUpper((LPTSTR)MAKELONG(str1[i3],0))!=(char)CharUpper((LPTSTR)MAKELONG(str2[i2],0))) break;
    196             }
    197         }
    198         if(IsDBCSLeadByte(str1[i])) i++;
    199         if(i2==len2) return str1+i3-i2;
    200     }
    201     return 0;
     211                if( !IsVariableChar( temp1[pos-1] )
     212                    && !IsVariableChar( temp1[pos+len2] ) ){
     213                        break;
     214                }
     215            }
     216        }
     217        else{
     218            break;
     219        }
     220
     221        temp3 = strstr( temp3 + 1, temp2 );
     222    }
     223
     224    char *result = NULL;
     225    if( temp3 ){
     226        int pos = (int)temp3 - (int)temp1;
     227        result = str1 + pos;
     228    }
     229
     230    free( temp1 );
     231    free( temp2 );
     232
     233    return result;
    202234}
    203235int GetOneParameter(char *Parameter,int pos,char *retAns){
     
    14691501    return 1;
    14701502}
     1503
     1504string GetLastErrorString(){
     1505    char *lpMsgBuf;
     1506
     1507    FormatMessage(
     1508        FORMAT_MESSAGE_ALLOCATE_BUFFER |
     1509        FORMAT_MESSAGE_FROM_SYSTEM |
     1510        FORMAT_MESSAGE_IGNORE_INSERTS,
     1511        NULL,
     1512        GetLastError(),
     1513        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // デフォルト言語
     1514        (LPTSTR) &lpMsgBuf,
     1515        0,
     1516        NULL
     1517    );
     1518
     1519    string result = lpMsgBuf;
     1520
     1521    LocalFree( lpMsgBuf );
     1522
     1523    return result;
     1524}
Note: See TracChangeset for help on using the changeset viewer.