[poincare] LayoutHelper::String second parameter is a length, not size

This commit is contained in:
Léa Saviot
2018-11-19 11:20:58 +01:00
committed by Émilie Feral
parent a289d77425
commit 5e404736b3
4 changed files with 9 additions and 9 deletions

View File

@@ -84,8 +84,8 @@ void VariableBoxEmptyController::setType(Type type) {
messages[0] = I18n::Message::EmptyExpressionBox0;
messages[1] = I18n::Message::EmptyExpressionBox1;
messages[2] = I18n::Message::EmptyExpressionBox2;
char storeExpression[] = {'3', Ion::Charset::Sto, 'A', 0};
layout = LayoutHelper::String(storeExpression, sizeof(storeExpression)-1, VariableBoxEmptyView::k_font);
char storeExpression[] = {'3', Ion::Charset::Sto, 'A'};
layout = LayoutHelper::String(storeExpression, sizeof(storeExpression), VariableBoxEmptyView::k_font);
break;
}
case Type::Functions:
@@ -93,8 +93,8 @@ void VariableBoxEmptyController::setType(Type type) {
messages[0] = I18n::Message::EmptyFunctionBox0;
messages[1] = I18n::Message::EmptyFunctionBox1;
messages[2] = I18n::Message::EmptyFunctionBox2;
char storeFunction[] = {'3', '+', Graph::StorageCartesianFunctionStore::Symbol(), Ion::Charset::Sto, 'f', '(', Graph::StorageCartesianFunctionStore::Symbol(), ')', 0};
layout = LayoutHelper::String(storeFunction, sizeof(storeFunction)-1, VariableBoxEmptyView::k_font);
char storeFunction[] = {'3', '+', Graph::StorageCartesianFunctionStore::Symbol(), Ion::Charset::Sto, 'f', '(', Graph::StorageCartesianFunctionStore::Symbol(), ')'};
layout = LayoutHelper::String(storeFunction, sizeof(storeFunction), VariableBoxEmptyView::k_font);
break;
}
default:

View File

@@ -14,7 +14,7 @@ namespace LayoutHelper {
/* Create special layouts */
Layout Parentheses(Layout layout, bool cloneLayout);
HorizontalLayout String(const char * buffer, int bufferSize, const KDFont * font = KDFont::LargeFont);
HorizontalLayout String(const char * buffer, int bufferLen, const KDFont * font = KDFont::LargeFont);
Layout Logarithm(Layout argument, Layout index);
};

View File

@@ -53,10 +53,10 @@ Layout LayoutHelper::Parentheses(Layout layout, bool cloneLayout) {
return result;
}
HorizontalLayout LayoutHelper::String(const char * buffer, int bufferSize, const KDFont * font) {
assert(bufferSize > 0);
HorizontalLayout LayoutHelper::String(const char * buffer, int bufferLen, const KDFont * font) {
assert(bufferLen > 0);
HorizontalLayout resultLayout;
for (int i = 0; i < bufferSize; i++) {
for (int i = 0; i < bufferLen; i++) {
resultLayout.addChildAtIndex(CharLayout(buffer[i], font), i, i, nullptr);
}
return resultLayout;

View File

@@ -18,7 +18,7 @@ Expression UndefinedNode::setSign(Sign s, Context & context, Preferences::AngleU
}
Layout UndefinedNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::String(Undefined::Name(), Undefined::NameSize());
return LayoutHelper::String(Undefined::Name(), Undefined::NameSize()-1);
}
int UndefinedNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {