VI bug

Karl Heuer karl at haddock.ISC.COM
Wed Mar 2 11:34:09 AEST 1988


In article <1027 at sauron.Columbia.NCR.COM> wescott at sauron.Columbia.NCR.COM (Mike Wescott) writes:
>[vi uses isdigit() on an out-of-band value]
>Did isdigit() once have range checking built in?  Or was it a version
>called _isdigit()?

Not that I know of.  But a simple fix is
  #define isdigit(c) ((unsigned)((c)-'0') < (unsigned)10)
which will work if the digits are contiguous.  (This is true of every
character set I'm familiar with, and required by ANSI C.)

(I prefer to use such macros rather than <ctype.h>, because many systems still
implement the latter with a 128-character range, and I like my software to
work even when you hand it 8-bit data.)

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.bugs.4bsd.ucb-fixes mailing list