# HG changeset patch # User Giacomo Lozito # Date 1186857133 -7200 # Node ID 63d7947d73760fe211f9c5164e2b7c7dc8d8831b # Parent ea806daf3ef03ab52baa4f178331535e2e730664 simplified the tuple formatter a bit diff -r ea806daf3ef0 -r 63d7947d7376 src/audacious/tuple_formatter.c --- a/src/audacious/tuple_formatter.c Sat Aug 11 23:59:24 2007 +0900 +++ b/src/audacious/tuple_formatter.c Sat Aug 11 20:32:13 2007 +0200 @@ -86,10 +86,13 @@ for (iter = string; *iter != '\0'; iter++) { /* if it's raw text, just copy the byte */ - if (*iter != '$' && *iter != '%' && (*iter != '}' || (*iter == '}' && level > 0))) + if (*iter != '$' && *iter != '%' && *iter != '}' ) + { + g_string_append_c(ctx->str, *iter); + } + else if (*iter == '}' && level > 0) { level--; - g_string_append_c(ctx->str, *iter); } else if (g_str_has_prefix(iter, "${") == TRUE) { @@ -97,13 +100,12 @@ GString *argument = g_string_new(""); GString *sel = expression; gchar *result; - gboolean rewind = FALSE; + level++; for (iter += 2; *iter != '\0'; iter++) { if (*iter == ':') { - level++; if (sel != argument) { sel = argument; @@ -125,13 +127,10 @@ else if (*iter == '}' && (sel == argument)) { level--; - if (level + 1 > 0) - { - iter++; - rewind = *(iter - 1) == '}' && *iter != '}'; - break; - } - g_string_append_c(sel, *iter); + if (level == 0) + break; + else + g_string_append_c(sel, *iter); } else if (*iter == '}' && ((sel != argument))) break; @@ -158,9 +157,6 @@ if (*iter == '\0') break; - - if (rewind) - iter--; } else if (g_str_has_prefix(iter, "%{") == TRUE) { @@ -168,13 +164,12 @@ GString *argument = g_string_new(""); GString *sel = expression; gchar *result; - gboolean rewind = FALSE; + level++; for (iter += 2; *iter != '\0'; iter++) { if (*iter == ':') { - level++; if (sel != argument) { sel = argument; @@ -196,12 +191,9 @@ else if (*iter == '}' && (sel == argument)) { level--; - if (level + 1 > 0) - { - iter++; - rewind = *(iter - 1) == '}' && *iter != '}'; - break; - } + if (level == 0) + break; + else g_string_append_c(sel, *iter); } else if (*iter == '}' && ((sel != argument))) @@ -229,9 +221,6 @@ if (*iter == '\0') break; - - if (rewind) - iter--; } }