| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: meta.c,v 1.1.1.1 2011/06/18 22:18:04 bsiegert Exp $ */ | | 1 | /* $NetBSD: meta.c,v 1.2 2014/03/31 08:37:25 wiz Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Implement 'meta' mode. | | 4 | * Implement 'meta' mode. |
5 | * Adapted from John Birrell's patches to FreeBSD make. | | 5 | * Adapted from John Birrell's patches to FreeBSD make. |
6 | * --sjg | | 6 | * --sjg |
7 | */ | | 7 | */ |
8 | /* | | 8 | /* |
9 | * Copyright (c) 2009-2010, Juniper Networks, Inc. | | 9 | * Copyright (c) 2009-2010, Juniper Networks, Inc. |
10 | * Portions Copyright (c) 2009, John Birrell. | | 10 | * Portions Copyright (c) 2009, John Birrell. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -756,27 +756,27 @@ fgetLine(char **bufp, size_t *szp, int o | | | @@ -756,27 +756,27 @@ fgetLine(char **bufp, size_t *szp, int o |
756 | return x; | | 756 | return x; |
757 | /* | | 757 | /* |
758 | * We need to grow the buffer. | | 758 | * We need to grow the buffer. |
759 | * The meta file can give us a clue. | | 759 | * The meta file can give us a clue. |
760 | */ | | 760 | */ |
761 | if (fstat(fileno(fp), &fs) == 0) { | | 761 | if (fstat(fileno(fp), &fs) == 0) { |
762 | size_t newsz; | | 762 | size_t newsz; |
763 | char *p; | | 763 | char *p; |
764 | | | 764 | |
765 | newsz = ROUNDUP((fs.st_size / 2), BUFSIZ); | | 765 | newsz = ROUNDUP((fs.st_size / 2), BUFSIZ); |
766 | if (newsz <= bufsz) | | 766 | if (newsz <= bufsz) |
767 | newsz = ROUNDUP(fs.st_size, BUFSIZ); | | 767 | newsz = ROUNDUP(fs.st_size, BUFSIZ); |
768 | if (DEBUG(META)) | | 768 | if (DEBUG(META)) |
769 | fprintf(debug_file, "growing buffer %u -> %u\n", | | 769 | fprintf(debug_file, "growing buffer %zu -> %zu\n", |
770 | bufsz, newsz); | | 770 | bufsz, newsz); |
771 | p = bmake_realloc(buf, newsz); | | 771 | p = bmake_realloc(buf, newsz); |
772 | if (p) { | | 772 | if (p) { |
773 | *bufp = buf = p; | | 773 | *bufp = buf = p; |
774 | *szp = bufsz = newsz; | | 774 | *szp = bufsz = newsz; |
775 | /* fetch the rest */ | | 775 | /* fetch the rest */ |
776 | if (!fgets(&buf[x], bufsz - x, fp)) | | 776 | if (!fgets(&buf[x], bufsz - x, fp)) |
777 | return x; /* truncated! */ | | 777 | return x; /* truncated! */ |
778 | goto check_newline; | | 778 | goto check_newline; |
779 | } | | 779 | } |
780 | } | | 780 | } |
781 | } | | 781 | } |
782 | return 0; | | 782 | return 0; |