Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages
checkbrack(1) hxtools checkbrack(1)

checkbrack — check parenthesis and bracket count

checkbrack [-p] file...

Displays each line of the file(s), together with their open bracket count that is reached at the end of line. Particularly, it allows you to find missing closing brackets. This is especially helpful because the Perl interpreter for example has problems telling you where exactly something went wrong.

Enable Perl/PHP mode, that is, do not consider presence $(, $), $[ and $] of a bracket imbalance.

$ checkbrack /usr/lib/hxtools/bin/checkbrack | less -S
#   () [] {}
13  0  0  1 foreach my $file (@ARGV) {
14  0  0  1     if (!-f $file) { next; }
15  0  0  1     print "Displaying $file...0;
16  0  0  2     if (!open(IN, "< $file")) {
17  0  0  2         print "Error opening $file: $!0;
18  0  0  2         next;
19  0  0  1     }

The numbers at the front are: line number, number of unclosed left parentheses, number of unclosed left square brackets and number of unclosed left square braces.

At the end of line 19, we would need to close one more brace to make it syntactically valid code.

The interesting thing of this, that if GCC, Perl or whatever outputs an error and you do not figure out what it means — that is often the case with missing braces — run checkbrack on the source file, skip to the end, and watch the brace counts.

Scroll up until the brace counts seem normal (i.e. 0 open braces) at outside any function.

2008-02-06 hxtools

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.