Commit 265c5294 by Dave Brolley Committed by Dave Brolley

cccp.c (rescan): Handle multibyte chartacters ending in backslash.

Fri Oct 16 15:44:02 1998  Dave Brolley  <brolley@cygnus.com>
        * cccp.c (rescan): Handle multibyte chartacters ending in backslash.
        (rescan): Ditto.
        (skip_if_group): Ditto.
        (skip_to_end_of_comment): Ditto.
        (macarg1): Ditto.
        (discard_comments): Ditto.
        (change_newlines): Ditto.

From-SVN: r23135
parent cde7b1b0
Fri Oct 16 15:44:02 1998 Dave Brolley <brolley@cygnus.com>
* cccp.c (rescan): Handle multibyte chartacters ending in backslash.
(rescan): Ditto.
(skip_if_group): Ditto.
(skip_to_end_of_comment): Ditto.
(macarg1): Ditto.
(discard_comments): Ditto.
(change_newlines): Ditto.
Fri Oct 16 15:26:24 1998 Dave Brolley <brolley@cygnus.com> Fri Oct 16 15:26:24 1998 Dave Brolley <brolley@cygnus.com>
* c-lex.c (yylex): Fix unaligned access of wchar_t. * c-lex.c (yylex): Fix unaligned access of wchar_t.
......
...@@ -3006,24 +3006,30 @@ do { ip = &instack[indepth]; \ ...@@ -3006,24 +3006,30 @@ do { ip = &instack[indepth]; \
U_CHAR *before_bp = ibp; U_CHAR *before_bp = ibp;
while (++ibp < limit) { while (++ibp < limit) {
if (*ibp == '\n') { if (*ibp == '\n')
if (ibp[-1] != '\\') { {
if (put_out_comments) { if (put_out_comments) {
bcopy ((char *) before_bp, (char *) obp, ibp - before_bp); bcopy ((char *) before_bp, (char *) obp, ibp - before_bp);
obp += ibp - before_bp; obp += ibp - before_bp;
} }
break; break;
} }
if (warn_comments) if (*ibp == '\\')
warning ("multiline `//' comment"); {
++ip->lineno; if (ibp + 1 < limit && ibp[1] == '\n')
/* Copy the newline into the output buffer, in order to {
avoid the pain of a #line every time a multiline comment if (warn_comments)
is seen. */ warning ("multiline `//' comment");
if (!put_out_comments) ++ip->lineno;
*obp++ = '\n'; /* Copy the newline into the output buffer, in order to
++op->lineno; avoid the pain of a #line every time a multiline comment
} is seen. */
if (!put_out_comments)
*obp++ = '\n';
++op->lineno;
++ibp;
}
}
else else
{ {
#ifdef MULTIBYTE_CHARS #ifdef MULTIBYTE_CHARS
...@@ -3527,9 +3533,11 @@ randomchar: ...@@ -3527,9 +3533,11 @@ randomchar:
for (ibp += 2; ; ibp++) for (ibp += 2; ; ibp++)
{ {
if (*ibp == '\n') if (*ibp == '\n')
break;
if (*ibp == '\\' && ibp[1] == '\n')
{ {
if (ibp[-1] != '\\') if (put_out_comments)
break; *obp++ = *ibp++;
} }
else else
{ {
...@@ -7606,13 +7614,15 @@ skip_if_group (ip, any, op) ...@@ -7606,13 +7614,15 @@ skip_if_group (ip, any, op)
bp += 2; bp += 2;
} else if (bp[1] == '/' && cplusplus_comments) { } else if (bp[1] == '/' && cplusplus_comments) {
for (bp += 2; ; bp++) { for (bp += 2; ; bp++) {
if (*bp == '\n') { if (*bp == '\n')
if (bp[-1] != '\\') break;
break; if (*bp == '\\' && bp[1] == '\n')
if (warn_comments) {
warning ("multiline `//' comment"); if (warn_comments)
ip->lineno++; warning ("multiline `//' comment");
} ip->lineno++;
bp++;
}
else else
{ {
#ifdef MULTIBYTE_CHARS #ifdef MULTIBYTE_CHARS
...@@ -7969,16 +7979,21 @@ skip_to_end_of_comment (ip, line_counter, nowarn) ...@@ -7969,16 +7979,21 @@ skip_to_end_of_comment (ip, line_counter, nowarn)
} }
if (cplusplus_comments && bp[-1] == '/') { if (cplusplus_comments && bp[-1] == '/') {
for (; bp < limit; bp++) { for (; bp < limit; bp++) {
if (*bp == '\n') { if (*bp == '\n')
if (bp[-1] != '\\') break;
break; if (*bp == '\\' && bp + 1 < limit && bp[1] == '\n')
if (!nowarn && warn_comments) {
warning ("multiline `//' comment"); if (!nowarn && warn_comments)
if (line_counter) warning ("multiline `//' comment");
++*line_counter; if (line_counter)
if (op) ++*line_counter;
++op->lineno; if (op)
} {
++op->lineno;
*op->bufp++ = *bp;
}
++bp;
}
else else
{ {
#ifdef MULTIBYTE_CHARS #ifdef MULTIBYTE_CHARS
...@@ -8951,11 +8966,15 @@ macarg1 (start, limit, macro, depthptr, newlines, comments, rest_args) ...@@ -8951,11 +8966,15 @@ macarg1 (start, limit, macro, depthptr, newlines, comments, rest_args)
for (bp += 2; bp < limit; bp++) { for (bp += 2; bp < limit; bp++) {
if (*bp == '\n') { if (*bp == '\n') {
++*newlines; ++*newlines;
if (bp[-1] != '\\') break;
break;
if (warn_comments)
warning ("multiline `//' comment");
} }
if (*bp == '\\' && bp + 1 < limit && bp[1] == '\n')
{
++*newlines;
if (warn_comments)
warning ("multiline `//' comment");
++bp;
}
else else
{ {
#ifdef MULTIBYTE_CHARS #ifdef MULTIBYTE_CHARS
...@@ -9077,10 +9096,9 @@ discard_comments (start, length, newlines) ...@@ -9077,10 +9096,9 @@ discard_comments (start, length, newlines)
while (ibp < limit) while (ibp < limit)
{ {
if (*ibp == '\n') if (*ibp == '\n')
{ break;
if (ibp[-1] != '\\') if (*ibp == '\\' && ibp + 1 < limit && ibp[1] == '\n')
break; ibp++;
}
else else
{ {
#ifdef MULTIBYTE_CHARS #ifdef MULTIBYTE_CHARS
...@@ -9215,10 +9233,9 @@ change_newlines (start, length) ...@@ -9215,10 +9233,9 @@ change_newlines (start, length)
while (ibp < limit) { while (ibp < limit) {
*obp++ = c = *ibp++; *obp++ = c = *ibp++;
if (c == quotec) if (c == quotec)
{ break;
if (ibp[-2] != '\\') else if (c == '\\' && ibp < limit && *ibp == '\n')
break; *obp++ = *ibp++;
}
else if (c == '\n') else if (c == '\n')
{ {
if (quotec == '\'') if (quotec == '\'')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment