diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-07-04 21:43:27 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-07-04 21:43:27 +0100 |
commit | 88cb69b10c66751f687c3745c8e9861b105de3a2 (patch) | |
tree | 3887fc1f4f4cf61b9111b62f6e85af0b72534782 /test | |
parent | 8a10ab1c04298d6c22ae8aabec5d762141a8e98f (diff) |
[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.
Diffstat (limited to 'test')
-rw-r--r-- | test/make-cairo-test-constructors.c | 28 |
1 files changed, 15 insertions, 13 deletions
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_<testname>() in reverse order. */ + /* Keep this file ANSI compliant without any special needs. */ #include <stdio.h> #include <stdlib.h> #include <string.h> -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 ("}"); |