Changeset 14 in dev for BasicCompiler_Common/preprocessor.cpp
- Timestamp:
- Dec 10, 2006, 10:58:26 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/preprocessor.cpp
r5 r14 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 };21 10 CDefine::CDefine(){ 22 11 extern HANDLE hHeap; … … 311 300 312 301 char *IncludeFiles(char *base){ 313 extern HANDLE hHeap;314 302 extern char szIncludeDir[MAX_PATH]; 315 303 extern char BasicCurDir[MAX_PATH]; … … 435 423 436 424 i3=lstrlen(buffer)+FileSize; 437 base=(char *) HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,base,i3*2);425 base=(char *)realloc(base,i3*2); 438 426 buffer=base+2; 439 427 SlideString(buffer+i2,FileSize+(i-i2)); … … 463 451 return base; 464 452 } 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.