lfoard@wpi.wpi.edu (Lawrence C Foard) (03/24/89)
oops. It appears that the original posting had a bug /** **/ blew up here is a fixed version. Why is this program better than LEX?? Because it is free there are still some people who use PC and buy there own software. --------------Cut here--------------- /* Public domain C comment stripper created by Lawrence Foard */ /* version 2 */ #include <stdio.h> char *a="/* this is a test 'of the emergency \" comment stripper \\ \'*/"; /* this is a'nasty\' "comment" meant / * to really confuse it"*//*\*/ int no_com() { int c; static int quote=0,squote=0,slash=0; c=getc(stdin); if (slash || (c=='\\')) { slash=!slash; return(c); } if ((quote^=((c=='"') && !squote)) || (squote^=((c=='\''/*\ and right here two \*/) && !quote))) return(c); if (c=='/') if ((c=getc(stdin))!='*') { ungetc(c,stdin); return('/'); } else { c=0; do { ungetc(c,stdin); while(getc(stdin)!='*'); } while((c=getc(stdin))!='/'); return(no_com()); } return(c); } main() { int c; while((c=no_com())!=EOF) fputc(c,stdout); } -- Disclaimer: My school does not share my views about FORTRAN. FORTRAN does not share my views about my school.