From cb5ad9178810a66a02b93978d64ee949d4865ef6 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 6 Jun 2017 12:32:46 +0930 Subject: [PATCH] tools/generate-wire.py: allow consecutive fields to use same len var. Signed-off-by: Rusty Russell --- tools/generate-wire.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/generate-wire.py b/tools/generate-wire.py index 56d74130f..a4805388e 100755 --- a/tools/generate-wire.py +++ b/tools/generate-wire.py @@ -410,8 +410,12 @@ for line in fileinput.input(options.files): # commit_sig,0,channel-id,u64 for m in messages: if m.name == parts[0]: - m.addField(Field(parts[0], parts[2], parts[3], comments, prevfield)) - prevfield = parts[2] + f = Field(parts[0], parts[2], parts[3], comments, prevfield) + m.addField(f) + # If it used prevfield as lenvar, keep that for next + # time (multiple fields can use the same lenvar). + if not f.lenvar: + prevfield = parts[2] break comments=[] else: