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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
const DELIM: &[u8] = b" /,=:";
const DQUOTE: &[u8] = b"\"";
//$Procedure ZZLEXMET ( Scan method string )
pub fn ZZLEXMET(
METHOD: &[u8],
MAXN: i32,
N: &mut i32,
BEGS: &mut [i32],
ENDS: &mut [i32],
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let mut BEGS = DummyArrayMut::new(BEGS, 1..);
let mut ENDS = DummyArrayMut::new(ENDS, 1..);
let mut B: i32 = 0;
let mut E: i32 = 0;
let mut EQ: i32 = 0;
let mut I: i32 = 0;
let mut LOC: i32 = 0;
let mut NCHAR: i32 = 0;
let mut QPOS: i32 = 0;
let mut R: i32 = 0;
let mut ROOM: i32 = 0;
let mut TKE: i32 = 0;
//
// SPICELIB functions
//
//
// Local parameters
//
//
// Note the leading blank in DELIM below; this
// indicates that the blank character is a delimiter.
//
//
// Local variables
//
if RETURN(ctx) {
return Ok(());
}
CHKIN(b"ZZLEXMET", ctx)?;
if fstr::eq(METHOD, b" ") {
//
// No tokens here.
//
*N = 0;
CHKOUT(b"ZZLEXMET", ctx)?;
return Ok(());
}
*N = 0;
ROOM = MAXN;
R = RTRIM(METHOD);
I = 1;
while (I <= R) {
//
// Look ahead in the input string for the start of a
// quoted string.
//
QPOS = CPOS(fstr::substr(METHOD, I..), DQUOTE, 1);
B = I;
if (QPOS == 0) {
//
// There are no quoted string tokens in the input string
// from index I onward.
//
E = R;
} else {
E = ((I + QPOS) - 2);
}
if (B <= E) {
//
// Locate any tokens between indices B and E.
//
I = B;
while (I <= E) {
//
// Find the next delimiter in the substring
// from indices I : E.
//
LOC = CPOS(fstr::substr(METHOD, I..=E), DELIM, 1);
if (LOC == 1) {
//
// There is a delimiter character at index I in METHOD.
//
TKE = ((I - 1) + LOC);
} else if (LOC > 1) {
//
// There is a delimiter character at index
//
// I - 1 + LOC
//
// in METHOD.
//
if fstr::ne(fstr::substr(METHOD, I..=((I + LOC) - 2)), b" ") {
//
// There's a token preceding the delimiter.
//
TKE = ((I - 2) + LOC);
} else {
//
// The delimiter is all we've got.
//
TKE = ((I - 1) + LOC);
}
} else {
//
// The token, if any, ends at the end of
// substring we're considering.
//
TKE = E;
}
//
// There is a token, which may be blank, between
// indices I and TKE. We don't return blank tokens
// in the output array.
//
if fstr::ne(fstr::substr(METHOD, I..=TKE), b" ") {
if (ROOM > 0) {
*N = (*N + 1);
ROOM = (ROOM - 1);
BEGS[*N] = ((LTRIM(fstr::substr(METHOD, I..=TKE)) + I) - 1);
ENDS[*N] = ((RTRIM(fstr::substr(METHOD, I..=TKE)) + I) - 1);
} else {
SETMSG(b"Need more room in output arrays. Token count = #; substring indices = #:#; substring = #.", ctx);
ERRINT(b"#", *N, ctx);
ERRINT(b"#", I, ctx);
ERRINT(b"#", TKE, ctx);
SIGERR(b"SPICE(ARRAYTOOSMALL)", ctx)?;
CHKOUT(b"ZZLEXMET", ctx)?;
return Ok(());
}
}
I = (TKE + 1);
}
}
if (E < R) {
//
// We expect to find at least one quoted string starting
// at index E + 1.
//
I = (E + 1);
LXQSTR(fstr::substr(METHOD, I..), DQUOTE, 1, &mut EQ, &mut NCHAR);
if (NCHAR > 0) {
if (ROOM > 0) {
*N = (*N + 1);
ROOM = (ROOM - 1);
BEGS[*N] = I;
ENDS[*N] = ((I - 1) + EQ);
} else {
SETMSG(b"Need more room in output arrays. Token count = #; substring indices = #:#; substring = #.", ctx);
ERRINT(b"#", *N, ctx);
ERRINT(b"#", I, ctx);
ERRINT(b"#", TKE, ctx);
ERRCH(b"#", fstr::substr(METHOD, I..=TKE), ctx);
SIGERR(b"SPICE(ARRAYTOOSMALL)", ctx)?;
CHKOUT(b"ZZLEXMET", ctx)?;
return Ok(());
}
} else {
//
// We have a syntax error in the input string.
//
SETMSG(
b"Invalid quoted string found starting at index #. Substring is #.",
ctx,
);
ERRINT(b"#", I, ctx);
ERRCH(b"#", fstr::substr(METHOD, I..), ctx);
SIGERR(b"SPICE(SYNTAXERROR)", ctx)?;
CHKOUT(b"ZZLEXMET", ctx)?;
return Ok(());
}
I = (ENDS[*N] + 1);
}
//
// The index I has been moved forward by at least one position.
//
}
CHKOUT(b"ZZLEXMET", ctx)?;
Ok(())
}