diff options
Diffstat (limited to 'src/htmldocvisitor.cpp')
-rw-r--r-- | src/htmldocvisitor.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index 9939ef2..c70f2c5 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -44,27 +44,30 @@ static QCString convertIndexWordToAnchor(const QString &word) QCString result; const char *str = word.data(); unsigned char c; - while ((c = *str++)) - { - if ((c >= 'a' && c <= 'z') || // ALPHA - (c >= 'A' && c <= 'A') || // ALPHA - (c >= '0' && c <= '9') || // DIGIT - c == '-' || - c == '.' || - c == '_' || - c == '~' - ) - { - result += c; - } - else + if (str) + { + while ((c = *str++)) { - char enc[4]; - enc[0] = '%'; - enc[1] = hex[(c & 0xf0) >> 4]; - enc[2] = hex[c & 0xf]; - enc[3] = 0; - result += enc; + if ((c >= 'a' && c <= 'z') || // ALPHA + (c >= 'A' && c <= 'A') || // ALPHA + (c >= '0' && c <= '9') || // DIGIT + c == '-' || + c == '.' || + 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; |