Changeset 735 in dev for trunk/ab5.0/abdev/ab_common/src/Lexical/Source.cpp
- Timestamp:
- Aug 25, 2008, 5:26:44 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/ab_common/src/Lexical/Source.cpp
r706 r735 6 6 7 7 class CDefine{ 8 std ::vector<std::string> names;8 stdext::hash_set<std::string> names; 9 9 public: 10 void Free();10 // void Free(); 11 11 void Init( bool isDebug, bool isDll, bool isUnicode, int majorVer ); 12 12 13 BOOLadd(char const *name);14 BOOLundef(char const *name);15 BOOLcheck(char const *name);13 bool add(char const *name); 14 bool undef(char const *name); 15 bool check(char const *name); 16 16 void preprocessor_ifdef(char *buffer,bool isNot); 17 17 void DirectiveIfdef(char *buffer); … … 84 84 add(temporary); 85 85 } 86 BOOLCDefine::add(char const *name)86 bool CDefine::add(char const *name) 87 87 { 88 //重複チェック 89 if(check(name)) return 0; 90 91 //追加 92 names.push_back( name ); 93 94 return 1; 95 } 96 BOOL CDefine::undef(char const *name){ 97 std::vector<std::string>::iterator i = names.begin(); 98 BOOST_FOREACH( const std::string &temp, names ){ 99 if( temp == name ){ 100 names.erase( i ); 101 return 1; 102 } 103 i++; 104 } 105 106 return 0; 107 } 108 BOOL CDefine::check(char const *name){ 109 110 //重複チェック 111 BOOST_FOREACH( const std::string &temp, names ){ 112 if( temp == name ){ 113 return 1; 114 } 115 } 116 return 0; 88 return names.insert(name).second; 89 } 90 bool CDefine::undef(char const *name){ 91 return names.erase(name) > 0; 92 } 93 bool CDefine::check(char const *name){ 94 return names.find(name) != names.end(); 117 95 } 118 96 … … 167 145 168 146 //#ifdefの行を消去 169 Text::SlideString(buffer+i,-i); 170 i=0; 147 memset(buffer,' ',static_cast<size_t>(i)); 171 148 172 149 BOOL bElse=0; … … 304 281 temporary[i3]=buffer[i2]; 305 282 } 306 307 283 add(temporary); 308 309 i2-=i;310 311 284 //ディレクティブを消去 312 Text::SlideString(buffer+i+i2,-i2); 285 memset(buffer+i,' ',static_cast<size_t>(i2-i)); 286 i=i2; 313 287 } 314 288 if(memicmp(buffer+i,"#undef",6)==0){ 315 i2=i+ 7;289 i2=i+6; 316 290 while(buffer[i2]==' '||buffer[i2]=='\t') i2++; 317 291 … … 323 297 temporary[i3]=buffer[i2]; 324 298 } 325 326 299 undef(temporary); 327 328 i2-=i;329 330 300 //ディレクティブを消去 331 Text::SlideString(buffer+i+i2,-i2); 301 memset(buffer+i,' ',static_cast<size_t>(i2-i)); 302 i=i2; 332 303 } 333 304 else if(memicmp(buffer+i,"#ifdef",6)==0){ … … 367 338 368 339 return true; 340 } 341 342 //改行コードのCRLFをLFに変換 343 int ChangeReturnCodeImpl(char *buffer) 344 { 345 int i; 346 for(i=0;buffer[i]!='\0';i++){ 347 if(buffer[i]=='\r'&&buffer[i+1]=='\n'){ 348 buffer[i]=' '; 349 } 350 } 351 return i; 369 352 } 370 353 … … 418 401 #endif 419 402 420 //改行コードのCRLFをLFに変換 421 for(i=0,i2=0;;i++,i2++){ 422 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i++; 423 buffer[i2]=buffer[i]; 424 if(buffer[i]=='\0') break; 425 } 403 ChangeReturnCodeImpl(buffer); 426 404 427 405 length = i; … … 471 449 if(buffer[i]=='\0') break; 472 450 } 473 st rcpy(buffer,temporary);451 std::swap(buffer,temporary); 474 452 free(temporary); 475 453 } … … 683 661 //カッコ'('直下の改行 684 662 while(buffer[0]=='\n'){ 685 Text::SlideString(buffer+1,-1);663 buffer[0]=' '; 686 664 (*pRnum)++; 687 665 }
Note:
See TracChangeset
for help on using the changeset viewer.