FindAdv: Comments

This commit is contained in:
Kornel Benko 2018-12-14 16:02:33 +01:00
parent f3558213e1
commit 2682170556

View File

@ -1010,19 +1010,34 @@ static Features identifyFeatures(string const & s)
class KeyInfo { class KeyInfo {
public: public:
enum KeyType { enum KeyType {
/* Char type with content discarded
* like \hspace{1cm} */
noContent,
/* Char, like \backslash */
isChar, isChar,
/* \part, \section*, ... */
isSectioning, isSectioning,
isMain, /* for \\foreignlanguage */ /* \foreignlanguage{ngerman}, ... */
noMain, /* to discard language in content */ isMain,
/* inside \code{} or \footnote{}
* to discard language in content */
noMain,
isRegex, isRegex,
/* \begin{eqnarray}...\end{eqnarray}, ... $...$ */
isMath, isMath,
/* fonts, colors, markups, ... */
isStandard, isStandard,
noContent, /* discard content */ /* footnotesize, ... large, ...
* Ignore all of them */
isSize, isSize,
invalid, invalid,
/* inputencoding, shortcut, ...
* Discard also content, because they do not help in search */
doRemove, doRemove,
/* item */
isList, isList,
isIgnored /* to be ignored by creating infos */ /* tex, latex, ... like isChar */
isIgnored
}; };
KeyInfo() KeyInfo()
: keytype(invalid), : keytype(invalid),
@ -1571,7 +1586,8 @@ void LatexInfo::buildEntries(bool isPatternString)
found._tokenstart = sub.position(size_t(0)); found._tokenstart = sub.position(size_t(0));
if (found.parenthesiscount == 0) { if (found.parenthesiscount == 0) {
// Probably to be discarded // Probably to be discarded
char following = interval.par[sub.position(size_t(0)) + sub.str(3).length() + 1]; size_t following_pos = sub.position(size_t(0)) + sub.str(3).length() + 1;
char following = interval.par[following_pos];
if (following == ' ') if (following == ' ')
found.head = "\\" + sub.str(3) + " "; found.head = "\\" + sub.str(3) + " ";
else if (following == '=') { else if (following == '=') {
@ -1874,6 +1890,10 @@ int LatexInfo::dispatch(ostringstream &os, int previousStart, KeyInfo &actual)
int nextKeyIdx = 0; int nextKeyIdx = 0;
switch (actual.keytype) switch (actual.keytype)
{ {
case KeyInfo::noContent: { /* char like "\hspace{2cm}" */
interval.addIntervall(actual._dataStart, actual._dataEnd);
}
// fall through
case KeyInfo::isChar: { case KeyInfo::isChar: {
nextKeyIdx = getNextKey(); nextKeyIdx = getNextKey();
break; break;
@ -1896,10 +1916,6 @@ int LatexInfo::dispatch(ostringstream &os, int previousStart, KeyInfo &actual)
} }
break; break;
} }
case KeyInfo::noContent: {
interval.addIntervall(actual._dataStart, actual._dataEnd);
}
// fall through
case KeyInfo::noMain: case KeyInfo::noMain:
// fall through // fall through
case KeyInfo::isStandard: { case KeyInfo::isStandard: {