Changeset 15207

Show
Ignore:
Timestamp:
24.04.2008 11:41:19 (12 years ago)
Author:
mdewsnip
Message:

Fixed up some crazy obfuscated lines and fixed a bug where the remove_old_keys() function didn't work because the GDBM file hadn't been opened for writing.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/src/recpt/userdb.cpp

    r15087 r15207  
    374374{ 
    375375  storedkeydbfilename = keydbfilename; 
    376   activated = (!keydb.opendatabase(storedkeydbfilename, GDBM_READER, 1000, true)) ? false : true; 
     376  activated = keydb.opendatabase(storedkeydbfilename, GDBM_READER, 1000, true); 
    377377  if (activated == false)  
    378378    { 
    379       activated = (!keydb.opendatabase(storedkeydbfilename, GDBM_WRCREAT, 1000, true)) ? false : true; 
     379      activated = keydb.opendatabase(storedkeydbfilename, GDBM_WRCREAT, 1000, true); 
    380380      if (activated == true) 
    381381        { 
    382382          keydb.closedatabase(); 
    383           activated = (!keydb.opendatabase(storedkeydbfilename, GDBM_READER, 1000, true)) ? false : true; 
     383          activated = keydb.opendatabase(storedkeydbfilename, GDBM_READER, 1000, true); 
    384384        } 
    385385    } 
     
    508508      } 
    509509       
    510       // delete the keys 
    511       text_tarray::iterator keys_here = oldkeys.begin(); 
    512       text_tarray::iterator keys_end = oldkeys.end(); 
    513       while (keys_here != keys_end) { 
    514         keydb.deletekey(*keys_here); 
    515         ++keys_here; 
     510      // delete the old keys 
     511      if (oldkeys.size() > 0) { 
     512    keydb.closedatabase(); 
     513    keydb.opendatabase(storedkeydbfilename, GDBM_WRCREAT, 1000, true); 
     514    text_tarray::iterator keys_here = oldkeys.begin(); 
     515    text_tarray::iterator keys_end = oldkeys.end(); 
     516    while (keys_here != keys_end) { 
     517      keydb.deletekey(*keys_here); 
     518      ++keys_here; 
     519    } 
     520    keydb.closedatabase(); 
     521    keydb.opendatabase(storedkeydbfilename, GDBM_READER, 1000, true); 
    516522      } 
    517523    }