Next: , Previous: boilerplate invocation, Up: Scanning for boilerplate   [Contents][Index]


2.2 cbb: Count the boilerplate blocks in source files

The command cbb stands for "count comment blocks". The purpose of this command is to display the size of the boilerplate in the given files. Here is how the command is normally executed:

$ licensing cbb foo.c
2 17 foo.c

This example shows that there are 2 comment-blocks at the beginning of foo.c, having 17 lines in total.

By default the cbb command automatically detects comments, but any of the commenting-style options can be used to detect a particular commenting-style instead. See Common Commenting-style options for more information.

The --lines option causes cbb to display only the number of lines in the boilerplate, and the --blocks option displays only the number of blocks.

The cbb command can assist in iterating through the various comment-blocks in boilerplate.

#!/bin/bash
blocks=`licensing cbb foo.c | cut -f1 -d' '`
for (( b=1; b<=$blocks; b++ )); do
  licensing boilerplate -b$b foo.c
done

When the input file is -, it is read from the standard input.