From 73e466cfef6497aff840cfac35d80d74e7b0fd0c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 18 Jan 2009 19:24:14 +0100 Subject: jack: parse "ports" setting with g_strsplit() Don't modify the configured string. --- src/output/jack_plugin.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/output/jack_plugin.c b/src/output/jack_plugin.c index 8b78d524d..5723a04ca 100644 --- a/src/output/jack_plugin.c +++ b/src/output/jack_plugin.c @@ -189,7 +189,6 @@ mpd_jack_init(struct audio_output *ao, struct block_param *bp; char *endptr; int val; - char *cp = NULL; jd = mpd_jack_new(); jd->ao = ao; @@ -199,28 +198,16 @@ mpd_jack_init(struct audio_output *ao, return jd; if ( (bp = getBlockParam(param, "ports")) ) { - g_debug("output_ports=%s", bp->value); + char **ports = g_strsplit(bp->value, ",", 0); - if (!(cp = strchr(bp->value, ','))) - g_error("expected comma and a second value for '%s' " - "at line %d: %s", - bp->name, bp->line, bp->value); + if (ports[0] == NULL || ports[1] == NULL || ports[2] != NULL) + g_error("two port names expected in line %d", + bp->line); - *cp = '\0'; - jd->output_ports[0] = g_strdup(bp->value); - *cp++ = ','; + jd->output_ports[0] = ports[0]; + jd->output_ports[1] = ports[1]; - if (!*cp) - g_error("expected a second value for '%s' at line %d: %s", - bp->name, bp->line, bp->value); - - jd->output_ports[1] = g_strdup(cp); - - if (strchr(cp,',')) - g_error("Only %d values are supported for '%s' " - "at line %d", - (int)G_N_ELEMENTS(jd->output_ports), - bp->name, bp->line); + g_free(ports); } if ( (bp = getBlockParam(param, "ringbuffer_size")) ) { -- cgit v1.2.3