[Assorted-commits] SF.net SVN: assorted:[1454] sandbox/trunk/src/one-off-scripts
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-06-19 09:53:38
|
Revision: 1454 http://assorted.svn.sourceforge.net/assorted/?rev=1454&view=rev Author: yangzhang Date: 2009-06-19 09:53:33 +0000 (Fri, 19 Jun 2009) Log Message: ----------- added findreps script Added Paths: ----------- sandbox/trunk/src/one-off-scripts/find-reps/ sandbox/trunk/src/one-off-scripts/find-reps/Makefile sandbox/trunk/src/one-off-scripts/find-reps/findreps.cc Added: sandbox/trunk/src/one-off-scripts/find-reps/Makefile =================================================================== --- sandbox/trunk/src/one-off-scripts/find-reps/Makefile (rev 0) +++ sandbox/trunk/src/one-off-scripts/find-reps/Makefile 2009-06-19 09:53:33 UTC (rev 1454) @@ -0,0 +1,2 @@ +CXXFLAGS = -Wall +all: findreps Added: sandbox/trunk/src/one-off-scripts/find-reps/findreps.cc =================================================================== --- sandbox/trunk/src/one-off-scripts/find-reps/findreps.cc (rev 0) +++ sandbox/trunk/src/one-off-scripts/find-reps/findreps.cc 2009-06-19 09:53:33 UTC (rev 1454) @@ -0,0 +1,26 @@ +#include <cstdio> +#include <unistd.h> +using namespace std; +enum { size = 4096 }; +int main() { + char buf[size]; + int counter = 0, charno = 0; + bool started = false; + while (true) { + ssize_t r = read(0, buf, size); + if (r < 0) { perror("read"); break; } + if (r == 0) { break; } + for (int i = 0; i < size; ++i, ++charno) { + if (buf[i] == 'a') { + ++counter; + started = true; + } else { + if (started && counter > 1024) + printf("charno %d counter %d\n", charno, counter); + counter = 0; + started = false; + } + } + } + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |