]> git.ipfire.org Git - pakfire.git/commitdiff
*: Replace pakfire_remove_trailing_newline with pakfire_string_rstrip
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 26 Oct 2024 12:33:02 +0000 (12:33 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 26 Oct 2024 12:33:02 +0000 (12:33 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/arch.c
src/libpakfire/file.c
src/libpakfire/include/pakfire/util.h
src/libpakfire/key.c
src/libpakfire/parser.c
src/libpakfire/util.c

index c3081826e6f389ef2caa47bfde28f95b9755162f..064e27ba1625107980db732c9bab846e2a6efe55 100644 (file)
@@ -283,7 +283,7 @@ static char* find_interpreter(DIR* dir, const char* path, const char* magic) {
                        break;
 
                // Remove the newline
-               pakfire_remove_trailing_newline(line);
+               pakfire_string_rstrip(line);
 
                // Look for the "enabled" line
                if (strcmp("enabled", line) == 0) {
index c4f8a8bd0f6737dca91380966727947dbd464913..8843c21fd4cdc3e03f12e552adf255fb5f6358d0 100644 (file)
@@ -2089,7 +2089,7 @@ static int pakfire_file_fix_interpreter(struct pakfire_file* file, const char* i
                                }
 
                                // Remove the trailing newline
-                               pakfire_remove_trailing_newline(line);
+                               pakfire_string_rstrip(line);
 
                                // Start at the beginning of the line (after shebang)
                                p = line + 2;
index 0b97941970dab9ef976fb5a279457ff10ffde076..e8066f54c5a075e0bbc88b2e40983686d8a8cc59 100644 (file)
@@ -51,8 +51,6 @@ static inline void* pakfire_realloc(void* p, size_t size) {
 
 time_t pakfire_path_age(const char* path);
 
-char* pakfire_remove_trailing_newline(char* str);
-
 int pakfire_read_file_into_buffer(FILE* f, char** buffer, size_t* len);
 
 #define pakfire_hexlify(digest) __pakfire_hexlify(digest, sizeof(digest))
index 9658c239423ff6884591b2ecb08542396c421a51..788790bbd2e312d992d02a4e7f7d5adf5c943f8e 100644 (file)
@@ -139,7 +139,7 @@ static int pakfire_key_create(struct pakfire_key** key, struct pakfire_ctx* ctx,
                        goto ERROR;
 
                // Remove any trailing newline
-               pakfire_remove_trailing_newline(k->comment);
+               pakfire_string_rstrip(k->comment);
        }
 
        // Return the pointer
index b07fd3f328e90499a5f3a4cde6d08f148908b84d..ece3af4a05d346c329feeedb145c00971a7e616a 100644 (file)
@@ -484,7 +484,7 @@ static int pakfire_parser_expand_commands(struct pakfire_parser* parser, char**
 
                // Strip newline from output
                if (output)
-                       pakfire_remove_trailing_newline(output);
+                       pakfire_string_rstrip(output);
 
                // Find the entire matched pattern
                r = pcre2_substring_get_bynumber(match, 0, &pattern, &pattern_length);
index d4fe0d76a5e9dd88499344ebf3d71a039c2b0a1d..ec9fb9860ebc947907111e3c6b9901b6f1949a33 100644 (file)
@@ -129,15 +129,6 @@ ERROR:
        return r;
 }
 
-char* pakfire_remove_trailing_newline(char* str) {
-       ssize_t pos = strlen(str) - 1;
-
-       if (str[pos] == '\n')
-               str[pos] = '\0';
-
-       return str;
-}
-
 int pakfire_read_file_into_buffer(FILE* f, char** buffer, size_t* len) {
        if (!f)
                return -EBADF;