Changeset 530 for trunk/src/gmake/read.c
- Timestamp:
- Sep 17, 2006, 10:38:57 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmake/read.c
r528 r530 461 461 } 462 462 463 #ifdef CONFIG_WITH_INCLUDEDEP 464 /* no nonsense dependency file including. */ 465 void 466 eval_include_dep(char *name, struct floc *f) 467 { 468 FILE *fp; 469 long max_size; 470 long size; 471 char *buf; 472 unsigned int saved_var_len; 473 char *saved_var_buf; 474 475 /* ignore non-existing dependency files. */ 476 if (!file_exists_p (name)) 477 return; 478 479 /* open it and determin the size. */ 480 errno = 0; 481 fp = fopen (name, "r"); 482 if (!fp) 483 { 484 error (f, "%s: %s", name, strerror (errno)); 485 return; 486 } 487 488 if (fseek (fp, 0, SEEK_END)) 489 fatal (f, "%s: fseek failed - %s", name, strerror (errno)); 490 max_size = ftell (fp); 491 if (max_size < 0) 492 fatal (f, "%s: ftell failed - %s", name, strerror (errno)); 493 if (fseek (fp, 0, SEEK_SET)) 494 fatal (f, "%s: fseek failed - %s", name, strerror (errno)); 495 496 /* ignore empty files. */ 497 if (max_size == 0) 498 { 499 fclose (fp); 500 return; 501 } 502 503 /* allocate a buffer and read the file. \r\n -> \n conversion 504 make this intersting ... */ 505 buf = xmalloc (max_size + 1); 506 size = fread (buf, 1, max_size, fp); /* FIXME: EINTR? incomplete reads? */ 507 if ( size == -1 508 || (ferror (fp) && !feof (fp))) 509 fatal (f, "%s: fread failed - %s", name, strerror (errno)); 510 if (size < max_size / 2) 511 fatal (f, "%s: fread failed - %s", name, strerror (errno)); 512 buf[size] = '\0'; 513 514 /* evaluate the buffer and cleanup. */ 515 install_variable_buffer (&saved_var_buf, &saved_var_len); 516 eval_buffer (buf); 517 restore_variable_buffer (saved_var_buf, saved_var_len); 518 519 free (buf); 520 fclose (fp); 521 } 522 #endif /* CONFIG_WITH_INCLUDEDEP */ 523 463 524 464 525 … … 809 870 does not globbing and doesn't support multiple names. It's 810 871 trying to save time by being dead simple. */ 811 struct conditionals *save;812 struct conditionals new_conditionals;813 872 char *name = p2; 814 873 char *end = strchr(name, '\0'); 815 874 char saved; 816 int r;817 875 818 876 while (end > name && isspace ((unsigned char)end[-1])) 819 877 --end; 878 820 879 saved = *end; /* not sure if this is required... */ 821 880 *end = '\0'; 822 823 if (file_exists_p (name)) 824 { 825 /* Save the state of conditionals and start 826 the included makefile with a clean slate. */ 827 save = install_conditionals (&new_conditionals); 828 829 /* Record the rules that are waiting so they will determine 830 the default goal before those in the included makefile. */ 831 record_waiting_files (); 832 833 /* Read the makefile. */ 834 r = eval_makefile (name, RM_INCLUDED | RM_NO_TILDE | RM_DONTCARE); 835 if (!r) 836 error (fstart, "%s: %s", name, strerror (errno)); 837 838 /* Restore conditional state. */ 839 restore_conditionals (save); 840 } 881 eval_include_dep (name, fstart); 841 882 *end = saved; 883 842 884 goto rule_complete; 843 885 }
Note:
See TracChangeset
for help on using the changeset viewer.