Skip to content

Commit f8287c5

Browse files
committed
Handle finding regexps on empty lines
1 parent 75f7e80 commit f8287c5

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

Finding.cpp

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -289,43 +289,44 @@ CString strStatus = TFormat ("Finding: %s", (LPCTSTR) FindInfo.m_strFindStringLi
289289
WrapUpFind (FindInfo);
290290
return true; // found it!
291291
} // end if found
292-
else
293-
{
294-
// nothing found, try previous line
295-
FindInfo.m_nCurrentLine--;
296-
continue; // skip other testing
297-
} // end if not found
292+
293+
// nothing found, try previous line
294+
FindInfo.m_nCurrentLine--;
295+
continue; // skip other testing
298296

299297
} // end of searching backwards with repeat on same line
300298

301299
// if text found on this line, then we have done it!
302300

303-
if (FindInfo.m_bRegexp )
301+
if (maximum (FindInfo.m_iStartColumn, 0) < strLine.GetLength ())
304302
{
305-
306-
if (regexec (FindInfo.m_regexp, strLine, maximum (FindInfo.m_iStartColumn, 0)))
303+
if (FindInfo.m_bRegexp )
307304
{
308-
// work out what column it must have been at
309-
FindInfo.m_iStartColumn = FindInfo.m_regexp->m_vOffsets [0];
310-
FindInfo.m_iEndColumn = FindInfo.m_regexp->m_vOffsets [1];
311-
WrapUpFind (FindInfo);
312-
return true; // found it!
313-
}
314-
} // end of regular expression
315-
else
316-
{ // not regular expression
317305

318-
// if case-insensitive search wanted, force this line to lower case
319-
if (!FindInfo.m_bMatchCase)
320-
strLine.MakeLower ();
321-
if ((FindInfo.m_iStartColumn = strLine.Find (strFindString, maximum (FindInfo.m_iStartColumn, 0))) != -1)
322-
{
323-
// work out ending column
324-
FindInfo.m_iEndColumn = FindInfo.m_iStartColumn + strFindString.GetLength ();
325-
WrapUpFind (FindInfo);
326-
return true; // found it!
327-
} // end of found
328-
} // end of not regular expression
306+
if (regexec (FindInfo.m_regexp, strLine, maximum (FindInfo.m_iStartColumn, 0)))
307+
{
308+
// work out what column it must have been at
309+
FindInfo.m_iStartColumn = FindInfo.m_regexp->m_vOffsets [0];
310+
FindInfo.m_iEndColumn = FindInfo.m_regexp->m_vOffsets [1];
311+
WrapUpFind (FindInfo);
312+
return true; // found it!
313+
}
314+
} // end of regular expression
315+
else
316+
{ // not regular expression
317+
318+
// if case-insensitive search wanted, force this line to lower case
319+
if (!FindInfo.m_bMatchCase)
320+
strLine.MakeLower ();
321+
if ((FindInfo.m_iStartColumn = strLine.Find (strFindString, maximum (FindInfo.m_iStartColumn, 0))) != -1)
322+
{
323+
// work out ending column
324+
FindInfo.m_iEndColumn = FindInfo.m_iStartColumn + strFindString.GetLength ();
325+
WrapUpFind (FindInfo);
326+
return true; // found it!
327+
} // end of found
328+
} // end of not regular expression
329+
} // end of start column being inside the line
329330

330331
// keep track of line count
331332

0 commit comments

Comments
 (0)