diff options
Diffstat (limited to 'doc/progs/cat_rot13.go')
-rw-r--r-- | doc/progs/cat_rot13.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/doc/progs/cat_rot13.go b/doc/progs/cat_rot13.go index 42c6195fb..03fc02259 100644 --- a/doc/progs/cat_rot13.go +++ b/doc/progs/cat_rot13.go @@ -15,10 +15,10 @@ var rot13Flag = flag.Bool("rot13", false, "rot13 the input") func rot13(b byte) byte { if 'a' <= b && b <= 'z' { - b = 'a' + ((b - 'a') + 13) % 26 + b = 'a' + ((b-'a')+13)%26 } if 'A' <= b && b <= 'Z' { - b = 'A' + ((b - 'A') + 13) % 26 + b = 'A' + ((b-'A')+13)%26 } return b } @@ -29,7 +29,7 @@ type reader interface { } type rotate13 struct { - source reader + source reader } func newRotate13(source reader) *rotate13 { @@ -57,11 +57,11 @@ func cat(r reader) { r = newRotate13(r) } for { - switch nr, er := r.Read(&buf); { + switch nr, er := r.Read(buf[:]); { case nr < 0: fmt.Fprintf(os.Stderr, "cat: error reading from %s: %s\n", r.String(), er.String()) os.Exit(1) - case nr == 0: // EOF + case nr == 0: // EOF return case nr > 0: nw, ew := file.Stdout.Write(buf[0:nr]) @@ -73,7 +73,7 @@ func cat(r reader) { } func main() { - flag.Parse() // Scans the arg list and sets up flags + flag.Parse() // Scans the arg list and sets up flags if flag.NArg() == 0 { cat(file.Stdin) } |