If the comment spans for more than one line, then it will append all lines together to make it as a single line...
for example, if your program contains comment like
/** this is fist line
extended to next line
closed here **/
then the first section of sed script will convert it as single line
/** this is fist line extended to next line closed here **/
Then the last section of sed script will delete the anything in between /* and */
Here is how it works :
======================
example :
$more mah.txt
a
b
/*** this is a comment
extented to next line
and ends here ***/
c
d /** this is also comment **/
e
f
g
h
first line of sed script is "/\/\*/!b" - check for "/*" pattern in the line, if not found branch to the end of sed script, ie. don't do anything to the current line of input file and proceed to next line of input file... b denotes branch, hence there is no lable next to b, it will branch/go to the end of sed script
1st and 2nd line of input file (mah.txt) do not contain "/*", hence it won't do anything for the first two lines
now, the third line of input file contains "/*" ( "/*** this is a comment" ).. hence first line of the sed script fails, then go the next line in sed script and creates a lable :x ( you will use it later )...
next search for "*/" in the current line, if not found then append ( N in sed ) next line of the input file to current line ...
now 3rd and 4th line got appended as single line and now the current line contains "/*** this is a comment
extented to next line"
then branch/go to the lable x (ie bx in sed ).. it goes back to line :x in sed script
next line in the sed script again checks for "*/", if not found then append the next line again ( N in sed ), now along with 3rd and 4th line of input file, 5 line also will get appended... now the current line holds "/*** this is a commentextented to next lineand ends here ***/"
Next line in the sed script says brach/go back to lable x. Now again we are back to the lable :x, the next line sed script searchs for "*/", this time it matches and proceeds... and do a s/\/\*.*\*\/// which will delete the comment fully.
There is a good article on the net which explains in detail about the hold spaces, pattern spaces, branching etc..
http://www.grymoire.com/Unix/Sed.html