prutils.c revision 1.3.6.2 1 1.3.6.2 yamt /******************************************************************************
2 1.3.6.2 yamt *
3 1.3.6.2 yamt * Module Name: prutils - Preprocessor utilities
4 1.3.6.2 yamt *
5 1.3.6.2 yamt *****************************************************************************/
6 1.3.6.2 yamt
7 1.3.6.2 yamt /*
8 1.3.6.2 yamt * Copyright (C) 2000 - 2013, Intel Corp.
9 1.3.6.2 yamt * All rights reserved.
10 1.3.6.2 yamt *
11 1.3.6.2 yamt * Redistribution and use in source and binary forms, with or without
12 1.3.6.2 yamt * modification, are permitted provided that the following conditions
13 1.3.6.2 yamt * are met:
14 1.3.6.2 yamt * 1. Redistributions of source code must retain the above copyright
15 1.3.6.2 yamt * notice, this list of conditions, and the following disclaimer,
16 1.3.6.2 yamt * without modification.
17 1.3.6.2 yamt * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.3.6.2 yamt * substantially similar to the "NO WARRANTY" disclaimer below
19 1.3.6.2 yamt * ("Disclaimer") and any redistribution must be conditioned upon
20 1.3.6.2 yamt * including a substantially similar Disclaimer requirement for further
21 1.3.6.2 yamt * binary redistribution.
22 1.3.6.2 yamt * 3. Neither the names of the above-listed copyright holders nor the names
23 1.3.6.2 yamt * of any contributors may be used to endorse or promote products derived
24 1.3.6.2 yamt * from this software without specific prior written permission.
25 1.3.6.2 yamt *
26 1.3.6.2 yamt * Alternatively, this software may be distributed under the terms of the
27 1.3.6.2 yamt * GNU General Public License ("GPL") version 2 as published by the Free
28 1.3.6.2 yamt * Software Foundation.
29 1.3.6.2 yamt *
30 1.3.6.2 yamt * NO WARRANTY
31 1.3.6.2 yamt * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.3.6.2 yamt * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.3.6.2 yamt * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.3.6.2 yamt * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.3.6.2 yamt * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.3.6.2 yamt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.3.6.2 yamt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.3.6.2 yamt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.3.6.2 yamt * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.3.6.2 yamt * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.3.6.2 yamt * POSSIBILITY OF SUCH DAMAGES.
42 1.3.6.2 yamt */
43 1.3.6.2 yamt
44 1.3.6.2 yamt #include "aslcompiler.h"
45 1.3.6.2 yamt #include "dtcompiler.h"
46 1.3.6.2 yamt
47 1.3.6.2 yamt
48 1.3.6.2 yamt #define _COMPONENT ASL_PREPROCESSOR
49 1.3.6.2 yamt ACPI_MODULE_NAME ("prutils")
50 1.3.6.2 yamt
51 1.3.6.2 yamt
52 1.3.6.2 yamt /******************************************************************************
53 1.3.6.2 yamt *
54 1.3.6.2 yamt * FUNCTION: PrGetNextToken
55 1.3.6.2 yamt *
56 1.3.6.2 yamt * PARAMETERS: Buffer - Current line buffer
57 1.3.6.2 yamt * MatchString - String with valid token delimiters
58 1.3.6.2 yamt * Next - Set to next possible token in buffer
59 1.3.6.2 yamt *
60 1.3.6.2 yamt * RETURN: Next token (null-terminated). Modifies the input line.
61 1.3.6.2 yamt * Remainder of line is stored in *Next.
62 1.3.6.2 yamt *
63 1.3.6.2 yamt * DESCRIPTION: Local implementation of strtok() with local storage for the
64 1.3.6.2 yamt * next pointer. Not only thread-safe, but allows multiple
65 1.3.6.2 yamt * parsing of substrings such as expressions.
66 1.3.6.2 yamt *
67 1.3.6.2 yamt *****************************************************************************/
68 1.3.6.2 yamt
69 1.3.6.2 yamt char *
70 1.3.6.2 yamt PrGetNextToken (
71 1.3.6.2 yamt char *Buffer,
72 1.3.6.2 yamt char *MatchString,
73 1.3.6.2 yamt char **Next)
74 1.3.6.2 yamt {
75 1.3.6.2 yamt char *TokenStart;
76 1.3.6.2 yamt
77 1.3.6.2 yamt
78 1.3.6.2 yamt if (!Buffer)
79 1.3.6.2 yamt {
80 1.3.6.2 yamt /* Use Next if it is valid */
81 1.3.6.2 yamt
82 1.3.6.2 yamt Buffer = *Next;
83 1.3.6.2 yamt if (!(*Next))
84 1.3.6.2 yamt {
85 1.3.6.2 yamt return (NULL);
86 1.3.6.2 yamt }
87 1.3.6.2 yamt }
88 1.3.6.2 yamt
89 1.3.6.2 yamt /* Skip any leading delimiters */
90 1.3.6.2 yamt
91 1.3.6.2 yamt while (*Buffer)
92 1.3.6.2 yamt {
93 1.3.6.2 yamt if (strchr (MatchString, *Buffer))
94 1.3.6.2 yamt {
95 1.3.6.2 yamt Buffer++;
96 1.3.6.2 yamt }
97 1.3.6.2 yamt else
98 1.3.6.2 yamt {
99 1.3.6.2 yamt break;
100 1.3.6.2 yamt }
101 1.3.6.2 yamt }
102 1.3.6.2 yamt
103 1.3.6.2 yamt /* Anything left on the line? */
104 1.3.6.2 yamt
105 1.3.6.2 yamt if (!(*Buffer))
106 1.3.6.2 yamt {
107 1.3.6.2 yamt *Next = NULL;
108 1.3.6.2 yamt return (NULL);
109 1.3.6.2 yamt }
110 1.3.6.2 yamt
111 1.3.6.2 yamt TokenStart = Buffer;
112 1.3.6.2 yamt
113 1.3.6.2 yamt /* Find the end of this token */
114 1.3.6.2 yamt
115 1.3.6.2 yamt while (*Buffer)
116 1.3.6.2 yamt {
117 1.3.6.2 yamt if (strchr (MatchString, *Buffer))
118 1.3.6.2 yamt {
119 1.3.6.2 yamt *Buffer = 0;
120 1.3.6.2 yamt *Next = Buffer+1;
121 1.3.6.2 yamt if (!**Next)
122 1.3.6.2 yamt {
123 1.3.6.2 yamt *Next = NULL;
124 1.3.6.2 yamt }
125 1.3.6.2 yamt return (TokenStart);
126 1.3.6.2 yamt }
127 1.3.6.2 yamt Buffer++;
128 1.3.6.2 yamt }
129 1.3.6.2 yamt
130 1.3.6.2 yamt *Next = NULL;
131 1.3.6.2 yamt return (TokenStart);
132 1.3.6.2 yamt }
133 1.3.6.2 yamt
134 1.3.6.2 yamt
135 1.3.6.2 yamt /*******************************************************************************
136 1.3.6.2 yamt *
137 1.3.6.2 yamt * FUNCTION: PrError
138 1.3.6.2 yamt *
139 1.3.6.2 yamt * PARAMETERS: Level - Seriousness (Warning/error, etc.)
140 1.3.6.2 yamt * MessageId - Index into global message buffer
141 1.3.6.2 yamt * Column - Column in current line
142 1.3.6.2 yamt *
143 1.3.6.2 yamt * RETURN: None
144 1.3.6.2 yamt *
145 1.3.6.2 yamt * DESCRIPTION: Preprocessor error reporting. Front end to AslCommonError2
146 1.3.6.2 yamt *
147 1.3.6.2 yamt ******************************************************************************/
148 1.3.6.2 yamt
149 1.3.6.2 yamt void
150 1.3.6.2 yamt PrError (
151 1.3.6.2 yamt UINT8 Level,
152 1.3.6.2 yamt UINT8 MessageId,
153 1.3.6.2 yamt UINT32 Column)
154 1.3.6.2 yamt {
155 1.3.6.2 yamt #if 0
156 1.3.6.2 yamt AcpiOsPrintf ("%s (%u) : %s", Gbl_Files[ASL_FILE_INPUT].Filename,
157 1.3.6.2 yamt Gbl_CurrentLineNumber, Gbl_CurrentLineBuffer);
158 1.3.6.2 yamt #endif
159 1.3.6.2 yamt
160 1.3.6.2 yamt
161 1.3.6.2 yamt if (Column > 120)
162 1.3.6.2 yamt {
163 1.3.6.2 yamt Column = 0;
164 1.3.6.2 yamt }
165 1.3.6.2 yamt
166 1.3.6.2 yamt /* TBD: Need Logical line number? */
167 1.3.6.2 yamt
168 1.3.6.2 yamt AslCommonError2 (Level, MessageId,
169 1.3.6.2 yamt Gbl_CurrentLineNumber, Column,
170 1.3.6.2 yamt Gbl_CurrentLineBuffer,
171 1.3.6.2 yamt Gbl_Files[ASL_FILE_INPUT].Filename, "Preprocessor");
172 1.3.6.2 yamt
173 1.3.6.2 yamt Gbl_PreprocessorError = TRUE;
174 1.3.6.2 yamt }
175 1.3.6.2 yamt
176 1.3.6.2 yamt
177 1.3.6.2 yamt /*******************************************************************************
178 1.3.6.2 yamt *
179 1.3.6.2 yamt * FUNCTION: PrReplaceData
180 1.3.6.2 yamt *
181 1.3.6.2 yamt * PARAMETERS: Buffer - Original(target) buffer pointer
182 1.3.6.2 yamt * LengthToRemove - Length to be removed from target buffer
183 1.3.6.2 yamt * BufferToAdd - Data to be inserted into target buffer
184 1.3.6.2 yamt * LengthToAdd - Length of BufferToAdd
185 1.3.6.2 yamt *
186 1.3.6.2 yamt * RETURN: None
187 1.3.6.2 yamt *
188 1.3.6.2 yamt * DESCRIPTION: Generic buffer data replacement.
189 1.3.6.2 yamt *
190 1.3.6.2 yamt ******************************************************************************/
191 1.3.6.2 yamt
192 1.3.6.2 yamt void
193 1.3.6.2 yamt PrReplaceData (
194 1.3.6.2 yamt char *Buffer,
195 1.3.6.2 yamt UINT32 LengthToRemove,
196 1.3.6.2 yamt char *BufferToAdd,
197 1.3.6.2 yamt UINT32 LengthToAdd)
198 1.3.6.2 yamt {
199 1.3.6.2 yamt UINT32 BufferLength;
200 1.3.6.2 yamt
201 1.3.6.2 yamt
202 1.3.6.2 yamt /* Buffer is a string, so the length must include the terminating zero */
203 1.3.6.2 yamt
204 1.3.6.2 yamt BufferLength = strlen (Buffer) + 1;
205 1.3.6.2 yamt
206 1.3.6.2 yamt if (LengthToRemove != LengthToAdd)
207 1.3.6.2 yamt {
208 1.3.6.2 yamt /*
209 1.3.6.2 yamt * Move some of the existing data
210 1.3.6.2 yamt * 1) If adding more bytes than removing, make room for the new data
211 1.3.6.2 yamt * 2) if removing more bytes than adding, delete the extra space
212 1.3.6.2 yamt */
213 1.3.6.2 yamt if (LengthToRemove > 0)
214 1.3.6.2 yamt {
215 1.3.6.2 yamt memmove ((Buffer + LengthToAdd), (Buffer + LengthToRemove),
216 1.3.6.2 yamt (BufferLength - LengthToRemove));
217 1.3.6.2 yamt }
218 1.3.6.2 yamt }
219 1.3.6.2 yamt
220 1.3.6.2 yamt /* Now we can move in the new data */
221 1.3.6.2 yamt
222 1.3.6.2 yamt if (LengthToAdd > 0)
223 1.3.6.2 yamt {
224 1.3.6.2 yamt memmove (Buffer, BufferToAdd, LengthToAdd);
225 1.3.6.2 yamt }
226 1.3.6.2 yamt }
227 1.3.6.2 yamt
228 1.3.6.2 yamt
229 1.3.6.2 yamt /*******************************************************************************
230 1.3.6.2 yamt *
231 1.3.6.2 yamt * FUNCTION: PrOpenIncludeFile
232 1.3.6.2 yamt *
233 1.3.6.2 yamt * PARAMETERS: Filename - Filename or pathname for include file
234 1.3.6.2 yamt *
235 1.3.6.2 yamt * RETURN: None.
236 1.3.6.2 yamt *
237 1.3.6.2 yamt * DESCRIPTION: Open an include file and push it on the input file stack.
238 1.3.6.2 yamt *
239 1.3.6.2 yamt ******************************************************************************/
240 1.3.6.2 yamt
241 1.3.6.2 yamt void
242 1.3.6.2 yamt PrOpenIncludeFile (
243 1.3.6.2 yamt char *Filename)
244 1.3.6.2 yamt {
245 1.3.6.2 yamt FILE *IncludeFile;
246 1.3.6.2 yamt ASL_INCLUDE_DIR *NextDir;
247 1.3.6.2 yamt
248 1.3.6.2 yamt
249 1.3.6.2 yamt /* Start the actual include file on the next line */
250 1.3.6.2 yamt
251 1.3.6.2 yamt Gbl_CurrentLineOffset++;
252 1.3.6.2 yamt
253 1.3.6.2 yamt /* Attempt to open the include file */
254 1.3.6.2 yamt /* If the file specifies an absolute path, just open it */
255 1.3.6.2 yamt
256 1.3.6.2 yamt if ((Filename[0] == '/') ||
257 1.3.6.2 yamt (Filename[0] == '\\') ||
258 1.3.6.2 yamt (Filename[1] == ':'))
259 1.3.6.2 yamt {
260 1.3.6.2 yamt IncludeFile = PrOpenIncludeWithPrefix ("", Filename);
261 1.3.6.2 yamt if (!IncludeFile)
262 1.3.6.2 yamt {
263 1.3.6.2 yamt goto ErrorExit;
264 1.3.6.2 yamt }
265 1.3.6.2 yamt return;
266 1.3.6.2 yamt }
267 1.3.6.2 yamt
268 1.3.6.2 yamt /*
269 1.3.6.2 yamt * The include filename is not an absolute path.
270 1.3.6.2 yamt *
271 1.3.6.2 yamt * First, search for the file within the "local" directory -- meaning
272 1.3.6.2 yamt * the same directory that contains the source file.
273 1.3.6.2 yamt *
274 1.3.6.2 yamt * Construct the file pathname from the global directory name.
275 1.3.6.2 yamt */
276 1.3.6.2 yamt IncludeFile = PrOpenIncludeWithPrefix (Gbl_DirectoryPath, Filename);
277 1.3.6.2 yamt if (IncludeFile)
278 1.3.6.2 yamt {
279 1.3.6.2 yamt return;
280 1.3.6.2 yamt }
281 1.3.6.2 yamt
282 1.3.6.2 yamt /*
283 1.3.6.2 yamt * Second, search for the file within the (possibly multiple)
284 1.3.6.2 yamt * directories specified by the -I option on the command line.
285 1.3.6.2 yamt */
286 1.3.6.2 yamt NextDir = Gbl_IncludeDirList;
287 1.3.6.2 yamt while (NextDir)
288 1.3.6.2 yamt {
289 1.3.6.2 yamt IncludeFile = PrOpenIncludeWithPrefix (NextDir->Dir, Filename);
290 1.3.6.2 yamt if (IncludeFile)
291 1.3.6.2 yamt {
292 1.3.6.2 yamt return;
293 1.3.6.2 yamt }
294 1.3.6.2 yamt
295 1.3.6.2 yamt NextDir = NextDir->Next;
296 1.3.6.2 yamt }
297 1.3.6.2 yamt
298 1.3.6.2 yamt /* We could not open the include file after trying very hard */
299 1.3.6.2 yamt
300 1.3.6.2 yamt ErrorExit:
301 1.3.6.2 yamt snprintf (Gbl_MainTokenBuffer, ASL_DEFAULT_LINE_BUFFER_SIZE, "%s, %s",
302 1.3.6.2 yamt Filename, strerror (errno));
303 1.3.6.2 yamt PrError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, 0);
304 1.3.6.2 yamt }
305 1.3.6.2 yamt
306 1.3.6.2 yamt
307 1.3.6.2 yamt /*******************************************************************************
308 1.3.6.2 yamt *
309 1.3.6.2 yamt * FUNCTION: FlOpenIncludeWithPrefix
310 1.3.6.2 yamt *
311 1.3.6.2 yamt * PARAMETERS: PrefixDir - Prefix directory pathname. Can be a zero
312 1.3.6.2 yamt * length string.
313 1.3.6.2 yamt * Filename - The include filename from the source ASL.
314 1.3.6.2 yamt *
315 1.3.6.2 yamt * RETURN: Valid file descriptor if successful. Null otherwise.
316 1.3.6.2 yamt *
317 1.3.6.2 yamt * DESCRIPTION: Open an include file and push it on the input file stack.
318 1.3.6.2 yamt *
319 1.3.6.2 yamt ******************************************************************************/
320 1.3.6.2 yamt
321 1.3.6.2 yamt FILE *
322 1.3.6.2 yamt PrOpenIncludeWithPrefix (
323 1.3.6.2 yamt char *PrefixDir,
324 1.3.6.2 yamt char *Filename)
325 1.3.6.2 yamt {
326 1.3.6.2 yamt FILE *IncludeFile;
327 1.3.6.2 yamt char *Pathname;
328 1.3.6.2 yamt
329 1.3.6.2 yamt
330 1.3.6.2 yamt /* Build the full pathname to the file */
331 1.3.6.2 yamt
332 1.3.6.2 yamt Pathname = FlMergePathnames (PrefixDir, Filename);
333 1.3.6.2 yamt
334 1.3.6.2 yamt DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
335 1.3.6.2 yamt "Include: Opening file - \"%s\"\n",
336 1.3.6.2 yamt Gbl_CurrentLineNumber, Pathname);
337 1.3.6.2 yamt
338 1.3.6.2 yamt /* Attempt to open the file, push if successful */
339 1.3.6.2 yamt
340 1.3.6.2 yamt IncludeFile = fopen (Pathname, "r");
341 1.3.6.2 yamt if (!IncludeFile)
342 1.3.6.2 yamt {
343 1.3.6.2 yamt fprintf (stderr, "Could not open include file %s\n", Pathname);
344 1.3.6.2 yamt ACPI_FREE (Pathname);
345 1.3.6.2 yamt return (NULL);
346 1.3.6.2 yamt }
347 1.3.6.2 yamt
348 1.3.6.2 yamt /* Push the include file on the open input file stack */
349 1.3.6.2 yamt
350 1.3.6.2 yamt PrPushInputFileStack (IncludeFile, Pathname);
351 1.3.6.2 yamt return (IncludeFile);
352 1.3.6.2 yamt }
353 1.3.6.2 yamt
354 1.3.6.2 yamt
355 1.3.6.2 yamt /*******************************************************************************
356 1.3.6.2 yamt *
357 1.3.6.2 yamt * FUNCTION: AslPushInputFileStack
358 1.3.6.2 yamt *
359 1.3.6.2 yamt * PARAMETERS: InputFile - Open file pointer
360 1.3.6.2 yamt * Filename - Name of the file
361 1.3.6.2 yamt *
362 1.3.6.2 yamt * RETURN: None
363 1.3.6.2 yamt *
364 1.3.6.2 yamt * DESCRIPTION: Push the InputFile onto the file stack, and point the parser
365 1.3.6.2 yamt * to this file. Called when an include file is successfully
366 1.3.6.2 yamt * opened.
367 1.3.6.2 yamt *
368 1.3.6.2 yamt ******************************************************************************/
369 1.3.6.2 yamt
370 1.3.6.2 yamt void
371 1.3.6.2 yamt PrPushInputFileStack (
372 1.3.6.2 yamt FILE *InputFile,
373 1.3.6.2 yamt char *Filename)
374 1.3.6.2 yamt {
375 1.3.6.2 yamt PR_FILE_NODE *Fnode;
376 1.3.6.2 yamt
377 1.3.6.2 yamt
378 1.3.6.2 yamt /* Save the current state in an Fnode */
379 1.3.6.2 yamt
380 1.3.6.2 yamt Fnode = UtLocalCalloc (sizeof (PR_FILE_NODE));
381 1.3.6.2 yamt
382 1.3.6.2 yamt Fnode->File = Gbl_Files[ASL_FILE_INPUT].Handle;
383 1.3.6.2 yamt Fnode->Next = Gbl_InputFileList;
384 1.3.6.2 yamt Fnode->Filename = Gbl_Files[ASL_FILE_INPUT].Filename;
385 1.3.6.2 yamt Fnode->CurrentLineNumber = Gbl_CurrentLineNumber;
386 1.3.6.2 yamt
387 1.3.6.2 yamt /* Push it on the stack */
388 1.3.6.2 yamt
389 1.3.6.2 yamt Gbl_InputFileList = Fnode;
390 1.3.6.2 yamt
391 1.3.6.2 yamt DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
392 1.3.6.2 yamt "Push InputFile Stack: handle %p\n\n",
393 1.3.6.2 yamt Gbl_CurrentLineNumber, InputFile);
394 1.3.6.2 yamt
395 1.3.6.2 yamt /* Reset the global line count and filename */
396 1.3.6.2 yamt
397 1.3.6.2 yamt Gbl_Files[ASL_FILE_INPUT].Filename = Filename;
398 1.3.6.2 yamt Gbl_Files[ASL_FILE_INPUT].Handle = InputFile;
399 1.3.6.2 yamt Gbl_PreviousLineNumber = 0;
400 1.3.6.2 yamt Gbl_CurrentLineNumber = 0;
401 1.3.6.2 yamt
402 1.3.6.2 yamt /* Emit a new #line directive for the include file */
403 1.3.6.2 yamt
404 1.3.6.2 yamt FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n",
405 1.3.6.2 yamt 1, Filename);
406 1.3.6.2 yamt }
407 1.3.6.2 yamt
408 1.3.6.2 yamt
409 1.3.6.2 yamt /*******************************************************************************
410 1.3.6.2 yamt *
411 1.3.6.2 yamt * FUNCTION: AslPopInputFileStack
412 1.3.6.2 yamt *
413 1.3.6.2 yamt * PARAMETERS: None
414 1.3.6.2 yamt *
415 1.3.6.2 yamt * RETURN: 0 if a node was popped, -1 otherwise
416 1.3.6.2 yamt *
417 1.3.6.2 yamt * DESCRIPTION: Pop the top of the input file stack and point the parser to
418 1.3.6.2 yamt * the saved parse buffer contained in the fnode. Also, set the
419 1.3.6.2 yamt * global line counters to the saved values. This function is
420 1.3.6.2 yamt * called when an include file reaches EOF.
421 1.3.6.2 yamt *
422 1.3.6.2 yamt ******************************************************************************/
423 1.3.6.2 yamt
424 1.3.6.2 yamt BOOLEAN
425 1.3.6.2 yamt PrPopInputFileStack (
426 1.3.6.2 yamt void)
427 1.3.6.2 yamt {
428 1.3.6.2 yamt PR_FILE_NODE *Fnode;
429 1.3.6.2 yamt
430 1.3.6.2 yamt
431 1.3.6.2 yamt Fnode = Gbl_InputFileList;
432 1.3.6.2 yamt DbgPrint (ASL_PARSE_OUTPUT, "\n" PR_PREFIX_ID
433 1.3.6.2 yamt "Pop InputFile Stack, Fnode %p\n\n",
434 1.3.6.2 yamt Gbl_CurrentLineNumber, Fnode);
435 1.3.6.2 yamt
436 1.3.6.2 yamt if (!Fnode)
437 1.3.6.2 yamt {
438 1.3.6.2 yamt return (FALSE);
439 1.3.6.2 yamt }
440 1.3.6.2 yamt
441 1.3.6.2 yamt /* Close the current include file */
442 1.3.6.2 yamt
443 1.3.6.2 yamt fclose (Gbl_Files[ASL_FILE_INPUT].Handle);
444 1.3.6.2 yamt
445 1.3.6.2 yamt /* Update the top-of-stack */
446 1.3.6.2 yamt
447 1.3.6.2 yamt Gbl_InputFileList = Fnode->Next;
448 1.3.6.2 yamt
449 1.3.6.2 yamt /* Reset global line counter and filename */
450 1.3.6.2 yamt
451 1.3.6.2 yamt Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename;
452 1.3.6.2 yamt Gbl_Files[ASL_FILE_INPUT].Handle = Fnode->File;
453 1.3.6.2 yamt Gbl_CurrentLineNumber = Fnode->CurrentLineNumber;
454 1.3.6.2 yamt Gbl_PreviousLineNumber = 0;
455 1.3.6.2 yamt
456 1.3.6.2 yamt /* Emit a new #line directive after the include file */
457 1.3.6.2 yamt
458 1.3.6.2 yamt FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n",
459 1.3.6.2 yamt Gbl_CurrentLineNumber + 1, Fnode->Filename);
460 1.3.6.2 yamt
461 1.3.6.2 yamt /* All done with this node */
462 1.3.6.2 yamt
463 1.3.6.2 yamt ACPI_FREE (Fnode);
464 1.3.6.2 yamt return (TRUE);
465 1.3.6.2 yamt }
466