1 |
294 |
jeremybenn |
-- CHECK_FILE.ADA
|
2 |
|
|
--
|
3 |
|
|
-- Grant of Unlimited Rights
|
4 |
|
|
--
|
5 |
|
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
6 |
|
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
7 |
|
|
-- unlimited rights in the software and documentation contained herein.
|
8 |
|
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
9 |
|
|
-- this public release, the Government intends to confer upon all
|
10 |
|
|
-- recipients unlimited rights equal to those held by the Government.
|
11 |
|
|
-- These rights include rights to use, duplicate, release or disclose the
|
12 |
|
|
-- released technical data and computer software in whole or in part, in
|
13 |
|
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
14 |
|
|
-- to do so.
|
15 |
|
|
--
|
16 |
|
|
-- DISCLAIMER
|
17 |
|
|
--
|
18 |
|
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
19 |
|
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
20 |
|
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
21 |
|
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
22 |
|
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
23 |
|
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
24 |
|
|
--*
|
25 |
|
|
--
|
26 |
|
|
-- THIS IS A PROCEDURE USED BY MANY OF THE CHAPTER 14 TESTS TO CHECK THE
|
27 |
|
|
-- CONTENTS OF A TEXT FILE.
|
28 |
|
|
|
29 |
|
|
-- THIS PROCEDURE ASSUMES THE FILE PARAMETER PASSED TO IT IS AN OPEN
|
30 |
|
|
-- TEXT FILE.
|
31 |
|
|
|
32 |
|
|
-- THE STRING PARAMETER CONTAINS THE CHARACTERS THAT ARE SUPPOSED TO BE
|
33 |
|
|
-- IN THE TEXT FILE. A '#' CHARACTER IS USED IN THE STRING TO DENOTE
|
34 |
|
|
-- THE END OF A LINE. A '@' CHARACTER IS USED TO DENOTE THE END OF A
|
35 |
|
|
-- PAGE. A '%' CHARACTER IS USED TO DENOTE THE END OF THE TEXT FILE.
|
36 |
|
|
-- THESE SYMBOLS SHOULD NOT BE USED AS TEXT OUTPUT.
|
37 |
|
|
|
38 |
|
|
-- SPS 11/30/82
|
39 |
|
|
-- JBG 2/3/83
|
40 |
|
|
|
41 |
|
|
WITH REPORT; USE REPORT;
|
42 |
|
|
WITH TEXT_IO; USE TEXT_IO;
|
43 |
|
|
|
44 |
|
|
PROCEDURE CHECK_FILE (FILE: IN OUT FILE_TYPE; CONTENTS : STRING) IS
|
45 |
|
|
|
46 |
|
|
X : CHARACTER;
|
47 |
|
|
COL_COUNT : POSITIVE_COUNT := 1;
|
48 |
|
|
LINE_COUNT : POSITIVE_COUNT := 1;
|
49 |
|
|
PAGE_COUNT : POSITIVE_COUNT := 1;
|
50 |
|
|
TRAILING_BLANKS_MSG_WRITTEN : BOOLEAN := FALSE;
|
51 |
|
|
STOP_PROCESSING : EXCEPTION;
|
52 |
|
|
|
53 |
|
|
PROCEDURE CHECK_END_OF_LINE (EXPECT_END_OF_PAGE : BOOLEAN) IS
|
54 |
|
|
BEGIN
|
55 |
|
|
|
56 |
|
|
-- SKIP OVER ANY TRAILING BLANKS. AN IMPLEMENTATION CAN LEGALLY
|
57 |
|
|
-- APPEND BLANKS TO THE END OF ANY LINE.
|
58 |
|
|
|
59 |
|
|
WHILE NOT END_OF_LINE (FILE) LOOP
|
60 |
|
|
GET (FILE, X);
|
61 |
|
|
IF X /= ' ' THEN
|
62 |
|
|
FAILED ("FROM CHECK_FILE: END OF LINE EXPECTED - " &
|
63 |
|
|
X & " ENCOUNTERED");
|
64 |
|
|
RAISE STOP_PROCESSING;
|
65 |
|
|
ELSE
|
66 |
|
|
IF NOT TRAILING_BLANKS_MSG_WRITTEN THEN
|
67 |
|
|
COMMENT ("FROM CHECK_FILE: " &
|
68 |
|
|
"THIS IMPLEMENTATION PADS " &
|
69 |
|
|
"LINES WITH BLANKS");
|
70 |
|
|
TRAILING_BLANKS_MSG_WRITTEN := TRUE;
|
71 |
|
|
END IF;
|
72 |
|
|
END IF;
|
73 |
|
|
END LOOP;
|
74 |
|
|
|
75 |
|
|
IF LINE_COUNT /= LINE (FILE) THEN
|
76 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
77 |
|
|
"LINE COUNT INCORRECT - EXPECTED " &
|
78 |
|
|
POSITIVE_COUNT'IMAGE(LINE_COUNT) &
|
79 |
|
|
" GOT FROM FILE " &
|
80 |
|
|
POSITIVE_COUNT'IMAGE(LINE(FILE)));
|
81 |
|
|
END IF;
|
82 |
|
|
|
83 |
|
|
-- NOTE: DO NOT SKIP_LINE WHEN AT END OF PAGE BECAUSE SKIP_LINE WILL
|
84 |
|
|
-- ALSO SKIP THE PAGE TERMINATOR. SEE RM 14.3.5 PARAGRAPH 1.
|
85 |
|
|
|
86 |
|
|
IF NOT EXPECT_END_OF_PAGE THEN
|
87 |
|
|
IF END_OF_PAGE (FILE) THEN
|
88 |
|
|
FAILED ("FROM CHECK_FILE: PREMATURE END OF PAGE");
|
89 |
|
|
RAISE STOP_PROCESSING;
|
90 |
|
|
ELSE
|
91 |
|
|
SKIP_LINE (FILE);
|
92 |
|
|
LINE_COUNT := LINE_COUNT + 1;
|
93 |
|
|
END IF;
|
94 |
|
|
END IF;
|
95 |
|
|
COL_COUNT := 1;
|
96 |
|
|
END CHECK_END_OF_LINE;
|
97 |
|
|
|
98 |
|
|
PROCEDURE CHECK_END_OF_PAGE IS
|
99 |
|
|
BEGIN
|
100 |
|
|
IF NOT END_OF_PAGE (FILE) THEN
|
101 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
102 |
|
|
"END_OF_PAGE NOT WHERE EXPECTED");
|
103 |
|
|
RAISE STOP_PROCESSING;
|
104 |
|
|
ELSE
|
105 |
|
|
IF PAGE_COUNT /= PAGE (FILE) THEN
|
106 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
107 |
|
|
"PAGE COUNT INCORRECT - EXPECTED " &
|
108 |
|
|
POSITIVE_COUNT'IMAGE (PAGE_COUNT) &
|
109 |
|
|
" GOT FROM FILE " &
|
110 |
|
|
POSITIVE_COUNT'IMAGE (PAGE(FILE)));
|
111 |
|
|
END IF;
|
112 |
|
|
|
113 |
|
|
SKIP_PAGE (FILE);
|
114 |
|
|
PAGE_COUNT := PAGE_COUNT + 1;
|
115 |
|
|
LINE_COUNT := 1;
|
116 |
|
|
END IF;
|
117 |
|
|
END CHECK_END_OF_PAGE;
|
118 |
|
|
|
119 |
|
|
BEGIN
|
120 |
|
|
|
121 |
|
|
RESET (FILE, IN_FILE);
|
122 |
|
|
SET_LINE_LENGTH (STANDARD_OUTPUT, 0);
|
123 |
|
|
SET_PAGE_LENGTH (STANDARD_OUTPUT, 0);
|
124 |
|
|
|
125 |
|
|
FOR I IN 1 .. CONTENTS'LENGTH LOOP
|
126 |
|
|
|
127 |
|
|
BEGIN
|
128 |
|
|
CASE CONTENTS (I) IS
|
129 |
|
|
WHEN '#' =>
|
130 |
|
|
CHECK_END_OF_LINE (CONTENTS (I + 1) = '@');
|
131 |
|
|
WHEN '@' =>
|
132 |
|
|
CHECK_END_OF_PAGE;
|
133 |
|
|
WHEN '%' =>
|
134 |
|
|
IF NOT END_OF_FILE (FILE) THEN
|
135 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
136 |
|
|
"END_OF_FILE NOT WHERE EXPECTED");
|
137 |
|
|
RAISE STOP_PROCESSING;
|
138 |
|
|
END IF;
|
139 |
|
|
WHEN OTHERS =>
|
140 |
|
|
IF COL_COUNT /= COL(FILE) THEN
|
141 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
142 |
|
|
"COL COUNT INCORRECT - " &
|
143 |
|
|
"EXPECTED " & POSITIVE_COUNT'
|
144 |
|
|
IMAGE(COL_COUNT) & " GOT FROM " &
|
145 |
|
|
"FILE " & POSITIVE_COUNT'IMAGE
|
146 |
|
|
(COL(FILE)));
|
147 |
|
|
END IF;
|
148 |
|
|
GET (FILE, X);
|
149 |
|
|
COL_COUNT := COL_COUNT + 1;
|
150 |
|
|
IF X /= CONTENTS (I) THEN
|
151 |
|
|
FAILED("FROM CHECK_FILE: " &
|
152 |
|
|
"FILE DOES NOT CONTAIN CORRECT " &
|
153 |
|
|
"OUTPUT - EXPECTED " & CONTENTS(I)
|
154 |
|
|
& " - GOT " & X);
|
155 |
|
|
RAISE STOP_PROCESSING;
|
156 |
|
|
END IF;
|
157 |
|
|
END CASE;
|
158 |
|
|
EXCEPTION
|
159 |
|
|
WHEN STOP_PROCESSING =>
|
160 |
|
|
COMMENT ("FROM CHECK_FILE: " &
|
161 |
|
|
"LAST CHARACTER IN FOLLOWING STRING " &
|
162 |
|
|
"REVEALED ERROR: " & CONTENTS (1 .. I));
|
163 |
|
|
EXIT;
|
164 |
|
|
END;
|
165 |
|
|
|
166 |
|
|
END LOOP;
|
167 |
|
|
|
168 |
|
|
EXCEPTION
|
169 |
|
|
WHEN STATUS_ERROR =>
|
170 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
171 |
|
|
"STATUS_ERROR RAISED - FILE CHECKING INCOMPLETE");
|
172 |
|
|
WHEN MODE_ERROR =>
|
173 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
174 |
|
|
"MODE_ERROR RAISED - FILE CHECKING INCOMPLETE");
|
175 |
|
|
WHEN NAME_ERROR =>
|
176 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
177 |
|
|
"NAME_ERROR RAISED - FILE CHECKING INCOMPLETE");
|
178 |
|
|
WHEN USE_ERROR =>
|
179 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
180 |
|
|
"USE_ERROR RAISED - FILE CHECKING INCOMPLETE");
|
181 |
|
|
WHEN DEVICE_ERROR =>
|
182 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
183 |
|
|
"DEVICE_ERROR RAISED - FILE CHECKING INCOMPLETE");
|
184 |
|
|
WHEN END_ERROR =>
|
185 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
186 |
|
|
"END_ERROR RAISED - FILE CHECKING INCOMPLETE");
|
187 |
|
|
WHEN DATA_ERROR =>
|
188 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
189 |
|
|
"DATA_ERROR RAISED - FILE CHECKING INCOMPLETE");
|
190 |
|
|
WHEN LAYOUT_ERROR =>
|
191 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
192 |
|
|
"LAYOUT_ERROR RAISED - FILE CHECKING INCOMPLETE");
|
193 |
|
|
WHEN OTHERS =>
|
194 |
|
|
FAILED ("FROM CHECK_FILE: " &
|
195 |
|
|
"SOME EXCEPTION RAISED - FILE CHECKING INCOMPLETE");
|
196 |
|
|
|
197 |
|
|
END CHECK_FILE;
|