while ((f = text.find('%', f)) != wxString::npos) {
f++;
e = text.find('%', f);
#ifdef CHECKED
if (e == wxString::npos) {
wxMessageBox(wxString("wxHTML #include error: % signs should bracket variable names in file attribute. To use a percent sign in a filename write double percents (%%)."), "Error" ,wxICON_ERROR);
// make a copy so we can replace text as we go without affecting the original
wxString output = text;
while ((i = (output.Lower()).Find(ft)) != -1) {
// This loop makes more recursion unnecessary since each iteration adds
// the new include files to output.
int n, c;
wxString fname;
n = (output.Mid(i+21)).Find("-->");
if (n == -1) {
#ifdef CHECKED
wxMessageBox("wxHTML #include error: Could not read filename. Premature end of file.","Error",wxICON_ERROR);
#endif
break;
}
fname = output.Mid(i+21, n);
// Clip off any quotation marks if they exist. (don't die if there arn't any)
c = fname.Find("\"");
if (c != -1) fname = fname.Mid(c+1);
c = fname.Find("\"");
if (c != -1) fname = fname.Mid(0, c);
// remove the #include tag
output.Remove(i, n+21+3);
wxFSFile * file;
file = m_FS->OpenFile(ParseFilename(fname));
if (!file) {
#ifdef CHECKED
wxMessageBox(wxString("wxHTML #include error: File not Found ") + fname + wxString("."),"Error",wxICON_ERROR);
#endif
delete file;
continue;
}
wxString tmp;
do {
char tmp2[257];
(file->GetStream())->Read(tmp2, 256);
c = (file->GetStream())->LastRead();
tmp2[c] = 0;
tmp += wxString(tmp2);
} while (c == 256);
output = (output.Mid(0,i) + tmp + output.Mid(i));
#ifdef CHECKED
if (openedcount > RECURSE_LIMIT) {
wxMessageBox(wxString("wxHTML #include error: More than RECURSE_LIMIT files have been #included you may have a file that is directly or indirectly including itself, causing an endless loop"), "Error" ,wxICON_ERROR);