[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[4] | 3 | void KillSpaces(char *str1,char *str2){
|
---|
| 4 | int i,i2,i3,IsStr;
|
---|
| 5 | for(i=0,i2=0,IsStr=0;;i++,i2++){
|
---|
| 6 | if((str1[i]==' '||str1[i]=='\t')&&IsStr==0){
|
---|
| 7 | i3=i+1;
|
---|
| 8 | while(str1[i3]==' '||str1[i3]=='\t') i3++;
|
---|
| 9 | if(i!=0){
|
---|
| 10 | if(i==1){
|
---|
| 11 | if(IsVariableChar(str1[i-1])&&
|
---|
| 12 | IsVariableChar(str1[i3])){
|
---|
| 13 | //識別子間にある省略すべきでない空白
|
---|
| 14 | str2[i2++]=' ';
|
---|
| 15 | }
|
---|
| 16 | }
|
---|
| 17 | else{
|
---|
| 18 | if(str1[i-2]!=1&&IsVariableChar(str1[i-1])&&
|
---|
| 19 | IsVariableChar(str1[i3])){
|
---|
| 20 | //識別子間にある省略すべきでない空白
|
---|
| 21 | str2[i2++]=' ';
|
---|
| 22 | }
|
---|
| 23 | }
|
---|
| 24 | }
|
---|
| 25 | i=i3;
|
---|
| 26 | }
|
---|
| 27 | if(str1[i]=='\"') IsStr^=1;
|
---|
| 28 | str2[i2]=str1[i];
|
---|
| 29 | if(str1[i]=='\0') break;
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
| 32 | void KillStringSpaces(char *str){
|
---|
| 33 | char *s2;
|
---|
| 34 |
|
---|
| 35 | extern HANDLE hHeap;
|
---|
| 36 | s2=(char *)HeapAlloc(hHeap,0,lstrlen(str)+1);
|
---|
| 37 | lstrcpy(s2,str);
|
---|
| 38 | KillSpaces(s2,str);
|
---|
| 39 | HeapDefaultFree(s2);
|
---|
| 40 | return;
|
---|
| 41 | }
|
---|
| 42 | BOOL RemoveStringQuotes(char *str){
|
---|
| 43 | int i;
|
---|
| 44 | if(str[0]!='\"') return 0;
|
---|
| 45 | for(i=0;;i++){
|
---|
| 46 | str[i]=str[i+1];
|
---|
| 47 | if(str[i]=='\"') break;
|
---|
| 48 | }
|
---|
| 49 | str[i]=0;
|
---|
| 50 | if(str[i+2]!='\0') return 0;
|
---|
| 51 | return 1;
|
---|
| 52 | }
|
---|
[387] | 53 | bool RemoveStringQuotes( std::string &str )
|
---|
| 54 | {
|
---|
| 55 | if( str[0] != '\"' )
|
---|
| 56 | {
|
---|
| 57 | return false;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | str = str.substr( 1, str.length() - 2 );
|
---|
| 61 | return true;
|
---|
| 62 | }
|
---|
[4] | 63 | void RemoveStringPare(char *str){
|
---|
| 64 | int i;
|
---|
| 65 | i=lstrlen(str);
|
---|
| 66 | if(str[0]!='('||str[i-1]!=')') return;
|
---|
| 67 | SlideString(str+1,-1);
|
---|
| 68 | str[i-2]=0;
|
---|
| 69 | }
|
---|
| 70 | void RemoveStringBracket(char *str){
|
---|
| 71 | int i;
|
---|
| 72 | i=lstrlen(str);
|
---|
| 73 | if(str[0]!='['||str[i-1]!=']') return;
|
---|
| 74 | SlideString(str+1,-1);
|
---|
| 75 | str[i-2]=0;
|
---|
| 76 | }
|
---|
| 77 | void SetStringQuotes(char *str){
|
---|
| 78 | int i;
|
---|
| 79 | if(str[0]=='\"') return;
|
---|
| 80 | i=lstrlen(str);
|
---|
| 81 | SlideString(str,1);
|
---|
| 82 | str[0]='\"';
|
---|
| 83 | str[i+1]='\"';
|
---|
| 84 | str[i+2]=0;
|
---|
| 85 | }
|
---|
| 86 | int FormatString_EscapeSequence(char *buffer){
|
---|
| 87 | int i2,i3,i4;
|
---|
| 88 |
|
---|
| 89 | for(i2=0,i3=0;;i2++,i3++){
|
---|
| 90 | if(IsDBCSLeadByte(buffer[i3])){
|
---|
| 91 | buffer[i2++]=buffer[i3++];
|
---|
| 92 | buffer[i2]=buffer[i3];
|
---|
| 93 | if(buffer[i3]=='\0') break;
|
---|
| 94 | continue;
|
---|
| 95 | }
|
---|
| 96 | if(buffer[i3]=='\\'){
|
---|
| 97 | switch(buffer[i3+1]){
|
---|
| 98 | case '\\':
|
---|
| 99 | buffer[i2]='\\';
|
---|
| 100 | i3++;
|
---|
| 101 | break;
|
---|
| 102 | case '0':
|
---|
| 103 | buffer[i2]='\0';
|
---|
| 104 | i3++;
|
---|
| 105 | break;
|
---|
| 106 | case 'n':
|
---|
| 107 | buffer[i2]='\n';
|
---|
| 108 | i3++;
|
---|
| 109 | break;
|
---|
| 110 | case 'q':
|
---|
| 111 | buffer[i2]='\"';
|
---|
| 112 | i3++;
|
---|
| 113 | break;
|
---|
| 114 | case 'r':
|
---|
| 115 | buffer[i2]='\r';
|
---|
| 116 | i3++;
|
---|
| 117 | break;
|
---|
| 118 | case 't':
|
---|
| 119 | buffer[i2]='\t';
|
---|
| 120 | i3++;
|
---|
| 121 | break;
|
---|
| 122 | case 'x':
|
---|
| 123 | //16進表記
|
---|
| 124 | char temporary[8];
|
---|
| 125 | temporary[0]=buffer[i3+2];
|
---|
| 126 | temporary[1]=buffer[i3+3];
|
---|
| 127 | temporary[2]=0;
|
---|
| 128 | CharUpper(temporary);
|
---|
| 129 |
|
---|
| 130 | i4=temporary[0]-0x30;
|
---|
| 131 | if(i4<0||9<i4){
|
---|
| 132 | i4=temporary[0]-0x41+10;
|
---|
| 133 | if(i4<0xA||0xF<i4){
|
---|
| 134 | buffer[i2]=buffer[i3];
|
---|
| 135 | break;
|
---|
| 136 | }
|
---|
| 137 | }
|
---|
| 138 | temporary[0]=i4;
|
---|
| 139 |
|
---|
| 140 | i4=temporary[1]-0x30;
|
---|
| 141 | if(i4<0||9<i4){
|
---|
| 142 | i4=temporary[1]-0x41+10;
|
---|
| 143 | if(i4<0xA||0xF<i4){
|
---|
| 144 | buffer[i2]=buffer[i3];
|
---|
| 145 | break;
|
---|
| 146 | }
|
---|
| 147 | }
|
---|
| 148 | temporary[1]=i4;
|
---|
| 149 |
|
---|
| 150 | buffer[i2]=temporary[0]*0x10+temporary[1];
|
---|
| 151 | i3+=3;
|
---|
| 152 | break;
|
---|
| 153 | default:
|
---|
| 154 | buffer[i2]=buffer[i3];
|
---|
| 155 | break;
|
---|
| 156 | }
|
---|
| 157 | }
|
---|
| 158 | else{
|
---|
| 159 | buffer[i2]=buffer[i3];
|
---|
| 160 | if(buffer[i3]=='\0') break;
|
---|
| 161 | }
|
---|
| 162 | }
|
---|
| 163 | return i2;
|
---|
| 164 | }
|
---|
| 165 | void SlideString(char *buffer, int slide){
|
---|
[727] | 166 | Text::SlideString(buffer,slide);
|
---|
[4] | 167 | }
|
---|
| 168 | void SlideBuffer(char *buffer,int length,int slide){
|
---|
[727] | 169 | memmove(buffer+slide,buffer,length);
|
---|
[4] | 170 | }
|
---|
[77] | 171 |
|
---|
[313] | 172 | int GetSourceCodeIndexFromLine( const char *source, int LineNum ){
|
---|
[4] | 173 | int i,nCount=0;
|
---|
| 174 | for(i=0;;i++){
|
---|
[313] | 175 | if(source[i]=='\n'){
|
---|
[4] | 176 | nCount++;
|
---|
| 177 | if(LineNum==nCount){
|
---|
| 178 | for(i++;;i++){
|
---|
[313] | 179 | if(IsCommandDelimitation(source[i])) break;
|
---|
[4] | 180 | }
|
---|
| 181 | return i;
|
---|
| 182 | }
|
---|
| 183 | }
|
---|
| 184 | }
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | char GetEndXXXCommand(char es){
|
---|
| 188 | switch(es){
|
---|
| 189 | case ESC_SUB:
|
---|
| 190 | return ESC_ENDSUB;
|
---|
| 191 | case ESC_FUNCTION:
|
---|
| 192 | return ESC_ENDFUNCTION;
|
---|
| 193 | case ESC_MACRO:
|
---|
| 194 | return ESC_ENDMACRO;
|
---|
| 195 | case ESC_TYPE:
|
---|
| 196 | return ESC_ENDTYPE;
|
---|
| 197 | case ESC_CLASS:
|
---|
| 198 | return ESC_ENDCLASS;
|
---|
| 199 | case ESC_INTERFACE:
|
---|
| 200 | return ESC_ENDINTERFACE;
|
---|
| 201 | case ESC_ENUM:
|
---|
| 202 | return ESC_ENDENUM;
|
---|
| 203 | }
|
---|
| 204 | return 0;
|
---|
| 205 | }
|
---|
| 206 | void GetDefaultNameFromES(char es,char *name){
|
---|
| 207 | name[0]=0;
|
---|
| 208 | switch(es){
|
---|
| 209 | case ESC_PSMEM:
|
---|
| 210 | lstrcpy(name,"->");
|
---|
| 211 | break;
|
---|
| 212 | case ESC_MOD:
|
---|
| 213 | lstrcpy(name,"Mod");
|
---|
| 214 | break;
|
---|
| 215 | case ESC_AND:
|
---|
| 216 | lstrcpy(name,"And");
|
---|
| 217 | break;
|
---|
| 218 | case ESC_OR:
|
---|
| 219 | lstrcpy(name,"Or");
|
---|
| 220 | break;
|
---|
| 221 | case ESC_XOR:
|
---|
| 222 | lstrcpy(name,"Xor");
|
---|
| 223 | break;
|
---|
| 224 | case ESC_NOT:
|
---|
| 225 | lstrcpy(name,"Not");
|
---|
| 226 | break;
|
---|
| 227 | case ESC_AS:
|
---|
| 228 | lstrcpy(name,"As");
|
---|
| 229 | break;
|
---|
| 230 | case ESC_THEN:
|
---|
| 231 | lstrcpy(name,"Then");
|
---|
| 232 | break;
|
---|
| 233 | case ESC_ELSE:
|
---|
| 234 | lstrcpy(name,"Else");
|
---|
| 235 | break;
|
---|
| 236 | case ESC_IF:
|
---|
| 237 | lstrcpy(name,"If");
|
---|
| 238 | break;
|
---|
| 239 | case ESC_ELSEIF:
|
---|
| 240 | lstrcpy(name,"ElseIf");
|
---|
| 241 | break;
|
---|
| 242 | case ESC_ENDIF:
|
---|
| 243 | lstrcpy(name,"End If");
|
---|
| 244 | break;
|
---|
| 245 | case ESC_DEF:
|
---|
| 246 | lstrcpy(name,"Def");
|
---|
| 247 | break;
|
---|
| 248 | case ESC_DECLARE:
|
---|
| 249 | lstrcpy(name,"Declare");
|
---|
| 250 | break;
|
---|
| 251 | case ESC_ABSTRACT:
|
---|
| 252 | lstrcpy(name,"Abstract");
|
---|
| 253 | break;
|
---|
| 254 | case ESC_VIRTUAL:
|
---|
| 255 | lstrcpy(name,"Virtual");
|
---|
| 256 | break;
|
---|
| 257 | case ESC_OVERRIDE:
|
---|
| 258 | lstrcpy(name,"Override");
|
---|
| 259 | break;
|
---|
| 260 | case ESC_SUB:
|
---|
| 261 | lstrcpy(name,"Sub");
|
---|
| 262 | break;
|
---|
| 263 | case ESC_ENDSUB:
|
---|
| 264 | lstrcpy(name,"End Sub");
|
---|
| 265 | break;
|
---|
| 266 | case ESC_EXITSUB:
|
---|
| 267 | lstrcpy(name,"Exit Sub");
|
---|
| 268 | break;
|
---|
| 269 | case ESC_FUNCTION:
|
---|
| 270 | lstrcpy(name,"Function");
|
---|
| 271 | break;
|
---|
| 272 | case ESC_ENDFUNCTION:
|
---|
| 273 | lstrcpy(name,"End Function");
|
---|
| 274 | break;
|
---|
| 275 | case ESC_EXITFUNCTION:
|
---|
| 276 | lstrcpy(name,"Exit Function");
|
---|
| 277 | break;
|
---|
| 278 | case ESC_BYVAL:
|
---|
| 279 | lstrcpy(name,"ByVal ");
|
---|
| 280 | break;
|
---|
| 281 | case ESC_BYREF:
|
---|
| 282 | lstrcpy(name,"ByRef ");
|
---|
| 283 | break;
|
---|
| 284 | case ESC_TYPE:
|
---|
| 285 | lstrcpy(name,"Type");
|
---|
| 286 | break;
|
---|
| 287 | case ESC_ENDTYPE:
|
---|
| 288 | lstrcpy(name,"End Type");
|
---|
| 289 | break;
|
---|
| 290 | case ESC_EXITFOR:
|
---|
| 291 | lstrcpy(name,"Exit For");
|
---|
| 292 | break;
|
---|
| 293 | case ESC_EXITWHILE:
|
---|
| 294 | lstrcpy(name,"Exit While");
|
---|
| 295 | break;
|
---|
| 296 | case ESC_EXITDO:
|
---|
| 297 | lstrcpy(name,"Exit Do");
|
---|
| 298 | break;
|
---|
| 299 | case ESC_SELECTCASE:
|
---|
| 300 | lstrcpy(name,"Select Case");
|
---|
| 301 | break;
|
---|
| 302 | case ESC_CASE:
|
---|
| 303 | lstrcpy(name,"Case");
|
---|
| 304 | break;
|
---|
| 305 | case ESC_CASEELSE:
|
---|
| 306 | lstrcpy(name,"Case Else");
|
---|
| 307 | break;
|
---|
| 308 | case ESC_ENDSELECT:
|
---|
| 309 | lstrcpy(name,"End Select");
|
---|
| 310 | break;
|
---|
| 311 | case ESC_CONST:
|
---|
| 312 | lstrcpy(name,"Const");
|
---|
| 313 | break;
|
---|
| 314 | case ESC_TYPEDEF:
|
---|
| 315 | lstrcpy(name,"TypeDef");
|
---|
| 316 | break;
|
---|
| 317 | case ESC_WITH:
|
---|
| 318 | lstrcpy(name,"With");
|
---|
| 319 | break;
|
---|
| 320 | case ESC_ENDWITH:
|
---|
| 321 | lstrcpy(name,"End With");
|
---|
| 322 | break;
|
---|
| 323 | case ESC_CDECL:
|
---|
| 324 | lstrcpy(name,"cdecl");
|
---|
| 325 | break;
|
---|
| 326 | case ESC_MACRO:
|
---|
| 327 | lstrcpy(name,"Macro");
|
---|
| 328 | break;
|
---|
| 329 | case ESC_ENDMACRO:
|
---|
| 330 | lstrcpy(name,"End Macro");
|
---|
| 331 | break;
|
---|
| 332 | case ESC_EXITMACRO:
|
---|
| 333 | lstrcpy(name,"Exit Macro");
|
---|
| 334 | break;
|
---|
| 335 | case ESC_EXPORT:
|
---|
| 336 | lstrcpy(name,"Export");
|
---|
| 337 | break;
|
---|
| 338 | case ESC_CONTINUE:
|
---|
| 339 | lstrcpy(name,"Continue");
|
---|
| 340 | break;
|
---|
| 341 | case ESC_CLASS:
|
---|
| 342 | lstrcpy(name,"Class");
|
---|
| 343 | break;
|
---|
| 344 | case ESC_ENDCLASS:
|
---|
| 345 | lstrcpy(name,"End Class");
|
---|
| 346 | break;
|
---|
| 347 | case ESC_INTERFACE:
|
---|
| 348 | lstrcpy(name,"Interface");
|
---|
| 349 | break;
|
---|
| 350 | case ESC_ENDINTERFACE:
|
---|
| 351 | lstrcpy(name,"End Interface");
|
---|
| 352 | break;
|
---|
| 353 | case ESC_ENUM:
|
---|
| 354 | lstrcpy(name,"Enum");
|
---|
| 355 | break;
|
---|
| 356 | case ESC_ENDENUM:
|
---|
| 357 | lstrcpy(name,"End Enum");
|
---|
| 358 | break;
|
---|
[632] | 359 | case ESC_OPERATOR:
|
---|
| 360 | lstrcpy( name, "Operator" );
|
---|
| 361 | break;
|
---|
[4] | 362 | }
|
---|
| 363 | }
|
---|
[206] | 364 | const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source )
|
---|
| 365 | {
|
---|
| 366 | int maxLength = (int)source.size();
|
---|
[4] | 367 |
|
---|
[206] | 368 | char *temporary = (char *)malloc( source.size() + 8192 );
|
---|
| 369 | lstrcpy( temporary, source.c_str() );
|
---|
[4] | 370 |
|
---|
[206] | 371 | for( int i=0; i<maxLength-1; i++ )
|
---|
| 372 | {
|
---|
| 373 | if( temporary[i] == 1 )
|
---|
| 374 | {
|
---|
[632] | 375 | int esc = temporary[i+1];
|
---|
[206] | 376 | char temp2[255];
|
---|
[632] | 377 | GetDefaultNameFromES( esc, temp2 );
|
---|
[206] | 378 | if( i>0 )
|
---|
| 379 | {
|
---|
| 380 | char temp3[255];
|
---|
| 381 | wsprintf( temp3, " %s", temp2 );
|
---|
| 382 | lstrcpy( temp2, temp3 );
|
---|
| 383 | }
|
---|
| 384 | if( i<maxLength-2 )
|
---|
| 385 | {
|
---|
| 386 | lstrcat( temp2, " " );
|
---|
| 387 | }
|
---|
[4] | 388 |
|
---|
[632] | 389 | int slide = 2;
|
---|
| 390 |
|
---|
| 391 | if( esc == ESC_OPERATOR )
|
---|
| 392 | {
|
---|
[736] | 393 | extern char const *calcNames[256];
|
---|
[644] | 394 | unsigned char calcId = temporary[i+2];
|
---|
[632] | 395 | if( calcNames[calcId] )
|
---|
| 396 | {
|
---|
| 397 | lstrcat( temp2, calcNames[calcId] );
|
---|
| 398 | }
|
---|
| 399 | slide = 3;
|
---|
| 400 | }
|
---|
| 401 |
|
---|
[206] | 402 | int length = lstrlen( temp2 );
|
---|
[632] | 403 | SlideString( temporary + i+slide, length-slide );
|
---|
[206] | 404 | memcpy( temporary + i, temp2, length );
|
---|
| 405 | maxLength = lstrlen( temporary );
|
---|
| 406 | }
|
---|
[4] | 407 | }
|
---|
[206] | 408 |
|
---|
[727] | 409 | static std::string resultStr = temporary;
|
---|
[206] | 410 |
|
---|
| 411 | free( temporary );
|
---|
| 412 |
|
---|
| 413 | return resultStr;
|
---|
[4] | 414 | }
|
---|
| 415 |
|
---|
[279] | 416 | bool IsFileExist(const char *path){
|
---|
[4] | 417 | WIN32_FIND_DATA wfd;
|
---|
| 418 | HANDLE hFind;
|
---|
| 419 |
|
---|
| 420 | hFind=FindFirstFile(path,&wfd);
|
---|
| 421 | if(hFind==INVALID_HANDLE_VALUE){
|
---|
[279] | 422 | return false;
|
---|
[4] | 423 | }
|
---|
| 424 | FindClose(hFind);
|
---|
| 425 |
|
---|
[279] | 426 | return true;
|
---|
[4] | 427 | }
|
---|
| 428 | BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle){
|
---|
| 429 | BROWSEINFO BrowseInfo;
|
---|
| 430 | LPITEMIDLIST pidlBrowse;
|
---|
| 431 | char temporary[MAX_PATH];
|
---|
| 432 |
|
---|
| 433 | BrowseInfo.hwndOwner=hWnd;
|
---|
| 434 | BrowseInfo.pszDisplayName=temporary;
|
---|
| 435 | BrowseInfo.pidlRoot=NULL;
|
---|
| 436 | BrowseInfo.lpszTitle=OpenFolderTitle;
|
---|
| 437 | BrowseInfo.ulFlags=BIF_RETURNONLYFSDIRS;
|
---|
| 438 | BrowseInfo.lpfn=NULL;
|
---|
| 439 | BrowseInfo.lParam=(LPARAM)0;
|
---|
| 440 | BrowseInfo.iImage=0;
|
---|
| 441 | pidlBrowse=SHBrowseForFolder(&BrowseInfo);
|
---|
| 442 | if(pidlBrowse){
|
---|
[727] | 443 | BOOL ret = SHGetPathFromIDList(pidlBrowse,folder);
|
---|
| 444 | CoTaskMemFree(pidlBrowse);
|
---|
| 445 | return ret;
|
---|
[4] | 446 | }
|
---|
| 447 | return 0;
|
---|
| 448 | }
|
---|
[31] | 449 |
|
---|
| 450 | void ShortPathToLongPath(const char *ShortPath,char *LongPath){
|
---|
| 451 | HANDLE hFind;
|
---|
| 452 | WIN32_FIND_DATA wfd;
|
---|
| 453 | int i;
|
---|
| 454 | char dummy[MAX_PATH];
|
---|
| 455 | for(i=0;i<MAX_PATH;i++){
|
---|
| 456 | LongPath[i]=ShortPath[i];
|
---|
| 457 | if((ShortPath[i-1]==':'&&ShortPath[i]=='\\')||(ShortPath[i-1]=='\\'&&ShortPath[i]=='\\')){
|
---|
| 458 | LongPath[i+1]=0;
|
---|
| 459 | break;
|
---|
| 460 | }
|
---|
| 461 | }
|
---|
| 462 | if(ShortPath[i-1]=='\\'&&ShortPath[i]=='\\'){
|
---|
| 463 | for(i++;i<MAX_PATH;i++){
|
---|
| 464 | if(IsDBCSLeadByte(ShortPath[i])){
|
---|
| 465 | i++;
|
---|
| 466 | continue;
|
---|
| 467 | }
|
---|
| 468 | LongPath[i]=ShortPath[i];
|
---|
| 469 | if(ShortPath[i]=='\\'){
|
---|
| 470 | LongPath[i+1]=0;
|
---|
| 471 | break;
|
---|
| 472 | }
|
---|
| 473 | }
|
---|
| 474 | for(i++;i<MAX_PATH;i++){
|
---|
| 475 | if(IsDBCSLeadByte(ShortPath[i])){
|
---|
| 476 | i++;
|
---|
| 477 | continue;
|
---|
| 478 | }
|
---|
| 479 | LongPath[i]=ShortPath[i];
|
---|
| 480 | if(ShortPath[i]=='\\'){
|
---|
| 481 | LongPath[i+1]=0;
|
---|
| 482 | break;
|
---|
| 483 | }
|
---|
| 484 | }
|
---|
| 485 | }
|
---|
| 486 | for(i++;i<MAX_PATH;i++){
|
---|
| 487 | if(IsDBCSLeadByte(ShortPath[i])){
|
---|
| 488 | i++;
|
---|
| 489 | continue;
|
---|
| 490 | }
|
---|
| 491 | if(ShortPath[i]=='\\'||ShortPath[i]=='\0'){
|
---|
| 492 | strncpy(dummy,ShortPath,i);
|
---|
| 493 | dummy[i]=0;
|
---|
| 494 | if((hFind=FindFirstFile(dummy,&wfd))!=INVALID_HANDLE_VALUE) FindClose(hFind);
|
---|
| 495 | lstrcat(LongPath,wfd.cFileName);
|
---|
| 496 |
|
---|
| 497 | if(ShortPath[i]=='\0') break;
|
---|
| 498 | lstrcat(LongPath,"\\");
|
---|
| 499 |
|
---|
| 500 | if(ShortPath[i]=='\\'&&ShortPath[i+1]=='\0'){
|
---|
| 501 | break;
|
---|
| 502 | }
|
---|
| 503 | }
|
---|
| 504 | }
|
---|
| 505 | }
|
---|
[400] | 506 |
|
---|
| 507 |
|
---|
| 508 | bool IsVariableTopChar(char c){
|
---|
| 509 | if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||c=='_')
|
---|
| 510 | {
|
---|
| 511 | return true;
|
---|
| 512 | }
|
---|
| 513 | return false;
|
---|
| 514 | }
|
---|
| 515 | bool IsVariableChar( char c, bool isGenericsChars ){
|
---|
| 516 | if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||
|
---|
| 517 | c=='%'||c=='!'||c=='#'||c=='$'||
|
---|
| 518 | c=='_'||c=='.')
|
---|
| 519 | {
|
---|
| 520 | return true;
|
---|
| 521 | }
|
---|
| 522 |
|
---|
| 523 | if( isGenericsChars )
|
---|
| 524 | {
|
---|
| 525 | if( c == '<' || c == '>' )
|
---|
| 526 | {
|
---|
| 527 | return true;
|
---|
| 528 | }
|
---|
| 529 | }
|
---|
| 530 |
|
---|
| 531 | return false;
|
---|
| 532 | }
|
---|
| 533 | bool IsBlank(char c){
|
---|
| 534 | if(c==' '||c=='\t') return 1;
|
---|
| 535 | return 0;
|
---|
| 536 | }
|
---|
| 537 | int GetOneParameter(const char *Parameter,int pos,char *retAns){
|
---|
| 538 | int i,i2,i3,IsStr;
|
---|
| 539 | for(i=pos,i2=0,IsStr=0;;i++,i2++){
|
---|
| 540 | if(Parameter[i]=='\"') IsStr^=1;
|
---|
| 541 | else if(Parameter[i]=='('&&IsStr==0){
|
---|
| 542 | i3=GetStringInPare(retAns+i2,Parameter+i);
|
---|
| 543 | i+=i3-1;
|
---|
| 544 | i2+=i3-1;
|
---|
| 545 | continue;
|
---|
| 546 | }
|
---|
| 547 | else if(Parameter[i]=='['&&IsStr==0){
|
---|
| 548 | i3=GetStringInBracket(retAns+i2,Parameter+i);
|
---|
| 549 | i+=i3-1;
|
---|
| 550 | i2+=i3-1;
|
---|
| 551 | continue;
|
---|
| 552 | }
|
---|
| 553 | else if(Parameter[i]==','&&IsStr==0){
|
---|
| 554 | retAns[i2]=0;
|
---|
| 555 | i++;
|
---|
| 556 | break;
|
---|
| 557 | }
|
---|
| 558 |
|
---|
| 559 | if(IsCommandDelimitation(Parameter[i])&&IsStr==0
|
---|
| 560 | || Parameter[i] == ')' && IsStr == 0 ){
|
---|
| 561 | retAns[i2]=0;
|
---|
| 562 | break;
|
---|
| 563 | }
|
---|
| 564 |
|
---|
| 565 | retAns[i2]=Parameter[i];
|
---|
| 566 | }
|
---|
| 567 | return i;
|
---|
| 568 | }
|
---|
| 569 | int JumpOneParameter(char *Parameter,int i){
|
---|
| 570 | int i2,IsStr;
|
---|
| 571 | for(i2=0,IsStr=0;;i++,i2++){
|
---|
| 572 | if(Parameter[i]=='\"') IsStr^=1;
|
---|
| 573 | else if(Parameter[i]=='('&&IsStr==0){
|
---|
| 574 | i=JumpStringInPare(Parameter,i+1);
|
---|
| 575 | continue;
|
---|
| 576 | }
|
---|
| 577 | else if(Parameter[i]=='['&&IsStr==0){
|
---|
| 578 | i=JumpStringInBracket(Parameter,i+1);
|
---|
| 579 | continue;
|
---|
| 580 | }
|
---|
| 581 | else if(Parameter[i]==','&&IsStr==0){
|
---|
| 582 | i++;
|
---|
| 583 | break;
|
---|
| 584 | }
|
---|
| 585 | if(IsCommandDelimitation(Parameter[i])) break;
|
---|
| 586 | }
|
---|
| 587 | return i;
|
---|
| 588 | }
|
---|
| 589 | int GetStringInQuotation(char *buffer,char *ReadBuffer){
|
---|
| 590 | int i;
|
---|
| 591 |
|
---|
| 592 | if(ReadBuffer[0]=='\"'){
|
---|
| 593 | buffer[0]=ReadBuffer[0];
|
---|
| 594 | i=1;
|
---|
| 595 | }
|
---|
| 596 | else i=0;
|
---|
| 597 |
|
---|
| 598 | for(;;i++){
|
---|
| 599 | buffer[i]=ReadBuffer[i];
|
---|
| 600 | if(IsDBCSLeadByte(ReadBuffer[i])){
|
---|
| 601 | i++;
|
---|
| 602 | buffer[i]=ReadBuffer[i];
|
---|
| 603 | continue;
|
---|
| 604 | }
|
---|
| 605 | if(ReadBuffer[i]=='\"'){
|
---|
| 606 | i++;
|
---|
| 607 | buffer[i]=0;
|
---|
| 608 | break;
|
---|
| 609 | }
|
---|
| 610 | if(ReadBuffer[i]=='\0') return 0;
|
---|
| 611 | }
|
---|
| 612 | return i;
|
---|
| 613 | }
|
---|
| 614 | int GetStringInPare( char *buffer, const char *ReadBuffer, bool isRemovePare ){
|
---|
| 615 | int i,IsStr,PareNum;
|
---|
| 616 | for(i=0,IsStr=0,PareNum=0;;i++){
|
---|
| 617 | buffer[i]=ReadBuffer[i];
|
---|
| 618 | if(IsDBCSLeadByte(ReadBuffer[i])){
|
---|
| 619 | i++;
|
---|
| 620 | buffer[i]=ReadBuffer[i];
|
---|
| 621 | continue;
|
---|
| 622 | }
|
---|
| 623 | if(ReadBuffer[i]=='\"') IsStr^=1;
|
---|
| 624 | else if(ReadBuffer[i]=='('&&IsStr==0) PareNum++;
|
---|
| 625 | else if(ReadBuffer[i]==')'&&IsStr==0){
|
---|
| 626 | PareNum--;
|
---|
| 627 | if(PareNum==0){
|
---|
| 628 | i++;
|
---|
| 629 | buffer[i]=0;
|
---|
| 630 | break;
|
---|
| 631 | }
|
---|
| 632 | }
|
---|
| 633 | else if(ReadBuffer[i]=='\0') return 0;
|
---|
| 634 | }
|
---|
| 635 |
|
---|
| 636 | if( isRemovePare )
|
---|
| 637 | {
|
---|
| 638 | RemoveStringPare( buffer );
|
---|
| 639 | }
|
---|
| 640 |
|
---|
| 641 | return i;
|
---|
| 642 | }
|
---|
| 643 | int GetStringInBracket(char *buffer,const char *ReadBuffer){
|
---|
| 644 | int i,IsStr,PareNum;
|
---|
| 645 | for(i=0,IsStr=0,PareNum=0;;i++){
|
---|
| 646 | buffer[i]=ReadBuffer[i];
|
---|
| 647 | if(IsDBCSLeadByte(ReadBuffer[i])){
|
---|
| 648 | i++;
|
---|
| 649 | buffer[i]=ReadBuffer[i];
|
---|
| 650 | continue;
|
---|
| 651 | }
|
---|
| 652 | if(ReadBuffer[i]=='\"') IsStr^=1;
|
---|
| 653 | else if(ReadBuffer[i]=='['&&IsStr==0) PareNum++;
|
---|
| 654 | else if(ReadBuffer[i]==']'&&IsStr==0){
|
---|
| 655 | PareNum--;
|
---|
| 656 | if(PareNum==0){
|
---|
| 657 | i++;
|
---|
| 658 | buffer[i]=0;
|
---|
| 659 | break;
|
---|
| 660 | }
|
---|
| 661 | }
|
---|
| 662 | else if(ReadBuffer[i]=='\0') return 0;
|
---|
| 663 | }
|
---|
| 664 | return i;
|
---|
| 665 | }
|
---|
| 666 | int GetStringInGenericBracket(char *buffer,const char *ReadBuffer){
|
---|
| 667 | int i,IsStr,PareNum;
|
---|
| 668 | for(i=0,IsStr=0,PareNum=0;;i++){
|
---|
| 669 | buffer[i]=ReadBuffer[i];
|
---|
| 670 | if(IsDBCSLeadByte(ReadBuffer[i])){
|
---|
| 671 | i++;
|
---|
| 672 | buffer[i]=ReadBuffer[i];
|
---|
| 673 | continue;
|
---|
| 674 | }
|
---|
| 675 | if(ReadBuffer[i]=='\"') IsStr^=1;
|
---|
| 676 | else if(ReadBuffer[i]=='<'&&IsStr==0) PareNum++;
|
---|
| 677 | else if(ReadBuffer[i]=='>'&&IsStr==0){
|
---|
| 678 | PareNum--;
|
---|
| 679 | if(PareNum==0){
|
---|
| 680 | i++;
|
---|
| 681 | buffer[i]=0;
|
---|
| 682 | break;
|
---|
| 683 | }
|
---|
| 684 | }
|
---|
| 685 | else if(ReadBuffer[i]=='\0') return 0;
|
---|
| 686 | }
|
---|
| 687 | return i;
|
---|
| 688 | }
|
---|
| 689 | int JumpStringInPare(const char *buffer,int pos){
|
---|
| 690 | int PareNum;
|
---|
| 691 | for(PareNum=1;;pos++){
|
---|
| 692 | if(buffer[pos]=='\"'){
|
---|
| 693 | for(pos++;;pos++){
|
---|
| 694 | if(buffer[pos]=='\"') break;
|
---|
| 695 | }
|
---|
| 696 | continue;
|
---|
| 697 | }
|
---|
| 698 | else if(buffer[pos]=='(') PareNum++;
|
---|
| 699 | else if(buffer[pos]==')'){
|
---|
| 700 | PareNum--;
|
---|
| 701 | if(PareNum==0) return pos;
|
---|
| 702 | }
|
---|
| 703 | else if(buffer[pos]=='\0') break;
|
---|
| 704 | }
|
---|
| 705 | return 0;
|
---|
| 706 | }
|
---|
| 707 | int JumpStringInBracket(const char *buffer,int pos){
|
---|
| 708 | int PareNum;
|
---|
| 709 | for(PareNum=1;;pos++){
|
---|
| 710 | if(buffer[pos]=='\"'){
|
---|
| 711 | for(pos++;;pos++){
|
---|
| 712 | if(buffer[pos]=='\"') break;
|
---|
| 713 | }
|
---|
| 714 | continue;
|
---|
| 715 | }
|
---|
| 716 | else if(buffer[pos]=='[') PareNum++;
|
---|
| 717 | else if(buffer[pos]==']'){
|
---|
| 718 | PareNum--;
|
---|
| 719 | if(PareNum==0) return pos;
|
---|
| 720 | }
|
---|
| 721 | else if(buffer[pos]=='\0') break;
|
---|
| 722 | }
|
---|
| 723 | return 0;
|
---|
| 724 | }
|
---|
| 725 | bool IsCommandDelimitation( char c ){
|
---|
| 726 | if( c == '\n' || c == ':' || c == '\0' ){
|
---|
| 727 | return true;
|
---|
| 728 | }
|
---|
| 729 |
|
---|
| 730 | return false;
|
---|
| 731 | }
|
---|
| 732 |
|
---|
| 733 | int GetStringInPare_RemovePare(char *buffer,const char *ReadBuffer){
|
---|
| 734 | int i,IsStr,PareNum;
|
---|
| 735 | for(i=0,IsStr=0,PareNum=1;;i++){
|
---|
| 736 | buffer[i]=ReadBuffer[i];
|
---|
| 737 | if(IsDBCSLeadByte(ReadBuffer[i])){
|
---|
| 738 | i++;
|
---|
| 739 | buffer[i]=ReadBuffer[i];
|
---|
| 740 | continue;
|
---|
| 741 | }
|
---|
| 742 | if(ReadBuffer[i]=='\"') IsStr^=1;
|
---|
| 743 | else if(ReadBuffer[i]=='('&&IsStr==0) PareNum++;
|
---|
| 744 | else if(ReadBuffer[i]==')'&&IsStr==0){
|
---|
| 745 | PareNum--;
|
---|
| 746 | if(PareNum==0){
|
---|
| 747 | buffer[i]=0;
|
---|
| 748 | break;
|
---|
| 749 | }
|
---|
| 750 | }
|
---|
| 751 | else if(ReadBuffer[i]=='\0') return 0;
|
---|
| 752 | }
|
---|
| 753 | return i;
|
---|
| 754 | }
|
---|
| 755 |
|
---|
| 756 | void SplitParameter( const std::string &src, Jenga::Common::Strings &dests, bool isClear )
|
---|
| 757 | {
|
---|
| 758 | const char *buffer = src.c_str();
|
---|
| 759 | int i = 0;
|
---|
| 760 |
|
---|
| 761 | if( isClear )
|
---|
| 762 | {
|
---|
| 763 | dests.clear();
|
---|
| 764 | }
|
---|
| 765 |
|
---|
| 766 | while( buffer[i] )
|
---|
| 767 | {
|
---|
| 768 | char result[8192];
|
---|
| 769 | i = GetOneParameter( buffer, i, result );
|
---|
| 770 | dests.push_back( result );
|
---|
| 771 | }
|
---|
| 772 | }
|
---|
| 773 |
|
---|
| 774 |
|
---|
| 775 | bool SplitMemberName( const char *desc, char *object, char *member, ReferenceKind &refType ){
|
---|
| 776 | int lastIndex = -1;
|
---|
| 777 | for( int i=0; desc[i]; i++ ){
|
---|
| 778 | if( desc[i] == '(' ){
|
---|
| 779 | i=JumpStringInPare(desc,i+1);
|
---|
| 780 | continue;
|
---|
| 781 | }
|
---|
| 782 | else if( desc[i] == '[' ){
|
---|
| 783 | i=JumpStringInBracket(desc,i+1);
|
---|
| 784 | continue;
|
---|
| 785 | }
|
---|
| 786 | else if(desc[i]=='.'||(desc[i]==1&&desc[i+1]==ESC_PSMEM)){
|
---|
| 787 | lastIndex = i;
|
---|
| 788 | }
|
---|
| 789 | }
|
---|
| 790 | if( lastIndex == -1 ){
|
---|
| 791 | if( object )
|
---|
| 792 | {
|
---|
| 793 | object[0] = 0;
|
---|
| 794 | }
|
---|
| 795 | lstrcpy( member, desc );
|
---|
| 796 | return false;
|
---|
| 797 | }
|
---|
| 798 |
|
---|
| 799 | if(desc[lastIndex]=='.'){
|
---|
| 800 | lstrcpy(member,desc+lastIndex+1);
|
---|
| 801 | refType = RefDot;
|
---|
| 802 | }
|
---|
| 803 | else{
|
---|
| 804 | lstrcpy(member,desc+lastIndex+2);
|
---|
| 805 | refType = RefPointer;
|
---|
| 806 | }
|
---|
| 807 |
|
---|
| 808 | if( object ){
|
---|
| 809 | lstrcpy( object, desc );
|
---|
| 810 | object[lastIndex]=0;
|
---|
| 811 | }
|
---|
| 812 |
|
---|
| 813 | return true;
|
---|
| 814 | }
|
---|
| 815 | bool SplitMemberName( const char *desc, char *object, char *member ){
|
---|
| 816 | ReferenceKind dummyRefType;
|
---|
| 817 | return SplitMemberName( desc, object, member, dummyRefType );
|
---|
| 818 | }
|
---|
| 819 |
|
---|
| 820 | void SplitSyntacticForAs( const char *src, char *varName, char *typeName)
|
---|
| 821 | {
|
---|
| 822 | int i = 0;
|
---|
| 823 | for( ; ; i++ )
|
---|
| 824 | {
|
---|
| 825 | if( src[i] == '\0' || src[i] == 1 && src[i+1] == ESC_AS )
|
---|
| 826 | {
|
---|
| 827 | varName[i] = 0;
|
---|
| 828 | break;
|
---|
| 829 | }
|
---|
| 830 | varName[i] = src[i];
|
---|
| 831 | }
|
---|
| 832 |
|
---|
| 833 | if( src[i] )
|
---|
| 834 | {
|
---|
| 835 | lstrcpy( typeName, src + i + 2 );
|
---|
| 836 | }
|
---|
| 837 | else
|
---|
| 838 | {
|
---|
| 839 | typeName[i] = 0;
|
---|
| 840 | }
|
---|
| 841 | }
|
---|
| 842 |
|
---|
| 843 | bool IsGenericTypeSourcePart( const char *buffer )
|
---|
| 844 | {
|
---|
| 845 | if( buffer[0] != '<' )
|
---|
| 846 | {
|
---|
| 847 | Jenga::Throw( "意図しない文字列に対してIsGenericTypeSourcePart関数が呼ばれた" );
|
---|
| 848 | return false;
|
---|
| 849 | }
|
---|
| 850 |
|
---|
| 851 | int i=1, scopeCount=1;
|
---|
| 852 | for( ; ; i++ )
|
---|
| 853 | {
|
---|
| 854 | if( buffer[i] == '\0' )
|
---|
| 855 | {
|
---|
| 856 | break;
|
---|
| 857 | }
|
---|
| 858 | if( buffer[i] == '<' )
|
---|
| 859 | {
|
---|
| 860 | scopeCount++;
|
---|
| 861 | }
|
---|
| 862 | else if( buffer[i] == '>' )
|
---|
| 863 | {
|
---|
| 864 | scopeCount--;
|
---|
| 865 |
|
---|
| 866 | if( scopeCount == 0 )
|
---|
| 867 | {
|
---|
| 868 | break;
|
---|
| 869 | }
|
---|
| 870 | }
|
---|
| 871 | }
|
---|
| 872 |
|
---|
| 873 | if( buffer[i] != '>' )
|
---|
| 874 | {
|
---|
| 875 | return false;
|
---|
| 876 | }
|
---|
| 877 |
|
---|
| 878 |
|
---|
| 879 | /////////////////////////////////////////////////////////////////
|
---|
| 880 | // '>'に続く文字を判定する
|
---|
| 881 | /////////////////////////////////////////////////////////////////
|
---|
| 882 |
|
---|
| 883 | i++;
|
---|
| 884 | while( IsBlank( buffer[i] ) )
|
---|
| 885 | {
|
---|
| 886 | i++;
|
---|
| 887 | }
|
---|
| 888 |
|
---|
| 889 | if( IsVariableChar( buffer[i] ) )
|
---|
| 890 | {
|
---|
| 891 | return false;
|
---|
| 892 | }
|
---|
| 893 |
|
---|
| 894 | return true;
|
---|
| 895 | }
|
---|