Add the LINTCOMMENT hack, unconditional (no #ifdefs). Since gcc 3.0's cpp
does this Right (without even the overwrite-with-whitespace kludge), we don't need to worry about breaking anything here. Both -C and -CC will result in full lint-capable comments.
This commit is contained in:
parent
0079971ec4
commit
6c78eab38c
|
@ -2779,7 +2779,8 @@ do { ip = &instack[indepth]; \
|
|||
RECACHE;
|
||||
continue;
|
||||
}
|
||||
if (!traditional) {
|
||||
if (!(traditional || put_out_comments))
|
||||
{
|
||||
error_with_line (line_for_error (start_line),
|
||||
"unterminated string or character constant");
|
||||
if (multiline_string_line) {
|
||||
|
@ -2797,7 +2798,8 @@ do { ip = &instack[indepth]; \
|
|||
++op->lineno;
|
||||
/* Traditionally, end of line ends a string constant with no error.
|
||||
So exit the loop and record the new line. */
|
||||
if (traditional) {
|
||||
if (traditional || put_out_comments)
|
||||
{
|
||||
beg_of_line = ibp;
|
||||
goto while2end;
|
||||
}
|
||||
|
@ -2868,7 +2870,7 @@ do { ip = &instack[indepth]; \
|
|||
break;
|
||||
|
||||
case '/':
|
||||
if (ip->macro != 0)
|
||||
if (ip->macro != 0 && put_out_comments == 0)
|
||||
goto randomchar;
|
||||
if (*ibp == '\\' && ibp[1] == '\n')
|
||||
newline_fix (ibp);
|
||||
|
@ -3777,7 +3779,8 @@ handle_directive (ip, op)
|
|||
limit = ip->buf + ip->length;
|
||||
unterminated = 0;
|
||||
already_output = 0;
|
||||
keep_comments = traditional && kt->type == T_DEFINE;
|
||||
keep_comments = kt->type == T_DEFINE && (traditional ||
|
||||
put_out_comments);
|
||||
/* #import is defined only in Objective C, or when on the NeXT. */
|
||||
if (kt->type == T_IMPORT
|
||||
&& !(objc || lookup ((U_CHAR *) "__NeXT__", -1, -1)))
|
||||
|
@ -4025,7 +4028,7 @@ handle_directive (ip, op)
|
|||
while (xp != ip->bufp)
|
||||
*cp++ = *xp++;
|
||||
/* Delete or replace the slash. */
|
||||
else if (traditional)
|
||||
else if (traditional || put_out_comments)
|
||||
cp--;
|
||||
else
|
||||
cp[-1] = ' ';
|
||||
|
@ -6208,6 +6211,20 @@ collect_expansion (buf, end, nargs, arglist)
|
|||
stringify = p;
|
||||
}
|
||||
break;
|
||||
case '/':
|
||||
if (expected_delimiter != '\0') /* No comments inside strings. */
|
||||
break;
|
||||
if (*p == '*') {
|
||||
while (p < limit) {
|
||||
*exp_p++ = *p++;
|
||||
if (p[0] == '*' && p[1] == '/') {
|
||||
*exp_p++ = *p++;
|
||||
*exp_p++ = *p++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* In -traditional mode, recognize arguments inside strings and
|
||||
|
@ -6240,11 +6257,22 @@ collect_expansion (buf, end, nargs, arglist)
|
|||
/* If we find a comment that wasn't removed by handle_directive,
|
||||
this must be -traditional. So replace the comment with
|
||||
nothing at all. */
|
||||
exp_p--;
|
||||
while (++p < limit) {
|
||||
if (p[0] == '*' && p[1] == '/') {
|
||||
p += 2;
|
||||
break;
|
||||
if (!put_out_comments) {
|
||||
exp_p--;
|
||||
while (++p < limit) {
|
||||
if (p[0] == '*' && p[1] == '/') {
|
||||
p += 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (p < limit) {
|
||||
*exp_p++ = *p++;
|
||||
if (p[0] == '*' && p[1] == '/') {
|
||||
*exp_p++ = *p++;
|
||||
*exp_p++ = *p++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
|
@ -7243,6 +7271,24 @@ eval_if_expression (buf, length)
|
|||
pcp_inside_if = 0;
|
||||
delete_macro (save_defined); /* clean up special symbol */
|
||||
|
||||
if (put_out_comments) {
|
||||
char *ptr, *eptr = temp_obuf.buf + temp_obuf.length;
|
||||
|
||||
for (ptr = temp_obuf.buf; ptr < eptr; ptr++) {
|
||||
if (*ptr == '/' && ptr + 1 < eptr && ptr[1] == '*') {
|
||||
*ptr++ = ' ';
|
||||
*ptr++ = ' ';
|
||||
while (ptr < eptr) {
|
||||
if (*ptr == '*' && ptr + 1 < eptr && ptr[1] == '/') {
|
||||
*ptr++ = ' ';
|
||||
*ptr++ = ' ';
|
||||
break;
|
||||
} else
|
||||
*ptr++ = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
temp_obuf.buf[temp_obuf.length] = '\n';
|
||||
value = parse_c_expression ((char *) temp_obuf.buf,
|
||||
warn_undef && !instack[indepth].system_header_p);
|
||||
|
|
Loading…
Reference in New Issue