Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/gnu/dist/toolchain/gcc Add the LINTCOMMENT hack, uncondition...
details: https://anonhg.NetBSD.org/src/rev/e7e4fe7ada38
branches: trunk
changeset: 513789:e7e4fe7ada38
user: tv <tv%NetBSD.org@localhost>
date: Tue Aug 14 01:13:34 2001 +0000
description:
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.
diffstat:
gnu/dist/toolchain/gcc/cccp.c | 66 ++++++++++++++++++++++++++++++++++++------
1 files changed, 56 insertions(+), 10 deletions(-)
diffs (125 lines):
diff -r 60eb559fc292 -r e7e4fe7ada38 gnu/dist/toolchain/gcc/cccp.c
--- a/gnu/dist/toolchain/gcc/cccp.c Tue Aug 14 01:09:33 2001 +0000
+++ b/gnu/dist/toolchain/gcc/cccp.c Tue Aug 14 01:13:34 2001 +0000
@@ -2779,7 +2779,8 @@
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 @@
++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 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
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);
Home |
Main Index |
Thread Index |
Old Index