From 4c93718fd5fb1daeccbd0ccd4f3b38b321461205 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Thu, 29 Apr 2021 18:44:47 +0200 Subject: Fixed typo, use QCString, and some minor reformating --- src/mandocvisitor.cpp | 4 ++-- src/rtfdocvisitor.cpp | 4 ++-- src/util.cpp | 19 ++++++++++--------- src/util.h | 5 +++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/mandocvisitor.cpp b/src/mandocvisitor.cpp index e835267..93ae712 100644 --- a/src/mandocvisitor.cpp +++ b/src/mandocvisitor.cpp @@ -691,10 +691,10 @@ void ManDocVisitor::visitPre(DocHtmlListItem *li) m_t << man_listItemInfo[m_indent].number; break; case 'a': - m_t << intergerToAlpha(man_listItemInfo[m_indent].number,false); + m_t << integerToAlpha(man_listItemInfo[m_indent].number,false); break; case 'A': - m_t << intergerToAlpha(man_listItemInfo[m_indent].number); + m_t << integerToAlpha(man_listItemInfo[m_indent].number); break; case 'i': m_t << integerToRoman(man_listItemInfo[m_indent].number,false); diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp index 4ab089e..4e7cfda 100644 --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -931,10 +931,10 @@ void RTFDocVisitor::visitPre(DocHtmlListItem *) m_t << rtf_listItemInfo[m_indentLevel].number; break; case 'a': - m_t << intergerToAlpha(rtf_listItemInfo[m_indentLevel].number,false); + m_t << integerToAlpha(rtf_listItemInfo[m_indentLevel].number,false); break; case 'A': - m_t << intergerToAlpha(rtf_listItemInfo[m_indentLevel].number); + m_t << integerToAlpha(rtf_listItemInfo[m_indentLevel].number); break; case 'i': m_t << integerToRoman(rtf_listItemInfo[m_indentLevel].number,false); diff --git a/src/util.cpp b/src/util.cpp index 3d9a63b..75e82f0 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -7461,9 +7461,9 @@ std::string join(const StringVector &sv,const std::string &delimiter) return result; } -std::string intergerToAlpha(const int n, const bool upper) +QCString integerToAlpha(int n, bool upper) { - std::string result = ""; + QCString result; int residual = n; char modVal[2]; @@ -7477,20 +7477,21 @@ std::string intergerToAlpha(const int n, const bool upper) return result; } -std::string integerToRoman(const int n, const bool upper) +QCString integerToRoman(int n, bool upper) { - static std::string str_romans_upper[] = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"}; - static std::string str_romans_lower[] = {"m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix", "v", "iv", "i"}; - static int values[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; + static const char *str_romans_upper[] = { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" }; + static const char *str_romans_lower[] = { "m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix", "v", "iv", "i" }; + static const int values[] = { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 }; + static const char **str_romans = upper ? str_romans_upper : str_romans_lower; - std::string result = ""; + QCString result; int residual = n; for (int i = 0; i < 13; ++i) { - while(residual - values[i] >= 0) + while (residual - values[i] >= 0) { - result += (upper ? str_romans_upper[i] : str_romans_lower[i]); + result += str_romans[i]; residual -= values[i]; } } diff --git a/src/util.h b/src/util.h index cbc18f1..3034c23 100644 --- a/src/util.h +++ b/src/util.h @@ -460,6 +460,7 @@ std::string join(const StringVector &s,const std::string &delimiter); bool recognizeFixedForm(const QCString &contents, FortranFormat format); FortranFormat convertFileNameFortranParserCode(QCString fn); -std::string intergerToAlpha(const int n, const bool upper=true); -std::string integerToRoman(const int n, const bool upper=true); +QCString integerToAlpha(int n, bool upper=true); +QCString integerToRoman(int n, bool upper=true); + #endif -- cgit v0.12