diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1995-07-10 20:16:27 -0400 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1995-07-10 20:16:27 -0400 |
commit | a0469a32455e689977fe199de5e0dec871fb5486 (patch) | |
tree | 2122861dbb4b4a8c35578e25e5958075bc3ec028 /gcc | |
parent | d679bebf473bee3e804b0d4563a8314372833a18 (diff) | |
download | gcc-a0469a32455e689977fe199de5e0dec871fb5486.zip gcc-a0469a32455e689977fe199de5e0dec871fb5486.tar.gz gcc-a0469a32455e689977fe199de5e0dec871fb5486.tar.bz2 |
(rescan): Don't address outside of array when preprocessing C++
comments.
From-SVN: r10118
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cccp.c | 47 |
1 files changed, 19 insertions, 28 deletions
@@ -2991,38 +2991,29 @@ do { ip = &instack[indepth]; \ /* C++ style comment... */ start_line = ip->lineno; - --ibp; /* Back over the slash */ - --obp; - /* Comments are equivalent to spaces. */ if (! put_out_comments) - *obp++ = ' '; - else { - /* must fake up a comment here */ - *obp++ = '/'; - *obp++ = '/'; - } - { - U_CHAR *before_bp = ibp+2; + obp[-1] = ' '; - while (ibp < limit) { - if (ibp[-1] != '\\' && *ibp == '\n') { - if (put_out_comments) { - bcopy ((char *) before_bp, (char *) obp, ibp - before_bp); - obp += ibp - before_bp; - } - break; - } else { - if (*ibp == '\n') { - ++ip->lineno; - /* Copy the newline into the output buffer, in order to - avoid the pain of a #line every time a multiline comment - is seen. */ - if (!put_out_comments) - *obp++ = '\n'; - ++op->lineno; + { + U_CHAR *before_bp = ibp; + + while (++ibp < limit) { + if (*ibp == '\n') { + if (ibp[-1] != '\\') { + if (put_out_comments) { + bcopy ((char *) before_bp, (char *) obp, ibp - before_bp); + obp += ibp - before_bp; + } + break; } - ibp++; + ++ip->lineno; + /* Copy the newline into the output buffer, in order to + avoid the pain of a #line every time a multiline comment + is seen. */ + if (!put_out_comments) + *obp++ = '\n'; + ++op->lineno; } } break; |