1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
include <ctype.h>
# IO_LINEID - Get the line identification string from input line and advance
# pointer to next non-white character. Convert matching string to uppercase,
# and keep characters in the [A..Z, 0..9] set, but return both the original
# and compressed matching strings. The first one is intended for output to
# the user, and the second for internal use to avoid typos.
int procedure io_lineid (line, ip, uid, cid, maxch)
char line[ARB] # input line
int ip # input pointer
char uid[ARB] # user's (original) line identification string
char cid[ARB] # compressed line identification string
int maxch # output chars
int i, op
begin
# Discard the leading whitespaces.
while (IS_WHITE (line[ip]) && line[ip] != EOS)
ip = ip + 1
# Get the line identifier.
for (op = 1; !IS_WHITE (line[ip]) && line[ip] != EOS && op <= maxch;
op = op + 1) {
uid[op] = line[ip]
ip = ip + 1
}
uid[op] = EOS
# Copy the orignal identifier into the compressed identifier,
# and convert the latter to upper case.
call strcpy (uid, cid, maxch)
call strupr (cid)
# Take out all characters not belonging to the [A-Z,0-9,+,-,_] set.
op = 1
for (i = 1; cid[i] != EOS; i = i + 1) {
if (IS_UPPER (cid[i]) || IS_DIGIT (cid[i]) || (cid[i] == '+') ||
(cid[i] == '-') || (cid[i] == '_')) {
cid[op] = cid[i]
op = op + 1
}
}
cid[op] = EOS
# Return number of characters in compressed identifier
return (op - 1)
end
|