-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSTRINGS.C
87 lines (73 loc) · 1.44 KB
/
STRINGS.C
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
extern char ctp_[];
isalpha(x) { return x > 128 ? 0 : (ctp_[(x)+1]&0x03); }
isupper(x) { return x > 128 ? 0 : (ctp_[(x)+1]&0x01); }
islower(x) { return x > 128 ? 0 : (ctp_[(x)+1]&0x02); }
isdigit(x) { return x > 128 ? 0 : (ctp_[(x)+1]&0x04); }
isspace(x) { return x > 128 ? 0 : (ctp_[(x)+1]&0x10); }
isprint(x) { return x > 128 ? 0 : (ctp_[(x)+1]&0xc7); }
toascii(x)
{
return (x&127);
}
toupper(chr)
char chr;
{
return(islower(chr)?((chr)-('a'-'A')):(chr));
}
tolower(chr)
char chr;
{
return(isupper(chr)?((chr)+('a'-'A')):(chr));
}
stccpy(s1,s2,count)
char *s1, *s2;
int count;
{
while (count-->0 && *s2)
*s1++ = *s2++;
*s1 = 0;
/*
* lets return the address of the end of the string so
* we can use that info if we are going to cat on something else!!
*/
return (s1);
}
/*
* redo Lattice token parsing routines
*/
char *
stpblk(str)
char *str;
{
while (isspace(*str))
str++;
return(str);
}
stpbrk(str,brk)
char *str,*brk;
{
while(*str && !index(brk,*str))
str++;
return(*str ? str : 0);
}
/*
* remove trailing whitespace from the end of a line
*/
endblk(str)
char *str;
{
register char *backup;
backup = str + strlen(str);
while (backup != str && isspace(*(--backup)))
*backup = 0;
return(str);
}
/*
* lcase: convert a string to lower case
*/
lcase(str)
char *str;
{
while ( *str = tolower(*str) )
str++;
}