[net.lang.c] iscntrl

rcd@opus.UUCP (Dick Dunn) (01/17/85)

> > > iscntrl( c ) should return non-zero for c in
> > > { 0, 1, ..., 036, 037, 0177 } and zero for c in
> > > { 040, 041, ..., 0175, 0176 }.
> ...
> (Again, this is a matter of the C library, not of the compiler!)
> I confirmed that the 4.2BSD iscntrl() ctype macro is broken in the way
> previously described.  UNIX System V iscntrl() performs as I described
> and as, apparently, the DeSmet C88 and CI-C86 C systems do.

I remember complaining about the broken iscntrl() in 4.[12] some time ago;
it may have been in unix-wizards.  The response to "why did they do this?"
was mostly stunning silence.  We fixed our version (i.e., put it back to
the way the manual documents it, the way V7 and successors have it, and the
way ASCII defines control character).  There's no reason for a big stink--
but let's get it fixed before this stupidity becomes institutionalized.

> I wonder how ANYone could have decided that e.g. LF is NOT a control
> character?  (I'm sure the 4.2BSD fans will think that makes sense!)

Doug will be glad (?!) to know that one exception to my earlier complaints
came from a rabid Berkeleyphile who claimed that he had a 4.2 version that
"works just fine" but didn't bother to explain.  I'm sure that some 4.2BSD
fans know that LF is a control character!
-- 
Dick Dunn	{hao,ucbvax,allegra}!nbires!rcd		(303)444-5710 x3086
   ...A friend of the devil is a friend of mine.

rcd@opus.UUCP (Dick Dunn) (01/17/85)

> >I wonder how ANYone could have decided that e.g. LF is NOT a control
> >character?  (I'm sure the 4.2BSD fans will think that makes sense!)
> 
> This was already in the original v7 ctype.h...

NO, the mistake was not in the original v7 ctype.h (or, more precisely,
ctype_.c).  I was made painfully aware of the fact by a program which
broke when I moved from V7 to 4.1.

> When one first checks for 'isspace' and only then for 'iscntrl',
> everything goes well...

And if one checks iscntrl but not isspace, one is out of luck.  Pray tell,
what do I do if I want to know if variable `c' is a control character (by
standard definition of that term)?  Are you really suggesting that
	(iscntrl(c) || (isspace(c) && (c!=' '))
is reasonable?!
-- 
Dick Dunn	{hao,ucbvax,allegra}!nbires!rcd		(303)444-5710 x3086
   ...A friend of the devil is a friend of mine.

henry@utzoo.UUCP (Henry Spencer) (01/20/85)

> > >I wonder how ANYone could have decided that e.g. LF is NOT a control
> > >character?  (I'm sure the 4.2BSD fans will think that makes sense!)
> > 
> > This was already in the original v7 ctype.h...
> 
> NO, the mistake was not in the original v7 ctype.h (or, more precisely,
> ctype_.c).  I was made painfully aware of the fact by a program which
> broke when I moved from V7 to 4.1.

Strange...  Our V7 definitely thinks iscntrl('\n') == 0.  And ours is
pretty much straight off the Bell distribution tape; I did our V6-V7
conversion and can attest to this.  We've certainly never messed with
ctype_.c -- I just checked.  What was the history of your V7?
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry

cottrell@nbs-vms.ARPA (02/01/85)

/*
...just a wag...
maybe what they really meant was 'isweird()'. we all know what to do
with garden variety ctl chars such as bs, ht, lf, etc. the weird ones
are things like si, em, soh, etc. one could make a case that format
effectors are not really ctl chars, but I won't argue the point. sigh.
*/