Hi,
the attached diff makes caesar(1) to accept negative arguments, so one
may type:
$ echo IBM | caesar -1
HAL
$ echo HAL | caesar 1
IBM
$ echo IBM | caesar -1 | caesar 1
IBM
Maybe this is more expected then just
$ echo IBM | caesar 25
HAL
Regards
Dieter
Index: caesar.c
===================================================================
RCS file: /cvs/src/games/caesar/caesar.c,v
retrieving revision 1.13
diff -u -p -r1.13 caesar.c
--- caesar.c 9 Jul 2004 15:59:26 -0000 1.13
+++ caesar.c 25 Oct 2008 17:39:39 -0000
@@ -150,9 +150,12 @@ printit(int rot)
{
int ch;
- if ((rot < 0) || ( rot >= 26))
+ if ((rot < -25) || ( rot >= 26))
errx(1, "bad rotation value");
+ if ( rot < 0 )
+ rot += 26;
+
while ((ch = getchar()) != EOF)
putchar(ROTATE(ch, rot));
exit(0);