// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
static inline wxChar* copystring(const wxChar* s)
{ return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); }
static inline wxChar* copystring(const wxChar* s)
{ return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); }
// Update current column, but only if we're guaranteed to
// be ordinary text (not mark-up stuff)
int i;
if (ordinaryText)
// Update current column, but only if we're guaranteed to
// be ordinary text (not mark-up stuff)
int i;
if (ordinaryText)
TexMacroDef *MatchMacro(wxChar *buffer, int *pos, wxChar **env, bool *parseToBrace)
{
TexMacroDef *MatchMacro(wxChar *buffer, int *pos, wxChar **env, bool *parseToBrace)
{
- *parseToBrace = true;
- int i = (*pos);
- TexMacroDef *def = NULL;
- wxChar macroBuf[40];
-
- // First, try to find begin{thing}
- if (wxStrncmp(buffer+i, _T("begin{"), 6) == 0)
- {
- i += 6;
+ *parseToBrace = true;
+ int i = (*pos);
+ TexMacroDef *def = NULL;
+ wxChar macroBuf[40];
- int j = i;
- while ((isalpha(buffer[j]) || buffer[j] == '*') && ((j - i) < 39))
+ // First, try to find begin{thing}
+ if (wxStrncmp(buffer+i, _T("begin{"), 6) == 0)
- if (def)
- {
- *pos = j + 1; // BUGBUG Should this be + 1???
- *env = def->name;
- ForbidWarning(def);
- return def;
+ int j = i;
+ while ((isalpha(buffer[j]) || buffer[j] == '*') && ((j - i) < 39))
+ {
+ macroBuf[j-i] = buffer[j];
+ j ++;
+ }
+ macroBuf[j-i] = 0;
+ def = (TexMacroDef *)MacroDefs.Get(macroBuf);
+
+ if (def)
+ {
+ *pos = j + 1; // BUGBUG Should this be + 1???
+ *env = def->name;
+ ForbidWarning(def);
+ return def;
+ }
+ else
+ {
+ return NULL;
+ }
- // First try getting a one-character macro, but ONLY
- // if these TWO characters are not both alphabetical (could
- // be a longer macro)
- if (!(isalpha(buffer[i]) && isalpha(buffer[i+1])))
- {
- macroBuf[0] = buffer[i];
- macroBuf[1] = 0;
+ // First try getting a one-character macro, but ONLY
+ // if these TWO characters are not both alphabetical (could
+ // be a longer macro)
+ if (!(isalpha(buffer[i]) && isalpha(buffer[i+1])))
+ {
+ macroBuf[0] = buffer[i];
+ macroBuf[1] = 0;
- // We want to check whether this is a space-consuming macro
- // (e.g. {\bf word})
- // No brace, e.g. \input thing.tex instead of \input{thing};
- // or a numeric argument, such as \parindent0pt
- if ((def->no_args > 0) && ((buffer[i] == 32) || (buffer[i] == '=') || (isdigit(buffer[i]))))
- if ((buffer[i] == 32) || (buffer[i] == '='))
- i ++;
+ i = j;
+
+ // We want to check whether this is a space-consuming macro
+ // (e.g. {\bf word})
+ // No brace, e.g. \input thing.tex instead of \input{thing};
+ // or a numeric argument, such as \parindent0pt
+ if ((def->no_args > 0) && ((buffer[i] == 32) || (buffer[i] == '=') || (isdigit(buffer[i]))))
+ {
+ if ((buffer[i] == 32) || (buffer[i] == '='))
+ i ++;
wxString errBuf;
errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(), MAX_LINE_BUFFER_SIZE);
wxString errBuf;
errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(), MAX_LINE_BUFFER_SIZE);
{
wxString errBuf;
errBuf.Printf(_T("An extra right Curly brace ('}') was detected at line %lu inside file %s"), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str());
{
wxString errBuf;
errBuf.Printf(_T("An extra right Curly brace ('}') was detected at line %lu inside file %s"), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str());
// Reduce the count of right Curly braces, so the mismatched count
// isn't reported on every line that has a '}' after the first mismatch
// Reduce the count of right Curly braces, so the mismatched count
// isn't reported on every line that has a '}' after the first mismatch
wxString errBuf;
errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE);
wxString errBuf;
errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE);
wxString errBuf;
errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE);
wxString errBuf;
errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE);
wxString errBuf;
errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE);
wxString errBuf;
errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE);
wxString errBuf;
errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE);
wxString errBuf;
errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE);
wxString errBuf;
errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE);
wxString errBuf;
errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE);
// wxString errBuf;
// errBuf.Printf(_T("An underscore ('_') was detected at line %lu inside file %s that should NOT have a '\\' before it."),
// LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str());
// wxString errBuf;
// errBuf.Printf(_T("An underscore ('_') was detected at line %lu inside file %s that should NOT have a '\\' before it."),
// LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str());
wxString errBuf;
errBuf.Printf(_T("An underscore ('_') was detected at line %lu inside file %s that may need a '\\' before it."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str());
wxString errBuf;
errBuf.Printf(_T("An underscore ('_') was detected at line %lu inside file %s that may need a '\\' before it."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str());
}
else if ((buf[bufIndex-1] != '\\') && (buf[0] != '%') && // If it is a comment line, then no warnings
(wxStrncmp(buf, _T("\\input"), 6))) // do not report filenames that have underscores in them
}
else if ((buf[bufIndex-1] != '\\') && (buf[0] != '%') && // If it is a comment line, then no warnings
(wxStrncmp(buf, _T("\\input"), 6))) // do not report filenames that have underscores in them
wxString errBuf;
errBuf.Printf(_T("An underscore ('_') was detected at line %lu inside file %s that may need a '\\' before it."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str());
wxString errBuf;
errBuf.Printf(_T("An underscore ('_') was detected at line %lu inside file %s that may need a '\\' before it."),
LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str());
wxString errBuf;
errBuf.Printf(_T("Curly braces do not match inside file %s\n%lu opens, %lu closes"),
(const wxChar*) currentFileName.c_str(),leftCurly,rightCurly);
wxString errBuf;
errBuf.Printf(_T("Curly braces do not match inside file %s\n%lu opens, %lu closes"),
(const wxChar*) currentFileName.c_str(),leftCurly,rightCurly);
fileNameStr.Replace(_T("\\"), _T(""));
// Ignore some types of input files (e.g. macro definition files)
fileNameStr.Replace(_T("\\"), _T(""));
// Ignore some types of input files (e.g. macro definition files)
currentFileName = fileOnly;
if (IgnorableInputFiles.Member(fileOnly))
return read_a_line(buf);
wxString actualFile = TexPathList.FindValidPath(fileNameStr);
currentFileName = fileOnly;
if (IgnorableInputFiles.Member(fileOnly))
return read_a_line(buf);
wxString actualFile = TexPathList.FindValidPath(fileNameStr);
{
wxChar buf2[400];
wxSnprintf(buf2, sizeof(buf2), _T("%s.tex"), fileNameStr.c_str());
{
wxChar buf2[400];
wxSnprintf(buf2, sizeof(buf2), _T("%s.tex"), fileNameStr.c_str());
LineNumbers[CurrentInputIndex],
currentFileName.c_str());
}
LineNumbers[CurrentInputIndex],
currentFileName.c_str());
}
wxString errBuf;
errBuf.Printf(_T("Curly braces do not match inside file %s\n%lu opens, %lu closes"),
(const wxChar*) currentFileName.c_str(),leftCurly,rightCurly);
wxString errBuf;
errBuf.Printf(_T("Curly braces do not match inside file %s\n%lu opens, %lu closes"),
(const wxChar*) currentFileName.c_str(),leftCurly,rightCurly);
errBuf.Printf(_T("Could not find macro: %s at line %d, file %s"),
macroBuf, (int)(LineNumbers[CurrentInputIndex]-1), FileNames[CurrentInputIndex]);
errBuf.Printf(_T("Could not find macro: %s at line %d, file %s"),
macroBuf, (int)(LineNumbers[CurrentInputIndex]-1), FileNames[CurrentInputIndex]);
- pos = ParseMacroBody(def->name, chunk, chunk->no_args,
- buffer, pos, env, tmpParseToBrace, customMacroArgs);
+ pos = ParseMacroBody(def->name,
+ chunk, chunk->no_args,
+ buffer,
+ pos,
+ env,
+ tmpParseToBrace,
+ customMacroArgs);
tmpBuffer = tmpBuffer.Mid(0,tmpBuffer.length()-4);
}
errBuf.Printf(_T("Missing macro argument in the line:\n\t%s\n"),tmpBuffer.c_str());
tmpBuffer = tmpBuffer.Mid(0,tmpBuffer.length()-4);
}
errBuf.Printf(_T("Missing macro argument in the line:\n\t%s\n"),tmpBuffer.c_str());
- static wxChar *line_buffer;
- stopRunning = false;
- wxStrcpy(TexFileRoot, filename);
- StripExtension(TexFileRoot);
- wxSnprintf(TexBibName, 300, _T("%s.bb"), TexFileRoot);
- wxSnprintf(TexTmpBibName, 300, _T("%s.bb1"), TexFileRoot);
+ static wxChar *line_buffer;
+ stopRunning = false;
+ wxStrcpy(TexFileRoot, filename);
+ StripExtension(TexFileRoot);
+ wxSnprintf(TexBibName, 300, _T("%s.bb"), TexFileRoot);
+ wxSnprintf(TexTmpBibName, 300, _T("%s.bb1"), TexFileRoot);
- Inputs[0] = wxFopen(filename, _T("r"));
- LineNumbers[0] = 1;
- FileNames[0] = copystring(filename);
- if (Inputs[0])
- {
- read_a_line(line_buffer);
- ParseMacroBody(_T("toplevel"), TopLevel, 1, line_buffer, 0, NULL, true);
- if (Inputs[0]) fclose(Inputs[0]);
- return true;
- }
+ Inputs[0] = wxFopen(filename, _T("r"));
+ LineNumbers[0] = 1;
+ FileNames[0] = copystring(filename);
+ if (Inputs[0])
+ {
+ read_a_line(line_buffer);
+ ParseMacroBody(_T("toplevel"), TopLevel, 1, line_buffer, 0, NULL, true);
+ if (Inputs[0]) fclose(Inputs[0]);
+ return true;
+ }
}
TexMacroDef::TexMacroDef(int the_id, const wxChar *the_name, int n, bool ig, bool forbidLevel)
}
TexMacroDef::TexMacroDef(int the_id, const wxChar *the_name, int n, bool ig, bool forbidLevel)
- TexOutput(_T("<<"), true);
+ {
+ if (convertMode == TEX_HTML)
+ TexOutput(_T("<<"));
+ else
+ TexOutput(_T("<<"), true);
+ }
- TexOutput(_T(">>"), true);
+ {
+ if (convertMode == TEX_HTML)
+ TexOutput(_T(">>"));
+ else
+ TexOutput(_T(">>"), true);
+ }
wxChar fileBuf[300];
wxStrcpy(fileBuf, bibFile);
wxString actualFile = TexPathList.FindValidPath(fileBuf);
wxChar fileBuf[300];
wxStrcpy(fileBuf, bibFile);
wxString actualFile = TexPathList.FindValidPath(fileBuf);
{
wxStrcat(fileBuf, _T(".bib"));
actualFile = TexPathList.FindValidPath(fileBuf);
}
{
wxStrcat(fileBuf, _T(".bib"));
actualFile = TexPathList.FindValidPath(fileBuf);
}
{
if (!ReadBib((wxChar*) (const wxChar*) actualFile))
{
wxString errBuf;
errBuf.Printf(_T(".bib file %s not found or malformed"), (const wxChar*) actualFile);
{
if (!ReadBib((wxChar*) (const wxChar*) actualFile))
{
wxString errBuf;
errBuf.Printf(_T(".bib file %s not found or malformed"), (const wxChar*) actualFile);