Optimization: eliminate some usages of strcat()
* defs.h: Declare stpcpy().
* util.c: Define stpcpy().
* file.c: Remove static str_append().
(sprint_open_modes): Use stpcpy() instead of str_append().
(sprintflags): Use stpcpy() instead of strcat().
(printpathn): Eliminate usage of strcat().
(printstr): Eliminate usage of strcat().
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
diff --git a/file.c b/file.c
index 5d5a0fe..c40fde2 100644
--- a/file.c
+++ b/file.c
@@ -343,17 +343,6 @@
#endif
/*
- * Pity stpcpy() is not standardized...
- */
-static char *
-str_append(char *dst, const char *src)
-{
- while ((*dst = *src++) != '\0')
- dst++;
- return dst;
-}
-
-/*
* low bits of the open(2) flags define access mode,
* other bits are real flags.
*/
@@ -366,10 +355,10 @@
const char *str;
const struct xlat *x;
- p = str_append(outstr, "flags ");
+ p = stpcpy(outstr, "flags ");
str = xlookup(open_access_modes, flags & 3);
if (str) {
- p = str_append(p, str);
+ p = stpcpy(p, str);
flags &= ~3;
if (!flags)
return outstr;
@@ -380,7 +369,7 @@
if ((flags & x->val) == x->val) {
if (sep)
*p++ = sep;
- p = str_append(p, x->str);
+ p = stpcpy(p, x->str);
flags &= ~x->val;
if (!flags)
return outstr;