Skip to content

Commit 7888e99

Browse files
committed
issue #10977 dontinclude pattern find itself
Giving warning regarding "should throw a warning if returned text is empty" i.e. when a pattern cannot be found in the `\include` / `\dontinclude` file.
1 parent 379ccce commit 7888e99

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/docnode.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ void DocIncOperator::parse()
321321
"No previous '\\include' or '\\dontinclude' command for '\\%s' present",
322322
typeAsString());
323323
}
324+
bool found = false;
324325

325326
m_includeFileName = parser()->context.includeFileName;
326327
const char *p = parser()->context.includeFileText.data();
@@ -352,6 +353,7 @@ void DocIncOperator::parse()
352353
{
353354
m_line = il;
354355
m_text = parser()->context.includeFileText.mid(so,o-so);
356+
found = true;
355357
AUTO_TRACE_ADD("\\line {}",Trace::trunc(m_text));
356358
}
357359
parser()->context.includeFileOffset = std::min(l,o+1); // set pointer to start of new line
@@ -380,6 +382,7 @@ void DocIncOperator::parse()
380382
{
381383
m_line = il;
382384
m_text = parser()->context.includeFileText.mid(so,o-so);
385+
found = true;
383386
AUTO_TRACE_ADD("\\skipline {}",Trace::trunc(m_text));
384387
break;
385388
}
@@ -409,6 +412,7 @@ void DocIncOperator::parse()
409412
}
410413
if (parser()->context.includeFileText.mid(so,o-so).find(m_pattern)!=-1)
411414
{
415+
found = true;
412416
break;
413417
}
414418
o++; // skip new line
@@ -440,6 +444,7 @@ void DocIncOperator::parse()
440444
{
441445
m_line = il;
442446
m_text = parser()->context.includeFileText.mid(bo,o-bo);
447+
found = true;
443448
AUTO_TRACE_ADD("\\until {}",Trace::trunc(m_text));
444449
break;
445450
}
@@ -449,6 +454,11 @@ void DocIncOperator::parse()
449454
m_showLineNo = parser()->context.includeFileShowLineNo;
450455
break;
451456
}
457+
if (!found)
458+
{
459+
warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
460+
"referenced pattern '%s' for command '\\%s' not found",qPrint(m_pattern),typeAsString());
461+
}
452462
}
453463

454464
//---------------------------------------------------------------------------

0 commit comments

Comments
 (0)