X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fexamples_exist.c;h=073a0b2c215c74e57b1b53cbed309a864c1a5aa9;hb=f243444490e8dcdaa399942b70e72d03005370f7;hp=7e9dd97cc8afa379ba227108e3fd0354c80b9aff;hpb=af5b1a18948345c5f9f9abf4eda3ab9fe0aa9a9f;p=ccan diff --git a/tools/ccanlint/tests/examples_exist.c b/tools/ccanlint/tests/examples_exist.c index 7e9dd97c..073a0b2c 100644 --- a/tools/ccanlint/tests/examples_exist.c +++ b/tools/ccanlint/tests/examples_exist.c @@ -19,7 +19,7 @@ static char *add_example(struct manifest *m, struct ccan_file *source, struct doc_section *example) { - char *name; + char *name, *linemarker; unsigned int i; int fd; struct ccan_file *f; @@ -43,6 +43,11 @@ static char *add_example(struct manifest *m, struct ccan_file *source, return talloc_asprintf(m, "Creating temporary file %s: %s", f->fullname, strerror(errno)); + /* Add #line to demark where we are from, so errors are correct! */ + linemarker = talloc_asprintf(f, "#line %i \"%s\"\n", + example->srcline+2, source->fullname); + write(fd, linemarker, strlen(linemarker)); + for (i = 0; i < example->num_lines; i++) { if (write(fd, example->lines[i], strlen(example->lines[i])) != strlen(example->lines[i])