mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-05 12:56:08 +00:00
Fix for PR# 1095, make's continuation line handling buggy
when used with .elif. Additional fixes include: - fix continuation line handling when using .for - plug up a memory leak
This commit is contained in:
parent
2e66d503c6
commit
6bf3beb134
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=18456
@ -434,3 +434,28 @@ Buf_Destroy (buf, freeData)
|
||||
}
|
||||
free ((char *)buf);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_ReplaceLastByte --
|
||||
* Replace the last byte in a buffer.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* If the buffer was empty intially, then a new byte will be added.
|
||||
* Otherwise, the last byte is overwritten.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_ReplaceLastByte (buf, byte)
|
||||
Buffer buf; /* buffer to augment */
|
||||
Byte byte; /* byte to be written */
|
||||
{
|
||||
if (buf->inPtr == buf->outPtr)
|
||||
Buf_AddByte(buf, byte);
|
||||
else
|
||||
*(buf->inPtr - 1) = byte;
|
||||
}
|
||||
|
@ -76,5 +76,6 @@ void Buf_Discard __P((Buffer, int));
|
||||
int Buf_Size __P((Buffer));
|
||||
Buffer Buf_Init __P((int));
|
||||
void Buf_Destroy __P((Buffer, Boolean));
|
||||
void Buf_ReplaceLastByte __P((Buffer, Byte));
|
||||
|
||||
#endif /* _BUF_H */
|
||||
|
@ -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)'\0');
|
||||
line = (char *)Buf_GetAll (buf, &lineLength);
|
||||
Buf_Destroy (buf, FALSE);
|
||||
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_Destroy(buf, FALSE);
|
||||
return line;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user