Skip to content

Commit

Permalink
check: only check EXPERIMENTAL-tagged BOLT quotes if EXPERIMENTAL_FEA…
Browse files Browse the repository at this point in the history
…TURES

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jul 24, 2019
1 parent 46cbca9 commit c5ae29d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,16 @@ check-bolt-dependency:

BOLT_DEPS += check-bolt-dependency

# Experimental quotes quote the exact version.
ifeq ($(EXPERIMENTAL_FEATURES),1)
CHECK_BOLT_PREFIX=--prefix="BOLT-$(BOLTVERSION)"
else
CHECK_BOLT_PREFIX=
endif

# Any mention of BOLT# must be followed by an exact quote, modulo whitespace.
bolt-check/%: % bolt-precheck tools/check-bolt
@if [ -d .tmp.lightningrfc ]; then tools/check-bolt .tmp.lightningrfc $<; else echo "Not checking BOLTs: BOLTDIR $(BOLTDIR) does not exist" >&2; fi
@if [ -d .tmp.lightningrfc ]; then tools/check-bolt $(CHECK_BOLT_PREFIX) .tmp.lightningrfc $<; else echo "Not checking BOLTs: BOLTDIR $(BOLTDIR) does not exist" >&2; fi

LOCAL_BOLTDIR=.tmp.lightningrfc

Expand Down
11 changes: 7 additions & 4 deletions tools/check-bolt.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ static struct bolt_file *get_bolt_files(const char *dir)
return bolts;
}

static char *find_bolt_ref(char **p, size_t *len)
static char *find_bolt_ref(const char *prefix, char **p, size_t *len)
{
for (;;) {
char *bolt, *end;
size_t preflen;

/* BOLT #X: */
*p = strstr(*p, "BOLT");
*p = strstr(*p, prefix);
if (!*p)
return NULL;
*p += 4;
*p += strlen(prefix);
while (cisspace(**p))
(*p)++;
if (**p != '#')
Expand Down Expand Up @@ -259,6 +259,7 @@ int main(int argc, char *argv[])

struct bolt_file *bolts;
int i;
char *prefix = "BOLT";

err_set_progname(argv[0]);

Expand All @@ -268,6 +269,8 @@ int main(int argc, char *argv[])
"Print this message.");
opt_register_noarg("--verbose", opt_set_bool, &verbose,
"Print out files as we find them");
opt_register_arg("--prefix", opt_set_charp, opt_show_charp, &prefix,
"Only check these markers");

opt_parse(&argc, argv, opt_log_stderr_exit);
if (argc < 2)
Expand All @@ -285,7 +288,7 @@ int main(int argc, char *argv[])
printf("Checking %s...\n", argv[i]);

p = f;
while ((bolt = find_bolt_ref(&p, &len)) != NULL) {
while ((bolt = find_bolt_ref(prefix, &p, &len)) != NULL) {
char *pattern = code_to_regex(p, len, true);
struct bolt_file *b = find_bolt(bolt, bolts);
if (!b)
Expand Down

0 comments on commit c5ae29d

Please sign in to comment.