#-h- cprsym 213 asc 07-may-80 15:35:30 # symbols for compress and expand tools # put on a file called 'cprsym' # Used only by compress and expand #must have RCODE > MAXCHUNK or RCODE = 0 define(MAXCHUNK,124) define(RCODE,125) define(THRESH,4) #-h- expand.r 1406 asc 07-may-80 15:35:31 #-h- main 310 asc 07-may-80 15:35:22 #--------------------------------------------------------------------- # include symbol definitions # include symbols include cprsym #--------------------------------------------------------------------- ## main - driver for expand tool # call initr4 # call expand # call endr4 # end #-h- expands 499 asc 07-may-80 15:35:23 ## expand - uncompress input files # subroutine expand subroutine main character buf(MAXLINE) integer getarg, open integer i for (i=1; getarg(i, buf, MAXLINE) != EOF; i=i+1) { if (buf(1) == QMARK & buf(2) == EOS) call error('usage: expand [file ...].') else if (buf(1) == MINUS & buf(2) == EOS) int = STDIN else { int = open(buf,READ) if (int == ERR) call cant(buf) } call xpd (int) if (int != STDIN) call close(int) } if (i == 1) call xpd(STDIN) return end #-h- xpd 450 asc 07-may-80 15:35:24 ## xpd - uncompress file -int- subroutine xpd (int) character getch character c, code while(getch(code,int) != EOF) if (code == RCODE) #expand repetition { if (getch(c,int) == EOF) break if (getch(code,int) == EOF) break for (; code >0; code = code - 1) call putc(c) } else { for (; code > 0; code = code - 1) { if (getch(c,int) == EOF) break call putc(c) } if (c == EOF) break } return end