[apps] When renaming a function, check that the name is not reserved

This commit is contained in:
Léa Saviot
2018-11-12 10:47:49 +01:00
committed by Émilie Feral
parent 2d20aacc89
commit f94dc63d16

View File

@@ -1,5 +1,6 @@
#include "storage_function.h"
#include <poincare/symbol.h>
#include "poincare/src/parsing/parser.h"
#include <string.h>
#include <cmath>
#include <assert.h>
@@ -16,6 +17,8 @@ bool StorageFunction::BaseNameCompliant(const char * baseName) {
return false;
}
const char * currentChar = baseName;
// The name should only have allowed characters
while (*currentChar != 0) {
if (!((*currentChar >= 'A' && *currentChar <= 'Z')
|| (*currentChar >= 'a' && *currentChar <= 'z')
@@ -25,6 +28,11 @@ bool StorageFunction::BaseNameCompliant(const char * baseName) {
}
currentChar++;
}
// The name should not be a reserved name
if (Parser::IsReservedName(baseName, strlen(baseName))) {
return false;
}
return true;
}