Converting C++ comments to C comments 
Author Message
 Converting C++ comments to C comments

I am looking for a script, macro, whatever that will go through a bunch
of source files and convert all the C++ style comments (//) to C style
comments (/*  */).

Anyone know of such a beast?  UNIX or DOS solutions welcome.

Trevor.



Sun, 13 Jul 1997 08:32:33 GMT  
 Converting C++ comments to C comments

Quote:

> I am looking for a script, macro, whatever that will go through a bunch
> of source files and convert all the C++ style comments (//) to C style
> comments (/*  */).

See http://www.cs.helsinki.fi/~wirzeniu/misc/ccmtcnvt.art, if you have
WWW access, or the comp.sources.misc archives (e.g., on ftp.uu.net,
under pub/usenet, I think), volume 43, issue 45, for my progra
ccmtcnvt, which does exactly what you want.

--

Publib version 0.4: ftp://ftp.cs.helsinki.fi/pub/Software/Local/Publib/



Sun, 13 Jul 1997 15:00:00 GMT  
 Converting C++ comments to C comments

Quote:

>I am looking for a script, macro, whatever that will go through a bunch
>of source files and convert all the C++ style comments (//) to C style
>comments (/*  */).

If you have perl:

perl -p -e 's#//(.*)#/\*\1\*/#' <file>

where <file> is the C source file name.

--
Len Charest, Jr.                                =Speed=of=Lightning==>
JPL Artificial Intelligence Group                            



Mon, 14 Jul 1997 07:32:46 GMT  
 Converting C++ comments to C comments

Quote:

>I am looking for a script, macro, whatever that will go through a bunch
>of source files and convert all the C++ style comments (//) to C style
>comments (/*  */).

If you have Bob Stouts SNIPPETS, there is a file COMMCONV.C
(BTW, why are these comment converters coming from Finland ?-)



-----------------====================================



Mon, 14 Jul 1997 21:09:23 GMT  
 Converting C++ comments to C comments

Quote:

> I am looking for a script, macro, whatever that will go through a bunch
> of source files and convert all the C++ style comments (//) to C style
> comments (/*  */).
> Anyone know of such a beast?  UNIX or DOS solutions welcome.
> Trevor.

For vi, try something like this:

:1,$s;//\(.*\);/\*\1&\*/;

which if I got it right says search all lines for a text string
that begins with "//" and continues to the end of the line, and
replace the "//" with "/*", insert all the remaining characters, then
append a "*/" to the end of the line.

Fred
--
-------------------------------------------------------------------------------
"The locus of computing has clearly moved from  | Fred Smith        BIX: fredex

 painting of icons and the tracking of mouse    |          Home: 617-438-5471
 balls." Stan Kelly-Bootle, Unix Review, Feb '95|          Office: 508-663-2524
-------------------------------------------------------------------------------



Wed, 23 Jul 1997 06:47:12 GMT  
 Converting C++ comments to C comments
|> I am looking for a script, macro, whatever that will go through a bunch
|> of source files and convert all the C++ style comments (//) to C style
|> comments (/*  */).
|
|For vi, try something like this:
|
|:1,$s;//\(.*\);/\*\1&\*/;
|
|which if I got it right says search all lines for a text string
|that begins with "//" and continues to the end of the line, and
|replace the "//" with "/*", insert all the remaining characters, then
|append a "*/" to the end of the line.

It is not so simple.  What about situations like:

// Since this is C code, this should really be a /* ... */ comment.
/* Do not use // comments in C code. */
char cplusplus_comment_start[] = "//";

--
------------------------------------------------------------------------

No warranty of any kind is provided with this message.



Thu, 24 Jul 1997 04:39:25 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Change C++ comments to C-comments

2. changing C++ comments // to C comments /*

3. changing C++ comments // to C comments /*

4. Need comments on commenting program

5. Multi-Line Comments Nested in Single Line Comments

6. comments on comments

7. Newbie: separate big .cs file into small .cs files

8. C# type xml comments in C++?

9. Looking for a C/C++ comment formatting tool

10. C++ to C comment replacement

11. C# type xml comments in C++?

12. C/C++ macro to comment out a line

 

 
Powered by phpBB® Forum Software