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