removed. This is recommended for comparing C code; it prevents the
comparison from being fooled by differences in indent style.</para>
-<para>The <option>-r</option> option removes comments. This is
-only effective in conjunction with <option>-C</option>.</para>
+<para>The <option>-r</option> option removes comments. This is only
+effective in conjunction with <option>-C</option>. All // comments,
+but only "winged" /* comments with the start and end of comment on the
+same line are ignored. Block /* comments are retained, but the
+beginning /* and ending */ are ignored, </para>
<para>The <option>-x</option> enables some debugging output. It
is for developers; if you need to understand it, read the code.</para>
{
if (remove_comments && remove_braces) /* remove_c_comments */
{
- char *start = strstr(buf, "/*"), *end = strstr(buf, "*/");
+ char *ss = strstr(buf, "//");
- if (start && end && start < end)
- strcpy(start, end+2);
+ if (ss)
+ *ss = '\0';
+ else
+ {
+ char *start = strstr(buf, "/*"), *end = strstr(buf, "*/");
+
+ if (start && end && start < end)
+ strcpy(start, end+2);
+ else if (start && !end)
+ *start = '\0';
+ else if (end && !start)
+ *end = '\0';
+ }
}
if (remove_whitespace) /* strip whitespace, ignore blank lines */
{