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 FILE *Handle,
63 ASL_FILE_STATUS *Status);
64
65static void
66FlConsumeNewComment (
67 FILE *Handle,
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: Handle - Open input file
257 * Status - File current status struct
258 *
259 * RETURN: Number of lines consumed
260 *
261 * DESCRIPTION: Step over both types of comment during check for ascii chars
262 *
263 ******************************************************************************/
264
265static void
266FlConsumeAnsiComment (
267 FILE *Handle,
268 ASL_FILE_STATUS *Status)
269{
270 UINT8 Byte;
271 BOOLEAN ClosingComment = FALSE;
272
273
274 while (fread (&Byte, 1, 1, Handle))
275 {
276 /* Scan until comment close is found */
277
278 if (ClosingComment)
279 {
280 if (Byte == '/')
281 {
282 return;
--- 20 unchanged lines hidden (view full) ---
303
304 Status->Offset++;
305 }
306}
307
308
309static void
310FlConsumeNewComment (
311 FILE *Handle,
312 ASL_FILE_STATUS *Status)
313{
314 UINT8 Byte;
315
316
317 while (fread (&Byte, 1, 1, Handle))
318 {
319 Status->Offset++;
320
321 /* Comment ends at newline */
322
323 if (Byte == 0x0A)
324 {
325 Status->Line++;
326 return;
327 }
328 }
329}
330
331
332/*******************************************************************************
333 *
334 * FUNCTION: FlCheckForAscii
335 *
336 * PARAMETERS: Handle - Open input file
337 * Filename - Input filename
338 * DisplayErrors - TRUE if error messages desired
339 *
340 * RETURN: Status
341 *
342 * DESCRIPTION: Verify that the input file is entirely ASCII. Ignores characters
343 * within comments. Note: does not handle nested comments and does
344 * not handle comment delimiters within string literals. However,
345 * on the rare chance this happens and an invalid character is
346 * missed, the parser will catch the error by failing in some
347 * spectactular manner.
348 *
349 ******************************************************************************/
350
351ACPI_STATUS
352FlCheckForAscii (
353 FILE *Handle,
354 char *Filename,
355 BOOLEAN DisplayErrors)
356{
357 UINT8 Byte;
358 ACPI_SIZE BadBytes = 0;
359 BOOLEAN OpeningComment = FALSE;
360 ASL_FILE_STATUS Status;
361
362
363 Status.Line = 1;
364 Status.Offset = 0;
365
366 /* Read the entire file */
367
368 while (fread (&Byte, 1, 1, Handle))
369 {
370 /* Ignore comment fields (allow non-ascii within) */
371
372 if (OpeningComment)
373 {
374 /* Check for second comment open delimiter */
375
376 if (Byte == '*')
377 {
378 FlConsumeAnsiComment (Handle, &Status);
379 }
380
381 if (Byte == '/')
382 {
383 FlConsumeNewComment (Handle, &Status);
384 }
385
386 /* Reset */
387
388 OpeningComment = FALSE;
389 }
390 else if (Byte == '/')
391 {
392 OpeningComment = TRUE;
393 }
394
395 /* Check for an ASCII character */
396
397 if (!ACPI_IS_ASCII (Byte))
398 {
399 if ((BadBytes < 10) && (DisplayErrors))
400 {
401 AcpiOsPrintf (
402 "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n",
403 Byte, Status.Line, Status.Offset);
404 }
405
406 BadBytes++;
407 }
--- 5 unchanged lines hidden (view full) ---
413 Status.Line++;
414 }
415
416 Status.Offset++;
417 }
418
419 /* Seek back to the beginning of the source file */
420
421 fseek (Handle, 0, SEEK_SET);
422
423 /* Were there any non-ASCII characters in the file? */
424
425 if (BadBytes)
426 {
427 if (DisplayErrors)
428 {
429 AcpiOsPrintf (
430 "%u non-ASCII characters found in input source text, could be a binary file\n",
431 BadBytes);
432 AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, Filename);
433 }
434
435 return (AE_BAD_CHARACTER);
436 }
437
438 /* File is OK (100% ASCII) */
439
440 return (AE_OK);
441}
442
443
444/*******************************************************************************
445 *
446 * 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 FILE *Handle,
63 ASL_FILE_STATUS *Status);
64
65static void
66FlConsumeNewComment (
67 FILE *Handle,
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: Handle - Open input file
257 * Status - File current status struct
258 *
259 * RETURN: Number of lines consumed
260 *
261 * DESCRIPTION: Step over both types of comment during check for ascii chars
262 *
263 ******************************************************************************/
264
265static void
266FlConsumeAnsiComment (
267 FILE *Handle,
268 ASL_FILE_STATUS *Status)
269{
270 UINT8 Byte;
271 BOOLEAN ClosingComment = FALSE;
272
273
274 while (fread (&Byte, 1, 1, Handle))
275 {
276 /* Scan until comment close is found */
277
278 if (ClosingComment)
279 {
280 if (Byte == '/')
281 {
282 return;
--- 20 unchanged lines hidden (view full) ---
303
304 Status->Offset++;
305 }
306}
307
308
309static void
310FlConsumeNewComment (
311 FILE *Handle,
312 ASL_FILE_STATUS *Status)
313{
314 UINT8 Byte;
315
316
317 while (fread (&Byte, 1, 1, Handle))
318 {
319 Status->Offset++;
320
321 /* Comment ends at newline */
322
323 if (Byte == 0x0A)
324 {
325 Status->Line++;
326 return;
327 }
328 }
329}
330
331
332/*******************************************************************************
333 *
334 * FUNCTION: FlCheckForAscii
335 *
336 * PARAMETERS: Handle - Open input file
337 * Filename - Input filename
338 * DisplayErrors - TRUE if error messages desired
339 *
340 * RETURN: Status
341 *
342 * DESCRIPTION: Verify that the input file is entirely ASCII. Ignores characters
343 * within comments. Note: does not handle nested comments and does
344 * not handle comment delimiters within string literals. However,
345 * on the rare chance this happens and an invalid character is
346 * missed, the parser will catch the error by failing in some
347 * spectactular manner.
348 *
349 ******************************************************************************/
350
351ACPI_STATUS
352FlCheckForAscii (
353 FILE *Handle,
354 char *Filename,
355 BOOLEAN DisplayErrors)
356{
357 UINT8 Byte;
358 ACPI_SIZE BadBytes = 0;
359 BOOLEAN OpeningComment = FALSE;
360 ASL_FILE_STATUS Status;
361
362
363 Status.Line = 1;
364 Status.Offset = 0;
365
366 /* Read the entire file */
367
368 while (fread (&Byte, 1, 1, Handle))
369 {
370 /* Ignore comment fields (allow non-ascii within) */
371
372 if (OpeningComment)
373 {
374 /* Check for second comment open delimiter */
375
376 if (Byte == '*')
377 {
378 FlConsumeAnsiComment (Handle, &Status);
379 }
380
381 if (Byte == '/')
382 {
383 FlConsumeNewComment (Handle, &Status);
384 }
385
386 /* Reset */
387
388 OpeningComment = FALSE;
389 }
390 else if (Byte == '/')
391 {
392 OpeningComment = TRUE;
393 }
394
395 /* Check for an ASCII character */
396
397 if (!ACPI_IS_ASCII (Byte))
398 {
399 if ((BadBytes < 10) && (DisplayErrors))
400 {
401 AcpiOsPrintf (
402 "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n",
403 Byte, Status.Line, Status.Offset);
404 }
405
406 BadBytes++;
407 }
--- 5 unchanged lines hidden (view full) ---
413 Status.Line++;
414 }
415
416 Status.Offset++;
417 }
418
419 /* Seek back to the beginning of the source file */
420
421 fseek (Handle, 0, SEEK_SET);
422
423 /* Were there any non-ASCII characters in the file? */
424
425 if (BadBytes)
426 {
427 if (DisplayErrors)
428 {
429 AcpiOsPrintf (
430 "%u non-ASCII characters found in input source text, could be a binary file\n",
431 BadBytes);
432 AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, Filename);
433 }
434
435 return (AE_BAD_CHARACTER);
436 }
437
438 /* File is OK (100% ASCII) */
439
440 return (AE_OK);
441}
442
443
444/*******************************************************************************
445 *
446 * FUNCTION: CmDoCompile
--- 453 unchanged lines hidden ---