From 5b03953fd15cce03138c91a4398d30f58645cc93 Mon Sep 17 00:00:00 2001 From: horchi Date: Sat, 3 Mar 2018 09:03:00 +0100 Subject: anged menu numbering handling vor mcMain --- coreengine/listelements.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'coreengine') diff --git a/coreengine/listelements.c b/coreengine/listelements.c index 7c8da35..9a2108b 100644 --- a/coreengine/listelements.c +++ b/coreengine/listelements.c @@ -474,6 +474,31 @@ cVeMenuMain::~cVeMenuMain(void) { free(label); } +int countDigits(int arg) +{ + return snprintf(NULL, 0, "%d", arg) - (arg < 0); +} + +void cVeMenuMain::SplitText(void) { + char* string = skipspace(text); + unsigned int num = atoi(string); + int digits = countDigits(num); + + free(number); + free(label); + + if (digits > 0 && digits < 4 && string[digits] == ' ') + { + if (asprintf(&label, "%s", string+digits+1)) ; + if (asprintf(&number, "%d", num)) ; + } + else + { + if (asprintf(&label, "%s", string)) ; + number = strdup(""); + } +} +/* void cVeMenuMain::SplitText(void) { char *start = skipspace(text); bool found = false; @@ -521,6 +546,7 @@ void cVeMenuMain::SplitText(void) { } label = strdup(skipspace(c)); } +*/ /****************************************************************** * cLeMenuMain -- cgit v1.2.3