aboutsummaryrefslogtreecommitdiffstats
path: root/src/strfsong.c
diff options
context:
space:
mode:
authorKalle Wallin <kaw@linux.se>2004-07-13 21:10:06 +0000
committerKalle Wallin <kaw@linux.se>2004-07-13 21:10:06 +0000
commit9a500d13055f16b70796a5fce5ec6de4a2844187 (patch)
tree8f57c14c8454ee836597cc47ed7eedd3b6f4dabe /src/strfsong.c
parente9f21b11c862ad168bb5a850730861e01ad6f3d8 (diff)
downloadmpd-9a500d13055f16b70796a5fce5ec6de4a2844187.tar.gz
mpd-9a500d13055f16b70796a5fce5ec6de4a2844187.tar.xz
mpd-9a500d13055f16b70796a5fce5ec6de4a2844187.zip
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
Diffstat (limited to 'src/strfsong.c')
-rw-r--r--src/strfsong.c25
1 files changed, 10 insertions, 15 deletions
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] != '%' && length<max)
{
- strncat(s, p, 1);
- length++;
- ++p;
+ s[length++] = *p;
+ p++;
continue;
}
/* let the escape character escape itself */
if (p[0] == '#' && p[1] != '\0' && length<max)
{
- strncat(s, p+1, 1);
- length++;
+ s[length++] = *(p+1);
p+=2;
continue;
}
@@ -185,13 +183,10 @@ _strfsong(gchar *s,
}
else if (strncmp("%time%", p, n) == 0)
{
- if (song->time != 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);
}