[auton-users] New gcc problems
Shang-Shan Chong
chong2 at andrew.cmu.edu
Mon Jul 22 18:43:08 EDT 2002
On Mon, Jul 22, 2002 at 06:17:27PM -0400, chong2 at andrew.cmu.edu wrote:
>
> On Mon, Jul 22, 2002 at 05:47:37PM -0400, Andrew W. Moore wrote:
> > Okay, I am convinced by Dan...we should also disallow // comment chars.
> > So my vote is in favor of setting the default to pedantic mode.
> >
> > Does anyone have the ability to write an ingenious script to automatically
> > turn all the current //'s into /* .. */'s?
> >
> > Andrew
>
> Hi,
>
> I'm normally a silent observer here, but the following perl script
> should do the trick, since // are single line comments but /* */'s are
> multi-line. It's a code fragment from something I've done before.
>
> #!/usr/bin/perl
> while (<>) {
> s/\/\/(.*)$/\/\*\1\*\//g;
> print;
> }
After seeing Dan's comment, I realize that even http://... stuff would
be changed, so the previous regexp is no good.
This is the new regexp, which relies on the fact that stuff in
comments should not be matched.
#!/usr/bin/perl
while (<>) {
s/^(.+?)\/\/(.*)$/\1\/\*\2\*\//;
print;
}
It still does not fix anything inside existing /* */'s, but should be
fine for fixing code with only // as comments.
css.
--
Shang-Shan CHONG Dept of Physics, Carnegie Mellon University
office: Wean Hall 8419 tel: (412) 268-4206 email: chongss+ at cmu.edu
More information about the Autonlab-users
mailing list