Commit 653a2a8b authored by Dimitri van Heesch's avatar Dimitri van Heesch

Bug 728530 - Crash on \addindex \term

parent 8ba739ad
...@@ -44,27 +44,30 @@ static QCString convertIndexWordToAnchor(const QString &word) ...@@ -44,27 +44,30 @@ static QCString convertIndexWordToAnchor(const QString &word)
QCString result; QCString result;
const char *str = word.data(); const char *str = word.data();
unsigned char c; unsigned char c;
while ((c = *str++)) if (str)
{ {
if ((c >= 'a' && c <= 'z') || // ALPHA while ((c = *str++))
(c >= 'A' && c <= 'A') || // ALPHA
(c >= '0' && c <= '9') || // DIGIT
c == '-' ||
c == '.' ||
c == '_' ||
c == '~'
)
{
result += c;
}
else
{ {
char enc[4]; if ((c >= 'a' && c <= 'z') || // ALPHA
enc[0] = '%'; (c >= 'A' && c <= 'A') || // ALPHA
enc[1] = hex[(c & 0xf0) >> 4]; (c >= '0' && c <= '9') || // DIGIT
enc[2] = hex[c & 0xf]; c == '-' ||
enc[3] = 0; c == '.' ||
result += enc; c == '_' ||
c == '~'
)
{
result += c;
}
else
{
char enc[4];
enc[0] = '%';
enc[1] = hex[(c & 0xf0) >> 4];
enc[2] = hex[c & 0xf];
enc[3] = 0;
result += enc;
}
} }
} }
return result; return result;
......
...@@ -38,17 +38,20 @@ static QCString escapeLabelName(const char *s) ...@@ -38,17 +38,20 @@ static QCString escapeLabelName(const char *s)
QCString result; QCString result;
const char *p=s; const char *p=s;
char c; char c;
while ((c=*p++)) if (p)
{ {
switch (c) while ((c=*p++))
{ {
case '%': result+="\\%"; break; switch (c)
case '|': result+="\\texttt{\"|}"; break; {
case '!': result+="\"!"; break; case '%': result+="\\%"; break;
case '{': result+="\\lcurly{}"; break; case '|': result+="\\texttt{\"|}"; break;
case '}': result+="\\rcurly{}"; break; case '!': result+="\"!"; break;
case '~': result+="````~"; break; // to get it a bit better in index together with other special characters case '{': result+="\\lcurly{}"; break;
default: result+=c; case '}': result+="\\rcurly{}"; break;
case '~': result+="````~"; break; // to get it a bit better in index together with other special characters
default: result+=c;
}
} }
} }
return result; return result;
...@@ -73,19 +76,22 @@ QCString LatexDocVisitor::escapeMakeIndexChars(const char *s) ...@@ -73,19 +76,22 @@ QCString LatexDocVisitor::escapeMakeIndexChars(const char *s)
const char *p=s; const char *p=s;
char str[2]; str[1]=0; char str[2]; str[1]=0;
char c; char c;
while ((c=*p++)) if (p)
{ {
switch (c) while ((c=*p++))
{ {
case '!': m_t << "\"!"; break; switch (c)
case '"': m_t << "\"\""; break; {
case '@': m_t << "\"@"; break; case '!': m_t << "\"!"; break;
case '|': m_t << "\\texttt{\"|}"; break; case '"': m_t << "\"\""; break;
case '[': m_t << "["; break; case '@': m_t << "\"@"; break;
case ']': m_t << "]"; break; case '|': m_t << "\\texttt{\"|}"; break;
case '{': m_t << "\\lcurly{}"; break; case '[': m_t << "["; break;
case '}': m_t << "\\rcurly{}"; break; case ']': m_t << "]"; break;
default: str[0]=c; filter(str); break; case '{': m_t << "\\lcurly{}"; break;
case '}': m_t << "\\rcurly{}"; break;
default: str[0]=c; filter(str); break;
}
} }
} }
return result; return result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment