1
2/******************************************************************************
3 *
4 * Module Name: aslcompile - top level compile module
5 *
6 *****************************************************************************/
7
8/*
--- 45 unchanged lines hidden (view full) ---
54/* Local prototypes */
55
56static void
57CmFlushSourceCode (
58 void);
59
60static void
61FlConsumeAnsiComment (
62 ASL_FILE_INFO *FileInfo,
63 ASL_FILE_STATUS *Status);
64
65static void
66FlConsumeNewComment (
67 ASL_FILE_INFO *FileInfo,
68 ASL_FILE_STATUS *Status);
69
70
71/*******************************************************************************
72 *
73 * FUNCTION: AslCompilerSignon
74 *
75 * PARAMETERS: FileId - ID of the output file
--- 172 unchanged lines hidden (view full) ---
248 AslResetCurrentLineBuffer ();
249}
250
251
252/*******************************************************************************
253 *
254 * FUNCTION: FlConsume*
255 *
256 * PARAMETERS: FileInfo - Points to an open input file
257 *
258 * RETURN: Number of lines consumed
259 *
260 * DESCRIPTION: Step over both types of comment during check for ascii chars
261 *
262 ******************************************************************************/
263
264static void
265FlConsumeAnsiComment (
266 ASL_FILE_INFO *FileInfo,
267 ASL_FILE_STATUS *Status)
268{
269 UINT8 Byte;
270 BOOLEAN ClosingComment = FALSE;
271
272
273 while (fread (&Byte, 1, 1, FileInfo->Handle))
274 {
275 /* Scan until comment close is found */
276
277 if (ClosingComment)
278 {
279 if (Byte == '/')
280 {
281 return;
--- 20 unchanged lines hidden (view full) ---
302
303 Status->Offset++;
304 }
305}
306
307
308static void
309FlConsumeNewComment (
310 ASL_FILE_INFO *FileInfo,
311 ASL_FILE_STATUS *Status)
312{
313 UINT8 Byte;
314
315
316 while (fread (&Byte, 1, 1, FileInfo->Handle))
317 {
318 Status->Offset++;
319
320 /* Comment ends at newline */
321
322 if (Byte == 0x0A)
323 {
324 Status->Line++;
325 return;
326 }
327 }
328}
329
330
331/*******************************************************************************
332 *
333 * FUNCTION: FlCheckForAscii
334 *
335 * PARAMETERS: FileInfo - Points to an open input file
336 *
337 * RETURN: Status
338 *
339 * DESCRIPTION: Verify that the input file is entirely ASCII. Ignores characters
340 * within comments. Note: does not handle nested comments and does
341 * not handle comment delimiters within string literals. However,
342 * on the rare chance this happens and an invalid character is
343 * missed, the parser will catch the error by failing in some
344 * spectactular manner.
345 *
346 ******************************************************************************/
347
348ACPI_STATUS
349FlCheckForAscii (
350 ASL_FILE_INFO *FileInfo)
351{
352 UINT8 Byte;
353 ACPI_SIZE BadBytes = 0;
354 BOOLEAN OpeningComment = FALSE;
355 ASL_FILE_STATUS Status;
356
357
358 Status.Line = 1;
359 Status.Offset = 0;
360
361 /* Read the entire file */
362
363 while (fread (&Byte, 1, 1, FileInfo->Handle))
364 {
365 /* Ignore comment fields (allow non-ascii within) */
366
367 if (OpeningComment)
368 {
369 /* Check for second comment open delimiter */
370
371 if (Byte == '*')
372 {
373 FlConsumeAnsiComment (FileInfo, &Status);
374 }
375
376 if (Byte == '/')
377 {
378 FlConsumeNewComment (FileInfo, &Status);
379 }
380
381 /* Reset */
382
383 OpeningComment = FALSE;
384 }
385 else if (Byte == '/')
386 {
387 OpeningComment = TRUE;
388 }
389
390 /* Check for an ASCII character */
391
392 if (!ACPI_IS_ASCII (Byte))
393 {
394 if (BadBytes < 10)
395 {
396 AcpiOsPrintf (
397 "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n",
398 Byte, Status.Line, Status.Offset);
399 }
400
401 BadBytes++;
402 }
--- 5 unchanged lines hidden (view full) ---
408 Status.Line++;
409 }
410
411 Status.Offset++;
412 }
413
414 /* Seek back to the beginning of the source file */
415
416 fseek (FileInfo->Handle, 0, SEEK_SET);
417
418 /* Were there any non-ASCII characters in the file? */
419
420 if (BadBytes)
421 {
422 AcpiOsPrintf (
423 "%u non-ASCII characters found in input source text, could be a binary file\n",
424 BadBytes);
425 AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, FileInfo->Filename);
426 return (AE_BAD_CHARACTER);
427 }
428
429 /* File is OK */
430
431 return (AE_OK);
432}
433
434
435/*******************************************************************************
436 *
437 * FUNCTION: CmDoCompile
--- 453 unchanged lines hidden ---
2/******************************************************************************
3 *
4 * Module Name: aslcompile - top level compile module
5 *
6 *****************************************************************************/
7
8/*
--- 45 unchanged lines hidden (view full) ---
54/* Local prototypes */
55
56static void
57CmFlushSourceCode (
58 void);
59
60static void
61FlConsumeAnsiComment (
62 ASL_FILE_INFO *FileInfo,
63 ASL_FILE_STATUS *Status);
64
65static void
66FlConsumeNewComment (
67 ASL_FILE_INFO *FileInfo,
68 ASL_FILE_STATUS *Status);
69
70
71/*******************************************************************************
72 *
73 * FUNCTION: AslCompilerSignon
74 *
75 * PARAMETERS: FileId - ID of the output file
--- 172 unchanged lines hidden (view full) ---
248 AslResetCurrentLineBuffer ();
249}
250
251
252/*******************************************************************************
253 *
254 * FUNCTION: FlConsume*
255 *
256 * PARAMETERS: FileInfo - Points to an open input file
257 *
258 * RETURN: Number of lines consumed
259 *
260 * DESCRIPTION: Step over both types of comment during check for ascii chars
261 *
262 ******************************************************************************/
263
264static void
265FlConsumeAnsiComment (
266 ASL_FILE_INFO *FileInfo,
267 ASL_FILE_STATUS *Status)
268{
269 UINT8 Byte;
270 BOOLEAN ClosingComment = FALSE;
271
272
273 while (fread (&Byte, 1, 1, FileInfo->Handle))
274 {
275 /* Scan until comment close is found */
276
277 if (ClosingComment)
278 {
279 if (Byte == '/')
280 {
281 return;
--- 20 unchanged lines hidden (view full) ---
302
303 Status->Offset++;
304 }
305}
306
307
308static void
309FlConsumeNewComment (
310 ASL_FILE_INFO *FileInfo,
311 ASL_FILE_STATUS *Status)
312{
313 UINT8 Byte;
314
315
316 while (fread (&Byte, 1, 1, FileInfo->Handle))
317 {
318 Status->Offset++;
319
320 /* Comment ends at newline */
321
322 if (Byte == 0x0A)
323 {
324 Status->Line++;
325 return;
326 }
327 }
328}
329
330
331/*******************************************************************************
332 *
333 * FUNCTION: FlCheckForAscii
334 *
335 * PARAMETERS: FileInfo - Points to an open input file
336 *
337 * RETURN: Status
338 *
339 * DESCRIPTION: Verify that the input file is entirely ASCII. Ignores characters
340 * within comments. Note: does not handle nested comments and does
341 * not handle comment delimiters within string literals. However,
342 * on the rare chance this happens and an invalid character is
343 * missed, the parser will catch the error by failing in some
344 * spectactular manner.
345 *
346 ******************************************************************************/
347
348ACPI_STATUS
349FlCheckForAscii (
350 ASL_FILE_INFO *FileInfo)
351{
352 UINT8 Byte;
353 ACPI_SIZE BadBytes = 0;
354 BOOLEAN OpeningComment = FALSE;
355 ASL_FILE_STATUS Status;
356
357
358 Status.Line = 1;
359 Status.Offset = 0;
360
361 /* Read the entire file */
362
363 while (fread (&Byte, 1, 1, FileInfo->Handle))
364 {
365 /* Ignore comment fields (allow non-ascii within) */
366
367 if (OpeningComment)
368 {
369 /* Check for second comment open delimiter */
370
371 if (Byte == '*')
372 {
373 FlConsumeAnsiComment (FileInfo, &Status);
374 }
375
376 if (Byte == '/')
377 {
378 FlConsumeNewComment (FileInfo, &Status);
379 }
380
381 /* Reset */
382
383 OpeningComment = FALSE;
384 }
385 else if (Byte == '/')
386 {
387 OpeningComment = TRUE;
388 }
389
390 /* Check for an ASCII character */
391
392 if (!ACPI_IS_ASCII (Byte))
393 {
394 if (BadBytes < 10)
395 {
396 AcpiOsPrintf (
397 "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n",
398 Byte, Status.Line, Status.Offset);
399 }
400
401 BadBytes++;
402 }
--- 5 unchanged lines hidden (view full) ---
408 Status.Line++;
409 }
410
411 Status.Offset++;
412 }
413
414 /* Seek back to the beginning of the source file */
415
416 fseek (FileInfo->Handle, 0, SEEK_SET);
417
418 /* Were there any non-ASCII characters in the file? */
419
420 if (BadBytes)
421 {
422 AcpiOsPrintf (
423 "%u non-ASCII characters found in input source text, could be a binary file\n",
424 BadBytes);
425 AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, FileInfo->Filename);
426 return (AE_BAD_CHARACTER);
427 }
428
429 /* File is OK */
430
431 return (AE_OK);
432}
433
434
435/*******************************************************************************
436 *
437 * FUNCTION: CmDoCompile
--- 453 unchanged lines hidden ---