X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f90e5ed24a5e5dcc3ccefbeff8b7b1a3c20499ee..a95cdab85c5e5abb2d40e594663f120db3675bb4:/utils/tex2rtf/src/texutils.cpp diff --git a/utils/tex2rtf/src/texutils.cpp b/utils/tex2rtf/src/texutils.cpp index 77ca009c1a..ad52f44ef0 100644 --- a/utils/tex2rtf/src/texutils.cpp +++ b/utils/tex2rtf/src/texutils.cpp @@ -26,6 +26,10 @@ #include +#ifdef new +#undef new +#endif + #if wxUSE_IOSTREAMH #include #include @@ -378,7 +382,7 @@ void AddTexRef(char *name, char *file, char *sectionName, void WriteTexReferences(char *filename) { - ofstream ostr(filename); + wxSTD ofstream ostr(filename); if (ostr.bad()) return; char buf[200]; @@ -405,7 +409,7 @@ void ReadTexReferences(char *filename) if (!wxFileExists(filename)) return; - ifstream istr(filename, ios::in); + wxSTD ifstream istr(filename, ios::in); if (istr.bad()) return; @@ -432,7 +436,14 @@ void ReadTexReferences(char *filename) istr.get(ch); } section[i] = 0; + + // 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, new TexRef(label, file, section, sectionName)); + TexReferences.DeleteContents(FALSE); } } } @@ -443,7 +454,7 @@ void ReadTexReferences(char *filename) * */ -void BibEatWhiteSpace(istream& str) +void BibEatWhiteSpace(wxSTD istream& str) { char ch = str.peek(); @@ -471,7 +482,7 @@ void BibEatWhiteSpace(istream& str) } // Read word up to { or , or space -void BibReadWord(istream& istr, char *buffer) +void BibReadWord(wxSTD istream& istr, char *buffer) { int i = 0; buffer[i] = 0; @@ -488,7 +499,7 @@ void BibReadWord(istream& istr, char *buffer) } // Read string (double-quoted or not) to end quote or EOL -void BibReadToEOL(istream& istr, char *buffer) +void BibReadToEOL(wxSTD istream& istr, char *buffer) { int i = 0; buffer[i] = 0; @@ -517,7 +528,7 @@ void BibReadToEOL(istream& istr, char *buffer) } // Read }-terminated value, taking nested braces into account. -void BibReadValue(istream& istr, char *buffer, bool ignoreBraces = TRUE, +void BibReadValue(wxSTD istream& istr, char *buffer, bool ignoreBraces = TRUE, bool quotesMayTerminate = TRUE) { int braceCount = 1; @@ -528,10 +539,10 @@ void BibReadValue(istream& istr, char *buffer, bool ignoreBraces = TRUE, while (!istr.eof() && !stopping) { // i ++; - if (i >= 2000) + if (i >= 4000) { char buf[100]; - sprintf(buf, "Sorry, value > 2000 chars in bib file at line %ld, terminating.", BibLine); + sprintf(buf, "Sorry, value > 4000 chars in bib file at line %ld, terminating.", BibLine); wxFatalError(buf, "Tex2RTF Fatal Error"); } istr.get(ch); @@ -573,7 +584,7 @@ bool ReadBib(char *filename) return FALSE; char buf[300]; - ifstream istr(filename, ios::in); + wxSTD ifstream istr(filename, ios::in); if (istr.bad()) return FALSE; BibLine = 1; @@ -581,7 +592,7 @@ bool ReadBib(char *filename) OnInform("Reading .bib file..."); char ch; - char fieldValue[2000]; + char fieldValue[4000]; char recordType[100]; char recordKey[100]; char recordField[100]; @@ -1295,7 +1306,7 @@ bool ReadCustomMacros(char *filename) if (!wxFileExists(filename)) return FALSE; - ifstream istr(filename, ios::in); + wxSTD ifstream istr(filename, ios::in); if (istr.bad()) return FALSE;