[apps/code] Handle too many Script default names used

When adding to many scripts without naming them, one can overflow the
number of default generated script names, in which case we force the
user to enter a name.
This commit is contained in:
Léa Saviot
2018-11-05 17:58:42 +01:00
committed by Émilie Feral
parent 0f9d1db851
commit e74e15eaf7
5 changed files with 32 additions and 20 deletions

View File

@@ -9,16 +9,18 @@ namespace Code {
* Script: | AutoImportationStatus | Content |*/
class Script : public Ion::Storage::Record {
private:
// Default script names are chosen between script1 and script99
static constexpr int k_maxNumberOfDefaultScriptNames = 99;
static constexpr int k_defaultScriptNameNumberMaxSize = 2; // Numbers from 1 to 99 have 2 digits max
public:
static constexpr size_t k_importationStatusSize = 1;
static constexpr int k_defaultScriptNameMaxSize = 6 + 2 + 1;
/* k_defaultScriptNameMaxSize is the length of a name between script1 and
* script99
* 6 = strlen("script")
* 2 = maxLength of integers between 1 and 99
static constexpr int k_defaultScriptNameMaxSize = 6 + k_defaultScriptNameNumberMaxSize + 1;
/* 6 = strlen("script")
* k_defaultScriptNameNumberMaxSize = maxLength of integers between 1 and 99
* 1 = null-terminating char */
static void DefaultName(char buffer[], size_t bufferSize);
static bool DefaultName(char buffer[], size_t bufferSize);
static bool nameCompliant(const char * name);
Script(Ion::Storage::Record r) : Record(r) {}