From a150899221a5badff9740703b754f901b4f52762 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Thu, 14 Apr 2011 17:27:24 +0000 Subject: fill /acme --- acme/bin/source/spout.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 acme/bin/source/spout.c (limited to 'acme/bin/source/spout.c') diff --git a/acme/bin/source/spout.c b/acme/bin/source/spout.c new file mode 100644 index 000000000..02429785a --- /dev/null +++ b/acme/bin/source/spout.c @@ -0,0 +1,123 @@ +#include +#include +#include +#include + +void spout(int, char*); + +Biobuf bout; + +void +main(int argc, char *argv[]) +{ + int i, fd; + + Binit(&bout, 1, OWRITE); + if(argc == 1) + spout(0, ""); + else + for(i=1; i' '; c++){ + n++; + s++; + } + inword = 0; + w = s; + t = s; + do{ + c = *(uchar*)t; + if(c < Runeself) + wid = 1; + else{ + wid = chartorune(&r, t); + c = r; + } + wordchar = 0; + if(isalpha(c)) + wordchar = 1; + if(inword && !wordchar){ + if(c=='\'' && isalpha(t[1])) + goto Continue; + m = t-w; + if(m > 1){ + memmove(buf, w, m); + buf[m] = 0; + Bprint(&bout, "%s:#%d,#%d:%s\n", name, wn, n, buf); + } + inword = 0; + }else if(!inword && wordchar){ + wn = n; + w = t; + inword = 1; + } + if(c=='\\' && (isalpha(t[1]) || t[1]=='(')){ + switch(t[1]){ + case '(': + m = 4; + break; + case 'f': + if(t[2] == '(') + m = 5; + else + m = 3; + break; + case 's': + if(t[2] == '+' || t[2]=='-'){ + if(t[3] == '(') + m = 6; + else + m = 4; + }else{ + if(t[2] == '(') + m = 5; + else if(t[2]=='1' || t[2]=='2' || t[2]=='3') + m = 4; + else + m = 3; + } + break; + default: + m = 2; + } + while(m-- > 0){ + if(*t == '\n') + break; + n++; + t++; + } + continue; + } + Continue: + n++; + t += wid; + }while(c != '\n'); + } + Bterm(&b); +} -- cgit v1.2.3