home *** CD-ROM | disk | FTP | other *** search
- ::::::::::
- fcheck.dis
- ::::::::::
- --
- -- The following files make up the distribution for FILE_CHECKER
- --
-
- -- Prologue file
- fcheck.pro
-
- -- Source files in compilation order
- -- (those commented out are components in the Ada Repository)
- --character_set.ada
- --cas3.ada
- --generic_list.ada
- fcheck.ada
-
- -- Documentation files (RNO is source)
- fcheck.rno
- ::::::::::
- fcheck.pro
- ::::::::::
-
- -------- SIMTEL20 Ada Software Repository Prologue ------------
- -- -*
- -- Unit name : FILE_CHECKER
- -- Version : 1.3
- -- Author : Richard Conn
- -- : TI Ada Technology Branch
- -- : Box 801, MS 8007
- -- : McKinney, TX 75069
- -- DDN Address : RCONN at SIMTEL20
- -- Copyright : (c) 1985 Richard Conn
- -- Date created : 15 Feb 85
- -- Release date : 15 Feb 85
- -- Last update : 2 Dec 85
- -- Machine/System Compiled/Run on : DG MV 10000, ROLM ADE
- -- DEC VAX 11/780, DEC Ada
- -- -*
- ---------------------------------------------------------------
- -- -*
- -- Keywords :
- ----------------: Ada Statements, Lines of Code, LOC, Checksum
- --
- -- Abstract :
- ----------------: FILE_CHECKER uses CAS3 to count the number
- -- of Ada statements (terminated by semicolons), the number of
- -- lines of code, and a checksum of the non-space (excludes tabs,
- -- CR, LF, FF, HT, and spaces) characters in a group of files.
- --
- -- FILE_CHECKER asks for one file name after another; the user
- -- terminates his input by striking RETURN to the file name prompt.
- -- FILE_CHECKER then gives a summary report of this data on all
- -- files listed. Include files may be specified along with
- -- other file names.
- --
- -- Ada components used by FILE_CHECKER include GENERIC_LIST and CAS3.
- -- CHARACTER_SET is used by CAS3.
- -- All are in the Ada Repository in the COMPONENTS subdirectory.
- -- -*
- ------------------ Revision history ---------------------------
- -- -*
- -- DATE VERSION AUTHOR HISTORY
- -- 2/15/85 1.0 Richard Conn Initial Release
- -- 4/9/85 1.1 Richard Conn Add Include Files, CAS3
- -- 9/25/85 1.2 Richard Conn Add Output File, Misc
- -- 12/2/85 1.3 Richard Conn Add Count Summary
- -- -*
- ------------------ Distribution and Copyright -----------------
- -- -*
- -- This prologue must be included in all copies of this software.
- --
- -- This software is copyright by the author.
- --
- -- This software is released to the Ada community.
- -- This software is released to the Public Domain (note:
- -- software released to the Public Domain is not subject
- -- to copyright protection).
- -- Restrictions on use or distribution: NONE
- -- -*
- ------------------ Disclaimer ---------------------------------
- -- -*
- -- This software and its documentation are provided "AS IS" and
- -- without any expressed or implied warranties whatsoever.
- -- No warranties as to performance, merchantability, or fitness
- -- for a particular purpose exist.
- --
- -- Because of the diversity of conditions and hardware under
- -- which this software may be used, no warranty of fitness for
- -- a particular purpose is offered. The user is advised to
- -- test the software thoroughly before relying on it. The user
- -- must assume the entire risk and liability of using this
- -- software.
- --
- -- In no event shall any person or organization of people be
- -- held responsible for any direct, indirect, consequential
- -- or inconsequential damages or lost profits.
- -- -*
- -------------------END-PROLOGUE--------------------------------
- ::::::::::
- fcheck.ada
- ::::::::::
-
- -------- SIMTEL20 Ada Software Repository Prologue ------------
- -- -*
- -- Unit name : FILE_CHECKER
- -- Version : 1.3
- -- Author : Richard Conn
- -- : TI Ada Technology Branch
- -- : Box 801, MS 8007
- -- : McKinney, TX 75069
- -- DDN Address : RCONN at SIMTEL20
- -- Copyright : (c) 1985 Richard Conn
- -- Date created : 15 Feb 85
- -- Release date : 15 Feb 85
- -- Last update : 2 Dec 85
- -- Machine/System Compiled/Run on : DG MV 10000, ROLM ADE
- -- DEC VAX 11/780, DEC Ada
- -- -*
- ---------------------------------------------------------------
- -- -*
- -- Keywords :
- ----------------: Ada Statements, Lines of Code, LOC, Checksum
- --
- -- Abstract :
- ----------------: FILE_CHECKER uses CAS3 to count the number
- -- of Ada statements (terminated by semicolons), the number of
- -- lines of code, and a checksum of the non-space (excludes tabs,
- -- CR, LF, FF, HT, and spaces) characters in a group of files.
- --
- -- FILE_CHECKER asks for one file name after another; the user
- -- terminates his input by striking RETURN to the file name prompt.
- -- FILE_CHECKER then gives a summary report of this data on all
- -- files listed. Include files may be specified along with
- -- other file names.
- --
- -- Ada components used by FILE_CHECKER include GENERIC_LIST and CAS3.
- -- CHARACTER_SET is used by CAS3.
- -- All are in the Ada Repository in the COMPONENTS subdirectory.
- -- -*
- ------------------ Revision history ---------------------------
- -- -*
- -- DATE VERSION AUTHOR HISTORY
- -- 2/15/85 1.0 Richard Conn Initial Release
- -- 4/9/85 1.1 Richard Conn Add Include Files, CAS3
- -- 9/25/85 1.2 Richard Conn Add Output File, Misc
- -- 12/2/85 1.3 Richard Conn Add Count Summary
- -- -*
- ------------------ Distribution and Copyright -----------------
- -- -*
- -- This prologue must be included in all copies of this software.
- --
- -- This software is copyright by the author.
- --
- -- This software is released to the Ada community.
- -- This software is released to the Public Domain (note:
- -- software released to the Public Domain is not subject
- -- to copyright protection).
- -- Restrictions on use or distribution: NONE
- -- -*
- ------------------ Disclaimer ---------------------------------
- -- -*
- -- This software and its documentation are provided "AS IS" and
- -- without any expressed or implied warranties whatsoever.
- -- No warranties as to performance, merchantability, or fitness
- -- for a particular purpose exist.
- --
- -- Because of the diversity of conditions and hardware under
- -- which this software may be used, no warranty of fitness for
- -- a particular purpose is offered. The user is advised to
- -- test the software thoroughly before relying on it. The user
- -- must assume the entire risk and liability of using this
- -- software.
- --
- -- In no event shall any person or organization of people be
- -- held responsible for any direct, indirect, consequential
- -- or inconsequential damages or lost profits.
- -- -*
- -------------------END-PROLOGUE--------------------------------
-
-
- --|MODULE : FCHECK
- --|PSEUDONYM: FILE_CHECKER
- --|AUTHOR : CONN
- --|LOCATION : PDL_TOOLS
- --|REQUIRES : COUNT_OF_ADA_STATEMENTS
- --|REQUIRES : GENERIC_LIST
- --|SEE_ALSO : LOCX
- --|IEEE_PDL : LOC_ANALYZER
- --|DESIGN_STATUS : DONE
- --|IMPLEMENTATION_STATUS : DONE
- --|DOCUMENTATION_STATUS : DONE
- --|DATE_RELEASED : 15 Feb 85
- --|DATE_LAST_MODIFIED : 2 Dec 85
- --|ABSTRACT :
- --| FILE_CHECKER accepts a number of file names and generates a
- --| report listing each file name and providing a count of the number
- --| of Ada statements in the file, the number of text lines in the
- --| file, and a count of the number of Ada comments in the file.
- --| The report is stored in an output file whose name is specified
- --| by the user.
-
- with TEXT_IO, GENERIC_LIST, COUNT_OF_ADA_STATEMENTS;
-
- procedure FILE_CHECKER is
- VERSION : constant STRING := "FILE CHECKER, Version 1.3";
- INCLUDE_CHARACTER : constant CHARACTER := '@';
- COMMENT_CHARACTER : constant CHARACTER := '-';
-
- --
- -- A doubly-linked list of file names
- --
- FILE_NAME_LENGTH : constant := 256;
- type FILE_NAME_STRING is
- record
- NAME : STRING(1 .. FILE_NAME_LENGTH);
- LENGTH : NATURAL;
- end record;
-
- package FN_LIST is
- new GENERIC_LIST(FILE_NAME_STRING);
-
- --
- -- Natural Number I/O
- --
- package NAT_IO is
- new TEXT_IO.INTEGER_IO(NATURAL);
-
- --
- -- Variables
- --
- DUMMY : BOOLEAN;
- STATEMENT_COUNT : NATURAL;
- LINE_COUNT : NATURAL;
- COMMENT_COUNT : NATURAL;
- STATEMENT_SUM : NATURAL;
- LINE_SUM : NATURAL;
- COMMENT_SUM : NATURAL;
- HASH : NATURAL;
- FILE_NAME_ENTRY : FILE_NAME_STRING;
- FILE_NAME : STRING(1 .. FILE_NAME_LENGTH);
- OUTPUT_FILE_NAME : FILE_NAME_STRING;
- OUTPUT_FD : TEXT_IO.FILE_TYPE;
- LENGTH : NATURAL;
- NUMBER_OF_FILES : NATURAL;
- USER_ABORT : exception;
-
- --
- -- Process Include File
- --
- procedure INCLUDE_FILE(INCLUDE_FILE_NAME : in STRING) is
- FILE_ID : TEXT_IO.FILE_TYPE;
- INPUT_LINE : STRING(1 .. FILE_NAME_LENGTH);
- LENGTH : NATURAL;
- LOCAL_FILE_NAME : FILE_NAME_STRING;
- begin
- TEXT_IO.OPEN(FILE_ID, TEXT_IO.IN_FILE, INCLUDE_FILE_NAME);
- TEXT_IO.PUT(" Processing Include File: ");
- TEXT_IO.PUT_LINE(INCLUDE_FILE_NAME);
- while not TEXT_IO.END_OF_FILE(FILE_ID) loop
- TEXT_IO.GET_LINE(FILE_ID, INPUT_LINE, LENGTH);
- TEXT_IO.PUT(" ");
- TEXT_IO.PUT_LINE(INPUT_LINE(1 .. LENGTH));
- if LENGTH /= 0 then
- case INPUT_LINE(1) is
- when INCLUDE_CHARACTER =>
- INCLUDE_FILE(INPUT_LINE(2 .. LENGTH));
- when COMMENT_CHARACTER =>
- null;
- when others =>
- LOCAL_FILE_NAME.NAME := INPUT_LINE;
- LOCAL_FILE_NAME.LENGTH := LENGTH;
- FN_LIST.APPEND_ELEMENT(LOCAL_FILE_NAME);
- end case;
- end if;
- end loop;
- TEXT_IO.PUT(" End of Include File: ");
- TEXT_IO.PUT_LINE(INCLUDE_FILE_NAME);
-
- exception
- when TEXT_IO.NAME_ERROR =>
- TEXT_IO.PUT(" Cannot Open Include File ");
- TEXT_IO.PUT_LINE(INCLUDE_FILE_NAME);
- when others =>
- TEXT_IO.PUT(" End of Include File: ");
- TEXT_IO.PUT_LINE(INCLUDE_FILE_NAME);
- end INCLUDE_FILE;
-
-
- --
- -- Mainline
- --
- begin
- TEXT_IO.PUT_LINE(VERSION);
- TEXT_IO.PUT(" Name of Output File (RETURN to Abort)? ");
- TEXT_IO.GET_LINE(OUTPUT_FILE_NAME.NAME, OUTPUT_FILE_NAME.LENGTH);
- if OUTPUT_FILE_NAME.LENGTH > 0 then
- begin
- TEXT_IO.CREATE(OUTPUT_FD, TEXT_IO.OUT_FILE, OUTPUT_FILE_NAME.NAME(1 ..
- OUTPUT_FILE_NAME.LENGTH));
-
- exception
- when others =>
- TEXT_IO.PUT_LINE("Cannot Create Output File - Aborting");
- raise USER_ABORT;
- end;
- else
- raise USER_ABORT;
- end if;
- FN_LIST.INITIALIZE_LIST;
- STATEMENT_SUM := 0;
- LINE_SUM := 0;
- COMMENT_SUM := 0;
- --
- -- Input file names, allowing for comments and include files
- --
- loop
- TEXT_IO.PUT(" File Name > ");
- TEXT_IO.GET_LINE(FILE_NAME, LENGTH);
- exit when LENGTH = 0;
- FILE_NAME_ENTRY.NAME := FILE_NAME;
- FILE_NAME_ENTRY.LENGTH := LENGTH;
- case FILE_NAME_ENTRY.NAME(1) is
- when INCLUDE_CHARACTER =>
- INCLUDE_FILE(FILE_NAME_ENTRY.NAME(2 .. FILE_NAME_ENTRY.LENGTH));
- when COMMENT_CHARACTER =>
- null;
- when others =>
- FN_LIST.APPEND_ELEMENT(FILE_NAME_ENTRY);
- end case;
- end loop;
- --
- -- Print banner
- --
- TEXT_IO.PUT_LINE(OUTPUT_FD, VERSION);
- TEXT_IO.NEW_LINE(OUTPUT_FD);
- TEXT_IO.PUT(OUTPUT_FD, "File Name ");
- TEXT_IO.PUT(OUTPUT_FD, " Statements");
- TEXT_IO.PUT(OUTPUT_FD, " Comments");
- TEXT_IO.PUT(OUTPUT_FD, " Stmts+Cmts");
- TEXT_IO.PUT(OUTPUT_FD, " Lines");
- TEXT_IO.NEW_LINE(OUTPUT_FD);
- TEXT_IO.PUT(OUTPUT_FD, "==============================");
- TEXT_IO.PUT(OUTPUT_FD, " ==========");
- TEXT_IO.PUT(OUTPUT_FD, " ==========");
- TEXT_IO.PUT(OUTPUT_FD, " ==========");
- TEXT_IO.PUT(OUTPUT_FD, " ==========");
- TEXT_IO.NEW_LINE(OUTPUT_FD);
- --
- -- Generate listing
- --
- FN_LIST.SET_FIRST;
- NUMBER_OF_FILES := FN_LIST.LAST_INDEX;
- for I in 1 .. NUMBER_OF_FILES loop
- --
- -- Get element, print file name, and compute counts
- --
- FILE_NAME_ENTRY := FN_LIST.RETURN_CURRENT_ELEMENT;
- TEXT_IO.PUT(OUTPUT_FD, FILE_NAME_ENTRY.NAME(1 .. FILE_NAME_ENTRY.LENGTH));
- begin
- COUNT_OF_ADA_STATEMENTS(FILE_NAME_ENTRY.NAME(1 .. FILE_NAME_ENTRY.LENGTH)
- , STATEMENT_COUNT, LINE_COUNT, COMMENT_COUNT, HASH);
-
- exception
- when others =>
- FILE_NAME_ENTRY.LENGTH := 40;
-
- -- force new line
- STATEMENT_COUNT := 0;
- LINE_COUNT := 0;
- COMMENT_COUNT := 0;
- HASH := 0;
- end;
-
- --
- -- Space over or goto next line, depending on file name length
- --
- if FILE_NAME_ENTRY.LENGTH <= 30 then
- for I in FILE_NAME_ENTRY.LENGTH + 1 .. 30 loop
- TEXT_IO.PUT(OUTPUT_FD, ' ');
-
- -- space fill
- end loop;
- else
- TEXT_IO.NEW_LINE(OUTPUT_FD);
- for I in 1 .. 30 loop
- TEXT_IO.PUT(OUTPUT_FD, ' ');
-
- -- space over on next line
- end loop;
- end if;
-
- --
- -- Print counts
- --
- TEXT_IO.PUT(OUTPUT_FD, " ");
- NAT_IO.PUT(OUTPUT_FD, STATEMENT_COUNT, 10);
- TEXT_IO.PUT(OUTPUT_FD, " ");
- NAT_IO.PUT(OUTPUT_FD, COMMENT_COUNT, 10);
- TEXT_IO.PUT(OUTPUT_FD, " ");
- NAT_IO.PUT(OUTPUT_FD, STATEMENT_COUNT + COMMENT_COUNT, 10);
- TEXT_IO.PUT(OUTPUT_FD, " ");
- NAT_IO.PUT(OUTPUT_FD, LINE_COUNT, 10);
- TEXT_IO.NEW_LINE(OUTPUT_FD);
-
- --
- -- Update Sums
- --
- STATEMENT_SUM := STATEMENT_SUM + STATEMENT_COUNT;
- COMMENT_SUM := COMMENT_SUM + COMMENT_COUNT;
- LINE_SUM := LINE_SUM + LINE_COUNT;
-
- --
- -- Advance to next element
- --
- DUMMY := FN_LIST.CURRENT_NEXT;
- end loop;
- TEXT_IO.NEW_LINE(OUTPUT_FD);
- TEXT_IO.PUT(OUTPUT_FD, "** TOTALS **");
- for I in 13 .. 30 loop
- TEXT_IO.PUT(OUTPUT_FD, ' ');
- end loop;
- TEXT_IO.PUT(OUTPUT_FD, " ");
- NAT_IO.PUT(OUTPUT_FD, STATEMENT_SUM, 10);
- TEXT_IO.PUT(OUTPUT_FD, " ");
- NAT_IO.PUT(OUTPUT_FD, COMMENT_SUM, 10);
- TEXT_IO.PUT(OUTPUT_FD, " ");
- NAT_IO.PUT(OUTPUT_FD, STATEMENT_SUM + COMMENT_SUM, 10);
- TEXT_IO.PUT(OUTPUT_FD, " ");
- NAT_IO.PUT(OUTPUT_FD, LINE_SUM, 10);
- TEXT_IO.NEW_LINE(OUTPUT_FD);
- TEXT_IO.CLOSE(OUTPUT_FD);
-
- exception
- when USER_ABORT =>
- null;
- when others =>
- TEXT_IO.NEW_LINE;
- TEXT_IO.PUT_LINE("Unknown Exception Trapped");
- end FILE_CHECKER;
- ::::::::::
- fcheck.rno
- ::::::::::
- .figure 4
- .CENTER; FILE__CHECKER, Version 1.1
- .skip 2
- .CENTER; by Richard Conn, TI Ada Technology Branch
- .figure 4
- .ap
- FILE__CHECKER is a tool which prints out the number of Ada
- statements, Ada comments, and text lines in a file. When executed,
- FILE__CHECKER prompts for the name of a file. The user enters a file
- name, strikes return, and FILE__CHECKER prompts again. This continues
- until the user has entered the names of all the desired files, at which
- point the user simply strikes return in response to the file name prompt.
- FILE__CHECKER then passes through the files in the order specified,
- generating a table of the file name, number of Ada statements, number
- of Ada comments, and number of text lines.
-
- .HEADER LEVEL 1 FILE__CHECKER Inputs and Include Files
-
- In response to the file name prompt, FILE__CHECKER recognizes and
- responds to the following types of input:
- .no autoparagraph
- .list "*"
- .LIST ELEMENT; A carriage return (RETURN key), which tells FILE__CHECKER to
- terminate input and to print the output table
- .LIST ELEMENT; A line beginning with a dash (_-), which is a comment line
- .LIST ELEMENT; A file name prefixed by an atsign (_@), which indicates an
- include file
- .LIST ELEMENT; Any other input, which indicates the name of a file to
- include
- .end list
- .ap
-
- If the user prefixes the name of a component file with an atsign
- character (_@), the indicated file is processed as an include file.
- An include file is a file which contains the names of zero or more component
- files, one name per line starting in the first column. Other
- include files may be referenced within an include file by prefixing
- their names with the atsign character. Comments may be placed within
- an include file by placing two dashes in the first two columns of a line.
- The following is an example of an include file:
-
- .tp 30
- .literal
-
- Example Comments
- ======= ========
- --
- -- This is an include file for Comment at the beginning
- -- my favorite tool
- --
- Blank lines are allowed
- --
- -- The following include file
- -- contains the names of the Another comment
- -- Ada source files in compilation
- -- order
- --
- @mytool.cmp
- --
- -- The following are the documentation
- -- files
- --
- mytool.ref
- mytool.doc
- mytool.idx
-
- .end literal
-
- The syntax for an include file used by FILE__CHECKER is identical to
- the syntax for an include file used by PAGER, another tool in the Ada
- Repository. Consequently, PAGER include files can be used to generate
- FILE__CHECKER reports.
-
-
- .HEADER LEVEL 1 Sample Session
-
- The following is a sample session which illustrates the use
- of FILE__CHECKER.
-
- .literal
-
-
- $ dir
-
- Directory USER4:[CONN.ADA]
-
- CAS3.ADA;1 15 (RWE,RWED,RE,RE)
- CHARACTER_SET.ADA;1
- 21 (RWE,RWED,RE,RE)
- LIB.DIR;1 3 (RE,RWE,RE,RE)
- PAGER.ADA;1 13 (RWE,RWED,RE,RE)
- PAGER.DIS;1 1 (RWE,RWED,RE,RE)
- PAGER.DOC;1 31 (RWE,RWED,RE,RE)
- PAGER.RNO;1 28 (RWE,RWED,RE,RE)
- PAGER.SRC;6 154 (RWE,RWED,RE,RE)
- PAGER_COMPILE.DIS;1
- 1 (RWE,RWED,RE,RE)
- PAGER_DOCUMENTATION.DIS;1
- 1 (RWE,RWED,RE,RE)
- PAGER_SUPPORT.ADA;1
- 47 (RWE,RWED,RE,RE)
-
- Total of 11 files, 315 blocks.
- $ type pager.dis
- --
- -- Distribution files for PAGER
- -- PAGER_COMPILE.DIS gives the source files in
- -- compilation order
- -- PAGER_DOCUMENTATION.DIS gives the documentation files
- --
- @pager_compile.dis
- @pager_documentation.dis
- $ type pager_compile.dis
- --
- -- Compilation order for all files required to create the
- -- PAGER program
- --
- character_set.ada
- cas3.ada
- pager_support.ada
- pager.ada
- $ fcheck
- FILE CHECKER, Version 1.1
- File Name > pager.ada
- File Name > pager_support.ada
- File Name >
-
- File Name Statements Comments Lines
- pager.ada 74 8 150
- pager_support.ada 324 172 714
- $ fcheck
- FILE CHECKER, Version 1.1
- File Name > @pager_compile.dis
- Processing Include File: pager_compile.dis
- --
- -- Compilation order for all files required to create the
- -- PAGER program
- --
- character_set.ada
- cas3.ada
- pager_support.ada
- pager.ada
- End of Include File: pager_compile.dis
- File Name >
-
- File Name Statements Comments Lines
- character_set.ada 174 30 321
- cas3.ada 56 95 194
- pager_support.ada 324 172 714
- pager.ada 74 8 150
- .end literal
-