sme@computing-maths.cardiff.ac.uk (Simon Elliott) (06/21/89)
This posting fixes a bug in agcpp (Alitair G Crookes' Pre-processor)
which led agcpp to not concatenate multiple adjacent strings correctly.
To reproduce the bug, run agcpp on the following:
main()
{
printf("first " "second " "third " "fourth\n");
}
The output is:
main()
{
printf("first second " "third fourth\n");
}
i.e. the 1st, 3rd, 5th ... concatenations are performed, but 2nd, 4th ...
are not. The following context diff will fix the problem.
*** agcpp.c Fri May 19 01:11:15 1989
--- agcpp.c.new Wed May 24 01:09:06 1989
***************
*** 183,190
op += n;
*op = 0;
if (s[n-1] == '\n') {
! for (cp = op = obuf ; *op ; ) {
! while (*op && *op != '"')
*cp++ = *op++;
if (*op == 0)
break;
--- 183,191 -----
op += n;
*op = 0;
if (s[n-1] == '\n') {
! cp = op = obuf;
! do {
! while (*op && *op != '"') {
*cp++ = *op++;
}
if (*op == 0)
***************
*** 186,191
for (cp = op = obuf ; *op ; ) {
while (*op && *op != '"')
*cp++ = *op++;
if (*op == 0)
break;
for (*cp++ = *op++ ; *op && *op != '"' ; *cp++ = *op++)
--- 187,193 -----
do {
while (*op && *op != '"') {
*cp++ = *op++;
+ }
if (*op == 0)
break;
*cp++ = *op++;
***************
*** 188,207
*cp++ = *op++;
if (*op == 0)
break;
! for (*cp++ = *op++ ; *op && *op != '"' ; *cp++ = *op++)
! if (*op == '\\')
! *cp++ = *op++;
! if (*op == 0)
! break;
! for (was = op++ ; *op && isspace(*op) ; op++)
! ;
! if (*op == 0)
! break;
! if (*op == '"')
! op++;
! else
! op = was;
! }
for (*cp-- = 0 ; cp != obuf && isspace(*cp) ; --cp)
;
if (*cp == '"')
--- 190,212 -----
}
if (*op == 0)
break;
! *cp++ = *op++;
! while (*op && *op != '"') {
! for (*cp++ = *op++ ; *op && *op != '"' ; *cp++ = *op++)
! if (*op == '\\')
! *cp++ = *op++;
! if (*op == 0)
! break;
! for (was = op++ ; *op && isspace(*op) ; op++)
! ;
! if (*op == 0)
! break;
! if (*op == '"')
! op++;
! else
! op = was;
! }
! } while (*op);
for (*cp-- = 0 ; cp != obuf && isspace(*cp) ; --cp)
;
if (*cp == '"')
Alastair: I tried to send this to you first, but mail bounced.
--
--------------------------------------------------------------------------
Simon Elliott Internet: sme%v1.cm.cf.ac.uk@nsfnet-relay.ac.uk
UWCC Computer Centre JANET: sme@uk.ac.cf.cm.v1
40/41 Park Place UUCP: {backbones}!mcvax!ukc!reading!cf-cm!sme
Cardiff, Wales PHONE: +44 222 874300