Changeset 15 in dev for BasicCompiler_Common/preprocessor.cpp
- Timestamp:
- Dec 11, 2006, 3:07:59 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/preprocessor.cpp
r14 r15 8 8 9 9 10 class CDefine{ 11 int num; 12 char **ppNames; 13 public: 14 CDefine(); 15 ~CDefine(); 16 17 BOOL add(char *name); 18 BOOL undef(char *name); 19 BOOL check(char *name); 20 }; 10 21 CDefine::CDefine(){ 11 22 extern HANDLE hHeap; … … 300 311 301 312 char *IncludeFiles(char *base){ 313 extern HANDLE hHeap; 302 314 extern char szIncludeDir[MAX_PATH]; 303 315 extern char BasicCurDir[MAX_PATH]; … … 423 435 424 436 i3=lstrlen(buffer)+FileSize; 425 base=(char *) realloc(base,i3*2);437 base=(char *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,base,i3*2); 426 438 buffer=base+2; 427 439 SlideString(buffer+i2,FileSize+(i-i2)); … … 451 463 return base; 452 464 } 465 char *OpenBasicFile(char *FileName){ 466 extern HANDLE hHeap; 467 char *base,*buffer; 468 DWORD dwFileSize,dwAccBytes; 469 HANDLE hFile; 470 471 //ファイルオープン 472 hFile=CreateFile(FileName,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); 473 if(hFile==INVALID_HANDLE_VALUE) return 0; 474 475 //#define情報を初期化 476 pobj_define=new CDefine; 477 478 //バッファ領域確保 479 dwFileSize=GetFileSize(hFile,0); 480 base=(char *)HeapAlloc(hHeap,0,dwFileSize*2+255); 481 base[0]='\n'; 482 base[1]='\n'; 483 buffer=base+2; 484 lstrcpy(buffer,"#include <basic.sbp>\n"); 485 buffer+=lstrlen(buffer); 486 487 //読み込み 488 ReadFile(hFile,buffer,dwFileSize,&dwAccBytes,0); 489 buffer[dwAccBytes]=0; 490 491 //CRLFをLFに変換 492 ChangeReturnCode(buffer); 493 494 //コメント削除 495 DeleteComment(buffer); 496 497 //#ifdefディレクティブ 498 DirectiveIfdef(buffer); 499 500 //最終行には文字を含ませないようにする 501 lstrcat(buffer,"\n"); 502 503 //ファイルクローズ 504 CloseHandle(hFile); 505 506 //インクルードファイルを読み込む 507 base=IncludeFiles(base); 508 509 //#define情報を破棄 510 delete pobj_define; 511 pobj_define=0; 512 513 return base; 514 }
Note:
See TracChangeset
for help on using the changeset viewer.