]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
util: Make pakfire_split_string private
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 10 Apr 2021 15:12:37 +0000 (15:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 10 Apr 2021 15:12:37 +0000 (15:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/package.c
src/libpakfire/include/pakfire/util.h
src/libpakfire/libpakfire.sym
src/libpakfire/util.c

index ddf4ba63b42cf3ec1d3efb4a94afcfc4cf4de201..13d7c0b9d78dcc84884173d19174814e9326b6c5 100644 (file)
@@ -292,22 +292,7 @@ static void Package_set_url(PackageObject* self, PyObject* value) {
 static PyObject* Package_get_groups(PackageObject* self) {
        const char* s = pakfire_package_get_groups(self->package);
 
-       PyObject* list = PyList_New(0);
-
-       char** groups = pakfire_split_string(s, ',');
-       char* group;
-
-       while ((group = *groups++) != NULL) {
-               PyObject* item = PyUnicode_FromString(group);
-               PyList_Append(list, item);
-               free(group);
-
-               Py_DECREF(item);
-       }
-
-       free(groups);
-
-       return list;
+       return PyUnicode_FromString(s);
 }
 
 static int Package_set_groups(PackageObject* self, PyObject* value) {
index 6bae7f20394f078eb5bddc48e1d8303a9a13ec79..8c64a75b071044aad4af7e2fd5e090e58f3c24a5 100644 (file)
@@ -27,8 +27,6 @@
 
 #include <pakfire/types.h>
 
-char** pakfire_split_string(const char* s, char delim);
-
 char* pakfire_generate_uuid();
 
 #ifdef PAKFIRE_PRIVATE
@@ -44,6 +42,7 @@ int pakfire_string_endswith(const char* s, const char* suffix);
 char* pakfire_unquote_in_place(char* s);
 int pakfire_string_partition(const char* s, const char* delim, char** s1, char** s2);
 char* pakfire_string_replace(const char* s, const char* pattern, const char* repl);
+char** pakfire_split_string(const char* s, char delim);
 
 char* pakfire_format_size(double size);
 char* pakfire_format_date(time_t t);
index f5775e714feb64fe92aec3efd83fd66e19b9b862..30cf0ba8929eccb59c5f73c8f7c4672c88232c36 100644 (file)
@@ -407,7 +407,6 @@ global:
 
        # util
        pakfire_generate_uuid;
-       pakfire_split_string;
 
 local:
        *;
index 8bdcb46d95ad60ac2f02d74e8dd07e3580ae1c70..d2cf572150e83a31b06650f044c182f9e634716a 100644 (file)
@@ -194,6 +194,39 @@ ERROR:
        return result;
 }
 
+char** pakfire_split_string(const char* s, char delim) {
+       // Copy string to stack and count spaces
+       char buffer[strlen(s) + 2];
+
+       size_t count = 1;
+       for (unsigned int i = 0; i < strlen(s) + 1; i++) {
+               buffer[i] = s[i];
+
+               if (s[i] == delim) {
+                       buffer[i] = '\0';
+                       count++;
+               }
+       }
+
+       // Allocate an array of sufficient size
+       char** ret = malloc(sizeof(*ret) * (count + 1));
+
+       // Copy strings to heap one by one
+       unsigned int i = 0;
+       char* p = buffer;
+       while (*p) {
+               ret[i++] = strdup(p);
+
+               // Move pointer to the next string
+               p += strlen(p) + 1;
+       }
+
+       // Terminate array
+       ret[count] = NULL;
+
+       return ret;
+}
+
 char* pakfire_format_size(double size) {
        char string[STRING_SIZE];
        const char* units[] = {" ", "k", "M", "G", "T", NULL};
@@ -332,39 +365,6 @@ int pakfire_read_file_into_buffer(FILE* f, char** buffer, size_t* len) {
        return 0;
 }
 
-PAKFIRE_EXPORT char** pakfire_split_string(const char* s, char delim) {
-       // Copy string to stack and count spaces
-       char buffer[strlen(s) + 2];
-
-       size_t count = 1;
-       for (unsigned int i = 0; i < strlen(s) + 1; i++) {
-               buffer[i] = s[i];
-
-               if (s[i] == delim) {
-                       buffer[i] = '\0';
-                       count++;
-               }
-       }
-
-       // Allocate an array of sufficient size
-       char** ret = malloc(sizeof(*ret) * (count + 1));
-
-       // Copy strings to heap one by one
-       unsigned int i = 0;
-       char* p = buffer;
-       while (*p) {
-               ret[i++] = strdup(p);
-
-               // Move pointer to the next string
-               p += strlen(p) + 1;
-       }
-
-       // Terminate array
-       ret[count] = NULL;
-
-       return ret;
-}
-
 PAKFIRE_EXPORT char* pakfire_generate_uuid() {
        uuid_t uuid;