Hi Everyone,

I noticed that /usr/games/caesar uses atoi() in order to parse the rotation
argument. I thought that it would be better if this used strtonum(), so
I've submitted a diff that changes this. It also changes the rotation
bounds check in the printit() function, and brings it into the argument
parsing portion of the main() code.

I wasn't sure if this is a worthwhile change, but it seems to clean up the
code a bit!

Thanks for your time,
Peter
Index: caesar.c
===================================================================
RCS file: /cvs/src/games/caesar/caesar.c,v
retrieving revision 1.18
diff -r1.18 caesar.c
73a74
>       const char *errstr;     
85c86
<               if ((i = atoi(argv[1])))
---
>               if ((i = strtonum(argv[1], 0, 25, &errstr)))
86a88,89
>               else if (errstr != NULL && errno == ERANGE)
>                       errx(1, "bad rotation value");  
139,141d141
< 
<       if ((rot < 0) || ( rot >= 26))
<               errx(1, "bad rotation value");

Reply via email to