]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/strutils: rename strappend() to strconcat()
authorKarel Zak <kzak@redhat.com>
Thu, 5 Aug 2021 09:25:54 +0000 (11:25 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 5 Aug 2021 09:30:37 +0000 (11:30 +0200)
It concatenates two strings to a new string. It's something else than
"append".

Signed-off-by: Karel Zak <kzak@redhat.com>
include/strutils.h
lib/strutils.c
lib/strv.c
libmount/src/tab.c
misc-utils/getopt.c
misc-utils/logger.c

index d6f57c71e0d4443bd609a932fde27163a0773cbd..e7edd852e353bceff2e9630a84a5cf1e383b8fc9 100644 (file)
@@ -378,9 +378,9 @@ static inline void strrem(char *s, int rem)
        *p = '\0';
 }
 
-extern char *strnappend(const char *s, const char *suffix, size_t b);
-extern char *strappend(const char *s, const char *suffix);
-extern char *strfappend(const char *s, const char *format, ...)
+extern char *strnconcat(const char *s, const char *suffix, size_t b);
+extern char *strconcat(const char *s, const char *suffix);
+extern char *strfconcat(const char *s, const char *format, ...)
                 __attribute__ ((__format__ (__printf__, 2, 3)));
 extern const char *split(const char **state, size_t *l, const char *separator, int quoted);
 
index cd49b9781732f38247a22e463cf0be0f121e4678..794203abd18cdb74985a9c2a66735457cfe464f6 100644 (file)
@@ -936,7 +936,8 @@ int streq_paths(const char *a, const char *b)
        return 0;
 }
 
-char *strnappend(const char *s, const char *suffix, size_t b)
+/* concatenate two strings to a new string, the size of the second string is limited by @b */
+char *strnconcat(const char *s, const char *suffix, size_t b)
 {
         size_t a;
         char *r;
@@ -966,12 +967,14 @@ char *strnappend(const char *s, const char *suffix, size_t b)
         return r;
 }
 
-char *strappend(const char *s, const char *suffix)
+/* concatenate two strings to a new string */
+char *strconcat(const char *s, const char *suffix)
 {
-        return strnappend(s, suffix, suffix ? strlen(suffix) : 0);
+        return strnconcat(s, suffix, suffix ? strlen(suffix) : 0);
 }
 
-char *strfappend(const char *s, const char *format, ...)
+/* concatenate @s and string defined by @format to a new string */
+char *strfconcat(const char *s, const char *format, ...)
 {
        va_list ap;
        char *val, *res;
@@ -984,7 +987,7 @@ char *strfappend(const char *s, const char *format, ...)
        if (sz < 0)
                return NULL;
 
-       res = strnappend(s, val, sz);
+       res = strnconcat(s, val, sz);
        free(val);
        return res;
 }
index ddc2a0c5dddb4d637b0cab041896d35e974b92db..58a4c97dec5a2f77310ddca31593b0c731ed1137 100644 (file)
@@ -162,7 +162,7 @@ int strv_extend_strv_concat(char ***a, char **b, const char *suffix) {
         STRV_FOREACH(s, b) {
                 char *v;
 
-                v = strappend(*s, suffix);
+                v = strconcat(*s, suffix);
                 if (!v)
                         return -ENOMEM;
 
index 0d5c11566c81217120c1791e9483c17ea6650053..5fd4608646cc8c4b89d23d5aa4db5ed9fd620ba4 100644 (file)
@@ -1747,7 +1747,7 @@ int __mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_f
                        src = mnt_fs_get_srcpath(rootfs);
                        if (fstype && strncmp(fstype, "nfs", 3) == 0 && root) {
                                /* NFS stores the root at the end of the source */
-                               src = src2 = strappend(src, root);
+                               src = src2 = strconcat(src, root);
                                free(root);
                                root = NULL;
                        }
index 3fc38c97d3a39c43a75e14af7257dea6566388a4..977b72560074ad1c521adaa418654370e41d3db4 100644 (file)
@@ -280,7 +280,7 @@ static void add_short_options(struct getopt_control *ctl, char *options)
 {
        free(ctl->optstr);
        if (*options != '+' && getenv("POSIXLY_CORRECT"))
-               ctl->optstr = strappend("+", options);
+               ctl->optstr = strconcat("+", options);
        else
                ctl->optstr = xstrdup(options);
        if (!ctl->optstr)
index 5b122de79f96af4d5c0311ef190127a809923d50..ba36b0fd9cf612c299a05242e1921f4329ab7f76 100644 (file)
@@ -654,7 +654,7 @@ static char *strdup_structured_data_list(struct list_head *ls)
 
                if (!one)
                        continue;
-               res = strappend(tmp, one);
+               res = strconcat(tmp, one);
                free(tmp);
                free(one);
        }
@@ -672,7 +672,7 @@ static char *get_structured_data_string(struct logger_ctl *ctl)
                usr = strdup_structured_data_list(&ctl->user_sds);
 
        if (sys && usr) {
-               res = strappend(sys, usr);
+               res = strconcat(sys, usr);
                free(sys);
                free(usr);
        } else