comparison src/audacious/tuple_formatter.c @ 3331:9c53688bb559 trunk

some debugging for giacomo
author William Pitcock <nenolod@atheme-project.org>
date Sat, 11 Aug 2007 07:34:28 -0500
parents de29bf952b77
children 63d7947d7376
comparison
equal deleted inserted replaced
3330:8745ffb73f49 3331:9c53688bb559
22 #include <mowgli.h> 22 #include <mowgli.h>
23 23
24 #include "config.h" 24 #include "config.h"
25 #include "tuple.h" 25 #include "tuple.h"
26 #include "tuple_formatter.h" 26 #include "tuple_formatter.h"
27
28 #define _DEBUG
29
30 #ifdef _DEBUG
31 # define _TRACE(fmt, ...) g_print("[tuple-fmt] %s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__);
32 #else
33 # define _TRACE(fmt, ...)
34 #endif
27 35
28 /* 36 /*
29 * the tuple formatter: 37 * the tuple formatter:
30 * 38 *
31 * this is a data-driven meta-language which eventually hopes to be 39 * this is a data-driven meta-language which eventually hopes to be
70 g_return_val_if_fail(string != NULL, NULL); 78 g_return_val_if_fail(string != NULL, NULL);
71 79
72 ctx = g_new0(TupleFormatterContext, 1); 80 ctx = g_new0(TupleFormatterContext, 1);
73 ctx->str = g_string_new(""); 81 ctx->str = g_string_new("");
74 82
83 _TRACE("parsing <%s>", string);
84
75 /* parsers are ugly */ 85 /* parsers are ugly */
76 for (iter = string; *iter != '\0'; iter++) 86 for (iter = string; *iter != '\0'; iter++)
77 { 87 {
78 /* if it's raw text, just copy the byte */ 88 /* if it's raw text, just copy the byte */
79 if (*iter != '$' && *iter != '%' && (*iter != '}' || (*iter == '}' && level > 0))) 89 if (*iter != '$' && *iter != '%' && (*iter != '}' || (*iter == '}' && level > 0)))
226 } 236 }
227 237
228 out = g_strdup(ctx->str->str); 238 out = g_strdup(ctx->str->str);
229 g_string_free(ctx->str, TRUE); 239 g_string_free(ctx->str, TRUE);
230 g_free(ctx); 240 g_free(ctx);
241
242 _TRACE("parsed <%s> as <%s>", string, out);
231 243
232 return out; 244 return out;
233 } 245 }
234 246
235 static GList *tuple_formatter_expr_list = NULL; 247 static GList *tuple_formatter_expr_list = NULL;