Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
toml: use elektraWriteArrayNumber instead of custom code
Browse files Browse the repository at this point in the history
  • Loading branch information
kodebach committed Jun 13, 2023
1 parent 3ec05e1 commit 3af13a2
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/plugins/toml/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "./utility.h"

#include <elektra/ease/array.h>
#include <elektra/utility/array.h>
#include <internal/utility/alloc.h>
#include <internal/utility/assert.h>
#include <internal/utility/compare.h>
Expand Down Expand Up @@ -37,21 +38,9 @@ void keyUpdateArrayMetakey (Key * key, size_t newIndex)

char * indexToArrayString (size_t index)
{
size_t digits = 1;
for (size_t value = index; value > 9; digits++)
{
value /= 10;
}
int strLen = 1 + // '#'
(digits - 1) + // underscores
digits + // actual digits
1; // '\0'
char * str = (char *) elektraCalloc (sizeof (char) * strLen);
memset (str, '_', sizeof (char) * strLen);
str[0] = '#';
str[strLen - 1] = 0;
snprintf (str + 1 + (digits - 1), strLen, "%lu", index);
return str;
char newName[ELEKTRA_MAX_ARRAY_SIZE];
elektraWriteArrayNumber (newName, index);
return elektraStrDup (newName);
}

size_t arrayStringToIndex (const char * indexStr)
Expand Down

0 comments on commit 3af13a2

Please sign in to comment.