From 88cb69b10c66751f687c3745c8e9861b105de3a2 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 4 Jul 2009 21:43:27 +0100 Subject: [boilerpate] Move target definition to backends. By moving the backend target definition out of the massive amlagamated block in cairo-boilerplate.c and into each of the cairo-boilerplate-backend.c, we make it much easier to add new targets as the information need only be entered in a single file and not scattered across three. However, updating the target interface means trawling across all the files -- except given that I found it difficult maintaining the single massive array I do not see this as an increase in the maintenance burden. --- test/make-cairo-test-constructors.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'test') diff --git a/test/make-cairo-test-constructors.c b/test/make-cairo-test-constructors.c index 1a8bd5532..e19de372b 100644 --- a/test/make-cairo-test-constructors.c +++ b/test/make-cairo-test-constructors.c @@ -27,17 +27,18 @@ * file with one function _cairo_test_runner_register_tests() which * calls the functions _register_() in reverse order. */ + /* Keep this file ANSI compliant without any special needs. */ #include #include #include -struct name { - struct name *next; - char *name; -}; +#define NAME "make-cairo-test-constructors.c" -static struct name *head = NULL; +static struct name { + struct name *next; + char name[1]; +} *head; static void * xmalloc (size_t n) @@ -53,10 +54,12 @@ xmalloc (size_t n) static void add_name (const char *name) { - struct name *node = xmalloc (sizeof (struct name)); + struct name *node; + int len; - node->name = xmalloc (strlen(name)+1); - strcpy (node->name, name); + len = strlen (name); + node = xmalloc (sizeof (struct name) + len); + memcpy (node->name, name, len + 1); node->next = head; head = node; @@ -97,7 +100,7 @@ scan_file (const char *filename, if (length == 0) { fprintf (stderr, "%s:%d: CAIRO_TEST invocation " - "can't be parsed by make-cairo-test-constructors.c\n", + "can't be parsed by " NAME "\n", filename, line_num); fail = 1; continue; @@ -126,14 +129,13 @@ main (int argc, char **argv) if (fail) exit(1); - puts ("/* WARNING: Autogenerated file - " - "see make-cairo-test-constructors.c! */"); + puts ("/* WARNING: Autogenerated file - see " NAME "! */"); puts (""); puts ("#include \"cairo-test-private.h\""); puts (""); for (node = head; node; node = node->next) { - printf("extern void _register_%s (void);\n", + printf ("extern void _register_%s (void);\n", node->name); } puts(""); @@ -145,7 +147,7 @@ main (int argc, char **argv) puts ("_cairo_test_runner_register_tests (void)"); puts ("{"); for (node = head; node; node = node->next) { - printf(" _register_%s ();\n", node->name); + printf (" _register_%s ();\n", node->name); } puts ("}"); -- cgit v1.2.3