X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a29912f608e082001ee53b9873323c4bcd71f21..a763ac036b30921d5c76a393c03dc19bf36fd0b7:/utils/tex2rtf/src/texutils.cpp diff --git a/utils/tex2rtf/src/texutils.cpp b/utils/tex2rtf/src/texutils.cpp index 5de8abcae7..f3c25d42b7 100644 --- a/utils/tex2rtf/src/texutils.cpp +++ b/utils/tex2rtf/src/texutils.cpp @@ -239,9 +239,9 @@ int ParseUnitArgument(char *unitArg) if (strcmp(units, "in") == 0) conversionFactor = 72.0; else if (strcmp(units, "cm") == 0) - conversionFactor = 72.0/2.51; + conversionFactor = (float)72.0/(float)2.51; else if (strcmp(units, "mm") == 0) - conversionFactor = 72.0/25.1; + conversionFactor = (float)72.0/(float)25.1; else if (strcmp(units, "pt") == 0) conversionFactor = 1; } @@ -402,7 +402,11 @@ void WriteTexReferences(char *filename) void ReadTexReferences(char *filename) { - ifstream istr(filename, ios::nocreate | ios::in); + if (!wxFileExists(filename)) + return; + + ifstream istr(filename, ios::in); + if (istr.bad()) return; char label[100]; @@ -428,7 +432,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); } } } @@ -524,10 +535,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); @@ -565,8 +576,11 @@ void BibReadValue(istream& istr, char *buffer, bool ignoreBraces = TRUE, bool ReadBib(char *filename) { + if (!wxFileExists(filename)) + return FALSE; + char buf[300]; - ifstream istr(filename, ios::nocreate | ios::in); + ifstream istr(filename, ios::in); if (istr.bad()) return FALSE; BibLine = 1; @@ -574,7 +588,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]; @@ -1159,6 +1173,8 @@ char *RegisterSetting(char *settingName, char *settingValue, bool interactive) winHelpContents = StringTobool(settingValue); else if (StringMatch(settingName, "htmlIndex", FALSE, TRUE)) htmlIndex = StringTobool(settingValue); + else if (StringMatch(settingName, "htmlWorkshopFiles", FALSE, TRUE)) + htmlWorkshopFiles = StringTobool(settingValue); else if (StringMatch(settingName, "htmlFrameContents", FALSE, TRUE)) htmlFrameContents = StringTobool(settingValue); else if (StringMatch(settingName, "upperCaseNames", FALSE, TRUE)) @@ -1283,7 +1299,11 @@ char *RegisterSetting(char *settingName, char *settingValue, bool interactive) bool ReadCustomMacros(char *filename) { - ifstream istr(filename, ios::nocreate | ios::in); + if (!wxFileExists(filename)) + return FALSE; + + ifstream istr(filename, ios::in); + if (istr.bad()) return FALSE; CustomMacroList.Clear(); @@ -1556,7 +1576,8 @@ void Tex2RTFYield(bool force) yieldCount = 0; if (yieldCount == 0) { - wxYield(); + if (wxTheApp) + wxYield(); yieldCount = 10; } yieldCount --; @@ -1626,10 +1647,10 @@ char *ConvertCase(char *s) int i; if (upperCaseNames) for (i = 0; i < len; i ++) - buf[i] = wxToUpper(s[i]); + buf[i] = toupper(s[i]); else for (i = 0; i < len; i ++) - buf[i] = wxToLower(s[i]); + buf[i] = tolower(s[i]); buf[i] = 0; return buf; }