[5639] in Athena Bugs

home help back first fref pref prev next nref lref last post

vax 7.0F: ctype.h

daemon@ATHENA.MIT.EDU (deevans@ATHENA.MIT.EDU)
Tue Jul 31 11:33:13 1990

From: deevans@ATHENA.MIT.EDU
To: bugs@ATHENA.MIT.EDU
Date: Tue, 31 Jul 90 11:32:51 EDT

System name:		ROBERT-SILVERBERG
Type and version:	CVAXSTAR 7.0F
Display type:		SM

It is my impression that the function
	int tolower(int c)
does not behave as specified, at least by K&R.  From K&R, p. 249 (2nd
ed.):
	``If c is an upper-case letter, tolower(c) returns the
	corresponding lower-case letter; otherwise it returns c.''

In fact, using cc on athena this does not seem to be the case.

I compile the following simple test program:

#include <string.h>
#include <stdio.h>
#include <ctype.h>

static char c[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$12345";
main()
{
  int i;

  for (i=0; c[i] != '\0'; i++) {
    printf("%c --> %c\n",c[i],tolower(c[i]));
  }

}

The compiled run generates:

A --> a
B --> b
C --> c
D --> d
E --> e
F --> f
G --> g
H --> h
I --> i
J --> j
K --> k
L --> l
M --> m
N --> n
O --> o
P --> p
Q --> q
R --> r
S --> s
T --> t
U --> u
V --> v
W --> w
X --> x
Y --> y
Z --> z
a -->
b -->
c -->
d -->
e -->
f -->
g -->
h -->
i -->
j -->

k -->

l -->

m -->
n -->
o -->
p -->
q -->
r -->
s -->
t -->
u -->
v -->
w -->
x -->
y -->
z -->
! --> A
@ --> `
# --> C
$ --> D
1 --> Q
2 --> R
3 --> S
4 --> T
5 --> U

It seems to be categorically subtracting the appropriate acsii value
from its argument regardless of wether it is an uppercase letter to
begin with.  Is this a bug or am I missing something?

Please describe any relevant documentation references:

K&R, Second Edition, p. 249.

man ctype:

     tolower        c is converted to lower case.  Return value
                    is undefined if not isupper(c).

(Well, I guess it does satisfy the "is undefined" return value spec.
Should have checked here first.  Does this mean athena c does not
conform to K&R????)

home help back first fref pref prev next nref lref last post