[apps/ion] Escapes cases when records/ strings are null

This commit is contained in:
Léa Saviot
2018-10-09 16:02:58 +02:00
committed by Émilie Feral
parent c95136c9b5
commit d869be7782
3 changed files with 8 additions and 11 deletions

View File

@@ -58,16 +58,10 @@ Ion::Storage::Record GlobalContext::RecordWithName(const char * name) {
return Ion::Storage::sharedStorage()->recordBaseNamedWithExtensions(name, extensions, 2);
}
const char * GlobalContext::ExtensionForExpression(const Expression & exp) {
// TODO Once we have matrix exact reducing, add a .mat extension and check here if the root is a matrix
// TODO .seq
if (exp.type() == ExpressionNode::Type::Function) {
return funcExtension;
}
return expExtension;
}
const Expression GlobalContext::expressionForSymbolAndRecord(const SymbolAbstract & symbol, Ion::Storage::Record r) {
if (r.isNull()) {
return Expression();
}
if (symbol.type() == ExpressionNode::Type::Symbol) {
return expressionForActualSymbol(symbol, r);
}

View File

@@ -40,7 +40,7 @@ void StorageExpressionModel::text(char * buffer, size_t bufferSize) const {
}
Expression StorageExpressionModel::expression() const {
if (m_expression.isUninitialized()) {
if (m_expression.isUninitialized() && !m_record.isNull()) {
m_expression = Expression::ExpressionFromAddress(expressionAddress(), expressionSize());
}
return m_expression;
@@ -51,7 +51,7 @@ Expression StorageExpressionModel::reducedExpression(Poincare::Context * context
}
Layout StorageExpressionModel::layout() {
if (m_layout.isUninitialized()) {
if (m_layout.isUninitialized() && !m_record.isNull()) {
m_layout = PoincareHelpers::CreateLayout(expression());
if (m_layout.isUninitialized()) {
m_layout = HorizontalLayout();

View File

@@ -414,6 +414,9 @@ bool Storage::FullNameCompliant(const char * fullName) {
}
bool Storage::FullNameHasExtension(const char * fullName, const char * extension, size_t extensionLength) {
if (fullName == nullptr) {
return false;
}
size_t fullNameLength = strlen(fullName);
if (fullNameLength > extensionLength) {
const char * ext = fullName + fullNameLength - extensionLength;