Dec 192017
 
CFC checks C source files for format discrepencies and possible errors not commonly flagged by compilers. C source code is included.
File CFC.ZIP from The Programmer’s Corner in
Category C Source Code
CFC checks C source files for format discrepencies and possible errors not commonly flagged by compilers. C source code is included.
File Name File Size Zip Size Zip Type
CF.BAT 1382 514 deflated
CFC.C 9107 2596 deflated
CFC.DOC 10801 3244 deflated
CFC.EXE 23957 12020 deflated

Download File CFC.ZIP Here

Contents of the CFC.DOC file


CFC - C fixed format checker v1.0 Copyright 1990 by Ron Mignery


CFC checks C source files for format discrepencies and
possible errors not commonly flagged by compilers. The C language
enforces few format rules. Most programmers follow one or more of a
large number of C source style conventions. C compilers, however,
will not report style errors. Often style errors occur as a result
of editing mistakes and generate real errors in the code. A compiler
may then report an error, but its origin in the source may be unclear
and difficult to track down. CFC (and a number of other programs)
flag style errors and allow the programmer to find source errors that
might otherwise slip pass the compiler.

CFC can be tailored to a wide range of formating styles
through command line options.

Note that CFC only reads the source file and does not modify
it. Nor does it report the errors commonly found by compilers. Its
use is conceived as applied to files that sucessfully compile or
compile with errors not easily identified, a supplement to the
error checking of the compiler.


Format is: cfc [-blesiondxxdxx...] filename.c [tab] [tab...]

b = show block comments
l = list error lines
e = enable reporting in DEBUG lines
s = stop on error
i = indent before lbrace ({)
o = outdent after rbrace (})
n = no indent on column 1
dxx = disable error report #xx


Examples:

"cfc" Display the help information.

"cfc yourfile.c" Scan yourfile.c, report all errors.

"cfc -ld00d16 yourfile.c" Same but show text of lines with errors
and do not report errors 00 and 16.

"cfc yourfile.c 5 9" Same but use tabstops 1, 5, 9, 13, 17...
instead of 1, 4, 7, 10....

"cfc yourfile.h > yf.err" Scan yourfile.h, write all errors to
the file yf.err.


Explanation of Command Line Options:


b = show block comments

The -b switch commands CFC to display all comments that
include line feeds and thus run to more than one line. This is
useful for detecting the error of unclosed comments. The comments
can be visually scanned to detect any code mistakenly enclosed in the
comment.


l = list error lines

The -l switch commands CFC to display the actual text of any
line for which it reports an error.


e = enable reporting in DEBUG lines

The -e switch commands CFC to process lines enclosed in
"#ifdef DEBUG/#endif" delimiters. By default, such lines are ignored
as they rarely follow the indenting format of the code in which they
are imbedded.


s = stop on error

The -s switch commands CFC to halt when an error is detected.
Otherwise CFC reports all errors in the source file. Often one error
propagates to many errors and only the first instance needs to be
detected.


i = indent before lbrace ({)

The -i switch commands CFC to expect an indentation before an
lbrace rather than after. See the discussion of indenting below for
further explanation.


o = outdent after rbrace (})

The -o switch commands CFC to expect an outdentation after an
rbrace rather than before. See the discussion of indenting below for
further explanation.


n = no indent on column 1

The -n switch commands CFC to expect no indentation after an
lbrace in column one. This is a popular space-saving convention.
See the discussion of indenting below for further explanation.


dxx = disable error report #xx

The -dxx switch commands CFC to not report the indicated
error. For example, cfc -d00 yourfile.c will not report trailing
blanks or tabs in the file. The possible error reports and their
numbers are listed below:

00 Trailing blanks or tabs in line
01 First Character not on tab stop in line
02 Missing indent in line
03 Extra indent in line

04 Characters past comment in line
05 Semicolon in comment line
06 Quotes in comment line
07 Braces in comment line
08 Characters past semicolon in line
09 Characters past lbrace in line
10 Semicolon in quotes in line
11 Rbrace in quotes in line
12 Lbrace in quotes in line
13 Rbrace not first char in line
14 Odd quotes in line
15 Comment not closed in line
16 More than 80 characters in line


Explanation of Error Codes:


00 Trailing blanks or tabs in line

This is just wasted space and makes the source file larger
than it needs to be.


01 First Character not on tab stop in line

CFC expects all first non-whitespace characters of a new line
(that is, one following a semicolon or a brace) to occur on a tab
stop. See the discussion of tab stops below for further information.


02 Missing indent in line

A new line of source (that is, one following a semicolon or a
brace) is insufficiently indented.


03 Extra indent in line

A new line of source (that is, one following a semicolon or a
brace) is excessivley indented.


04 Characters past comment in line

Non-whitespace characters have been found past a comment on a
line. Though this is often legitimate, it may indicate an editing
error.


05 Semicolon in comment line

A semicolon has been found inside a comment. Though this is
often legitimate, it may indicate an editing error.


06 Quotes in comment line

A quote has been found inside a comment. Though this is
often legitimate, it may indicate an editing error.


07 Braces in comment line

A brace has been found inside a comment. Though this is
often legitimate, it may indicate an editing error.


08 Characters past semicolon in line

Characters other than whitespace and comments have been
detected on a line past a semicolon. CFC expects only one statement
per line. Note that this error is not reported for for-next
condition expressions.


09 Characters past lbrace in line

Characters other than whitespace and comments have been
detected on a line past an lbrace ({). CFC expects only one statement
per line.


10 Semicolon in quotes in line

A semicolon has been found inside a literal. Though this is
often legitimate, it may indicate an editing error.


11 Rbrace in quotes in line

An rbrace (}) has been found inside a literal. Though this is
often legitimate, it may indicate an editing error.


12 Lbrace in quotes in line

An lbrace ({) has been found inside a literal. Though this is
often legitimate, it may indicate an editing error.


13 Rbrace not first char in line

Characters preceed an rbrace (}) on a line.


14 Odd quotes in line

A literal is extending to more than one line. Though this is
often legitimate, it may indicate an editing error.


15 Comment not closed in line

A comment is extending to more than one line. Though this is
often legitimate, it may indicate an editing error.


16 More than 80 characters in line

A line with more than 80 characters may hide its contents
with many editors that display only the first 80 characters of a
line.


Tabs:

The default tab stops are 1, 4, 7 etc. Alternate stops may
be specified on the command line after the source filename. Tab stop
1 is implied. Tab stops beyond those explicitly defined are
automatically generated at an interval equal to the difference
between the last two stops specified. If only one stop is specified,
then the interval is the difference between that stop and 1. Thus,
"cfc yourfile.c 5 8" will generate tab stops at columns 1, 5, 8, 11,
14 etc. "cfc yourfile.c 4" will generate tab stops at columns 1, 4,
7, 10 etc. CFC allows indentations to be generated by any
combination of tabs and spaces.


Indentation:

CFC only evaluates the indentation of statements. To CFC a
statement begins with a non-whitespace character and ends with a
semicolon or a brace. CFC only evaluates the tab position of the
first character of the statement. Thus for a statement that extends
to more than one line, the indentation of the second line is not
evaluated. Changes in expected levels of indentation only occur when
braces are encountered. Whether the change occurs before or after
the brace is determined by the setting of the -i, -o, and -n switches
described above. The proper settings of these switches for some
popular indentation format styles are presented below:


Style 1: default

type function() {
statement;
conditional {
statement;
statement;
}
}


Style 2: default

type function()
{
statement;
conditional
{
statement;
statement;
}
}


Style 3: -io

type function()
{
statement;
conditional
{
statement;
statement;
}
}


Style 4: -ion

type function()
{
statement;
conditional
{
statement;
statement;
}
}


Style 5: -n

type function()
{
statement;
conditional {
statement;
statement;
}
}


CF.BAT:


A batch file, CF.BAT, is provided to run CFC in your preferred
configuration. Edit it to your needs as detailed therein.


DISCLAIMER:

In no event will the author be liable to you for any damages,
including any lost profits, lost savings or other incidental or
consequential damages arising out of the use of or inability to use
these programs, even if the author has been advised of the
possibility of such damages, or for any claim by any other party.


DISTRIBUTION:


The distribution package for CFC consists of the following
files:

CFC.EXEthe executive file (compiled using TurboC)
CFC.Cthe source for CFC.EXE
CFC.DOCthis file
CF.BATruns a configured CFC.EXE

The author places no restrictions on the copying, porting and
distribution of CFC. If you are using this program and find it to be
of substantial value, a $5 contribution would be appreciated. Please
address all communications to the author:

Ron Mignery
85 Bartlett Street
Somerville, MA 02145

*** END OF CFC.DOC ***



 December 19, 2017  Add comments

Leave a Reply