5 Updates some MP reference documents.
7 Angel Ortega <angel@triptico.com>
11 sub load_ref_document(file)
12 /* loads a document and returns a structure with header,
13 data entries and signature */
22 if ((f = open(file, "r")) == NULL)
29 l = sregex("/\r?\n$/", l);
31 /* is the line only dashes? */
32 if (regex('/^-+$/', l)) {
37 /* concat all data and reset */
38 local b = join("\n", d);
41 /* flush previous data: is this the first one? */
43 /* yes; everything is the header */
47 /* there is a previous one; store */
53 /* if it's the empty string, it's the
54 signature mark; we're done */
56 r.sig = join("\n", [ l, read(f) ] );
70 sub save_ref_document(file, r, hash, prefix)
71 /* saves a parsed document filling empty entries from hash */
75 if ((f = open(file, "w")) == NULL)
81 foreach (local k, sort(keys(hash))) {
86 write(f, sregex('/./g', k, '-'));
89 write(f, r.data[k] || "\nTo be written.\n");
100 sub update_ref_document(file, hash, prefix)
104 if (r = load_ref_document(file))
105 save_ref_document(file, r, hash, prefix);
110 update_ref_document('doc/mp_configuration.txt', mp.config, 'mp.config');