/* rmccmt2.c MR Jun 2001
   Replace C-style comment by white space;
   keep everything on same lines and columns as in input file.
*/ 

#include <stdio.h>

main()
	{
	int ic = 0x00; 
	int icpr = 0x00; 
	int state = 0; 
	   /* state values:  
	       0 = Outside comment
	       1 = After 1st '/' of possible starting comment delimiter 
	       2 = Inside comment   
	       3 = After 1st '*' of possible ending comment delimiter
	   */
                           
	while ( icpr = ic, ( ic = getchar() ) != EOF )
		{
		switch ( state )
			{
		case 0:
			if ( ic == '/' ) { state = 1; }
			else { putchar( ic ); }
		break;
		case 1:
			if ( ic == '*' ) 
				{ 
				putchar( ' ' );
				putchar( ' ' );
				state = 2; 
				}
			else 
				{ 
				putchar( icpr ); /* The deceptive '/'  */
				putchar( ic );   /* The non-'*'        */
				state = 0; 
				}
		break;
		case 2:
			if ( ic == '*' ) { state = 3; }
			else 
				{ 
				putchar( ic == '\n' ? '\n' : ' ' );
				// Remain in same state
				}
		break;
		case 3:
			if ( ic == '/' ) 
				{ 
				putchar( ' ' );
				putchar( ' ' );
				state = 0; 
				}
			else 
				{ 
				putchar( ' ' );
				state = 2; 
				}
		break;
			}/*switch*/
		}/*while*/

	if ( state == 1 ) 
		{ 
		putchar( icpr ); /* Print deceptive '/' (=last char in file) */
		}

	return 0;
	}
