Commit 503dbd59 authored by Rusty Russell's avatar Rusty Russell

Store pristine contents of files: based on Joey's patch.

parent bda94e9f
......@@ -88,6 +88,11 @@ struct ccan_file {
char *name;
/* Pristine version of the original file.
* Use get_ccan_file_lines to fill this. */
const char *contents;
size_t contents_size;
/* Use get_ccan_file_lines / get_ccan_line_info to fill these. */
unsigned int num_lines;
char **lines;
......
......@@ -17,12 +17,9 @@
char **get_ccan_file_lines(struct ccan_file *f)
{
if (!f->lines) {
char *buffer = grab_file(f, f->name, NULL);
if (!buffer)
err(1, "Getting file %s", f->name);
f->lines = strsplit(f, buffer, "\n", &f->num_lines);
}
if (!f->lines)
f->lines = strsplit(f, f->contents, "\n", &f->num_lines);
return f->lines;
}
......@@ -76,13 +73,24 @@ static void add_files(struct manifest *m, const char *dir)
if (streq(f->name, "_info.c")) {
m->info_file = f;
f->contents = grab_file(f, f->name, &f->contents_size);
if (!f->contents)
err(1, "Reading file %s", f->name);
continue;
}
is_c_src = strends(f->name, ".c");
if (!is_c_src && !strends(f->name, ".h"))
if (!is_c_src && !strends(f->name, ".h")) {
/* We don't pull in contents of non-source files */
dest = &m->other_files;
else if (!strchr(f->name, '/')) {
continue;
}
f->contents = grab_file(f, f->name, &f->contents_size);
if (!f->contents)
err(1, "Reading file %s", f->name);
if (!strchr(f->name, '/')) {
if (is_c_src)
dest = &m->c_files;
else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment