aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/make/parse.c
diff options
context:
space:
mode:
authorSteve Price <steve@FreeBSD.org>1996-09-22 02:28:36 +0000
committerSteve Price <steve@FreeBSD.org>1996-09-22 02:28:36 +0000
commit6bf3beb134d3a2ad82485eff0afab2ee26f0ac69 (patch)
treea2c9ef65b1d82123e4257224bc26b25928f7c74a /usr.bin/make/parse.c
parent2e66d503c6f1ff39ed550d8405d7c92ac545a744 (diff)
Notes
Diffstat (limited to 'usr.bin/make/parse.c')
-rw-r--r--usr.bin/make/parse.c72
1 files changed, 31 insertions, 41 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index f99f186990a3..4e06ce45b80c 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -2009,54 +2009,44 @@ ParseSkipLine(skip)
int skip; /* Skip lines that don't start with . */
{
char *line;
- int c, lastc = '\0', lineLength;
+ int c, lastc, lineLength = 0;
Buffer buf;
- c = ParseReadc();
+ buf = Buf_Init(MAKE_BSIZE);
- if (skip) {
- /*
- * Skip lines until get to one that begins with a
- * special char.
- */
- while ((c != '.') && (c != EOF)) {
- while (((c != '\n') || (lastc == '\\')) && (c != EOF))
- {
- /*
- * Advance to next unescaped newline
- */
- if ((lastc = c) == '\n') {
- lineno++;
- }
- c = ParseReadc();
- }
- lineno++;
+ do {
+ Buf_Discard(buf, lineLength);
+ lastc = '\0';
- lastc = c;
- c = ParseReadc ();
- }
- }
+ while (((c = ParseReadc()) != '\n' || lastc == '\\')
+ && c != EOF) {
+ if (c == '\n') {
+ Buf_ReplaceLastByte(buf, (Byte)' ');
+ lineno++;
- if (c == EOF) {
- Parse_Error (PARSE_FATAL, "Unclosed conditional/for loop");
- return ((char *)NULL);
- }
+ while ((c = ParseReadc()) == ' ' || c == '\t');
- /*
- * Read the entire line into buf
- */
- buf = Buf_Init (MAKE_BSIZE);
- if (c != '\n') {
- do {
- Buf_AddByte (buf, (Byte)c);
- c = ParseReadc();
- } while ((c != '\n') && (c != EOF));
- }
- lineno++;
+ if (c == EOF)
+ break;
+ }
+
+ Buf_AddByte(buf, (Byte)c);
+ lastc = c;
+ }
+
+ if (c == EOF) {
+ Parse_Error(PARSE_FATAL, "Unclosed conditional/for loop");
+ Buf_Destroy(buf, TRUE);
+ return((char *)NULL);
+ }
+
+ lineno++;
+ Buf_AddByte(buf, (Byte)c);
+ Buf_AddByte(buf, (Byte)'\0');
+ line = (char *)Buf_GetAll(buf, &lineLength);
+ } while (skip == 1 && line[0] != '.');
- Buf_AddByte (buf, (Byte)'\0');
- line = (char *)Buf_GetAll (buf, &lineLength);
- Buf_Destroy (buf, FALSE);
+ Buf_Destroy(buf, FALSE);
return line;
}