diff --git a/statements/pbrst-cli.c b/statements/pbrst-cli.c index 9b086e0..643ec64 100644 --- a/statements/pbrst-cli.c +++ b/statements/pbrst-cli.c @@ -105,6 +105,7 @@ int main(int ac, char **av) } if (graphviz) { char *g_start = strstr(parseinfo, "diagram: graphviz: start\n"); + if (g_start == NULL) exit(0); // empty output g_start = strstr(g_start, "\n"); g_start++; char *g_end = strstr(parseinfo, "diagram: graphviz: end"); diff --git a/statements/tests/runme-graphviz b/statements/tests/runme-graphviz new file mode 100755 index 0000000..434e24c --- /dev/null +++ b/statements/tests/runme-graphviz @@ -0,0 +1,21 @@ +#!/bin/bash + +# This test assumes that pbrst-cli has already been compiled. +# It creates an HTML file with embedded SVG images. + +HTML=graphviz.html +echo "
" > $HTML + +FILES=`ls -1 *.brst` +F_NO=`ls -1 *.brst | wc -l` +n=0 +for i in $FILES; do + n=$((n+1)) + echo -n -e "\r$i ($n/$F_NO)\033[0K" + ../pbrst-cli -g $i > $i.dot + dot -Tsvg $i.dot > $i.svg + echo "
" >> $HTML + done +echo + +echo "
" >> $HTML