Deleted Added
full compact
aslcompile.c (234623) aslcompile.c (235945)
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 (
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,
62 FILE *Handle,
63 ASL_FILE_STATUS *Status);
64
65static void
66FlConsumeNewComment (
63 ASL_FILE_STATUS *Status);
64
65static void
66FlConsumeNewComment (
67 ASL_FILE_INFO *FileInfo,
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 *
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
256 * PARAMETERS: Handle - Open input file
257 * Status - File current status struct
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 (
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 (
266 ASL_FILE_INFO *FileInfo,
267 FILE *Handle,
267 ASL_FILE_STATUS *Status)
268{
269 UINT8 Byte;
270 BOOLEAN ClosingComment = FALSE;
271
272
268 ASL_FILE_STATUS *Status)
269{
270 UINT8 Byte;
271 BOOLEAN ClosingComment = FALSE;
272
273
273 while (fread (&Byte, 1, 1, FileInfo->Handle))
274 while (fread (&Byte, 1, 1, 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 (
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 (
310 ASL_FILE_INFO *FileInfo,
311 FILE *Handle,
311 ASL_FILE_STATUS *Status)
312{
313 UINT8 Byte;
314
315
312 ASL_FILE_STATUS *Status)
313{
314 UINT8 Byte;
315
316
316 while (fread (&Byte, 1, 1, FileInfo->Handle))
317 while (fread (&Byte, 1, 1, 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 *
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 *
335 * PARAMETERS: FileInfo - Points to an open input file
336 * PARAMETERS: Handle - Open input file
337 * Filename - Input filename
338 * DisplayErrors - TRUE if error messages desired
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 (
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 (
350 ASL_FILE_INFO *FileInfo)
353 FILE *Handle,
354 char *Filename,
355 BOOLEAN DisplayErrors)
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
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
363 while (fread (&Byte, 1, 1, FileInfo->Handle))
368 while (fread (&Byte, 1, 1, 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 {
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 {
373 FlConsumeAnsiComment (FileInfo, &Status);
378 FlConsumeAnsiComment (Handle, &Status);
374 }
375
376 if (Byte == '/')
377 {
379 }
380
381 if (Byte == '/')
382 {
378 FlConsumeNewComment (FileInfo, &Status);
383 FlConsumeNewComment (Handle, &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 {
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 {
394 if (BadBytes < 10)
399 if ((BadBytes < 10) && (DisplayErrors))
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
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
416 fseek (FileInfo->Handle, 0, SEEK_SET);
421 fseek (Handle, 0, SEEK_SET);
417
418 /* Were there any non-ASCII characters in the file? */
419
420 if (BadBytes)
421 {
422
423 /* Were there any non-ASCII characters in the file? */
424
425 if (BadBytes)
426 {
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);
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
426 return (AE_BAD_CHARACTER);
427 }
428
435 return (AE_BAD_CHARACTER);
436 }
437
429 /* File is OK */
438 /* File is OK (100% ASCII) */
430
431 return (AE_OK);
432}
433
434
435/*******************************************************************************
436 *
437 * FUNCTION: CmDoCompile

--- 453 unchanged lines hidden ---
439
440 return (AE_OK);
441}
442
443
444/*******************************************************************************
445 *
446 * FUNCTION: CmDoCompile

--- 453 unchanged lines hidden ---