From 9a500d13055f16b70796a5fce5ec6de4a2844187 Mon Sep 17 00:00:00 2001 From: Kalle Wallin Date: Tue, 13 Jul 2004 21:10:06 +0000 Subject: Use glib's str functions (g_strlcat, g_strlcpy, g_snprintf, g_strdup_vprintf) git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1868 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/strfsong.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'src/strfsong.c') diff --git a/src/strfsong.c b/src/strfsong.c index a06ae95a1..bac6d472f 100644 --- a/src/strfsong.c +++ b/src/strfsong.c @@ -114,7 +114,7 @@ _strfsong(gchar *s, temp = g_malloc0(max); if( _strfsong(temp, max, p+1, song, &p) >0 ) { - strncat(s, temp, max-length); + g_strlcat(s, temp, max); length = strlen(s); found = TRUE; } @@ -137,17 +137,15 @@ _strfsong(gchar *s, /* pass-through non-escaped portions of the format string */ if (p[0] != '#' && p[0] != '%' && lengthtime != MPD_SONG_NO_TIME) { - gchar s[10]; - snprintf(s, 9, "%d:%d", song->time / 60, - song->time % 60 + 1); - /* nasty hack to use static buffer */ - temp = g_strdup(s); - } + if (song->time != MPD_SONG_NO_TIME) + temp = g_strdup_printf("%d:%d", + song->time / 60, + song->time % 60 + 1); } if( temp == NULL) @@ -202,7 +197,7 @@ _strfsong(gchar *s, but put the real character back in (pseudo-const) */ if( length+templen > max ) templen = max-length; - strncat(s, p, templen); + g_strlcat(s, p,max); length+=templen; } else { @@ -211,7 +206,7 @@ _strfsong(gchar *s, found = TRUE; if( length+templen > max ) templen = max-length; - strncat(s, temp, templen); + g_strlcat(s, temp, max); length+=templen; g_free(temp); } -- cgit v1.2.3