/* column.tc - tct - 3/6-8/17 */ /* reads in linefeed delimited text files and outputs a file that */ /* has the same lines but with the leading 7 characters removed. motivated */ /* by my interest in removing the line numbers from the output of the */ /* history command under linux and the fact that the editor I use can't */ /* do column op's */ /* utility function: split the character string s, putting the addresses */ /* of the beginnings of each string into the integer array t */ /* look for where to split w/ the character string d */ split int t(0);char s(0),d(0) [ int y,ix,tx,sl,ds ds=strlen(d);t(0)=s;sl=strlen(s) while (sl-tx) [ ix=index(s+tx,sl-tx,d,ds) tx=tx+ix+ds-1;t(++y)=s+tx;s(tx-ds)=0 ] return y ] column char fn(20),fo(20) [ char text(15000),foo(15000),lf(2),dqt,comma int ta(1000),nl,i lf(0)=10;dqt=34;comma=44 pl "column.tc - tct - 3/8/17" pl "Usage: column " putchar dqt;ps "filein";putchar dqt putchar comma putchar dqt;ps "fileout";putchar dqt /* read the input file into the character string text */ readfile(fn,text,text+14999,1) /* split the text into pieces via its linefeeds, putting the addresses */ /* of the pieces into the integer array ta */ nl=split(ta,text,lf) while (i=7) strcat(foo,ta(i)+7) strcat(foo,lf);++i ] /* write the output file you've built */ writefile(fo,foo,foo+strlen(foo)-1,1);pl "" ]