It is not valid for the integer argument of a #line directive to be 0.
However, the generated C source will contain such a directive around the
prototypes of private functions that do not appear in the .gob file.
For example, the trivial
class My:Test from G:Object {
}
generates the invalid C code:
#line 0 "my-test.gob"
static void my_test_init (MyTest * o) G_GNUC_UNUSED;
/* ... */
#line 0 "my-test.gob"
static void my_test_class_init (MyTestClass * c) G_GNUC_UNUSED;
Fix this up and add an assertion to out_addline_infile to catch future
problems of this nature.
--- Hopefully this is the right place to send patches! The gob2 website doesn't make any mention of where they should be sent. src/main.c | 6 ++++-- src/out.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 5d2d4c9..cd8edef 100644 --- a/src/main.c +++ b/src/main.c @@ -578,7 +578,8 @@ put_priv_method_prot(const Method *m) m->cbuf)) { /* add unique ID */ char *s = g_strdup_printf("___%x_", (guint)m->unique_id); - out_addline_infile(out, m->line_no); + if (m->line_no > 0) + out_addline_infile(out, m->line_no); print_method(out, "static ", s, "", " ", "", no_gnu?";\n":" G_GNUC_UNUSED;\n", m, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE); @@ -590,7 +591,8 @@ put_priv_method_prot(const Method *m) m->method == CONSTRUCTOR_METHOD || m->method == DISPOSE_METHOD || m->method == FINALIZE_METHOD) { - out_addline_infile(out, m->line_no); + if (m->line_no > 0) + out_addline_infile(out, m->line_no); print_method(out, "static ", "", "", " ", "", no_gnu?";\n":" G_GNUC_UNUSED;\n", m, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE); diff --git a/src/out.c b/src/out.c index b6371f6..c93c933 100644 --- a/src/out.c +++ b/src/out.c @@ -54,6 +54,8 @@ out_printf(FILE *fp, const char *format,...) void out_addline_infile(FILE *fp, int line) { + g_return_if_fail(line > 0); + if(no_lines || no_write) return; -- 1.7.4.1Received on Wed Mar 30 2011 - 20:25:44 CDT
This archive was generated by hypermail 2.2.0 : Sun Apr 17 2011 - 21:05:02 CDT