- while (!istr.eof())
- {
- istr >> label;
- if (!istr.eof())
- {
- istr >> file;
- istr >> sectionName;
- char ch;
- istr.get(ch); // Read past space
- istr.get(ch);
- int i = 0;
- while (ch != '\n' && !istr.eof())
- {
- section[i] = ch;
- i ++;
- istr.get(ch);
- }
- section[i] = 0;
-
- wxString label_string = wxString::FromAscii(label);
- wxString file_string = wxString::FromAscii(file);
- wxString sectionName_string = wxString::FromAscii(sectionName);
- wxString section_string = wxString::FromAscii(section);
-
- // gt - needed to trick the hash table "TexReferences" into deleting the key
- // strings it creates in the Put() function, but not the item that is
- // created here, as that is destroyed elsewhere. Without doing this, there
- // were massive memory leaks
- TexReferences.DeleteContents(true);
- TexReferences.Put(
- label_string.c_str(),
- new TexRef(
- label_string.c_str(),
- file_string.c_str(),
- section_string.c_str(),
- sectionName_string.c_str()
- )
- );
- TexReferences.DeleteContents(false);
+ wxString line;
+ for ( line = file.GetFirstLine(); !file.Eof(); line = file.GetNextLine() )
+ {
+ wxString labelStr = line.BeforeFirst(wxT(' '));
+ line = line.AfterFirst(wxT(' '));
+ wxString fileStr = line.BeforeFirst(wxT(' '));
+ line = line.AfterFirst(wxT(' '));
+ wxString sectionNameStr = line.BeforeFirst(wxT(' '));
+ wxString sectionStr = line.AfterFirst(wxT(' '));
+
+ // gt - needed to trick the hash table "TexReferences" into deleting the key
+ // strings it creates in the Put() function, but not the item that is
+ // created here, as that is destroyed elsewhere. Without doing this, there
+ // were massive memory leaks
+ TexReferences.DeleteContents(true);
+ TexReferences.Put(
+ labelStr,
+ new TexRef(
+ labelStr.c_str(),
+ fileStr.c_str(),
+ sectionStr.c_str(),
+ sectionNameStr.c_str()
+ )
+ );
+ TexReferences.DeleteContents(false);