key/key-io.c: Produce valid key lines for empty keys.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 13 May 2017 15:29:09 +0000 (16:29 +0100)
If a key contains only an empty tree of structures, then `key_write'
returns an empty string, which breaks the whitespace-separated field
structure of the output key line.  Notice this and insert an empty
structure by hand as an unpleasant bodge.

The resulting key is still highly anomalous.  In particular, it doesn't
match any filter, because structure nodes don't have flags.  I don't
know what to do about this.

key/key-io.c

index b2dc918..c79c8e0 100644 (file)
@@ -352,7 +352,7 @@ int key_extract(key_file *f, key *k, FILE *fp, const key_filter *kf)
 
   key_fulltag(k, &d);
   DPUTC(&d, ' ');
-  key_write(k->k, &d, kf);
+  if (!key_write(k->k, &d, kf)) dstr_puts(&d, "struct:[]");
   DPUTC(&d, ' ');
   dstr_write(&d, fp);
   DRESET(&d);