home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / paged / pager.src < prev    next >
Encoding:
Text File  |  1988-05-03  |  84.7 KB  |  3,237 lines

  1. ::::::::::
  2. pager.dis
  3. ::::::::::
  4. --
  5. -- Distribution files for PAGER
  6. --    PAGER_COMPILE.DIS gives the source files in
  7. --      compilation order
  8. --    PAGER_DOCUMENTATION.DIS gives the documentation files
  9. --
  10. pager.pro
  11. @pager_compile.dis
  12. @pager_documentation.dis
  13. ::::::::::
  14. pager.pro
  15. ::::::::::
  16.  
  17. -------- SIMTEL20 Ada Software Repository Prologue ------------
  18. --                                                           -*
  19. -- Unit name    : PAGER
  20. -- Version      : 1.6
  21. -- Author       : Richard Conn
  22. --              : TI Ada Technology Branch
  23. --              : PO Box 801, MS 8007
  24. --              : McKinney, TX  75069
  25. -- DDN Address  : RCONN at SIMTEL20
  26. -- Copyright    : (c) 1985 by Richard Conn
  27. -- Date created : 8 Apr 85
  28. -- Release date : 8 Apr 85
  29. -- Last update  : 30 Oct 85
  30. -- Machine/System Compiled/Run on : DG MV10000, ROLM ADE
  31. --                                  DEC VAX 11/785, DEC Ada
  32. --                                                           -*
  33. ---------------------------------------------------------------
  34. --                                                           -*
  35. -- Keywords     : PAGED FILES, LIBRARY, REPOSITORY, PAGER, UNPAGE
  36. ----------------:
  37. --
  38. -- Abstract     : PAGER is a tool which creates, extracts from,
  39. -- and scans paged files, where a paged file is a file composed
  40. -- of one or more files prefixed by banners.  PAGER is based in
  41. -- concept on the UNPAGE tool submitted to the Ada Repository on
  42. -- SIMTEL20 by Mitre Corporation.
  43. --
  44. --      Paged files are convenient mechanisms for storing related files.
  45. -- They reduce cluttering in the directories and simplify the file
  46. -- transfer process (to and from the Ada Repository, for example) by
  47. -- requiring the user to transfer only one file in order to obtain all
  48. -- files pertinent to a particular project or tool.  Additionally, paged
  49. -- files are text files which can be handled more readily than the 8-bit
  50. -- binary images associated with other file grouping mechanisms.  Paged
  51. -- files may be manipulated by a text editor if necessary.
  52. --                                                           -*
  53. ------------------ Revision history ---------------------------
  54. --                                                           -*
  55. -- DATE         VERSION AUTHOR                  HISTORY
  56. -- 4/8/1985       1.4   Richard Conn            Initial Release
  57. -- 5/6/1985       1.5   Richard Conn            Numeric Error Trap Added
  58. -- 10/30/1985      1.6    Richard Conn        LIST Command Added
  59. --                                                           -*
  60. ------------------ Distribution and Copyright -----------------
  61. --                                                           -*
  62. -- This prologue must be included in all copies of this software.
  63. --
  64. -- This software is copyright by the author.
  65. --
  66. -- This software is released to the Ada community.
  67. -- This software is released to the Public Domain (note:
  68. --   software released to the Public Domain is not subject
  69. --   to copyright protection).
  70. -- Restrictions on use or distribution:  NONE
  71. --                                                           -*
  72. ------------------ Disclaimer ---------------------------------
  73. --                                                           -*
  74. -- This software and its documentation are provided "AS IS" and
  75. -- without any expressed or implied warranties whatsoever.
  76. -- No warranties as to performance, merchantability, or fitness
  77. -- for a particular purpose exist.
  78. --
  79. -- Because of the diversity of conditions and hardware under
  80. -- which this software may be used, no warranty of fitness for
  81. -- a particular purpose is offered.  The user is advised to
  82. -- test the software thoroughly before relying on it.  The user
  83. -- must assume the entire risk and liability of using this
  84. -- software.
  85. --
  86. -- In no event shall any person or organization of people be
  87. -- held responsible for any direct, indirect, consequential
  88. -- or inconsequential damages or lost profits.
  89. --                                                           -*
  90. -------------------END-PROLOGUE--------------------------------
  91. ::::::::::
  92. pager_compile.dis
  93. ::::::::::
  94. --
  95. -- Compilation order for all files required to create the
  96. --  PAGER program
  97. --
  98. character_set.ada
  99. cas3.ada
  100. pager_support.ada
  101. pager.ada
  102. ::::::::::
  103. character_set.ada
  104. ::::::::::
  105. --
  106. -- Components Package CHARACTER_SET
  107. -- by Richard Conn, TI Ada Technology Branch
  108. -- Version 1.1, Date 25 Feb 85
  109. -- Version 1.0, Date 13 Feb 85
  110. --
  111. package CHARACTER_SET is
  112.  
  113. --
  114. -- These routines test for the following subsets of ASCII
  115. --
  116. -- Routine              Subset tested for
  117. -- =======              =================
  118. -- ALPHA                'a'..'z' | 'A'..'Z'
  119. -- ALPHA_NUMERIC        ALPHA | '0'..'9'
  120. -- CONTROL              < ' ' | DEL
  121. -- DIGIT                '0'..'9'
  122. -- GRAPHIC              ' ' < ch < DEL (does not include space)
  123. -- HEXADECIMAL          DIGIT | 'A'..'F' | 'a'..'f'
  124. -- LOWER                'a'..'z'
  125. -- PRINTABLE            GRAPHIC | ' '
  126. -- PUNCTUATION          GRAPHIC and not ALPHA_NUMERIC
  127. -- SPACE                HT | LF | VT | FF | CR | ' '
  128. -- UPPER                'A'..'Z'
  129. --
  130.     function IS_ALPHA         (CH : CHARACTER) return BOOLEAN;
  131.     function IS_ALPHA_NUMERIC (CH : CHARACTER) return BOOLEAN;
  132.     function IS_CONTROL       (CH : CHARACTER) return BOOLEAN;
  133.     function IS_DIGIT         (CH : CHARACTER) return BOOLEAN;
  134.     function IS_GRAPHIC       (CH : CHARACTER) return BOOLEAN;
  135.     function IS_HEXADECIMAL   (CH : CHARACTER) return BOOLEAN;
  136.     function IS_LOWER         (CH : CHARACTER) return BOOLEAN;
  137.     function IS_PRINTABLE     (CH : CHARACTER) return BOOLEAN;
  138.     function IS_PUNCTUATION   (CH : CHARACTER) return BOOLEAN;
  139.     function IS_SPACE         (CH : CHARACTER) return BOOLEAN;
  140.     function IS_UPPER         (CH : CHARACTER) return BOOLEAN;
  141.  
  142. --
  143. -- These routines convert characters and strings to upper- or lower-case
  144. --
  145.     function  TO_LOWER (CH : CHARACTER) return CHARACTER;
  146.     procedure TO_LOWER (CH : in out CHARACTER);
  147.     procedure TO_LOWER (STR : in out STRING);
  148.     function  TO_UPPER (CH : CHARACTER) return CHARACTER;
  149.     procedure TO_UPPER (CH : in out CHARACTER);
  150.     procedure TO_UPPER (STR : in out STRING);
  151.  
  152. --
  153. -- These routines return the names of the control characters
  154. --
  155.     subtype CONTROL_CHARACTER_NAME_2 is STRING (1 .. 2);
  156.     subtype CONTROL_CHARACTER_NAME_3 is STRING (1 .. 3);
  157. --
  158.     function CC_NAME_2 (CH : CHARACTER) return CONTROL_CHARACTER_NAME_2;
  159.     function CC_NAME_3 (CH : CHARACTER) return CONTROL_CHARACTER_NAME_3;
  160.  
  161.  
  162. end CHARACTER_SET;
  163.  
  164. package body CHARACTER_SET is
  165.  
  166.     function IS_ALPHA (CH : CHARACTER) return BOOLEAN is
  167.     begin
  168.         case CH is
  169.             when 'a' .. 'z' =>
  170.                 return TRUE;
  171.             when 'A' .. 'Z' =>
  172.                 return TRUE;
  173.             when others =>
  174.                 return FALSE;
  175.         end case;
  176.     end IS_ALPHA;
  177.  
  178.     function IS_ALPHA_NUMERIC (CH : CHARACTER) return BOOLEAN is
  179.     begin
  180.         case CH is
  181.             when 'a' .. 'z' =>
  182.                 return TRUE;
  183.             when 'A' .. 'Z' =>
  184.                 return TRUE;
  185.             when '0' .. '9' =>
  186.                 return TRUE;
  187.             when others =>
  188.                 return FALSE;
  189.         end case;
  190.     end IS_ALPHA_NUMERIC;
  191.  
  192.     function IS_CONTROL (CH : CHARACTER) return BOOLEAN is
  193.     begin
  194.         if CH < ' ' or CH = ASCII.DEL then
  195.             return TRUE;
  196.         else
  197.             return FALSE;
  198.         end if;
  199.     end IS_CONTROL;
  200.  
  201.     function IS_DIGIT (CH : CHARACTER) return BOOLEAN is
  202.     begin
  203.         if CH in '0' .. '9' then
  204.             return TRUE;
  205.         else
  206.             return FALSE;
  207.         end if;
  208.     end IS_DIGIT;
  209.  
  210.     function IS_GRAPHIC (CH : CHARACTER) return BOOLEAN is
  211.     begin
  212.         if CH > ' ' and CH < ASCII.DEL then
  213.             return TRUE;
  214.         else
  215.             return FALSE;
  216.         end if;
  217.     end IS_GRAPHIC;
  218.  
  219.     function IS_HEXADECIMAL (CH : CHARACTER) return BOOLEAN is
  220.     begin
  221.         case CH is
  222.             when '0' .. '9' =>
  223.                 return TRUE;
  224.             when 'A' .. 'F' | 'a' .. 'f' =>
  225.                 return TRUE;
  226.             when others =>
  227.                 return FALSE;
  228.         end case;
  229.     end IS_HEXADECIMAL;
  230.  
  231.     function IS_LOWER (CH : CHARACTER) return BOOLEAN is
  232.     begin
  233.         if CH in 'a' .. 'z' then
  234.             return TRUE;
  235.         else
  236.             return FALSE;
  237.         end if;
  238.     end IS_LOWER;
  239.  
  240.     function IS_PRINTABLE (CH : CHARACTER) return BOOLEAN is
  241.     begin
  242.         if CH >= ' ' and CH < ASCII.DEL then
  243.             return TRUE;
  244.         else
  245.             return FALSE;
  246.         end if;
  247.     end IS_PRINTABLE;
  248.  
  249.     function IS_PUNCTUATION (CH : CHARACTER) return BOOLEAN is
  250.     begin
  251.         if (CH > ' ') and (CH < ASCII.DEL) and (not IS_ALPHA_NUMERIC (CH)) then
  252.             return TRUE;
  253.         else
  254.             return FALSE;
  255.         end if;
  256.     end IS_PUNCTUATION;
  257.  
  258.     function IS_SPACE (CH : CHARACTER) return BOOLEAN is
  259.     begin
  260.         case CH is
  261.             when ASCII.HT =>
  262.                 return TRUE;
  263.             when ASCII.LF =>
  264.                 return TRUE;
  265.             when ASCII.VT =>
  266.                 return TRUE;
  267.             when ASCII.FF =>
  268.                 return TRUE;
  269.             when ASCII.CR =>
  270.                 return TRUE;
  271.             when ' ' =>
  272.                 return TRUE;
  273.             when others =>
  274.                 return FALSE;
  275.         end case;
  276.     end IS_SPACE;
  277.  
  278.     function IS_UPPER (CH : CHARACTER) return BOOLEAN is
  279.     begin
  280.         if CH in 'A' .. 'Z' then
  281.             return TRUE;
  282.         else
  283.             return FALSE;
  284.         end if;
  285.     end IS_UPPER;
  286.  
  287.     function TO_LOWER (CH : CHARACTER) return CHARACTER is
  288.     begin
  289.         if IS_UPPER (CH) then
  290.             return CHARACTER'VAL
  291.                      (CHARACTER'POS (CH) - CHARACTER'POS ('A') +
  292.                       CHARACTER'POS ('a'));
  293.         else
  294.             return CH;
  295.         end if;
  296.     end TO_LOWER;
  297.  
  298.     procedure TO_LOWER (CH : in out CHARACTER) is
  299.     begin
  300.         if IS_UPPER (CH) then
  301.             CH := TO_LOWER (CH);
  302.         end if;
  303.     end TO_LOWER;
  304.  
  305.     procedure TO_LOWER (STR : in out STRING) is
  306.     begin
  307.         for I in STR'FIRST .. STR'LAST loop
  308.             STR (I) := TO_LOWER (STR (I));
  309.         end loop;
  310.     end TO_LOWER;
  311.  
  312.     function TO_UPPER (CH : CHARACTER) return CHARACTER is
  313.     begin
  314.         if IS_LOWER (CH) then
  315.             return CHARACTER'VAL
  316.                      (CHARACTER'POS (CH) - CHARACTER'POS ('a') +
  317.                       CHARACTER'POS ('A'));
  318.         else
  319.             return CH;
  320.         end if;
  321.     end TO_UPPER;
  322.  
  323.     procedure TO_UPPER (CH : in out CHARACTER) is
  324.     begin
  325.         if IS_LOWER (CH) then
  326.             CH := TO_UPPER (CH);
  327.         end if;
  328.     end TO_UPPER;
  329.  
  330.     procedure TO_UPPER (STR : in out STRING) is
  331.     begin
  332.         for I in STR'FIRST .. STR'LAST loop
  333.             STR (I) := TO_UPPER (STR (I));
  334.         end loop;
  335.     end TO_UPPER;
  336.  
  337.     function CC_NAME_2 (CH : CHARACTER) return CONTROL_CHARACTER_NAME_2 is
  338.         NAME : CONTROL_CHARACTER_NAME_2;
  339.     begin
  340.         case CH is
  341.             when ASCII.NUL =>  NAME := "^@";
  342.             when ASCII.SOH =>  NAME := "^A";
  343.             when ASCII.STX =>  NAME := "^B";
  344.             when ASCII.ETX =>  NAME := "^C";
  345.             when ASCII.EOT =>  NAME := "^D";
  346.             when ASCII.ENQ =>  NAME := "^E";
  347.             when ASCII.ACK =>  NAME := "^F";
  348.             when ASCII.BEL =>  NAME := "^G";
  349.             when ASCII.BS =>  NAME := "^H";
  350.             when ASCII.HT =>  NAME := "^I";
  351.             when ASCII.LF =>  NAME := "^J";
  352.             when ASCII.VT =>  NAME := "^K";
  353.             when ASCII.FF =>  NAME := "^L";
  354.             when ASCII.CR =>  NAME := "^M";
  355.             when ASCII.SO =>  NAME := "^N";
  356.             when ASCII.SI =>  NAME := "^O";
  357.             when ASCII.DLE =>  NAME := "^P";
  358.             when ASCII.DC1 =>  NAME := "^Q";
  359.             when ASCII.DC2 =>  NAME := "^R";
  360.             when ASCII.DC3 =>  NAME := "^S";
  361.             when ASCII.DC4 =>  NAME := "^T";
  362.             when ASCII.NAK =>  NAME := "^U";
  363.             when ASCII.SYN =>  NAME := "^V";
  364.             when ASCII.ETB =>  NAME := "^W";
  365.             when ASCII.CAN =>  NAME := "^X";
  366.             when ASCII.EM =>  NAME := "^Y";
  367.             when ASCII.SUB =>  NAME := "^Z";
  368.             when ASCII.ESC =>  NAME := "^[";
  369.             when ASCII.FS =>  NAME := "^\";
  370.             when ASCII.GS =>  NAME := "^]";
  371.             when ASCII.RS =>  NAME := "^^";
  372.             when ASCII.US =>  NAME := "^_";
  373.             when ASCII.DEL =>  NAME := "^`";
  374.             when others =>
  375.                 NAME := "  ";
  376.                 NAME (2) := CH;
  377.         end case;
  378.         return NAME;
  379.     end CC_NAME_2;
  380.  
  381.     function CC_NAME_3 (CH : CHARACTER) return CONTROL_CHARACTER_NAME_3 is
  382.         NAME : CONTROL_CHARACTER_NAME_3;
  383.     begin
  384.         case CH is
  385.             when ASCII.NUL =>  NAME := "NUL";
  386.             when ASCII.SOH =>  NAME := "SOH";
  387.             when ASCII.STX =>  NAME := "STX";
  388.             when ASCII.ETX =>  NAME := "ETX";
  389.             when ASCII.EOT =>  NAME := "EOT";
  390.             when ASCII.ENQ =>  NAME := "ENQ";
  391.             when ASCII.ACK =>  NAME := "ACK";
  392.             when ASCII.BEL =>  NAME := "BEL";
  393.             when ASCII.BS =>  NAME := "BS ";
  394.             when ASCII.HT =>  NAME := "HT ";
  395.             when ASCII.LF =>  NAME := "LF ";
  396.             when ASCII.VT =>  NAME := "VT ";
  397.             when ASCII.FF =>  NAME := "FF ";
  398.             when ASCII.CR =>  NAME := "CR ";
  399.             when ASCII.SO =>  NAME := "SO ";
  400.             when ASCII.SI =>  NAME := "SI ";
  401.             when ASCII.DLE =>  NAME := "DLE";
  402.             when ASCII.DC1 =>  NAME := "DC1";
  403.             when ASCII.DC2 =>  NAME := "DC2";
  404.             when ASCII.DC3 =>  NAME := "DC3";
  405.             when ASCII.DC4 =>  NAME := "DC4";
  406.             when ASCII.NAK =>  NAME := "NAK";
  407.             when ASCII.SYN =>  NAME := "SYN";
  408.             when ASCII.ETB =>  NAME := "ETB";
  409.             when ASCII.CAN =>  NAME := "CAN";
  410.             when ASCII.EM =>  NAME := "EM ";
  411.             when ASCII.SUB =>  NAME := "SUB";
  412.             when ASCII.ESC =>  NAME := "ESC";
  413.             when ASCII.FS =>  NAME := "FS ";
  414.             when ASCII.GS =>  NAME := "GS ";
  415.             when ASCII.RS =>  NAME := "RS ";
  416.             when ASCII.US =>  NAME := "US ";
  417.             when ASCII.DEL =>  NAME := "DEL";
  418.             when others =>
  419.                 NAME := "   ";
  420.                 NAME (2) := CH;
  421.         end case;
  422.         return NAME;
  423.     end CC_NAME_3;
  424.  
  425. end CHARACTER_SET;
  426. ::::::::::
  427. cas3.ada
  428. ::::::::::
  429.  
  430. -------- SIMTEL20 Ada Software Repository Prologue ------------
  431. -- 
  432. -- Unit name    : COUNT_OF_ADA_STATEMENTS_3
  433. -- Version      : 1.2
  434. -- Author       : Richard Conn
  435. --              : TI Ada Technology Branch
  436. --              : Box 801, MS 8007
  437. --              : McKinney, TX  75069
  438. -- DDN Address  : RCONN at SIMTEL20
  439. -- Derivation   : COUNT_OF_ADA_STATEMENTS_2 by Richard Conn
  440. -- Derivation   : COUNT_OF_ADA_STATEMENTS by Bill Whitaker
  441. -- Date created : 4 Apr 85
  442. -- Release date : 4 Apr 85
  443. -- Last update  : 24 June 85
  444. -- 
  445. ---------------------------------------------------------------
  446. -- 
  447. -- Keywords     :  Source analysis, Quantity, Statements
  448. -- 
  449. ----------------:
  450. -- 
  451. -- Abstract     :
  452. --  This procedure calculates the "STATEMENTS" of a valid Ada fragment
  453. --  specified by a FILE_NAME string parameter.  It need not be a complete
  454. --  compilation unit, but it should have closed all open parens and
  455. --  strings.
  456. -- 
  457. --  The Ada statement is defined by a semicolon terminator
  458. --  outside of comments, parentheses, or string or character literals.
  459. --  This definition is insensitive to formatting or layout of the source.
  460. -- 
  461. --  There are exotic cases for which this will misestimate the count
  462. --  but we have never encountered one in real code.
  463. -- 
  464. --  This procedure is derived from Bill Whitaker's original
  465. --  COUNT_OF_ADA_STATEMENTS, and it does not change his original algorithm.
  466. --  It adds a line count and a character-checksum hash (sum of POS values of
  467. --  all non-space characters in the file mod 256).  It also adds a count
  468. --  of the comment lines (over CAS2, which does not).
  469. -- 
  470. ------------------ Revision history ---------------------------
  471. -- 
  472. -- DATE         VERSION         AUTHOR          HISTORY
  473. -- 19850215     1.0             R Conn          Initial Release
  474. -- 19850506     1.1             R Conn          Overflow Traps Added
  475. -- 19850624     1.2             R Conn          Bug in Single-Quote Proc Fixed
  476. -- 
  477. ------------------ Distribution and Copyright -----------------
  478. -- 
  479. -- This software is released to the Public Domain (note:
  480. --   software released to the Public Domain is not subject
  481. --   to copyright protection).
  482. -- 
  483. ------------------ Disclaimer ---------------------------------
  484. -- 
  485. -- This software and its documentation are provided "AS IS" and
  486. -- without any expressed or implied warranties whatsoever.
  487. -- No warranties as to performance, merchantability, or fitness
  488. -- for a particular purpose exist.
  489. -- 
  490. -- In no event shall any person or organization of people be
  491. -- held responsible for any direct, indirect, consequential
  492. -- or inconsequential damages or lost profits.
  493. -- 
  494. -------------------END-PROLOGUE--------------------------------
  495.  
  496. with TEXT_IO,
  497.      CHARACTER_SET;
  498. procedure COUNT_OF_ADA_STATEMENTS (FILE_NAME  : STRING;
  499.                                    STATEMENTS : in out NATURAL;
  500.                                    LINE_COUNT : in out NATURAL;
  501.                                    COMMENTS   : in out NATURAL;
  502.                                    HASH       : in out NATURAL) is
  503. -- 
  504. --  Returned values:
  505. --     STATEMENTS    Number of Ada code statements
  506. --     LINE_COUNT    Number of lines of text
  507. --     COMMENTS      Number of comments in the file
  508. --     HASH          Checksum (Mod 256 sum) of all non-space
  509. --                    (a space character as defined by character_set)
  510. --                    characters
  511. -- 
  512.     INPUT        : TEXT_IO.FILE_TYPE;
  513.     CURRENT_LINE : STRING (1 .. 256); --  arbitrarily large
  514.     NEXT_CHAR    : NATURAL := 1;
  515.     LAST_CHAR    : NATURAL := 0;
  516.     C            : CHARACTER;
  517.     LEVEL        : INTEGER := 0;
  518.     CH_PENDING   : BOOLEAN := FALSE;
  519.     PENDING_CH   : CHARACTER;
  520.  
  521.     procedure UNGET (CH : CHARACTER) is
  522.     begin
  523.         CH_PENDING := TRUE;
  524.         PENDING_CH := CH;
  525.     end UNGET;
  526.  
  527.     procedure GET (CH : in out CHARACTER) is
  528.     begin
  529.         if CH_PENDING then
  530.             CH_PENDING := FALSE;
  531.             CH := PENDING_CH;
  532.         else
  533.             if NEXT_CHAR > LAST_CHAR then
  534.                 loop
  535.                     TEXT_IO.GET_LINE (INPUT, CURRENT_LINE, LAST_CHAR);
  536.                     begin
  537.                         LINE_COUNT := LINE_COUNT + 1;
  538.                     exception
  539.                         when others =>  null; -- trap overflow
  540.                     end;
  541.                     NEXT_CHAR := 1;
  542.                     exit when NEXT_CHAR <= LAST_CHAR;
  543.                 end loop;
  544.             end if;
  545.             CH := CURRENT_LINE (NEXT_CHAR);
  546.             if not CHARACTER_SET.IS_SPACE (CH) then
  547.                 HASH := (HASH + CHARACTER'POS (CH)) mod 256;
  548.             end if;
  549.             NEXT_CHAR := NEXT_CHAR + 1;
  550.         end if;
  551.     end GET;
  552.  
  553. begin
  554.  
  555.     TEXT_IO.OPEN (INPUT, TEXT_IO.IN_FILE, FILE_NAME);
  556.     STATEMENTS := 0;
  557.     LINE_COUNT := 0;
  558.     COMMENTS := 0;
  559.     HASH := 0;
  560.  
  561.     loop
  562.         GET (C);
  563.  
  564.         --  Check for comment on the line
  565.         if C = '-' then
  566.             GET (C);
  567.             --  Which is signaled by the '-' following a '-'
  568.             if C = '-' then
  569.                 --  Then just skip the rest of the line and go to the next
  570.                 NEXT_CHAR := LAST_CHAR + 1;
  571.                 begin
  572.                     COMMENTS := COMMENTS + 1;
  573.                 exception
  574.                     when others =>  null; -- trap overflow
  575.                 end;
  576.             end if;
  577.         end if;
  578.  
  579.         --  Check for one of the characters which introduce code constructs
  580.         --  like string or character literal or formal parameter list
  581.         --  within which a ';' does not terminate a "line of code"
  582.         if C = '(' or C = '"' or C = '%' or C = ''' then
  583.  
  584. --  Check for opening parentheses
  585. --  Every ';' within is in a formal parameter list
  586.             if C = '(' then
  587.                 --  Count the number of levels of parentheses
  588.                 LEVEL := LEVEL + 1;
  589.                 --  Read ahead until the whole construct is closed, LEVEL = 0
  590.                 while LEVEL > 0 loop
  591.                     GET (C);
  592.                     if C = '(' then
  593.                         --  Increase the level if another '(' is found
  594.                         LEVEL := LEVEL + 1;
  595.                     elsif C = ')' then
  596.                         --  Decrease the level if a ')' is found
  597.                         LEVEL := LEVEL - 1;
  598.                     end if;
  599.                 end loop;
  600.  
  601.                 --  Now check for string brackets of either kind, " or %
  602.             elsif C = '"' or C = '%' then
  603. --  Treat them in parallel, one must lead off
  604.                 if C = '"' then
  605.                     loop
  606.                         GET (C);
  607.                         --  Loop until the close comes
  608.                         --  If there is a doubled character it starts again
  609.                         exit when C = '"';
  610.                     end loop;
  611.                     --  The '%' is handled exactly the same way as '"'
  612.                 elsif C = '%' then
  613.                     loop
  614.                         GET (C);
  615.                         exit when C = '%';
  616.                     end loop;
  617.                 end if;
  618.  
  619.                 --  Character literals are just three characters long
  620.                 --  including '
  621.             elsif C = ''' then
  622.                 GET (C);
  623.                 GET (C);
  624.                 if C /= ''' then
  625.                     UNGET (C);
  626.                 end if;
  627.             end if;
  628.  
  629.             --  Any ';' that can be found at this point after all
  630.             --  exclusions must be a valid "line of code" terminator
  631.         elsif C = ';' then
  632.             begin
  633.                 STATEMENTS := STATEMENTS + 1;
  634.             exception
  635.                 when others =>  null; -- trap overflow
  636.             end;
  637.  
  638.         end if;
  639.  
  640.     end loop;
  641.  
  642. exception
  643.     when TEXT_IO.END_ERROR => 
  644.         TEXT_IO.CLOSE (INPUT); --  close input file
  645.     when TEXT_IO.NAME_ERROR => 
  646.         TEXT_IO.NEW_LINE;
  647.         TEXT_IO.PUT ("Error in File Name ");
  648.         TEXT_IO.PUT (FILE_NAME);
  649.         TEXT_IO.NEW_LINE;
  650.         raise TEXT_IO.NAME_ERROR;
  651.     when others => 
  652.         raise;
  653. end COUNT_OF_ADA_STATEMENTS;
  654. ::::::::::
  655. pager_support.ada
  656. ::::::::::
  657.  
  658.  
  659. --
  660. -- PAGER_SUPPORT by Richard Conn, TI Ada Technology Branch
  661. --
  662. package PAGER_SUPPORT is 
  663.  
  664.   FILE_NAME_LENGTH         : constant := 80; 
  665.   INPUT_FILE_NAME          : STRING(1 .. FILE_NAME_LENGTH); 
  666.   INPUT_FILE_NAME_LENGTH   : NATURAL; 
  667.   COMMENT_PREFIX           : BOOLEAN := FALSE; 
  668.   INCLUDE_FILE_PREFIX      : BOOLEAN := TRUE; 
  669.   INCLUDE_FILE_PREFIX_CHAR : constant CHARACTER := '@'; 
  670.   VERBOSE                  : BOOLEAN := TRUE; 
  671.   LIST_PREFIX              : constant STRING := "$$ "; 
  672.   --
  673.   -- INPUT_FILE_NAME and INPUT_FILE_NAME_LENGTH are set by the
  674.   --  function COMMAND
  675.   --
  676.   -- COMMENT_PREFIX is available to be set externally if desired;
  677.   --  if COMMENT_PREFIX is TRUE, all files created by PAGE will
  678.   --  present file indicators as comments; else, file indicators
  679.   --  will be presented in the UNIX standard form:
  680.   --      ::::::::::
  681.   --      filename
  682.   --      ::::::::::
  683.   --
  684.   -- INCLUDE_FILE_PREFIX is available to be set externally if desired;
  685.   --  if INCLUDE_FILE_PREFIX is TRUE, all include files referenced during
  686.   --  the PAGE command will be included as a prefix to their contents;
  687.   --  if FALSE, only the contents of the include files and not the include
  688.   --  files themselves will be included
  689.   -- INCLUDE_FILE_PREFIX_CHAR is the character prefixed to a file name to
  690.   --  designate it as an include file
  691.   -- LIST_PREFIX is the prefix to be placed before file names in the output
  692.   --  file generated by the list file names command.  This output file can
  693.   --  later be edited, and this prefix can be replaced via global substitution
  694.   --  with something else, such as "$ ada " to prefix each file name with a
  695.   --  DEC Ada compiler command (for example).
  696.   --
  697.  
  698.   procedure PAGE(OUTPUT_FILE_NAME : in STRING); 
  699.   --
  700.   -- PAGE prompts the user for the names of files and creates a paged
  701.   --  output file containing the indicated files
  702.   --
  703.  
  704.   procedure UNPAGE(INPUT_FILE_NAME : in STRING); 
  705.   --
  706.   -- UNPAGE extracts the files from a paged file
  707.   --
  708.  
  709.   procedure LIST_NAMES(INPUT_FILE_NAME : in STRING); 
  710.   -- 
  711.   -- LIST_NAMES lists the names of the files in a paged file out to a text
  712.   --  file.
  713.   -- 
  714.  
  715.   procedure ADA_CHECK(INPUT_FILE_NAME : in STRING); 
  716.   --
  717.   -- ADA_CHECK computes and displays the number of Ada statements, Ada
  718.   --  comments, text lines, and a checksum hash code for the indicated file
  719.   --
  720.  
  721.   procedure SCANPAGE(INPUT_FILE_NAME : in STRING); 
  722.   --
  723.   -- SCANPAGE lists the names of the files in a paged file
  724.   --
  725.  
  726.   function COMMAND return CHARACTER; 
  727.   --
  728.   -- COMMAND inputs a command line from the user and returns the first
  729.   --  character in this line as a command letter.  It returns this character
  730.   --  in upper-case.  It also does a simple parse of the command line
  731.   --  and fills the INPUT_FILE_NAME and INPUT_FILE_NAME_LENGTH values, where
  732.   --  the command line may be of the following two forms:
  733.   --
  734.   --     command_text
  735.   --     command_text file_name
  736.   --
  737.  
  738. end PAGER_SUPPORT; 
  739.  
  740. -- ====================================================================
  741.  
  742. with TEXT_IO, CHARACTER_SET, COUNT_OF_ADA_STATEMENTS; 
  743. package body PAGER_SUPPORT is 
  744.  
  745. --
  746. -- Common variables and exceptions
  747. --
  748.   MAX_STRING : constant := 1024; 
  749.   NEW_FILE   : TEXT_IO.FILE_TYPE; 
  750.   PAGED_FILE : TEXT_IO.FILE_TYPE; 
  751.   LAST       : NATURAL; 
  752.   LINE       : STRING(1 .. MAX_STRING); 
  753.  
  754.   type FILE_NAME_STRING is 
  755.     record
  756.       NAME   : STRING(1 .. FILE_NAME_LENGTH); 
  757.       LENGTH : NATURAL; 
  758.     end record; 
  759.  
  760.   FILE_CREATE_ERROR : exception; 
  761.   FILE_OPEN_ERROR   : exception; 
  762.  
  763.   -- ==============================================================
  764.  
  765.   package FN_LIST is 
  766.   --
  767.   -- This package provides simple manipulation for a singly-linked list
  768.   --   of objects of type FILE_NAME_STRING
  769.   --
  770.  
  771.     procedure INITIALIZE_LIST; 
  772.     --
  773.     -- Initialize the list
  774.     --
  775.  
  776.     procedure APPEND_ELEMENT(ELEMENT : in FILE_NAME_STRING); 
  777.     --
  778.     -- Add element onto the end of the list
  779.     --
  780.  
  781.     procedure SET_FIRST; 
  782.     --
  783.     -- Goto the front of the list
  784.     --
  785.  
  786.     function RETURN_CURRENT_ELEMENT return FILE_NAME_STRING; 
  787.     --
  788.     -- Return the current element in the list
  789.     --
  790.  
  791.     function CURRENT_NEXT return BOOLEAN; 
  792.     --
  793.     -- Advance to next element in the list; return TRUE if done
  794.     --
  795.  
  796.   end FN_LIST; 
  797.  
  798.   package body FN_LIST is 
  799.  
  800.     type FILE_NAME_ELEMENT; 
  801.     type ELEMENT_POINTER is access FILE_NAME_ELEMENT; 
  802.     type FILE_NAME_ELEMENT is 
  803.       record
  804.         DATA : FILE_NAME_STRING; 
  805.         NEXT : ELEMENT_POINTER; 
  806.       end record; 
  807.  
  808.     FIRST_ELEMENT   : ELEMENT_POINTER; 
  809.     CURRENT_ELEMENT : ELEMENT_POINTER; 
  810.  
  811.     procedure INITIALIZE_LIST is 
  812.     begin
  813.       FIRST_ELEMENT := null; 
  814.     end INITIALIZE_LIST; 
  815.  
  816.     procedure APPEND_ELEMENT(ELEMENT : in FILE_NAME_STRING) is 
  817.     begin
  818.       if FIRST_ELEMENT = null then 
  819.         FIRST_ELEMENT := new FILE_NAME_ELEMENT; 
  820.         CURRENT_ELEMENT := FIRST_ELEMENT; 
  821.         CURRENT_ELEMENT.NEXT := null; 
  822.         CURRENT_ELEMENT.DATA := ELEMENT; 
  823.       else 
  824.         CURRENT_ELEMENT.NEXT := new FILE_NAME_ELEMENT; 
  825.         CURRENT_ELEMENT := CURRENT_ELEMENT.NEXT; 
  826.         CURRENT_ELEMENT.NEXT := null; 
  827.         CURRENT_ELEMENT.DATA := ELEMENT; 
  828.       end if; 
  829.     end APPEND_ELEMENT; 
  830.  
  831.     procedure SET_FIRST is 
  832.     begin
  833.       CURRENT_ELEMENT := FIRST_ELEMENT; 
  834.     end SET_FIRST; 
  835.  
  836.     function RETURN_CURRENT_ELEMENT return FILE_NAME_STRING is 
  837.     begin
  838.       return CURRENT_ELEMENT.DATA; 
  839.     end RETURN_CURRENT_ELEMENT; 
  840.  
  841.     function CURRENT_NEXT return BOOLEAN is 
  842.     begin
  843.       if CURRENT_ELEMENT = null then 
  844.         return FALSE; 
  845.       elsif CURRENT_ELEMENT.NEXT = null then 
  846.         return FALSE; 
  847.       else 
  848.         CURRENT_ELEMENT := CURRENT_ELEMENT.NEXT; 
  849.         return TRUE; 
  850.       end if; 
  851.     end CURRENT_NEXT; 
  852.  
  853.   end FN_LIST; 
  854.  
  855.   -- ==============================================================
  856.   package NAT_IO is 
  857.     new TEXT_IO.INTEGER_IO(NATURAL); 
  858.  
  859.   --
  860.   -- Open the input file
  861.   --
  862.   procedure OPEN_INPUT(INPUT_FILE_NAME : in STRING) is 
  863.   begin
  864.     TEXT_IO.OPEN(PAGED_FILE, TEXT_IO.IN_FILE, INPUT_FILE_NAME); 
  865.   exception
  866.     when others => 
  867.       raise FILE_OPEN_ERROR; 
  868.   end OPEN_INPUT; 
  869.  
  870.   --
  871.   -- Create the paged output file
  872.   --
  873.   procedure CREATE_FILE(OUTPUT_FILE_NAME : in STRING) is 
  874.   begin
  875.     TEXT_IO.CREATE(PAGED_FILE, TEXT_IO.OUT_FILE, OUTPUT_FILE_NAME); 
  876.   exception
  877.     when others => 
  878.       raise FILE_CREATE_ERROR; 
  879.   end CREATE_FILE; 
  880.  
  881.   --
  882.   -- Close the paged file if it is open
  883.   --
  884.   procedure CLOSE_PAGED_FILE is 
  885.   begin
  886.     if TEXT_IO.IS_OPEN(PAGED_FILE) then 
  887.       TEXT_IO.CLOSE(PAGED_FILE); 
  888.     end if; 
  889.   end CLOSE_PAGED_FILE; 
  890.  
  891.   --
  892.   -- Test to see if current line denotes another file
  893.   --
  894.   function FILE_NAME_LINE return BOOLEAN is 
  895.   begin
  896.     if LAST >= 10 and then (LINE(1 .. 10) = "::::::::::" or LINE(1 .. 10) = 
  897.       "--::::::::") then 
  898.       return TRUE; 
  899.     else 
  900.       return FALSE; 
  901.     end if; 
  902.   end FILE_NAME_LINE; 
  903.  
  904.   --
  905.   --  PAGE accepts a number of file names and generates a paged file
  906.   --  containing each of the indicated files prefixed by the form:
  907.   --     ::::::::::
  908.   --     filename
  909.   --     ::::::::::
  910.   --
  911.   procedure PAGE(OUTPUT_FILE_NAME : in STRING) is 
  912.  
  913.     --
  914.     --  Variables for PAGE
  915.     --
  916.     FILE_NAME_ENTRY : FILE_NAME_STRING; 
  917.     FILE_NAME       : STRING(1 .. FILE_NAME_LENGTH); 
  918.     LENGTH          : NATURAL; 
  919.  
  920.     --
  921.     -- Append indicated file to end of output file
  922.     --
  923.     procedure APPEND_FILE(FILE_NAME : in STRING) is 
  924.       INPUT_FILE : TEXT_IO.FILE_TYPE; 
  925.       INLINE     : STRING(1 .. MAX_STRING); 
  926.       LENGTH     : NATURAL; 
  927.       LINE_COUNT : NATURAL := 0; 
  928.     begin
  929.       TEXT_IO.OPEN(INPUT_FILE, TEXT_IO.IN_FILE, FILE_NAME); 
  930.       if COMMENT_PREFIX then 
  931.         TEXT_IO.PUT(PAGED_FILE, "--"); 
  932.       end if; 
  933.       TEXT_IO.PUT_LINE(PAGED_FILE, "::::::::::"); 
  934.       if COMMENT_PREFIX then 
  935.         TEXT_IO.PUT(PAGED_FILE, "--"); 
  936.       end if; 
  937.       TEXT_IO.PUT_LINE(PAGED_FILE, FILE_NAME); 
  938.       if COMMENT_PREFIX then 
  939.         TEXT_IO.PUT(PAGED_FILE, "--"); 
  940.       end if; 
  941.       TEXT_IO.PUT_LINE(PAGED_FILE, "::::::::::"); 
  942.       while not TEXT_IO.END_OF_FILE(INPUT_FILE) loop
  943.         TEXT_IO.GET_LINE(INPUT_FILE, INLINE, LENGTH); 
  944.         TEXT_IO.PUT_LINE(PAGED_FILE, INLINE(1 .. LENGTH)); 
  945.         begin
  946.           LINE_COUNT := LINE_COUNT + 1; 
  947.         exception
  948.           when others => 
  949.             null; 
  950.  
  951.         -- trap overflow
  952.         end; 
  953.       end loop; 
  954.       TEXT_IO.CLOSE(INPUT_FILE); 
  955.       if VERBOSE then 
  956.         TEXT_IO.PUT("      "); 
  957.         NAT_IO.PUT(LINE_COUNT, 8); 
  958.         TEXT_IO.PUT_LINE(" Lines"); 
  959.       end if; 
  960.     exception
  961.       when TEXT_IO.NAME_ERROR => 
  962.         TEXT_IO.PUT_LINE("      File Name Error"); 
  963.         TEXT_IO.CLOSE(INPUT_FILE); 
  964.         raise FILE_OPEN_ERROR; 
  965.       when others => 
  966.         TEXT_IO.CLOSE(INPUT_FILE); 
  967.         raise FILE_OPEN_ERROR; 
  968.     end APPEND_FILE; 
  969.  
  970.     --
  971.     -- Process the indicated file as an include file; ie, this file
  972.     --  contains a list of files to be included
  973.     --
  974.     procedure INCLUDE_FILE(FILE_NAME : in STRING) is 
  975.       IFILE      : TEXT_IO.FILE_TYPE; 
  976.       IFILE_NAME : STRING(1 .. FILE_NAME_LENGTH); 
  977.       LENGTH     : NATURAL; 
  978.  
  979.       procedure NAME_INCLUDE_FILE is 
  980.       begin
  981.         if VERBOSE then 
  982.           TEXT_IO.PUT("      "); 
  983.           TEXT_IO.PUT_LINE(FILE_NAME_ENTRY.NAME(1 .. FILE_NAME_ENTRY.LENGTH)); 
  984.         end if; 
  985.       end NAME_INCLUDE_FILE; 
  986.  
  987.     begin
  988.       if VERBOSE then 
  989.         TEXT_IO.PUT("    Include File: "); 
  990.         TEXT_IO.PUT_LINE(FILE_NAME); 
  991.       end if; 
  992.  
  993.       --
  994.       -- Try to open include file
  995.       --
  996.       TEXT_IO.OPEN(IFILE, TEXT_IO.IN_FILE, FILE_NAME); 
  997.  
  998.       --
  999.       -- If INCLUDE_FILE_PREFIX is true, add the include file itself
  1000.       --
  1001.       if INCLUDE_FILE_PREFIX then 
  1002.         FILE_NAME_ENTRY.NAME(1 .. FILE_NAME'LENGTH) := FILE_NAME; 
  1003.         FILE_NAME_ENTRY.LENGTH := FILE_NAME'LENGTH; 
  1004.         FN_LIST.APPEND_ELEMENT(FILE_NAME_ENTRY); 
  1005.         NAME_INCLUDE_FILE; 
  1006.       end if; 
  1007.  
  1008.       --
  1009.       -- Add each file in the include file; omit blank lines and
  1010.       --  lines beginning with - (comment lines)
  1011.       --
  1012.       loop
  1013.         begin
  1014.           TEXT_IO.GET_LINE(IFILE, IFILE_NAME, LENGTH); 
  1015.           if LENGTH /= 0 and IFILE_NAME(1) /= '-' then 
  1016.           --
  1017.           -- Allow for include file nesting
  1018.           --
  1019.             if IFILE_NAME(1) = INCLUDE_FILE_PREFIX_CHAR then 
  1020.               INCLUDE_FILE(IFILE_NAME(2 .. LENGTH)); 
  1021.               --
  1022.               -- Include a conventional file
  1023.               --
  1024.             else 
  1025.               FILE_NAME_ENTRY.NAME := IFILE_NAME; 
  1026.               FILE_NAME_ENTRY.LENGTH := LENGTH; 
  1027.               FN_LIST.APPEND_ELEMENT(FILE_NAME_ENTRY); 
  1028.               NAME_INCLUDE_FILE; 
  1029.             end if; 
  1030.           end if; 
  1031.         exception
  1032.           when TEXT_IO.END_ERROR => 
  1033.             TEXT_IO.CLOSE(IFILE); 
  1034.             if VERBOSE then 
  1035.               TEXT_IO.PUT("    End of Include File "); 
  1036.               TEXT_IO.PUT_LINE(FILE_NAME); 
  1037.             end if; 
  1038.             exit; 
  1039.           when TEXT_IO.NAME_ERROR => 
  1040.             TEXT_IO.CLOSE(IFILE); 
  1041.             TEXT_IO.PUT_LINE("      File Name Error"); 
  1042.           when others => 
  1043.             TEXT_IO.CLOSE(IFILE); 
  1044.             raise; 
  1045.         end; 
  1046.       end loop; 
  1047.     exception
  1048.       when TEXT_IO.END_ERROR => 
  1049.         TEXT_IO.PUT_LINE("    Include File "); 
  1050.         TEXT_IO.PUT(FILE_NAME); 
  1051.         TEXT_IO.PUT_LINE(" NOT Found"); 
  1052.       when others => 
  1053.         raise; 
  1054.     end INCLUDE_FILE; 
  1055.  
  1056.   --
  1057.   --  Mainline of PAGE
  1058.   --
  1059.   begin
  1060.     CREATE_FILE(OUTPUT_FILE_NAME); 
  1061.     FN_LIST.INITIALIZE_LIST; 
  1062.     TEXT_IO.PUT_LINE("Enter Names of Files (RETURN when done)"); 
  1063.     loop
  1064.       TEXT_IO.PUT("  Input File Name > "); 
  1065.       TEXT_IO.GET_LINE(FILE_NAME, LENGTH); 
  1066.       exit when LENGTH = 0; 
  1067.       if FILE_NAME(1) = INCLUDE_FILE_PREFIX_CHAR then 
  1068.         INCLUDE_FILE(FILE_NAME(2 .. LENGTH)); 
  1069.       else 
  1070.         FILE_NAME_ENTRY.NAME := FILE_NAME; 
  1071.         FILE_NAME_ENTRY.LENGTH := LENGTH; 
  1072.         FN_LIST.APPEND_ELEMENT(FILE_NAME_ENTRY); 
  1073.       end if; 
  1074.     end loop; 
  1075.     TEXT_IO.NEW_LINE; 
  1076.     TEXT_IO.PUT_LINE("  Component Files --"); 
  1077.     FN_LIST.SET_FIRST; 
  1078.     loop
  1079.       begin
  1080.         FILE_NAME_ENTRY := FN_LIST.RETURN_CURRENT_ELEMENT; 
  1081.         TEXT_IO.PUT("    "); 
  1082.         TEXT_IO.PUT_LINE(FILE_NAME_ENTRY.NAME(1 .. FILE_NAME_ENTRY.LENGTH)); 
  1083.         APPEND_FILE(FILE_NAME_ENTRY.NAME(1 .. FILE_NAME_ENTRY.LENGTH)); 
  1084.         exit when not FN_LIST.CURRENT_NEXT; 
  1085.       exception
  1086.         when FILE_OPEN_ERROR => 
  1087.           TEXT_IO.PUT(" -- File NOT Found"); 
  1088.           exit when not FN_LIST.CURRENT_NEXT; 
  1089.         when others => 
  1090.           raise; 
  1091.       end; 
  1092.     end loop; 
  1093.     CLOSE_PAGED_FILE; 
  1094.   exception
  1095.     when FILE_CREATE_ERROR => 
  1096.       TEXT_IO.PUT("    Error in creating output file "); 
  1097.       TEXT_IO.PUT_LINE(OUTPUT_FILE_NAME); 
  1098.       CLOSE_PAGED_FILE; 
  1099.     when FILE_OPEN_ERROR => 
  1100.       TEXT_IO.PUT("    Error in opening input file "); 
  1101.       TEXT_IO.PUT_LINE(FILE_NAME_ENTRY.NAME(1 .. FILE_NAME_ENTRY.LENGTH)); 
  1102.       CLOSE_PAGED_FILE; 
  1103.     when others => 
  1104.       CLOSE_PAGED_FILE; 
  1105.   end PAGE; 
  1106.  
  1107.  
  1108.   --
  1109.   -- UNPAGE extracts the component files from a paged file and writes them
  1110.   --  out to their respective files
  1111.   --
  1112.   procedure UNPAGE(INPUT_FILE_NAME : in STRING) is 
  1113.  
  1114.     LINE_COUNT : NATURAL; 
  1115.  
  1116.     --
  1117.     -- Open new file for output
  1118.     --
  1119.     procedure OPEN_NEW_FILE is 
  1120.       NAME_START : INTEGER; 
  1121.     begin
  1122.       TEXT_IO.GET_LINE(PAGED_FILE, LINE, LAST); 
  1123.       TEXT_IO.PUT("     "); 
  1124.       TEXT_IO.PUT_LINE(LINE(1 .. LAST)); 
  1125.  
  1126.       if LINE(1 .. 2) = "--" then 
  1127.         NAME_START := 3; 
  1128.       else 
  1129.         NAME_START := 1; 
  1130.       end if; 
  1131.       loop
  1132.         begin
  1133.           TEXT_IO.CREATE(NEW_FILE, TEXT_IO.OUT_FILE, LINE(NAME_START .. LAST)); 
  1134.           exit; 
  1135.         exception
  1136.           when TEXT_IO.NAME_ERROR => 
  1137.             TEXT_IO.NEW_LINE; 
  1138.             TEXT_IO.PUT("  Invalid File Name ("); 
  1139.             TEXT_IO.PUT(LINE(NAME_START .. LAST)); 
  1140.             TEXT_IO.PUT_LINE(")"); 
  1141.             TEXT_IO.PUT("    Enter Valid File Name > "); 
  1142.             TEXT_IO.GET_LINE(LINE, LAST); 
  1143.             NAME_START := 1; 
  1144.           when others => 
  1145.             raise; 
  1146.         end; 
  1147.       end loop; 
  1148.  
  1149.       --Skip over the trailing ":::::::::::::" line
  1150.       TEXT_IO.GET_LINE(PAGED_FILE, LINE, LAST); 
  1151.     exception
  1152.       when others => 
  1153.         raise FILE_CREATE_ERROR; 
  1154.     end OPEN_NEW_FILE; 
  1155.  
  1156.   --
  1157.   -- Mainline of UNPAGE
  1158.   --
  1159.   begin
  1160.  
  1161.     OPEN_INPUT(INPUT_FILE_NAME); 
  1162.  
  1163.     --
  1164.     -- Search for first component in paged file
  1165.     --
  1166.     loop
  1167.       TEXT_IO.GET_LINE(PAGED_FILE, LINE, LAST); 
  1168.       exit when FILE_NAME_LINE; 
  1169.     end loop; 
  1170.     --
  1171.     -- Process each component in paged file
  1172.     --
  1173.     OPEN_NEW_FILE; 
  1174.     LINE_COUNT := 0; 
  1175.     loop
  1176.       TEXT_IO.GET_LINE(PAGED_FILE, LINE, LAST); 
  1177.       if FILE_NAME_LINE then 
  1178.         TEXT_IO.CLOSE(NEW_FILE); 
  1179.         if VERBOSE then 
  1180.           TEXT_IO.PUT("      "); 
  1181.           NAT_IO.PUT(LINE_COUNT, 8); 
  1182.           TEXT_IO.PUT_LINE(" Lines"); 
  1183.         end if; 
  1184.         LINE_COUNT := 0; 
  1185.         OPEN_NEW_FILE; 
  1186.       else 
  1187.         begin
  1188.           LINE_COUNT := LINE_COUNT + 1; 
  1189.         exception
  1190.           when others => 
  1191.             null; 
  1192.  
  1193.         -- trap overflow
  1194.         end; 
  1195.         TEXT_IO.PUT_LINE(NEW_FILE, LINE(1 .. LAST)); 
  1196.       end if; 
  1197.     end loop; 
  1198.  
  1199.   exception
  1200.     when FILE_CREATE_ERROR => 
  1201.       TEXT_IO.PUT_LINE("    Error in creating output file"); 
  1202.       CLOSE_PAGED_FILE; 
  1203.     when FILE_OPEN_ERROR => 
  1204.       TEXT_IO.PUT_LINE("    Error in opening input file"); 
  1205.       CLOSE_PAGED_FILE; 
  1206.     when TEXT_IO.END_ERROR => 
  1207.       if TEXT_IO.IS_OPEN(NEW_FILE) then 
  1208.         TEXT_IO.CLOSE(NEW_FILE); 
  1209.         if VERBOSE then 
  1210.           TEXT_IO.PUT("      "); 
  1211.           NAT_IO.PUT(LINE_COUNT, 8); 
  1212.           TEXT_IO.PUT_LINE(" Lines"); 
  1213.         end if; 
  1214.       end if; 
  1215.       CLOSE_PAGED_FILE; 
  1216.     when others => 
  1217.       CLOSE_PAGED_FILE; 
  1218.   end UNPAGE; 
  1219.  
  1220.   -- 
  1221.   -- LIST_NAMES lists the names of the files in a paged file out to a text file
  1222.   -- 
  1223.   procedure LIST_NAMES(INPUT_FILE_NAME : in STRING) is 
  1224.     LIST_FILE : TEXT_IO.FILE_TYPE; 
  1225.  
  1226.     -- 
  1227.     -- List name of component file
  1228.     -- 
  1229.     procedure LIST_COMPONENT_NAME is 
  1230.       NAME_START : INTEGER; 
  1231.     begin
  1232.       TEXT_IO.GET_LINE(PAGED_FILE, LINE, LAST); 
  1233.       if LINE(1 .. 2) = "--" then 
  1234.         NAME_START := 3; 
  1235.       else 
  1236.         NAME_START := 1; 
  1237.       end if; 
  1238.       TEXT_IO.PUT_LINE(LIST_FILE, LIST_PREFIX & LINE(NAME_START .. LAST)); 
  1239.       TEXT_IO.GET_LINE(PAGED_FILE, LINE, LAST); 
  1240.     end LIST_COMPONENT_NAME; 
  1241.  
  1242.     -- 
  1243.     -- Close listing file
  1244.     -- 
  1245.     procedure CLOSE_LISTING_FILE is 
  1246.     begin
  1247.       if TEXT_IO.IS_OPEN(LIST_FILE) then 
  1248.         TEXT_IO.CLOSE(LIST_FILE); 
  1249.       end if; 
  1250.     end CLOSE_LISTING_FILE; 
  1251.  
  1252.     -- 
  1253.     -- Mainline of LIST_NAMES
  1254.     -- 
  1255.   begin
  1256.     OPEN_INPUT(INPUT_FILE_NAME); 
  1257.     TEXT_IO.PUT("  Name of Output File (<RETURN> to Abort)? "); 
  1258.     TEXT_IO.GET_LINE(LINE, LAST); 
  1259.     if LAST = 0 then 
  1260.       TEXT_IO.PUT_LINE("     User Abort"); 
  1261.       CLOSE_PAGED_FILE; 
  1262.       return; 
  1263.     end if; 
  1264.     begin
  1265.       TEXT_IO.CREATE(LIST_FILE, TEXT_IO.OUT_FILE, LINE(1 .. LAST)); 
  1266.     exception
  1267.       when others => 
  1268.         raise FILE_CREATE_ERROR; 
  1269.     end; 
  1270.     loop
  1271.     -- 
  1272.     -- Look for file name prefix
  1273.     -- 
  1274.       loop
  1275.         TEXT_IO.GET_LINE(PAGED_FILE, LINE, LAST); 
  1276.         exit when FILE_NAME_LINE; 
  1277.       end loop; 
  1278.       LIST_COMPONENT_NAME; 
  1279.     end loop; 
  1280.   exception
  1281.     when FILE_CREATE_ERROR => 
  1282.       TEXT_IO.PUT_LINE("     Error in creating listing file"); 
  1283.       CLOSE_PAGED_FILE; 
  1284.     when FILE_OPEN_ERROR => 
  1285.       TEXT_IO.PUT_LINE("     Error in opening input file"); 
  1286.     when TEXT_IO.END_ERROR => 
  1287.       CLOSE_LISTING_FILE; 
  1288.       CLOSE_PAGED_FILE; 
  1289.       TEXT_IO.PUT_LINE("     Listing Done"); 
  1290.     when others => 
  1291.       CLOSE_LISTING_FILE; 
  1292.       CLOSE_PAGED_FILE; 
  1293.   end LIST_NAMES; 
  1294.  
  1295.   --
  1296.   -- ADA_CHECK computes and displays the number of Ada statements, Ada
  1297.   --  comments, text lines, and a checksum hash code for the indicated file
  1298.   --
  1299.   procedure ADA_CHECK(INPUT_FILE_NAME : in STRING) is 
  1300.     STATEMENTS : NATURAL; 
  1301.     LINES      : NATURAL; 
  1302.     COMMENTS   : NATURAL; 
  1303.     HASH       : NATURAL; 
  1304.   begin
  1305.     COUNT_OF_ADA_STATEMENTS(INPUT_FILE_NAME, STATEMENTS, LINES, COMMENTS, HASH)
  1306.       ; 
  1307.     TEXT_IO.PUT("Input File: "); 
  1308.     TEXT_IO.PUT_LINE(INPUT_FILE_NAME); 
  1309.     TEXT_IO.PUT("  Ada Statements: "); 
  1310.     NAT_IO.PUT(STATEMENTS, 6); 
  1311.     TEXT_IO.NEW_LINE; 
  1312.     TEXT_IO.PUT("  Ada Comments:   "); 
  1313.     NAT_IO.PUT(COMMENTS, 6); 
  1314.     TEXT_IO.NEW_LINE; 
  1315.     TEXT_IO.PUT("  Text Lines:     "); 
  1316.     NAT_IO.PUT(LINES, 6); 
  1317.     TEXT_IO.NEW_LINE; 
  1318.     TEXT_IO.PUT("  Checksum:       "); 
  1319.     NAT_IO.PUT(HASH, 6); 
  1320.     TEXT_IO.NEW_LINE; 
  1321.   end ADA_CHECK; 
  1322.  
  1323.   --
  1324.   -- SCANPAGE scans a paged file and prints out the names of the files
  1325.   --  contained therein
  1326.   --
  1327.   procedure SCANPAGE(INPUT_FILE_NAME : in STRING) is 
  1328.  
  1329.     --
  1330.     -- Variables et al
  1331.     --
  1332.     LINE_COUNT : NATURAL; 
  1333.  
  1334.     --
  1335.     -- Advance to a new file
  1336.     --
  1337.     procedure NEW_FILE is 
  1338.       NAME_START : NATURAL; 
  1339.     begin
  1340.     -- Get file name
  1341.       TEXT_IO.GET_LINE(PAGED_FILE, LINE, LAST); 
  1342.  
  1343.       -- Print file name
  1344.       if LINE(1 .. 2) = "--" then 
  1345.         NAME_START := 3; 
  1346.       else 
  1347.         NAME_START := 1; 
  1348.       end if; 
  1349.       TEXT_IO.PUT("    "); 
  1350.       TEXT_IO.PUT(LINE(NAME_START .. LAST)); 
  1351.       LINE_COUNT := 0; 
  1352.  
  1353.       -- Skip over the trailing ":::::::::::::" line
  1354.       TEXT_IO.GET_LINE(PAGED_FILE, LINE, LAST); 
  1355.  
  1356.     end NEW_FILE; 
  1357.  
  1358.     --
  1359.     -- Print value of LINE_COUNT
  1360.     --
  1361.     procedure PRINT_LINE_COUNT is 
  1362.     begin
  1363.       TEXT_IO.NEW_LINE; 
  1364.       if VERBOSE then 
  1365.         TEXT_IO.PUT("      "); 
  1366.         NAT_IO.PUT(LINE_COUNT, 8); 
  1367.         TEXT_IO.PUT_LINE(" Lines"); 
  1368.       end if; 
  1369.     end PRINT_LINE_COUNT; 
  1370.  
  1371.   --
  1372.   --  Mainline of SCANPAGE
  1373.   --
  1374.   begin
  1375.  
  1376.     ADA_CHECK(INPUT_FILE_NAME); 
  1377.     OPEN_INPUT(INPUT_FILE_NAME); 
  1378.  
  1379.     --
  1380.     -- Search for first component in paged file
  1381.     --
  1382.     loop
  1383.       TEXT_IO.GET_LINE(PAGED_FILE, LINE, LAST); 
  1384.       exit when FILE_NAME_LINE; 
  1385.     end loop; 
  1386.     TEXT_IO.PUT_LINE("  Component Files -- "); 
  1387.     --
  1388.     -- Process each component in paged file
  1389.     --
  1390.     NEW_FILE; 
  1391.     loop
  1392.       begin
  1393.         TEXT_IO.GET_LINE(PAGED_FILE, LINE, LAST); 
  1394.         begin
  1395.           LINE_COUNT := LINE_COUNT + 1; 
  1396.         exception
  1397.           when others => 
  1398.             null;  -- trap overflow
  1399.         end; 
  1400.         if FILE_NAME_LINE then 
  1401.           begin
  1402.             LINE_COUNT := LINE_COUNT - 1; 
  1403.           exception
  1404.             when others => 
  1405.               null; 
  1406.  
  1407.           -- trap overflow
  1408.           end; 
  1409.           PRINT_LINE_COUNT; 
  1410.           NEW_FILE; 
  1411.         end if; 
  1412.       exception
  1413.         when TEXT_IO.END_ERROR => 
  1414.           PRINT_LINE_COUNT; 
  1415.           exit; 
  1416.         when others => 
  1417.           raise; 
  1418.       end; 
  1419.     end loop; 
  1420.  
  1421.     CLOSE_PAGED_FILE; 
  1422.  
  1423.   exception
  1424.     when FILE_CREATE_ERROR => 
  1425.       TEXT_IO.PUT_LINE("    Error in creating output file"); 
  1426.       CLOSE_PAGED_FILE; 
  1427.     when FILE_OPEN_ERROR => 
  1428.       TEXT_IO.PUT_LINE("    Error in opening input file"); 
  1429.       CLOSE_PAGED_FILE; 
  1430.     when TEXT_IO.END_ERROR => 
  1431.       CLOSE_PAGED_FILE; 
  1432.     when others => 
  1433.       CLOSE_PAGED_FILE; 
  1434.   end SCANPAGE; 
  1435.  
  1436.   --
  1437.   -- COMMAND inputs and does a simple parse of the command line
  1438.   --
  1439.   function COMMAND return CHARACTER is 
  1440.     INDEX             : NATURAL; 
  1441.     FN_INDEX          : NATURAL; 
  1442.     COMMAND_LINE      : STRING(1 .. 256); 
  1443.     COMMAND_LENGTH    : NATURAL; 
  1444.     COMMAND_CHARACTER : CHARACTER; 
  1445.   begin
  1446.     loop
  1447.       TEXT_IO.GET_LINE(COMMAND_LINE, COMMAND_LENGTH); 
  1448.       COMMAND_LINE(COMMAND_LENGTH + 1) := ASCII.NUL; 
  1449.       if COMMAND_LENGTH > 0 then 
  1450.         COMMAND_CHARACTER := COMMAND_LINE(1); 
  1451.         INDEX := 1; 
  1452.  
  1453.         -- Skip over command name
  1454.         loop
  1455.           exit when CHARACTER_SET.IS_SPACE(COMMAND_LINE(INDEX)) or COMMAND_LINE(
  1456.             INDEX) = ASCII.NUL; 
  1457.           INDEX := INDEX + 1; 
  1458.         end loop; 
  1459.  
  1460.         -- Skip over space chars
  1461.         loop
  1462.           exit when (not CHARACTER_SET.IS_SPACE(COMMAND_LINE(INDEX))) or 
  1463.             COMMAND_LINE(INDEX) = ASCII.NUL; 
  1464.           INDEX := INDEX + 1; 
  1465.         end loop; 
  1466.  
  1467.         -- Save file name
  1468.         FN_INDEX := 1; 
  1469.         loop
  1470.           exit when COMMAND_LINE(INDEX) = ASCII.NUL; 
  1471.           INPUT_FILE_NAME(FN_INDEX) := COMMAND_LINE(INDEX); 
  1472.           INDEX := INDEX + 1; 
  1473.           FN_INDEX := FN_INDEX + 1; 
  1474.         end loop; 
  1475.         INPUT_FILE_NAME(FN_INDEX) := ASCII.NUL; 
  1476.         INPUT_FILE_NAME_LENGTH := FN_INDEX - 1; 
  1477.         exit; 
  1478.       end if; 
  1479.     end loop; 
  1480.     return CHARACTER_SET.TO_UPPER(COMMAND_CHARACTER); 
  1481.   end COMMAND; 
  1482.  
  1483. end PAGER_SUPPORT; 
  1484. ::::::::::
  1485. pager.ada
  1486. ::::::::::
  1487.  
  1488. --
  1489. -- PAGER by Richard Conn, TI Ada Technology Branch
  1490. -- Version 1.0, 10 Mar 85
  1491. -- Version 1.1, 13 Mar 85
  1492. -- Version 1.2, 14 Mar 85
  1493. -- Version 1.3, 4 Apr 85
  1494. -- Version 1.4, 8 Apr 85
  1495. -- Version 1.5, 6 May 85
  1496. -- Version 1.6, 30 Oct 85
  1497. --
  1498.  
  1499.  
  1500. --|MODULE: PAGER
  1501. --|AUTHOR: CONN
  1502. --|LOCATION: PDL-TOOLS
  1503. --|LOCATION: TOOLS
  1504. --|REQUIRES: CHARACTER_SET
  1505. --|REQUIRES: CAS3
  1506. --|IEEE_PDL: SUPPORT_MODULE
  1507. --|DESIGN_STATUS         : DONE
  1508. --|IMPLEMENTATION_STATUS : DONE
  1509. --|DOCUMENTATION_STATUS  : DONE
  1510. --|DATE_RELEASED         : 10 Mar 85
  1511. --|DATE_LAST_MODIFIED    : 30 Oct 85
  1512. --|ABSTRACT:
  1513. --|  PAGER manipulates text files as a library which takes the
  1514. --| form of a larger text files.  It creates the larger text file,
  1515. --| extracts its components, and analyzes it, giving information
  1516. --| on its content.  PAGER is a convenient tool for the collection
  1517. --| of related files.  This collection, then, can be copied and
  1518. --| archived, but, when the work is done on these files again,
  1519. --| the paged file can be copied out to a work area, torn apart
  1520. --| (unpaged), and the related files can be worked on independently.
  1521. --|
  1522.  
  1523. with TEXT_IO, PAGER_SUPPORT; 
  1524. procedure PAGER is 
  1525.  
  1526.   VERSION                  : constant STRING := "PAGER, Version 1.6"; 
  1527.   CURRENT_FILE_NAME        : STRING(1 .. PAGER_SUPPORT.FILE_NAME_LENGTH) := (
  1528.     others => ASCII.NUL); 
  1529.   CURRENT_FILE_NAME_LENGTH : NATURAL := 0; 
  1530.  
  1531.   NO_FILE_NAME             : exception; 
  1532.  
  1533.   procedure COMMENT_MESSAGE is 
  1534.   begin
  1535.     TEXT_IO.PUT("  Comment Prefix is "); 
  1536.     if PAGER_SUPPORT.COMMENT_PREFIX then 
  1537.       TEXT_IO.PUT_LINE("Enabled"); 
  1538.     else 
  1539.       TEXT_IO.PUT_LINE("Disabled"); 
  1540.     end if; 
  1541.   end COMMENT_MESSAGE; 
  1542.  
  1543.   procedure INCLUDE_MESSAGE is 
  1544.   begin
  1545.     TEXT_IO.PUT("  Include File Prefix is "); 
  1546.     if PAGER_SUPPORT.INCLUDE_FILE_PREFIX then 
  1547.       TEXT_IO.PUT_LINE("Enabled"); 
  1548.     else 
  1549.       TEXT_IO.PUT_LINE("Disabled"); 
  1550.     end if; 
  1551.   end INCLUDE_MESSAGE; 
  1552.  
  1553.   procedure VERBOSE_MESSAGE is 
  1554.   begin
  1555.     TEXT_IO.PUT("  Verbose Mode is "); 
  1556.     if PAGER_SUPPORT.VERBOSE then 
  1557.       TEXT_IO.PUT_LINE("Enabled"); 
  1558.     else 
  1559.       TEXT_IO.PUT_LINE("Disabled"); 
  1560.     end if; 
  1561.   end VERBOSE_MESSAGE; 
  1562.  
  1563. begin
  1564.   TEXT_IO.PUT_LINE(VERSION); 
  1565.   TEXT_IO.PUT_LINE("Type HELP for Help"); 
  1566.   loop
  1567.     begin
  1568.       TEXT_IO.PUT("PAGER> "); 
  1569.       case PAGER_SUPPORT.COMMAND is 
  1570.         when '-' => 
  1571.           null; 
  1572.         when 'C' => 
  1573.           if PAGER_SUPPORT.INPUT_FILE_NAME_LENGTH > 0 then 
  1574.             CURRENT_FILE_NAME := PAGER_SUPPORT.INPUT_FILE_NAME; 
  1575.             CURRENT_FILE_NAME_LENGTH := PAGER_SUPPORT.INPUT_FILE_NAME_LENGTH; 
  1576.           else 
  1577.             raise NO_FILE_NAME; 
  1578.           end if; 
  1579.           PAGER_SUPPORT.ADA_CHECK(CURRENT_FILE_NAME(1 .. 
  1580.             CURRENT_FILE_NAME_LENGTH)); 
  1581.         when 'H' => 
  1582.           TEXT_IO.PUT_LINE("PAGER Commands:"); 
  1583.           TEXT_IO.PUT_LINE(" CHECK filename  --  Ada Check on File"); 
  1584.           TEXT_IO.PUT_LINE(" LIST filename   --  List Names of Component Files")
  1585.             ; 
  1586.           TEXT_IO.PUT_LINE(" PAGE filename   --  Create Paged File"); 
  1587.           TEXT_IO.PUT_LINE(" SCAN filename   --  List Files in Paged File"); 
  1588.           TEXT_IO.PUT_LINE(" TOGGLE          --  Indicate Flag Settings"); 
  1589.           TEXT_IO.PUT_LINE(" TOGGLE flag     --  Toggle Indicated Flag:"); 
  1590.           TEXT_IO.PUT_LINE("                     Comment, Include File, or"); 
  1591.           TEXT_IO.PUT_LINE("                     Verbose"); 
  1592.           TEXT_IO.PUT_LINE(" UNPAGE filename --  Extract from Paged File"); 
  1593.           TEXT_IO.PUT_LINE(" X (Exit)        --  Exit PAGER"); 
  1594.         when 'L' => 
  1595.           if PAGER_SUPPORT.INPUT_FILE_NAME_LENGTH > 0 then 
  1596.             CURRENT_FILE_NAME := PAGER_SUPPORT.INPUT_FILE_NAME; 
  1597.             CURRENT_FILE_NAME_LENGTH := PAGER_SUPPORT.INPUT_FILE_NAME_LENGTH; 
  1598.           else 
  1599.             raise NO_FILE_NAME; 
  1600.           end if; 
  1601.           PAGER_SUPPORT.LIST_NAMES(CURRENT_FILE_NAME(1 .. 
  1602.             CURRENT_FILE_NAME_LENGTH)); 
  1603.         when 'P' => 
  1604.           if PAGER_SUPPORT.INPUT_FILE_NAME_LENGTH > 0 then 
  1605.             CURRENT_FILE_NAME := PAGER_SUPPORT.INPUT_FILE_NAME; 
  1606.             CURRENT_FILE_NAME_LENGTH := PAGER_SUPPORT.INPUT_FILE_NAME_LENGTH; 
  1607.           else 
  1608.             raise NO_FILE_NAME; 
  1609.           end if; 
  1610.           PAGER_SUPPORT.PAGE(CURRENT_FILE_NAME(1 .. CURRENT_FILE_NAME_LENGTH)); 
  1611.         when 'S' => 
  1612.           if PAGER_SUPPORT.INPUT_FILE_NAME_LENGTH > 0 then 
  1613.             CURRENT_FILE_NAME := PAGER_SUPPORT.INPUT_FILE_NAME; 
  1614.             CURRENT_FILE_NAME_LENGTH := PAGER_SUPPORT.INPUT_FILE_NAME_LENGTH; 
  1615.           else 
  1616.             raise NO_FILE_NAME; 
  1617.           end if; 
  1618.           PAGER_SUPPORT.SCANPAGE(CURRENT_FILE_NAME(1 .. CURRENT_FILE_NAME_LENGTH
  1619.             )); 
  1620.         when 'T' => 
  1621.           if PAGER_SUPPORT.INPUT_FILE_NAME_LENGTH > 0 then 
  1622.             case PAGER_SUPPORT.INPUT_FILE_NAME(1) is 
  1623.               when 'c' | 'C' => 
  1624.                 PAGER_SUPPORT.COMMENT_PREFIX := not PAGER_SUPPORT.COMMENT_PREFIX
  1625.                   ; 
  1626.                 COMMENT_MESSAGE; 
  1627.               when 'i' | 'I' => 
  1628.                 PAGER_SUPPORT.INCLUDE_FILE_PREFIX := not PAGER_SUPPORT.
  1629.                   INCLUDE_FILE_PREFIX; 
  1630.                 INCLUDE_MESSAGE; 
  1631.               when 'v' | 'V' => 
  1632.                 PAGER_SUPPORT.VERBOSE := not PAGER_SUPPORT.VERBOSE; 
  1633.                 VERBOSE_MESSAGE; 
  1634.               when others => 
  1635.                 TEXT_IO.PUT_LINE("    Invalid Toggle Option"); 
  1636.             end case; 
  1637.           else 
  1638.             COMMENT_MESSAGE; 
  1639.             INCLUDE_MESSAGE; 
  1640.             VERBOSE_MESSAGE; 
  1641.           end if; 
  1642.         when 'U' => 
  1643.           if PAGER_SUPPORT.INPUT_FILE_NAME_LENGTH > 0 then 
  1644.             CURRENT_FILE_NAME := PAGER_SUPPORT.INPUT_FILE_NAME; 
  1645.             CURRENT_FILE_NAME_LENGTH := PAGER_SUPPORT.INPUT_FILE_NAME_LENGTH; 
  1646.           else 
  1647.             raise NO_FILE_NAME; 
  1648.           end if; 
  1649.           PAGER_SUPPORT.UNPAGE(CURRENT_FILE_NAME(1 .. CURRENT_FILE_NAME_LENGTH))
  1650.             ; 
  1651.         when 'X' => 
  1652.           exit; 
  1653.         when others => 
  1654.           TEXT_IO.PUT_LINE("    Invalid Command - Use HELP Command"); 
  1655.       end case; 
  1656.     exception
  1657.       when NO_FILE_NAME => 
  1658.         TEXT_IO.PUT_LINE("    File Name Missing from Command"); 
  1659.       when others => 
  1660.         null; 
  1661.     end; 
  1662.   end loop; 
  1663. end PAGER; 
  1664. ::::::::::
  1665. pager_documentation.dis
  1666. ::::::::::
  1667. --
  1668. -- The following files comprise the documentation on
  1669. -- PAGER.  PAGER.DOC is the formatted document, PAGER.RNO
  1670. -- is the source from which formatting was done.
  1671. --
  1672. pager.doc
  1673. pager.rno
  1674. ::::::::::
  1675. pager.doc
  1676. ::::::::::
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.                           PAGER, Version 1.6
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.               by Richard Conn, TI Ada Technology Branch
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.      PAGER is a tool for creating, extracting from, and scanning paged
  1710.  
  1711. files,  where  a  paged  file  is a file composed of one or more files
  1712.  
  1713. prefixed by banners.  PAGER is based in concept  on  the  UNPAGE  tool
  1714.  
  1715. submitted to the Ada Repository on SIMTEL20 by Mitre Corporation.
  1716.  
  1717.  
  1718.  
  1719.      Paged files are convenient mechanisms for storing related  files.
  1720.  
  1721. They  reduce  cluttering  in  the  directories  and  simplify the file
  1722.  
  1723. transfer process (to and from the  Ada  Repository,  for  example)  by
  1724.  
  1725. requiring  the  user  to transfer only one file in order to obtain all
  1726.  
  1727. files pertinent to a particular project or tool.  Additionally,  paged
  1728.  
  1729. files  are text files which can be handled more readily than the 8-bit
  1730.  
  1731. binary images associated with other file grouping mechanisms (see  the
  1732.  
  1733. file   LBR.DOC   in  the  directory  MICRO:<ADA.GENERAL>  in  the  Ada
  1734.  
  1735. Repository).  Paged files may be  manipulated  by  a  text  editor  if
  1736.  
  1737. necessary.
  1738.  
  1739.  
  1740.  
  1741.      For these reasons, paged files have been adopted  as  a  standard
  1742.  
  1743. for  file  storage in the Ada Repository.  The file type of SRC (as in
  1744.  
  1745. MYFILE.SRC) is designated to indicate that a file is paged.
  1746.  
  1747.  
  1748.  
  1749.      PAGER 1.5 is an operational improvement over PAGER 1.4.   It  has
  1750.  
  1751. been discovered that the limitation (range) of the type NATURAL cannot
  1752.  
  1753. be assumed to be "large" for all  Ada  compilers.   The  Telesoft  Ada
  1754.  
  1755. compiler, version 2.1, uses 16 bits for objects of type NATURAL.  This
  1756.  
  1757. proved to be restrictive.  Consequently, PAGER 1.5  provides  numerous
  1758.  
  1759. constraint error traps whenever counts are made.
  1760.  
  1761.                                                                 Page 2
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767. 1  PAGED FILE FORMAT
  1768.  
  1769.  
  1770.  
  1771.      A paged file is a file composed of one or more files prefixed  by
  1772.  
  1773. banners of the form
  1774.  
  1775.  
  1776.  
  1777.                 ::::::::::
  1778.  
  1779.                 filename
  1780.  
  1781.                 ::::::::::
  1782.  
  1783.  
  1784.  
  1785. or
  1786.  
  1787.  
  1788.  
  1789.                 --::::::::::
  1790.  
  1791.                 --filename
  1792.  
  1793.                 --::::::::::
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.      The first banner conforms to the PAGE standard employed on  UNIX.
  1800.  
  1801. The  second  banner is an adaptation of the first form which resembles
  1802.  
  1803. Ada comments.  The second banner is convenient  when  the  paged  file
  1804.  
  1805. contains  several  files  associated with a particular Ada program and
  1806.  
  1807. they are placed in the paged file in compilation order.  The resulting
  1808.  
  1809. paged file may then be compiled without being disassembled first.
  1810.  
  1811.  
  1812.  
  1813.      A paged file is of the following general form
  1814.  
  1815.  
  1816.  
  1817.         Section                         Example
  1818.  
  1819.         =======                         =======
  1820.  
  1821.                                         ::::::::::
  1822.  
  1823.         banner                          firstfile.txt
  1824.  
  1825.                                         ::::::::::
  1826.  
  1827.                                          body
  1828.  
  1829.         first file                        of
  1830.  
  1831.                                          first file
  1832.  
  1833.                                         ::::::::::
  1834.  
  1835.         banner                          secondfile.txt
  1836.  
  1837.                                         ::::::::::
  1838.  
  1839.                                          body
  1840.  
  1841.         second file                       of
  1842.  
  1843.                                          second file
  1844.  
  1845.  
  1846.  
  1847.                                                                 Page 3
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853. 2  FUNCTIONS OF PAGER
  1854.  
  1855.  
  1856.  
  1857.      PAGER performs the following functions:
  1858.  
  1859.  
  1860.  
  1861.       *  CHECK - Count the number of Ada statements, Ada comments, and
  1862.  
  1863.          text lines in the indicated file (the indicated file does not
  1864.  
  1865.          have to be a paged file); CHECK also computes a  checksum  of
  1866.  
  1867.          all the printable characters in this file
  1868.  
  1869.  
  1870.  
  1871.       *  LIST - Create  a  text  file  containing  the  names  of  the
  1872.  
  1873.          component  files  of  a  paged  file.  One name is stored per
  1874.  
  1875.          line, and each name is prefixed with  "$$  "  to  allow  easy
  1876.  
  1877.          editing  for inserting compile commands before the file names
  1878.  
  1879.          in the preparation of batch command files.
  1880.  
  1881.  
  1882.  
  1883.       *  PAGE - Create a paged file from one or more  existing  files;
  1884.  
  1885.          the  component  files  may  be  specified  individually or by
  1886.  
  1887.          include files
  1888.  
  1889.  
  1890.  
  1891.       *  SCAN - Perform a CHECK and then report on the name and number
  1892.  
  1893.          of  text  lines in each component file of the indicated paged
  1894.  
  1895.          file; if the file is not a paged file, SCAN presents the same
  1896.  
  1897.          information as CHECK
  1898.  
  1899.  
  1900.  
  1901.       *  TOGGLE - Display and toggle options
  1902.  
  1903.  
  1904.  
  1905.       *  UNPAGE - Extract the component files from the indicated paged
  1906.  
  1907.          file; the paged file is left intact
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.      There are several options available under  PAGER,  and  they  are
  1914.  
  1915. toggled and displayed by the TOGGLE command.  These options are:
  1916.  
  1917.  
  1918.  
  1919.       *  TOGGLE COMMENT - Select the comment banner
  1920.  
  1921.  
  1922.  
  1923.       *  TOGGLE INCLUDE - Place include files in paged files
  1924.  
  1925.  
  1926.  
  1927.       *  TOGGLE VERBOSE - Enable verbose mode
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933.      More discussion  of  these  options  will  be  presented  in  the
  1934.  
  1935. discussions of the functions of PAGER which follow.
  1936.  
  1937.  
  1938.  
  1939.      Only the first letter of each command and  each  option  for  the
  1940.  
  1941. TOGGLE  command  is  significant.   All  other letters in a command or
  1942.  
  1943. option  are  ignored.   Only  with  file  names  are  all  letters  of
  1944.  
  1945. significance.  Hence,
  1946.  
  1947.  
  1948.  
  1949.         PAGE filename
  1950.  
  1951. and
  1952.  
  1953.         P filename
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959. are equivalent, as are
  1960.  
  1961.  
  1962.  
  1963.                                                                 Page 4
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.         TOGGLE INCLUDE
  1972.  
  1973. and
  1974.  
  1975.         T I
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.      Any PAGER command beginning with a dash (-) is a comment line  to
  1982.  
  1983. PAGER and is not processed in any way.
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.  
  1990.  
  1991. 2.1  CHECK Function
  1992.  
  1993.  
  1994.  
  1995.      CHECK counts the number of Ada statements, Ada comments, and text
  1996.  
  1997. lines  in  the indicated file.  It also computes a checksum of all the
  1998.  
  1999. printable characters in this file.  The indicated file does  not  have
  2000.  
  2001. to be a paged file.  The syntax of the CHECK command is:
  2002.  
  2003.  
  2004.  
  2005.                 CHECK filename
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.      CHECK is useful in providing a validity check of a file transfer.
  2012.  
  2013. By running CHECK on a file residing on a source computer, transferring
  2014.  
  2015. the file from the source computer to a destination computer, and  then
  2016.  
  2017. running  CHECK  on  the file as transferred to a destination computer,
  2018.  
  2019. the user can verify the transfer.   If  the  checksums  match,  it  is
  2020.  
  2021. likely  that  the  transfer  was  successful.   Since  the checksum is
  2022.  
  2023. computed on the printable characters (which  do  not  include  spaces,
  2024.  
  2025. tabs,  carriage  returns,  or line feeds), this check does not reflect
  2026.  
  2027. any differences caused by tab expansion (expanding tab characters into
  2028.  
  2029. spaces) and the like which may be caused by the transfer mechanism.
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037. 2.2  HELP Function
  2038.  
  2039.  
  2040.  
  2041.      The HELP command displays a brief help text  to  the  user.   The
  2042.  
  2043. syntax of this command is:
  2044.  
  2045.  
  2046.  
  2047.                 HELP
  2048.  
  2049.  
  2050.  
  2051.                                                                 Page 5
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057. 2.3  LIST Function
  2058.  
  2059.  
  2060.  
  2061.      The LIST function is used to create a text  file  containing  the
  2062.  
  2063. names  of  the component files within a paged file.  The syntax of the
  2064.  
  2065. LIST command is:
  2066.  
  2067.  
  2068.  
  2069.                 LIST paged_file_name
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.      Upon execution, this command will prompt the user for the name of
  2076.  
  2077. the  output file.  If he strikes just the RETURN key, PAGER aborts the
  2078.  
  2079. LIST function and does not generate an output file.
  2080.  
  2081.  
  2082.  
  2083.      The output file has the following general format:
  2084.  
  2085.         $$ file_name_1
  2086.  
  2087.         $$ file_name_2
  2088.  
  2089.         ...
  2090.  
  2091.  
  2092.  
  2093.      A text editor can be used to make a global  substitution  of  the
  2094.  
  2095. "$$  "  characters.   For  instance, if the component files were to be
  2096.  
  2097. compiled in the order they were stored in the paged file, substituting
  2098.  
  2099. "$  ada  "  for  "$$  " in this listing file creates a DEC submit file
  2100.  
  2101. which compiles all files named.  Likewise, a substitution of "$  print
  2102.  
  2103. " would print all files named.
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111. 2.4  PAGE Function
  2112.  
  2113.  
  2114.  
  2115.      The PAGE function is used to created a paged  file  from  one  or
  2116.  
  2117. more component files.  The syntax of the PAGE command is:
  2118.  
  2119.  
  2120.  
  2121.                 PAGE filename
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.      When the PAGE command is issued, the user  is  prompted  for  the
  2128.  
  2129. name of a file.  He may then type the name of a component file, strike
  2130.  
  2131. return, and he will be prompted again.  This process  continues  until
  2132.  
  2133. the  user  strikes  only a return in response to the file name prompt.
  2134.  
  2135. At this point, PAGE will create the  paged  file  from  the  component
  2136.  
  2137. files named by the user.
  2138.  
  2139.  
  2140.  
  2141.      If the user prefixes the name of a component file with an  atsign
  2142.  
  2143. character (@), the indicated file is processed as an include file.  An
  2144.  
  2145. include file is a file which  contains  the  names  of  zero  or  more
  2146.  
  2147. component  files,  one  name  per  line  starting in the first column.
  2148.  
  2149. Other include files may  be  referenced  within  an  include  file  by
  2150.  
  2151. prefixing  their  names  with  the  atsign character.  Comments may be
  2152.  
  2153. placed within an include file by placing two dashes in the  first  two
  2154.  
  2155. columns of a line.  The following is an example of an include file:
  2156.  
  2157.                                                                 Page 6
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.          Example                      Comments
  2166.  
  2167.          =======                      ========
  2168.  
  2169. --
  2170.  
  2171. -- This is an include file for        Comment at the beginning
  2172.  
  2173. --  my favorite tool
  2174.  
  2175. --
  2176.  
  2177.                                       Blank lines are allowed
  2178.  
  2179. --
  2180.  
  2181. -- The following include file
  2182.  
  2183. --  contains the names of the         Another comment
  2184.  
  2185. --  Ada source files in compilation
  2186.  
  2187. --  order
  2188.  
  2189. --
  2190.  
  2191. @mytool.cmp
  2192.  
  2193. --
  2194.  
  2195. -- The following are the documentation
  2196.  
  2197. --  files
  2198.  
  2199. --
  2200.  
  2201. mytool.ref
  2202.  
  2203. mytool.doc
  2204.  
  2205. mytool.idx
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.      The following toggled options are applicable to the PAGE command:
  2212.  
  2213.  
  2214.  
  2215.       *  TOGGLE COMMENT - If the COMMENT option is ON, the Ada comment
  2216.  
  2217.          banner  (--::::::::::) is used; if the COMMENT option is OFF,
  2218.  
  2219.          the standard banner (::::::::::) is used.
  2220.  
  2221.  
  2222.  
  2223.       *  TOGGLE INCLUDE - If the INCLUDE option  is  ON,  any  include
  2224.  
  2225.          file  referenced  is  placed in the paged file as a component
  2226.  
  2227.          file; if the INCLUDE option is OFF,  include  files  are  not
  2228.  
  2229.          placed  in  the  paged  file  unless  explicitly  named.  For
  2230.  
  2231.          example, if @MYTOOL.DIS is specified with INCLUDE  off,  only
  2232.  
  2233.          the files named in MYTOOL.DIS are included; if INCLUDE is on,
  2234.  
  2235.          MYTOOL.DIS is included as well as the files named within it.
  2236.  
  2237.  
  2238.  
  2239.       *  TOGGLE  VERBOSE  -  If  the  VERBOSE  option  is   ON,   more
  2240.  
  2241.          information  is  displayed  during  the execution of the PAGE
  2242.  
  2243.          command; if the VERBOSE option is OFF,  less  information  is
  2244.  
  2245.          displayed
  2246.  
  2247.  
  2248.  
  2249.                                                                 Page 7
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255. 2.5  SCAN Function
  2256.  
  2257.  
  2258.  
  2259.      The SCAN function is similar to the CHECK function, but  it  also
  2260.  
  2261. lists  the  names and number of text lines in the component files in a
  2262.  
  2263. paged file.  If SCAN is run on a file which is not a paged  file,  the
  2264.  
  2265. output is identical to CHECK.  The syntax of SCAN is:
  2266.  
  2267.  
  2268.  
  2269.                 SCAN filename
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.      The VERBOSE toggle causes SCAN to present the count of text lines
  2276.  
  2277. to the user as well as the file names of the component files.
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285. 2.6  TOGGLE Function
  2286.  
  2287.  
  2288.  
  2289.      The TOGGLE command displays and toggles  the  options  of  PAGER.
  2290.  
  2291. TOGGLE  with  no  argument displays the options.  TOGGLE followed by a
  2292.  
  2293. valid option toggles the state (ON/OFF) of that option.
  2294.  
  2295.  
  2296.  
  2297.      The options to the TOGGLE command are:
  2298.  
  2299.  
  2300.  
  2301.       *  COMMENT - Comment banner (PAGE command only)
  2302.  
  2303.  
  2304.  
  2305.       *  INCLUDE - Include file (PAGE command only)
  2306.  
  2307.  
  2308.  
  2309.       *  VERBOSE - Verbose mode
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319. 2.7  UNPAGE Function
  2320.  
  2321.  
  2322.  
  2323.      The UNPAGE command extracts the  components  from  the  indicated
  2324.  
  2325. paged  file,  leaving  the  original paged file intact.  The syntax of
  2326.  
  2327. UNPAGE is:
  2328.  
  2329.  
  2330.  
  2331.                 UNPAGE filename
  2332.  
  2333.  
  2334.  
  2335.  
  2336.  
  2337.      The VERBOSE toggle causes UNPAGE to present  the  count  of  text
  2338.  
  2339. lines to the user as each component file is extracted.
  2340.  
  2341.                                                                 Page 8
  2342.  
  2343.  
  2344.  
  2345.  
  2346.  
  2347. 2.8  X Function
  2348.  
  2349.  
  2350.  
  2351.      The X command exits PAGER.  Its syntax is:
  2352.  
  2353.  
  2354.  
  2355.                 X
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365. 3  SAMPLE SESSION
  2366.  
  2367.  
  2368.  
  2369.      The following is a sample PAGER session.  It was  run  on  a  VAX
  2370.  
  2371. 11/785 running VMS 4.0.
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377. $ dir
  2378.  
  2379.  
  2380.  
  2381. Directory USER4:[CONN.ADA]
  2382.  
  2383.  
  2384.  
  2385. CAS3.ADA;1               15  (RWE,RWED,RE,RE)
  2386.  
  2387. CHARACTER_SET.ADA;1
  2388.  
  2389.                          21  (RWE,RWED,RE,RE)
  2390.  
  2391. LIB.DIR;1                 3  (RE,RWE,RE,RE)
  2392.  
  2393. PAGER.ADA;2              13  (RWE,RWED,RE,RE)
  2394.  
  2395. PAGER_COMPILE.DIS;1
  2396.  
  2397.                           1  (RWE,RWED,RE,RE)
  2398.  
  2399. PAGER_SUPPORT.ADA;1
  2400.  
  2401.                          47  (RWE,RWED,RE,RE)
  2402.  
  2403.  
  2404.  
  2405. Total of 6 files, 100 blocks.
  2406.  
  2407.  
  2408.  
  2409. $ type pager_compile.dis
  2410.  
  2411.  
  2412.  
  2413. --
  2414.  
  2415. -- Compilation order for all files required to create the
  2416.  
  2417. --  PAGER program
  2418.  
  2419. --
  2420.  
  2421. character_set.ada
  2422.  
  2423. cas3.ada
  2424.  
  2425. pager_support.ada
  2426.  
  2427. pager.ada
  2428.  
  2429.  
  2430.  
  2431. $ pager
  2432.  
  2433. PAGER, Version 1.6
  2434.  
  2435. Type HELP for Help
  2436.  
  2437. PAGER> h
  2438.  
  2439. PAGER Commands:
  2440.  
  2441.  CHECK filename  --  Ada Check on File
  2442.  
  2443.  LIST filename   --  List Names of Component Files
  2444.  
  2445.  PAGE filename   --  Create Paged File
  2446.  
  2447.  SCAN filename   --  List Files in Paged File
  2448.  
  2449.  TOGGLE          --  Indicate Flag Settings
  2450.  
  2451.  TOGGLE flag     --  Toggle Indicated Flag:
  2452.  
  2453.                      Comment, Include File, or
  2454.  
  2455.                      Verbose
  2456.  
  2457.                                                                 Page 9
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  UNPAGE filename --  Extract from Paged File
  2464.  
  2465.  X (Exit)        --  Exit PAGER
  2466.  
  2467. PAGER> t
  2468.  
  2469.   Comment Prefix is Disabled
  2470.  
  2471.   Include File Prefix is Enabled
  2472.  
  2473.   Verbose Mode is Enabled
  2474.  
  2475. PAGER> -- I will now create PAGER.SRC, which is
  2476.  
  2477. PAGER> -- composed of PAGER_SUPPORT.ADA and PAGER.ADA
  2478.  
  2479. PAGER> page pager.src
  2480.  
  2481. Enter Names of Files (RETURN when done)
  2482.  
  2483.   Input File Name > pager_support.ada
  2484.  
  2485.   Input File Name > pager.ada
  2486.  
  2487.   Input File Name > 
  2488.  
  2489.  
  2490.  
  2491.   Component Files --
  2492.  
  2493.     pager_support.ada
  2494.  
  2495.            714 Lines
  2496.  
  2497.     pager.ada
  2498.  
  2499.            150 Lines
  2500.  
  2501. PAGER> -- PAGER_FULL.SRC contains all files required to compile
  2502.  
  2503. PAGER> -- PAGER.ADA.  The file PAGER_COMPILE.DIS contains those
  2504.  
  2505. PAGER> -- file names in compilation order.
  2506.  
  2507. PAGER> toggle comment
  2508.  
  2509.   Comment Prefix is Enabled
  2510.  
  2511. PAGER> t
  2512.  
  2513.   Comment Prefix is Enabled
  2514.  
  2515.   Include File Prefix is Enabled
  2516.  
  2517.   Verbose Mode is Enabled
  2518.  
  2519. PAGER> page pager_full.src
  2520.  
  2521. Enter Names of Files (RETURN when done)
  2522.  
  2523.   Input File Name > @pager_compile.dis
  2524.  
  2525.     Include File: pager_compile.dis
  2526.  
  2527.       pager_compile.dis
  2528.  
  2529.       character_set.ada
  2530.  
  2531.       cas3.ada
  2532.  
  2533.       pager_support.ada
  2534.  
  2535.       pager.ada
  2536.  
  2537.     End of Include File pager_compile.dis
  2538.  
  2539.   Input File Name > 
  2540.  
  2541.  
  2542.  
  2543.   Component Files --
  2544.  
  2545.     pager_compile.dis
  2546.  
  2547.              8 Lines
  2548.  
  2549.     character_set.ada
  2550.  
  2551.            321 Lines
  2552.  
  2553.     cas3.ada
  2554.  
  2555.            194 Lines
  2556.  
  2557.     pager_support.ada
  2558.  
  2559.            714 Lines
  2560.  
  2561.     pager.ada
  2562.  
  2563.            150 Lines
  2564.  
  2565. PAGER> x
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571. $ cd upload r
  2572.  
  2573.                                                                Page 10
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.   USER4:[CONN.UPLOAD]
  2580.  
  2581. $ pager
  2582.  
  2583. PAGER, Version 1.6
  2584.  
  2585. Type HELP for Help
  2586.  
  2587. PAGER> -- Demo of CHECK
  2588.  
  2589. PAGER> check [conn.ada]pager_full.src
  2590.  
  2591. Input File: [conn.ada]pager_full.src
  2592.  
  2593.   Ada Statements:    628
  2594.  
  2595.   Ada Comments:      309
  2596.  
  2597.   Text Lines:       1402
  2598.  
  2599.   Checksum:           91
  2600.  
  2601. PAGER> -- Demo of SCAN
  2602.  
  2603. PAGER> scan [conn.ada]pager_full.src
  2604.  
  2605. Input File: [conn.ada]pager_full.src
  2606.  
  2607.   Ada Statements:    628
  2608.  
  2609.   Ada Comments:      309
  2610.  
  2611.   Text Lines:       1402
  2612.  
  2613.   Checksum:           91
  2614.  
  2615.   Component Files -- 
  2616.  
  2617.     pager_compile.dis
  2618.  
  2619.              8 Lines
  2620.  
  2621.     character_set.ada
  2622.  
  2623.            321 Lines
  2624.  
  2625.     cas3.ada
  2626.  
  2627.            194 Lines
  2628.  
  2629.     pager_support.ada
  2630.  
  2631.            714 Lines
  2632.  
  2633.     pager.ada
  2634.  
  2635.            150 Lines
  2636.  
  2637. PAGER> -- Demo of UNPAGE
  2638.  
  2639. PAGER> unpage [conn.ada]pager_full.src
  2640.  
  2641.      pager_compile.dis
  2642.  
  2643.              8 Lines
  2644.  
  2645.      character_set.ada
  2646.  
  2647.            321 Lines
  2648.  
  2649.      cas3.ada
  2650.  
  2651.            194 Lines
  2652.  
  2653.      pager_support.ada
  2654.  
  2655.            714 Lines
  2656.  
  2657.      pager.ada
  2658.  
  2659.            150 Lines
  2660.  
  2661. PAGER> -- Check/Scan on a "normal" file
  2662.  
  2663. PAGER> check pager_support.ada
  2664.  
  2665. Input File: pager_support.ada
  2666.  
  2667.   Ada Statements:    324
  2668.  
  2669.   Ada Comments:      172
  2670.  
  2671.   Text Lines:        714
  2672.  
  2673.   Checksum:           22
  2674.  
  2675. PAGER> scan pager_support.ada
  2676.  
  2677. Input File: pager_support.ada
  2678.  
  2679.   Ada Statements:    324
  2680.  
  2681.   Ada Comments:      172
  2682.  
  2683.   Text Lines:        714
  2684.  
  2685.   Checksum:           22
  2686.  
  2687. PAGER> check pager.ada
  2688.  
  2689.                                                                Page 11
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695. Input File: pager.ada
  2696.  
  2697.   Ada Statements:     74
  2698.  
  2699.   Ada Comments:        8
  2700.  
  2701.   Text Lines:        150
  2702.  
  2703.   Checksum:           61
  2704.  
  2705. PAGER> x
  2706.  
  2707. $
  2708.  
  2709.  
  2710.  
  2711. ::::::::::
  2712. pager.rno
  2713. ::::::::::
  2714. .figure 4
  2715. .CENTER;  PAGER, Version 1.6
  2716. .figure 2
  2717. .CENTER;  by Richard Conn, TI Ada Technology Branch
  2718. .figure 4
  2719.  
  2720. .ap
  2721.  
  2722.     PAGER is a tool for creating, extracting from, and scanning paged
  2723. files, where a paged file is a file composed of one or more files prefixed
  2724. by banners.  PAGER is based in concept
  2725. on the UNPAGE tool submitted to the Ada Repository
  2726. on SIMTEL20 by Mitre Corporation.
  2727.  
  2728.     Paged files are convenient mechanisms for storing related files.
  2729. They reduce cluttering in the directories and simplify the file transfer
  2730. process (to and from the Ada Repository, for example) by requiring the user
  2731. to transfer only one file in order to obtain all files pertinent to a
  2732. particular project or tool.  Additionally, paged files are text files
  2733. which can be handled more readily than the 8-bit binary images associated
  2734. with other file grouping mechanisms (see the file LBR.DOC in the
  2735. directory MICRO:<ADA.GENERAL> in the Ada Repository).
  2736. Paged files may be manipulated by a text editor if necessary.
  2737.  
  2738.     For these reasons, paged files have been adopted as a standard
  2739. for file storage in the Ada Repository.  The file type of SRC (as in
  2740. MYFILE.SRC) is designated to indicate that a file is paged.
  2741.  
  2742.     PAGER 1.5 is an operational improvement over PAGER 1.4.  It
  2743. has been discovered that the limitation (range) of the type NATURAL
  2744. cannot be assumed to be "large" for all Ada compilers.  The
  2745. Telesoft Ada compiler, version 2.1, uses 16 bits for objects of
  2746. type NATURAL.  This proved to be restrictive.  Consequently,
  2747. PAGER 1.5 provides numerous constraint error traps whenever
  2748. counts are made.
  2749.  
  2750. .tp 20
  2751. .HEADER LEVEL 1 Paged File Format
  2752.  
  2753.     A paged file is a file composed of one or more files prefixed by
  2754. banners of the form
  2755.  
  2756. .tp 15
  2757. .literal
  2758.  
  2759.         ::::::::::
  2760.         filename
  2761.         ::::::::::
  2762.  
  2763. or
  2764.  
  2765.         --::::::::::
  2766.         --filename
  2767.         --::::::::::
  2768.  
  2769. .end literal
  2770.  
  2771.     The first banner conforms to the PAGE standard employed on UNIX.
  2772. The second banner is an adaptation of the first form which resembles Ada
  2773. comments.  The second banner is convenient when the paged file contains
  2774. several files associated with a particular Ada program and they are placed
  2775. in the paged file in compilation order.  The resulting paged file may
  2776. then be compiled without being disassembled first.
  2777.  
  2778.     A paged file is of the following general form
  2779.  
  2780. .tp 20
  2781. .literal
  2782.  
  2783.         Section                         Example
  2784.         =======                         =======
  2785.                                         ::::::::::
  2786.         banner                          firstfile.txt
  2787.                                         ::::::::::
  2788.                                          body
  2789.         first file                        of
  2790.                                          first file
  2791.                                         ::::::::::
  2792.         banner                          secondfile.txt
  2793.                                         ::::::::::
  2794.                                          body
  2795.         second file                       of
  2796.                                          second file
  2797.  
  2798. .end literal
  2799.  
  2800. .tp 20
  2801. .HEADER LEVEL 1 Functions of PAGER
  2802.  
  2803.     PAGER performs the following functions:
  2804.  
  2805. .no autoparagraph
  2806. .list "*"
  2807. .LIST ELEMENT; CHECK - Count the number of Ada statements, Ada comments,
  2808. and text lines in the indicated file (the indicated file does not have to
  2809. be a paged file); CHECK also computes a checksum of all the printable
  2810. characters in this file
  2811. .LIST ELEMENT; LIST - Create a text file containing the names of the component
  2812. files of a paged file.  One name is stored per line, and each name is prefixed
  2813. with "$$ " to allow easy editing for inserting compile commands before the
  2814. file names in the preparation of batch command files.
  2815. .LIST ELEMENT; PAGE - Create a paged file from one or more existing files;
  2816. the component files may be specified individually or by include files
  2817. .LIST ELEMENT; SCAN - Perform a CHECK and then report on the name and
  2818. number of text lines in each component file of the indicated paged file;
  2819. if the file is not a paged file, SCAN presents the same information as CHECK
  2820. .LIST ELEMENT; TOGGLE - Display and toggle options
  2821. .LIST ELEMENT; UNPAGE - Extract the component files from the indicated
  2822. paged file; the paged file is left intact
  2823. .end list
  2824. .ap
  2825.  
  2826.     There are several options available under PAGER, and they are
  2827. toggled and displayed by the TOGGLE command.
  2828. These options are:
  2829.  
  2830. .tp 15
  2831. .no autoparagraph
  2832. .list "*"
  2833. .LIST ELEMENT; TOGGLE COMMENT - Select the comment banner
  2834. .LIST ELEMENT; TOGGLE INCLUDE - Place include files in paged files
  2835. .LIST ELEMENT; TOGGLE VERBOSE - Enable verbose mode
  2836. .end list
  2837. .ap
  2838.  
  2839.     More discussion of these options
  2840. will be presented in the discussions of the functions of PAGER which follow.
  2841.  
  2842.     Only the first letter of each command and each option for the TOGGLE
  2843. command is significant.  All other letters in a command or option are ignored.
  2844. Only with file names are all letters of significance.
  2845. Hence,
  2846.  
  2847. .literal
  2848.  
  2849.     PAGE filename
  2850. and
  2851.     P filename
  2852.  
  2853.  
  2854. are equivalent, as are
  2855.  
  2856.  
  2857.     TOGGLE INCLUDE
  2858. and
  2859.     T I
  2860.  
  2861. .end literal
  2862.  
  2863.     Any PAGER command beginning with a dash (_-) is a comment line
  2864. to PAGER and is not processed in any way.
  2865.  
  2866. .tp 10
  2867. .HEADER LEVEL 2 CHECK Function
  2868.  
  2869.     CHECK counts the number of Ada statements, Ada comments, and text
  2870. lines in the indicated file.  It also computes a checksum of all the printable
  2871. characters in this file.  The indicated file does not have to be a paged file.
  2872. The syntax of the CHECK command is:
  2873.  
  2874. .literal
  2875.  
  2876.         CHECK filename
  2877.  
  2878. .end literal
  2879.  
  2880.     CHECK is useful in providing a validity check of a file transfer.
  2881. By running CHECK on a file residing on a source computer, transferring the
  2882. file from the source computer to a destination computer, and then running
  2883. CHECK on the file as transferred to a destination computer, the user can
  2884. verify the transfer.  If the checksums match, it is likely that the
  2885. transfer was successful.  Since the checksum is computed on the printable
  2886. characters (which do not include spaces, tabs, carriage returns, or line
  2887. feeds), this check does not reflect any differences caused by tab expansion
  2888. (expanding tab characters into spaces) and the like which may be caused by
  2889. the transfer mechanism.
  2890.  
  2891. .tp 15
  2892. .HEADER LEVEL 2 HELP Function
  2893.  
  2894.     The HELP command displays a brief help text to the user.  The
  2895. syntax of this command is:
  2896.  
  2897. .literal
  2898.  
  2899.         HELP
  2900.  
  2901. .end literal
  2902.  
  2903. .tp 15
  2904. .HEADER LEVEL 2 LIST Function
  2905.  
  2906.     The LIST function is used to create a text file containing the
  2907. names of the component files within a paged file.  The syntax of the LIST
  2908. command is:
  2909.  
  2910. .literal
  2911.  
  2912.         LIST paged_file_name
  2913.  
  2914. .end literal
  2915.  
  2916.     Upon execution, this command will prompt the user for the name of
  2917. the output file.  If he strikes just the RETURN key, PAGER aborts the LIST
  2918. function and does not generate an output file.
  2919.     The output file has the following general format:
  2920.  
  2921. .literal
  2922.     $$ file_name_1
  2923.     $$ file_name_2
  2924.     ...
  2925. .end literal
  2926.  
  2927.     A text editor can be used to make a global substitution of the "$$ "
  2928. characters.  For instance, if the component files were to be compiled in
  2929. the order they were stored in the paged file, substituting "$ ada " for
  2930. "$$ " in this listing file creates a DEC submit file which compiles all
  2931. files named.  Likewise, a substitution of "$ print " would print all
  2932. files named.
  2933.  
  2934. .tp 15
  2935. .HEADER LEVEL 2 PAGE Function
  2936.  
  2937.     The PAGE function is used to created a paged file from one or
  2938. more component files.  The syntax of the PAGE command is:
  2939.  
  2940. .literal
  2941.  
  2942.         PAGE filename
  2943.  
  2944. .end literal
  2945.  
  2946.     When the PAGE command is issued, the user is prompted for the
  2947. name of a file.  He may then type the name of a component file, strike
  2948. return, and he will be prompted again.  This process continues until the
  2949. user strikes only a return in response to the file name prompt.  At this
  2950. point, PAGE will create the paged file from the component files named by
  2951. the user.
  2952.  
  2953.     If the user prefixes the name of a component file with an atsign
  2954. character (_@), the indicated file is processed as an include file.
  2955. An include file is a file which contains the names of zero or more component
  2956. files, one name per line starting in the first column.  Other
  2957. include files may be referenced within an include file by prefixing
  2958. their names with the atsign character.  Comments may be placed within
  2959. an include file by placing two dashes in the first two columns of a line.
  2960. The following is an example of an include file:
  2961.  
  2962. .tp 30
  2963. .literal
  2964.  
  2965.          Example                      Comments
  2966.          =======                      ========
  2967. --
  2968. -- This is an include file for        Comment at the beginning
  2969. --  my favorite tool
  2970. --
  2971.                                       Blank lines are allowed
  2972. --
  2973. -- The following include file
  2974. --  contains the names of the         Another comment
  2975. --  Ada source files in compilation
  2976. --  order
  2977. --
  2978. @mytool.cmp
  2979. --
  2980. -- The following are the documentation
  2981. --  files
  2982. --
  2983. mytool.ref
  2984. mytool.doc
  2985. mytool.idx
  2986.  
  2987. .end literal
  2988.  
  2989.     The following toggled options are applicable to the PAGE command:
  2990.  
  2991. .no autoparagraph
  2992. .list "*"
  2993. .LIST ELEMENT; TOGGLE COMMENT - If the COMMENT option is ON, the Ada
  2994. comment banner (--::::::::::) is used; if the COMMENT option is OFF, the
  2995. standard banner (::::::::::) is used.
  2996. .LIST ELEMENT; TOGGLE INCLUDE - If the INCLUDE option is ON, any include
  2997. file referenced is placed in the paged file as a component file; if the
  2998. INCLUDE option is OFF, include files are not placed in the paged file
  2999. unless explicitly named.  For example, if _@MYTOOL.DIS is specified with
  3000. INCLUDE off, only the files named in MYTOOL.DIS are included; if INCLUDE
  3001. is on, MYTOOL.DIS is included as well as the files named within it.
  3002. .LIST ELEMENT; TOGGLE VERBOSE - If the VERBOSE option is ON, more information
  3003. is displayed during the execution of the PAGE command; if the VERBOSE option
  3004. is OFF, less information is displayed
  3005. .end list
  3006. .ap
  3007.  
  3008. .tp 15
  3009. .HEADER LEVEL 2 SCAN Function
  3010.  
  3011.     The SCAN function is similar to the CHECK function, but it also
  3012. lists the names and number of text lines in
  3013. the component files in a paged file.  If SCAN is run on a file which is not
  3014. a paged file, the output is identical to CHECK.  The syntax of SCAN is:
  3015.  
  3016. .literal
  3017.  
  3018.         SCAN filename
  3019.  
  3020. .end literal
  3021.  
  3022.     The VERBOSE toggle causes SCAN to present the count of text lines
  3023. to the user as well as the file names of the component files.
  3024.  
  3025. .tp 15
  3026. .HEADER LEVEL 2 TOGGLE Function
  3027.  
  3028.     The TOGGLE command displays and toggles the options of PAGER.
  3029. TOGGLE with no argument displays the options.  TOGGLE followed by a
  3030. valid option toggles the state (ON/OFF) of that option.
  3031.  
  3032.     The options to the TOGGLE command are:
  3033.  
  3034. .no autoparagraph
  3035. .list "*"
  3036. .LIST ELEMENT; COMMENT - Comment banner (PAGE command only)
  3037. .LIST ELEMENT; INCLUDE - Include file (PAGE command only)
  3038. .LIST ELEMENT; VERBOSE - Verbose mode
  3039. .end list
  3040. .ap
  3041.  
  3042. .tp 15
  3043. .HEADER LEVEL 2 UNPAGE Function
  3044.  
  3045.     The UNPAGE command extracts the components from the indicated paged
  3046. file, leaving the original paged file intact.  The syntax of UNPAGE is:
  3047.  
  3048. .literal
  3049.  
  3050.         UNPAGE filename
  3051.  
  3052. .end literal
  3053.  
  3054.     The VERBOSE toggle causes UNPAGE to present the count of text lines
  3055. to the user as each component file is extracted.
  3056.  
  3057. .tp 15
  3058. .HEADER LEVEL 2 X Function
  3059.  
  3060.     The X command exits PAGER.  Its syntax is:
  3061.  
  3062. .literal
  3063.  
  3064.         X
  3065.  
  3066. .end literal
  3067.  
  3068.  
  3069. .tp 20
  3070. .HEADER LEVEL 1 Sample Session
  3071.  
  3072.     The following is a sample PAGER session.  It was run on a VAX 11/785
  3073. running VMS 4.0.
  3074.  
  3075. .literal
  3076.  
  3077.  
  3078. $ dir
  3079.  
  3080. Directory USER4:[CONN.ADA]
  3081.  
  3082. CAS3.ADA;1               15  (RWE,RWED,RE,RE)
  3083. CHARACTER_SET.ADA;1
  3084.                          21  (RWE,RWED,RE,RE)
  3085. LIB.DIR;1                 3  (RE,RWE,RE,RE)
  3086. PAGER.ADA;2              13  (RWE,RWED,RE,RE)
  3087. PAGER_COMPILE.DIS;1
  3088.                           1  (RWE,RWED,RE,RE)
  3089. PAGER_SUPPORT.ADA;1
  3090.                          47  (RWE,RWED,RE,RE)
  3091.  
  3092. Total of 6 files, 100 blocks.
  3093.  
  3094. $ type pager_compile.dis
  3095.  
  3096. --
  3097. -- Compilation order for all files required to create the
  3098. --  PAGER program
  3099. --
  3100. character_set.ada
  3101. cas3.ada
  3102. pager_support.ada
  3103. pager.ada
  3104.  
  3105. $ pager
  3106. PAGER, Version 1.6
  3107. Type HELP for Help
  3108. PAGER> h
  3109. PAGER Commands:
  3110.  CHECK filename  --  Ada Check on File
  3111.  LIST filename   --  List Names of Component Files
  3112.  PAGE filename   --  Create Paged File
  3113.  SCAN filename   --  List Files in Paged File
  3114.  TOGGLE          --  Indicate Flag Settings
  3115.  TOGGLE flag     --  Toggle Indicated Flag:
  3116.                      Comment, Include File, or
  3117.                      Verbose
  3118.  UNPAGE filename --  Extract from Paged File
  3119.  X (Exit)        --  Exit PAGER
  3120. PAGER> t
  3121.   Comment Prefix is Disabled
  3122.   Include File Prefix is Enabled
  3123.   Verbose Mode is Enabled
  3124. PAGER> -- I will now create PAGER.SRC, which is
  3125. PAGER> -- composed of PAGER_SUPPORT.ADA and PAGER.ADA
  3126. PAGER> page pager.src
  3127. Enter Names of Files (RETURN when done)
  3128.   Input File Name > pager_support.ada
  3129.   Input File Name > pager.ada
  3130.   Input File Name > 
  3131.  
  3132.   Component Files --
  3133.     pager_support.ada
  3134.            714 Lines
  3135.     pager.ada
  3136.            150 Lines
  3137. PAGER> -- PAGER_FULL.SRC contains all files required to compile
  3138. PAGER> -- PAGER.ADA.  The file PAGER_COMPILE.DIS contains those
  3139. PAGER> -- file names in compilation order.
  3140. PAGER> toggle comment
  3141.   Comment Prefix is Enabled
  3142. PAGER> t
  3143.   Comment Prefix is Enabled
  3144.   Include File Prefix is Enabled
  3145.   Verbose Mode is Enabled
  3146. PAGER> page pager_full.src
  3147. Enter Names of Files (RETURN when done)
  3148.   Input File Name > @pager_compile.dis
  3149.     Include File: pager_compile.dis
  3150.       pager_compile.dis
  3151.       character_set.ada
  3152.       cas3.ada
  3153.       pager_support.ada
  3154.       pager.ada
  3155.     End of Include File pager_compile.dis
  3156.   Input File Name > 
  3157.  
  3158.   Component Files --
  3159.     pager_compile.dis
  3160.              8 Lines
  3161.     character_set.ada
  3162.            321 Lines
  3163.     cas3.ada
  3164.            194 Lines
  3165.     pager_support.ada
  3166.            714 Lines
  3167.     pager.ada
  3168.            150 Lines
  3169. PAGER> x
  3170.  
  3171.  
  3172. $ cd upload r
  3173.   USER4:[CONN.UPLOAD]
  3174. $ pager
  3175. PAGER, Version 1.6
  3176. Type HELP for Help
  3177. PAGER> -- Demo of CHECK
  3178. PAGER> check [conn.ada]pager_full.src
  3179. Input File: [conn.ada]pager_full.src
  3180.   Ada Statements:    628
  3181.   Ada Comments:      309
  3182.   Text Lines:       1402
  3183.   Checksum:           91
  3184. PAGER> -- Demo of SCAN
  3185. PAGER> scan [conn.ada]pager_full.src
  3186. Input File: [conn.ada]pager_full.src
  3187.   Ada Statements:    628
  3188.   Ada Comments:      309
  3189.   Text Lines:       1402
  3190.   Checksum:           91
  3191.   Component Files -- 
  3192.     pager_compile.dis
  3193.              8 Lines
  3194.     character_set.ada
  3195.            321 Lines
  3196.     cas3.ada
  3197.            194 Lines
  3198.     pager_support.ada
  3199.            714 Lines
  3200.     pager.ada
  3201.            150 Lines
  3202. PAGER> -- Demo of UNPAGE
  3203. PAGER> unpage [conn.ada]pager_full.src
  3204.      pager_compile.dis
  3205.              8 Lines
  3206.      character_set.ada
  3207.            321 Lines
  3208.      cas3.ada
  3209.            194 Lines
  3210.      pager_support.ada
  3211.            714 Lines
  3212.      pager.ada
  3213.            150 Lines
  3214. PAGER> -- Check/Scan on a "normal" file
  3215. PAGER> check pager_support.ada
  3216. Input File: pager_support.ada
  3217.   Ada Statements:    324
  3218.   Ada Comments:      172
  3219.   Text Lines:        714
  3220.   Checksum:           22
  3221. PAGER> scan pager_support.ada
  3222. Input File: pager_support.ada
  3223.   Ada Statements:    324
  3224.   Ada Comments:      172
  3225.   Text Lines:        714
  3226.   Checksum:           22
  3227. PAGER> check pager.ada
  3228. Input File: pager.ada
  3229.   Ada Statements:     74
  3230.   Ada Comments:        8
  3231.   Text Lines:        150
  3232.   Checksum:           61
  3233. PAGER> x
  3234. $
  3235.  
  3236. .end literal
  3237.