From db2eb89b4986cac249a7faca95ae9ab7f0857b29 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 27 Jul 2010 15:09:51 +0000 Subject: [PATCH] Patch level : Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/branches/R_10_00@20703 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- projects/fastrip.cpp | 57 +++++++++++++ projects/fastrip.vcproj | 181 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 238 insertions(+) create mode 100755 projects/fastrip.cpp create mode 100755 projects/fastrip.vcproj diff --git a/projects/fastrip.cpp b/projects/fastrip.cpp new file mode 100755 index 000000000..83770cf5f --- /dev/null +++ b/projects/fastrip.cpp @@ -0,0 +1,57 @@ +#include +#include +#include + + +void strip(FILE * i, FILE * o) +{ + char lin[513]; + + while (fgets(lin, 512, i) != NULL) + { + char * c = lin; + for(; isspace(*c); c++); // salta spazi iniziali + + char instring = '\0'; + char wasspace = 0; + + for (; *c; c++) + { + if (*c == '/' && *(c+1) == '/') break; + + if (*c == '#') + { + fputc(*c, o); + while (isspace(*(++c))); + } + if (*c == '"' || *c == '\'') + { + if (instring == *c) instring = '\0'; + else + if (instring == '\0') instring = *c; + } + + if (isspace(*c)) + { + if (!instring) + { + if (wasspace) continue; + wasspace = 1; + } + } else wasspace = 0; + + fputc(*c, o); + } + } +} + + +int main(int argc, char ** argv) +{ +// cerr << "Strip 0.93 - White spaces filter by Guy '93" << endl; + FILE * i = argc > 1 ? fopen(argv[1], "r") : stdin; + FILE * o = argc > 2 ? fopen(argv[2], "w") : stdout; + + strip(i, o); + return 0; +} diff --git a/projects/fastrip.vcproj b/projects/fastrip.vcproj new file mode 100755 index 000000000..4ec1f76e5 --- /dev/null +++ b/projects/fastrip.vcproj @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +