CFLAGS=-O2 -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Wundef -Wredundant-decls -Winline $(DEBUG) -std=gnu99
CFLAGS+=-Wno-pointer-sign -Wdisabled-optimization -Wno-missing-field-initializers
-all: test-io test-tok judge-tok
+all: test-io test-tok judge-tok filter-cmt
JLIB=utils.o io.o token.o
test-io: test-io.o $(JLIB)
test-tok: test-tok.o $(JLIB)
judge-tok: judge-tok.o $(JLIB)
+filter-cmt: filter-cmt.o $(JLIB)
clean::
rm -f `find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core`
- rm -f test-io test-tok judge-tok
+ rm -f test-io test-tok judge-tok filter-cmt
.PHONY: all clean distclean
--- /dev/null
+/*
+ * A filter removing C++-style comments
+ *
+ * (c) 2007 Martin Mares <mj@ucw.cz>
+ */
+
+#include "judge.h"
+
+int main(void)
+{
+ struct stream *i = sopen_fd("stdin", 0);
+ struct stream *o = sopen_fd("stdout", 1);
+
+ int c, d, nl = 1;
+ c = sgetc(i);
+ for (;;)
+ {
+ if (c == '/')
+ {
+ if ((d = sgetc(i)) == '/')
+ {
+ // skipping a comment...
+ while ((c = sgetc(i)) >= 0 && c != '\n')
+ ;
+ if (nl)
+ continue;
+ }
+ else
+ {
+ sputc(o, c);
+ c = d;
+ }
+ }
+ if (c < 0)
+ break;
+ sputc(o, c);
+ nl = (c == '\n');
+ c = sgetc(i);
+ }
+
+ sclose(o);
+ sclose(i);
+ return 0;
+}