Added cleaner ABORT handling in some situations
If \\end{document} is not found, then program auto-aborts after first pass to avoid hanging in some endless loop until all system resources are exhausted and the program crashes.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10532
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
+ if (stopRunning)
+ return FALSE;
+
// Reset variables
indentLevel = 0;
forbidParindent = 0;
// Reset variables
indentLevel = 0;
forbidParindent = 0;
SetCurrentOutput(Chapters);
SetCurrentOutput(Chapters);
+ if (stopRunning)
+ return FALSE;
+
OnInform("Converting...");
TraverseDocument();
OnInform("Converting...");
TraverseDocument();
void ForbidWarning(TexMacroDef *def)
{
void ForbidWarning(TexMacroDef *def)
{
switch (def->forbidden)
{
case FORBID_WARN:
{
switch (def->forbidden)
{
case FORBID_WARN:
{
- sprintf(buf, "Warning: it is recommended that command %s is not used.", def->name);
- OnInform(buf);
+ informBuf.Printf("Warning: it is recommended that command %s is not used.", def->name);
+ OnInform((char *)informBuf.c_str());
break;
}
case FORBID_ABSOLUTELY:
{
break;
}
case FORBID_ABSOLUTELY:
{
- sprintf(buf, "Error: command %s cannot be used and will lead to errors.", def->name);
- OnInform(buf);
+ informBuf.Printf("Error: command %s cannot be used and will lead to errors.", def->name);
+ OnInform((char *)informBuf.c_str());
errBuf.Printf("Could not find macro: %s at line %d, file %s",
macroBuf, (int)(LineNumbers[CurrentInputIndex]-1), FileNames[CurrentInputIndex]);
OnError((char *)errBuf.c_str());
errBuf.Printf("Could not find macro: %s at line %d, file %s",
macroBuf, (int)(LineNumbers[CurrentInputIndex]-1), FileNames[CurrentInputIndex]);
OnError((char *)errBuf.c_str());
+
+ if (wxStrcmp(macroBuf,"\\end{document}") == 0)
+ {
+ wxString buf;
+ buf = "Halted build due to unrecoverable error.";
+ OnInform((char *)buf.c_str());
+ stopRunning = TRUE;
+ }
CustomMacro *customMacro = FindCustomMacro(def->name);
TexChunk *chunk = new TexChunk(CHUNK_TYPE_MACRO, def);
CustomMacro *customMacro = FindCustomMacro(def->name);
TexChunk *chunk = new TexChunk(CHUNK_TYPE_MACRO, def);
chunk->no_args = def->no_args;
// chunk->name = copystring(def->name);
chunk->macroId = def->macroId;
chunk->no_args = def->no_args;
// chunk->name = copystring(def->name);
chunk->macroId = def->macroId;
isOptional = TRUE;
pos += 2;
}
isOptional = TRUE;
pos += 2;
}
+ else if (i > 0)
+ {
+ wxString errBuf;
+ wxString tmpBuffer(buffer);
+ if (tmpBuffer.length() > 4)
+ {
+ if (tmpBuffer.Right(4) == "\\par")
+ tmpBuffer = tmpBuffer.Mid(0,tmpBuffer.length()-4);
+ }
+ errBuf.Printf("Missing macro argument in the line:\n\t%s\n",tmpBuffer.c_str());
+ OnError((char *)errBuf.c_str());
+ }
+
}
arg->optional = isOptional;
}
arg->optional = isOptional;
OnMacro(chunk->macroId, chunk->no_args, TRUE);
wxNode *node = chunk->children.First();
OnMacro(chunk->macroId, chunk->no_args, TRUE);
wxNode *node = chunk->children.First();
+ TexChunk *child_chunk = NULL;
- TexChunk *child_chunk = (TexChunk *)node->Data();
+ child_chunk = (TexChunk *)node->Data();
TraverseFromChunk(child_chunk, node);
node = node->Next();
}
TraverseFromChunk(child_chunk, node);
node = node->Next();
}
- if (thisNode && thisNode->Next()) nextChunk = (TexChunk *)thisNode->Next()->Data();
+ if (thisNode && thisNode->Next())
+ nextChunk = (TexChunk *)thisNode->Next()->Data();
if (!childrenOnly)
OnMacro(chunk->macroId, chunk->no_args, FALSE);
if (!childrenOnly)
OnMacro(chunk->macroId, chunk->no_args, FALSE);
- if (thisNode && thisNode->Next()) nextChunk = (TexChunk *)thisNode->Next()->Data();
+ if (thisNode && thisNode->Next())
+ nextChunk = (TexChunk *)thisNode->Next()->Data();
isArgOptional = chunk->optional;
noArgs = chunk->no_args;
isArgOptional = chunk->optional;
noArgs = chunk->no_args;
// If non-whitespace text, we no longer have a new paragraph.
if (issuedNewParagraph && !((chunk->value[0] == 10 || chunk->value[0] == 13 || chunk->value[0] == 32)
&& chunk->value[1] == 0))
// If non-whitespace text, we no longer have a new paragraph.
if (issuedNewParagraph && !((chunk->value[0] == 10 || chunk->value[0] == 13 || chunk->value[0] == 32)
&& chunk->value[1] == 0))
issuedNewParagraph = FALSE;
issuedNewParagraph = FALSE;
TexOutput(chunk->value, TRUE);
}
break;
TexOutput(chunk->value, TRUE);
}
break;
- char buf[300];
- TexOutput("??", TRUE);
- sprintf(buf, "Warning: unresolved reference '%s'", refName);
- OnInform(buf);
+ wxString informBuf;
+ informBuf.Printf("Warning: unresolved reference '%s'", refName);
+ OnInform((char *)informBuf.c_str());
}
}
else TexOutput("??", TRUE);
}
}
else TexOutput("??", TRUE);
TexOutput(ref->sectionNumber, TRUE);
if (strcmp(ref->sectionNumber, "??") == 0)
{
TexOutput(ref->sectionNumber, TRUE);
if (strcmp(ref->sectionNumber, "??") == 0)
{
- char buf[300];
- sprintf(buf, "Warning: unresolved citation %s.", citeKey);
- OnInform(buf);
+ wxString informBuf;
+ informBuf.Printf("Warning: unresolved citation %s.", citeKey);
+ OnInform((char *)informBuf.c_str());
}
}
citeKey = ParseMultifieldString(citeKeys, &pos);
}
}
citeKey = ParseMultifieldString(citeKeys, &pos);
Tex2RTFYield(TRUE);
Go();
Tex2RTFYield(TRUE);
Go();
+ if (stopRunning)
+ {
+ SetStatusText("Build aborted!");
+ wxString errBuf;
+ errBuf.Printf("\nErrors encountered during this pass: %lu\n", errorCount);
+ OnInform((char *)errBuf.c_str());
+ }
+
+
+ if (runTwice && !stopRunning)
{
Tex2RTFYield(TRUE);
Go();
{
Tex2RTFYield(TRUE);
Go();
ChooseOutputFile();
#endif
ChooseOutputFile();
#endif
- if (!InputFile || !OutputFile)
+ if (!InputFile || !OutputFile || stopRunning)
return FALSE;
#ifndef NO_GUI
return FALSE;
#ifndef NO_GUI
OnInform("Reading LaTeX file...");
TexLoadFile(InputFile);
OnInform("Reading LaTeX file...");
TexLoadFile(InputFile);
+ if (stopRunning)
+ return FALSE;
+
switch (convertMode)
{
case TEX_RTF:
switch (convertMode)
{
case TEX_RTF: