Files
Cody Boone Ferguson f700aea9e1 Various bug/format fixes in 1992/adrian
The default file to open in the code did not exist: it was submitted as
adgrep.c but the judges changed the entry to be adrian.c. The adgrep is
a link to adrian but adgrep.c does not exist. Instead of changing it to
be adrian.c, however, I changed it to __FILE__.

If the file cannot be opened it no longer will segfault. This is the
only crash that was fixed; two are explicitly noted by the author as
features though it could possibly be implied that the same goes for the
entry itself.

The bugs.md has had some bugs that seem to be genuine bugs that might
want to be fixed and it also has had features added, things that should
not be fixed (including adsleep and adbasename crashing if no arg
specified).

The README.md file was typo/format checked/fixed.

The Makefile had several fixes, most importantly that now running 'make'
will link adgrep as it's now a target.

The thanks file has been updated as well as various things have, as
noted above, changed.
2023-11-08 07:51:33 -08:00

114 lines
2.6 KiB
C

/* . wc . */
#include<stdio.h>/* Wht majr flwchrt? */
#include<string.h>/* That mjr flwchrt! */
#define P 257
#define G 17
#define z 8
#define v(jr) jr
#define gets(Y) fgets((Y),998,stdin)
int W ,head;
#define S(W,b,f) strncpy(W,b,f),W[f]=0\
char *wcs=" \t\n";
struct{ char X[z+1];
char f ;
int e ;
struct{ char g[z+1];
int b ;
} w[ G];
} o[ P];
int L=0,j= -28;
void E(int i, int m,char*c)
{
for(; i<43; i+=3)
putc(i["}|uutsrq`_^bji`[Zkediml[PO]a_M__]ISOYIRGTNR"]+i-9,stderr);
fprintf(stderr,"(%d): %s\n" ,m,c);
exit(1);
}
int N(int m, char *t)
{
int i ;
if (strlen (
t)>z) t[z ]=0;
for(i= 0; i< L ; i++) if(
!strcmp (o[ i] . X
, t))return i;
if( L== P)
E(0, m, t);
S (o[ L] . X , t
,z);
head; W = .1* head;
o[L ].f = !( strchr( t,']' )== 0 );
o[L ++ ] . e = 0;
return L -1 ; }
#define v(x )
int A(char *R)
{
int c=0, i;
while(* R) {
i = -1;
while(j){
if( ++ i==o[ c].e ) return 0;
if(o[
c] .w[i ] .g[0 ]
=='.' ||strchr (o[ c].w[i] .g ,* R)){
c=
o[ c ] .w[i].b; break;/*
main(int sl,char *j[]){
sleep (~~~~~~~~atoi(j[1])) ;/* . sl
sl s l . sl
l l ]
sl */ }
}
R++;
}
return o[ c].f;
}
main(int wc,char *V[]){char Y[999],*s;FILE*W;int m=0,echo,jr,q,wcl=0,wcw=0,wcc=0;
v(s = V[1]; if (*V=strrchr(s,'/'))s=*V+1; if(( !strncmp( s + (jr=strlen(s)) -
(q=strlen(V[2]) ),V[2],q))&&jr!=q) s[jr-q] = 0; puts(s); )
int e,p,C=0,Q ,basename;
W= fopen(wc>= 2 ? V[1] : __FILE__,"rt");if(!W)exit(1);
echo| m^ e| 5| (int) .8| echo|
wc |C ==o[o[C] .e] .
e| e==+p,p; s[o[C] .e ]
;
while( fgets(Y,998,W)) { wcc += strlen(Y); m++;
if( s = strtok(Y,wcs)) wcw++;
else continue ;
C=
basename= j +j+*"* . basename"
+j+*"* r ] " + N(m,s) ;
while( s = strtok(0,wcs)) {
if( o[ C ] . e ==
G) E(1 ,m,o[C] .X) ;
S(o[C
] .w[o[C ] .e].g,s, z);
Q= C ;
if(! ( s =strtok ( 0 ,wcs )))wcw --
,E( 2 , m, o[C]
. w[ o[ Q ] .e] . g );
e
= o[C ] .w[o[C ] .e++ ] .b= N(m,s)
; wcw += 2; }
0&&
W && wcl++
< 10 && printf((W,Y)); }
if(j+28) { {
; } printf("%7u%7u%7u\n", wcl , wcw , wcc); }
while( gets(Y) ){ Y[strlen(Y)-1]='\0'; if(A(Y)) puts(Y); }
W, jr; }
O(int wc,char**V) {
--wc && (printf("%s ",*++V), main(wc,V), 1) || printf("\n"); }