Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 27 lines (24 sloc) 0.614 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#!/usr/bin/python
import sys

skip = int(sys.argv[1])
count = int(sys.argv[2])
sys.stdin.read(skip)

while True:
    r = sys.stdin.read(1)
    if not r:
        break
    n = ord(r[0])
    if n < 128:
        sys.stderr.write("COPY "+str(n+1)+"\n")
        sys.stdout.write(sys.stdin.read(n+1))
    elif n == 128:
        sys.stderr.write("SKIP\n")
        pass
    elif n < 256:
        count = (256-n) + 1
        sys.stderr.write("RPT "+str(count)+"\n")
        r = sys.stdin.read(1)
        for i in range(count):
            sys.stdout.write(r)
    else:
        sys.stderr.write("ERROR- VAL OUT OF RANGE\n")
Something went wrong with that request. Please try again.