string was not cleaned.
[r4657]
- * append a char to a string buffer
+ * Init the string.
+ */
+static void str_init(void *object, size_t n)
+{
+ strcpy(object, "");
+}
+
+/**
+ * append a char to a string buffer.
*/
static void str_append_char(void *object, size_t n, char ch)
{
*/
static void str_append_char(void *object, size_t n, char ch)
{
- * append a string to a string buffer
+ * append a string to a string buffer.
*/
static void str_append_str(void *object, size_t n, const char *str)
{
strncat(object, str, n);
}
*/
static void str_append_str(void *object, size_t n, const char *str)
{
strncat(object, str, n);
}
- * append a char to a file
+ * Init the file. i.e. do nothing.
+ */
+static void file_init(void *object, size_t n)
+{
+}
+
+/**
+ * append a char to a file.
*/
static void file_append_char(void *object, size_t n, char ch)
{
*/
static void file_append_char(void *object, size_t n, char ch)
{
- * append a string to a file
+ * append a string to a file.
*/
static void file_append_str(void *object, size_t n, const char *str)
{
*/
static void file_append_str(void *object, size_t n, const char *str)
{
* the file appender
*/
static const appender_t file_appender = {
* the file appender
*/
static const appender_t file_appender = {
file_append_char,
file_append_str
};
file_append_char,
file_append_str
};
* the string buffer appender
*/
static const appender_t str_appender = {
* the string buffer appender
*/
static const appender_t str_appender = {
str_append_char,
str_append_str
};
str_append_char,
str_append_str
};
+/* Length specifiers. */
+enum {
+ len_char,
+ len_short,
+ len_int,
+ len_long,
+ len_long_long
+};
+
+
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
static void dump_with_settings(const appender_t *app, void *object, size_t limit,
const struct settings *settings, const char *str)
{
static void dump_with_settings(const appender_t *app, void *object, size_t limit,
const struct settings *settings, const char *str)
{
-
-/* Length specifiers. */
-enum {
- len_char,
- len_short,
- len_int,
- len_long,
- len_long_long
-};
-
-
/**
* A small printf helper routine for ir nodes.
* @param app An appender (this determines where the stuff is dumped
/**
* A small printf helper routine for ir nodes.
* @param app An appender (this determines where the stuff is dumped
#define DUMP_STR(s) app->append_str(object, limit, s)
#define DUMP_CH(ch) app->append_char(object, limit, ch)
#define DUMP_STR(s) app->append_str(object, limit, s)
#define DUMP_CH(ch) app->append_char(object, limit, ch)
+ app->init(object, limit);
+
for(i = 0, n = strlen(fmt); i < n; ++i) {
char ch = fmt[i];
for(i = 0, n = strlen(fmt); i < n; ++i) {
char ch = fmt[i];
* Something that can append strings and chars to something.
*/
typedef struct _appender_t {
* Something that can append strings and chars to something.
*/
typedef struct _appender_t {
+ void (*init)(void *object, size_t n);
void (*append_char)(void *object, size_t n, char ch);
void (*append_str)(void *object, size_t n, const char *str);
} appender_t;
void (*append_char)(void *object, size_t n, char ch);
void (*append_str)(void *object, size_t n, const char *str);
} appender_t;