Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!vaxine!wjh12!genrad!decvax!harpo!ihnp4!zehntel!hplabs!sri-unix!mogul@Su-Coyote.ARPA From: mogul@Su-Coyote.ARPA Newsgroups: net.unix-wizards Subject: Pascal doesn't like mixed-case keywords Message-ID: <12064@sri-arpa.UUCP> Date: Fri, 6-Apr-84 21:58:25 EST Article-I.D.: sri-arpa.12064 Posted: Fri Apr 6 21:58:25 1984 Date-Received: Tue, 10-Apr-84 07:37:16 EST Lines: 97 From: Jeff Mogul Description: Unless run in "standard" (-s) mode, the Berkeley Pascal language processors (pi, pc, pxp) demand lower-case-only keywords. In standard mode, case in the source files is ignored. This leads to a dilemma for people trying to compile code written originally for other compilers, since if they want to use any extensions, they cannot use standard mode. Repeat-By: Try running this program through pi, pc, or pxp (don't use -s): PROGRAM Test(output); BEGIN writeln('hello') END. Fix: Since this is, in effect, a change to the Berkeley Pascal language, you might want to think twice about installing it; someone you know might have been stupid enough to write a Pascal program with identifiers that look like keywords, except for case. Otherwise, this fix makes sense: it converts a private copy of each token to lower case when looking up keywords. Line numbers are for comparison only; your actual line numbers may vary. *** hash.c.old Mon Jan 10 10:32:53 1983 --- hash.c Fri Apr 6 16:32:11 1984 *************** *** 117,122 int *sym; struct ht *htp; int sh; /* * The hash function is a modular hash of --- 124,131 ----- int *sym; struct ht *htp; int sh; + static char lc_buf[sizeof(token)]; /* for lower-case-ifying */ + register char *lc_bp = lc_buf; /* * The hash function is a modular hash of *************** *** 128,135 if (cp == NIL) cp = token; /* default symbol to be hashed */ i = 0; ! while (*cp) ! i = i*2 + *cp++; sh = (i&077777) % HASHINC; cp = s; if (cp == NIL) --- 137,149 ----- if (cp == NIL) cp = token; /* default symbol to be hashed */ i = 0; ! while (*cp) { ! register int c_tmp = *cp++; ! if (isupper(c_tmp)) /* all keywords are lower-case */ ! c_tmp = tolower(c_tmp); ! *lc_bp++ = c_tmp; /* construct a lower-case copy */ ! i = i*2 + c_tmp; ! } sh = (i&077777) % HASHINC; *lc_bp = 0; cp = lc_buf; *************** *** 131,139 while (*cp) i = i*2 + *cp++; sh = (i&077777) % HASHINC; ! cp = s; ! if (cp == NIL) ! cp = token; /* * There are as many as MAXHASH active * hash tables at any given point in time. --- 145,152 ----- i = i*2 + c_tmp; } sh = (i&077777) % HASHINC; ! *lc_bp = 0; ! cp = lc_buf; /* * There are as many as MAXHASH active * hash tables at any given point in time.