Dec 132017
 
C cross ref util for MSC 5.0.
File XC21.ZIP from The Programmer’s Corner in
Category C Source Code
C cross ref util for MSC 5.0.
File Name File Size Zip Size Zip Type
COMPILE.NOT 1332 699 deflated
XC.C 21156 7408 deflated
XC.DOC 12406 4087 deflated
XC.EXE 25887 15745 deflated

Download File XC21.ZIP Here

Contents of the XC.DOC file


XC - C cross-reference program



PURPOSE:

To create a cross-referenced list of the symbols in a C
program. This program can also create a listing of the C program,
or you can use the listing generated by the compiler. (Microsoft C
can generate a listing with compatible line numbers).

AUTHOR:

Michael Bate

Bug reports, suggestions for improvement, etc., should be sent
to me at:
195 Lake View Ave.
Cambridge, MA 02138
(617)-864-4358


ACKNOWLEDGMENT:

This program was originally based on a program by the same
name by Philip N. Hisley. His excellent program runs on CP/M-80
and is compiled by BDS C. It is Copyright (c) 1982 and released
for non-commercial distribution only.

The current version of this program has been almost entirely
rewritten.

INVOKING XC:

XC is invoked via:

xc [optional flags] filename

If no extent is specified on the filename, ".C" is assumed. XC
always writes to standard output, but you can redirect this with
MS-DOS ">" or "|". The flags are explained in detail by topic in
the following sections. They are summarized at the end of this
document.

Each flag is specified by a minus sign, followed by a letter, foll-
owed (for some flags) by value. Upper and lower case are equiva-
lent. Flags can be run together. That is, "-w80t4c" is the same
as "-w80 -t4 -c".

The filename can be a full MS-DOS path, including directory
specifications.

If you invoke xc with no arguments, or incorrectly, it will respond
with a description of its syntax and a list of legal flags.




1


XC - C cross-reference program


PRINTER WIDTH AND MARGIN:

The program is set up for a printer with 132 character
positions. You can specify a different printer width with the "-w"
flag. You can specify a left margin with the "-m" flag. Note that
the value given for "-w" (default 132) is total printer width,
including the margin, if any.

ORGANIZATION OF OUTPUT:

The output is divided into two sections. The program listing
(optional) and the cross-reference table.

To obtain a program listing, specify the "-l" flag. However,
if you specify the "-i" or "-s" flags (see INCLUDED FILES) below, a
program listing is also produced.

PAGE HEADERS:

Page header consists of:

Name of the source program file, as specified on the
command line (possibly with ".C" extension added).

Date and time associated with the source file. This is
taken from the MS-DOS directory and gives the time
the file was last modified. If you specify the "-d"
flag, the current date and time (when xc was run)
will be shown instead.

As much of the first line of the source file as will fit.
You may want to place a descriptive comment in this
line.

Page number. Pages are numbered continuously through
both sections of the output.

TAB EXPANSION:

If a program listing is requested, tabs in the source file are
always expanded before being written to output. Normally the
expansion is the standard ASCII default of 8 spaces per tab. You
can specify a different value with the "-t" flag. This can be very
useful if you have a deeply nested C program that is structured
with one tab per level.

PRE-PROCESSOR STATEMENTS:

xc, at present, does no special processing on any pre-
processor ("#...") statements except for #include.





2


XC - C cross-reference program


LEVEL NUMBER:

If a program listing is requested, the level number is shown
as an integer on each line. This is a count of the number of
outstanding left-curly braces. It goes up for each left curly
brace and down for each right curly brace.

Since xc does no special processing for pre-processor
statements, you can get in trouble with constructs such as:

#ifdef xxx
aa {
#else
bb {
#endif

In a primitive attempt to deal with this situation, xc:

(a) never allows the curly brace count to drop below
zero, and
(b) resets the curly brace count to zero after process-
ing each #include file (applies only if -s or -i are
in use).

If you do NOT wish this special processing, specify the "-c"
flag. One reason for not wishing it is because a negative curly
brace count might indicate a real user error - this can be a useful
diagnostic tool.


LINE NUMBERS:

If a program listing is requested, each line of source is
numbered sequentially, starting with 1 and running through the
entire source. This number, which is the first item on each source
line, is the number referenced by entries in the cross-reference
table.

If you have requested that included files be listed ("-s"
and/or "-i" flags), then a second line number appears on each line.
This specifies the number of the line within its respective source
file. This number is useful because it will correspond to line
numbers in diagnostic messages from the compiler and to line
numbers used by an editor.

INCLUDED FILES.

xc can be requested to list files included via "#include" pre-
procssor directives. These directives come in two "flavors":

#include <....> is generally used to include standard
system files such as stdio.h.



3


XC - C cross-reference program


#include "..." is generally used to include files that
are specific to one program or group of programs.

xc allows the user to request listing of either or both of
these flavors of #include-ed files.

-s specifies that #include <....> files should be
listed.
-i specifies that #include "..." files should be
listed.

The typical user will be interested in only the "-i" flag.

If EITHER of these flags is specified, then a program listing
is always generated (you do not have to specify the "-l" flag).

Symbols from the requested "#include" files will be included
in the cross-reference table. If these flags are not used, then
these symbols will NOT be included - in fact the files need not
even exist (to run xc, not to compile the program!).

LOCATING INCLUDED FILES:

xc follows a logic similar, but not identical to, that of
Microsoft C in searching for files referenced with "#include".
Note that these files are only searched for if the appropriate flag
("-i" or "-s") is specified.

The search logic is as follows:

1. The current directory is searched, even for <...>
files (this differs from Microsoft C).

2. If the user has specified a search directory with
the "-u" flag, then that is searched next.

3. If there exists an environment variable "INCLUDE",
then the directory specified by that will be
searched.

LONG LINES:

If a program listing is requested, xc handles the problem of
"long" source lines intelligently. A long source line is one that,
after tab expansion and prefixing of margins and line and level
numbers, will not fit within the designated printer width. Such a
line is "wrapped" to succeeding lines of output (as many lines as
necessary) and is indented so that the first wrapped position
appears under the first position of the source line. Wrapped lines
do not have line or level numbers, but are instead marked by the
characters
>>



4


XC - C cross-reference program


where the line number would ordinarily go.

RESERVED WORDS:

Ordinarily, C reserved words are not included in the cross-
reference table. Only user-defined symbols are included.

The "-r" flag may be used to include the reserved words.

USAGE SUMMARY:

Usage: xc filename

Flags:
-c "Crude" handling of curly-braces (see above).

-d Use the current date and time in page headers.
(Otherwise the date & time will be taken from
the input file directory entry and shows when
it was last modified).

-i Show #include "..." source files.

-l Generate source listing in addition to the
cross-reference table. This is forced when you
specify either "-i" or "-s".

-mNN left Margin value. Default is 0.

-r Cross-ref reserved words.

-s Show #include <...> source files.

-tNN Tab expansion size. Default is 8.

-Upath Directory to search for user #includes
(#include "..."). This directory will also be
searched for the input file. The current direc-
tory is always checked first.

-Wnnn specify printer width as "nnn". Default is
132.

flags may be given in either upper or lower case.

to show ALL included files, specify BOTH -I AND -S (or -IS).


Release notes:


Release 1.01: FIX order of keywords, handling of form-feeds
in source file, report error if invalid


5


XC - C cross-reference program


option selected.
ADD form-feed at end of output.

Release 2.0: FIX bug involving "a/b" - X-refed as "ab".
ADD support for "#include"-ed files,
file date and time in header.

Release 2.1: Cleaned up code involving get-next-token and get-
next-character. Compiled with Microsoft C
version 5.0. Program now runs twice as
fast as before. Note that, due to bug in
MSC, /Oi (optimization for intrinsics)
cannot be used to compile XC.










































6



 December 13, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)