forked from dungeons-of-moria/icmoria
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pascal.c
89 lines (72 loc) · 1.87 KB
/
pascal.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
88
89
/* pascal.c */
/* code to help port pascal */
#include "imoria.h"
//////////////////////////////////////////////////////////////////////
void writeln(char *out_line)
{
printf("%s\n\r",out_line);
};
//////////////////////////////////////////////////////////////////////
integer pindex(char *s1, char c1)
{
/*
pascal index function, return position of c1 in s1
returns i if (s1[i-1] == c1), returns 0 if c1 not found
*/
char *c2;
c2 = strchr(s1, c1);
if (c2 == NULL) {
return 0;
}
return (c2 - s1 + 1);
};
//////////////////////////////////////////////////////////////////////
boolean is_in(integer obj, obj_set oset)
{
integer i1, tmp;
boolean return_value = false;
// ENTER("is_in","m");
#if DO_DEBUG
tmp = 0;
for (i1=0; i1 < MAX_OBJ_SET; i1++) {
if ((tmp > oset[i1]) && (oset[i1] > 0)) {
printf("bad obj_set i1 = %ld\n\r", i1);
fprintf(debug_file,"bad obj_set: %d",oset[i1]);
for (i1=0; i1 < MAX_OBJ_SET; i1++) {
fprintf(debug_file,"%d ",oset[i1]);
}
fprintf(debug_file,"\n");
exit (0);
}
tmp = oset[i1];
}
#endif
tmp = 0;
for (i1=0;(i1<MAX_OBJ_SET)&&(oset[i1]<=obj)&&(!return_value); i1++) {
/*for (i1=0;(i1<MAX_OBJ_SET) && (!return_value); i1++) {*/
if (obj == oset[i1]) {
return_value = true;
}
}
// RETURN("is_in","m",'b',"isin",&return_value);
return return_value;
};
//////////////////////////////////////////////////////////////////////
boolean is_vowel(char a_char)
{
switch (a_char) {
case 'a': case 'A':
case 'e': case 'E':
case 'i': case 'I':
case 'o': case 'O':
case 'u': case 'U':
return true;
break;
default:
return false;
break;
}
};
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/* END FILE pascal.c */