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
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
const WDSIZE: i32 = 32;
struct SaveVars {
CMMORE: bool,
EXIT: Vec<u8>,
LC: i32,
R: i32,
FIRST: bool,
}
impl SaveInit for SaveVars {
fn new() -> Self {
let mut CMMORE: bool = false;
let mut EXIT = vec![b' '; WDSIZE as usize];
let mut LC: i32 = 0;
let mut R: i32 = 0;
let mut FIRST: bool = false;
FIRST = true;
Self {
CMMORE,
EXIT,
LC,
R,
FIRST,
}
}
}
//$Procedure CMMORE ( Command Loop---More Commands)
pub fn CMMORE(COMMND: &[u8], ctx: &mut Context) -> bool {
let save = ctx.get_vars::<SaveVars>();
let save = &mut *save.borrow_mut();
// SPICELIB Functions
//
//
// Local Variables.
//
//
// On the first pass we fetch the "exit" command and
// spruce it up a bit for use when comparing with
// the input command.
//
if save.FIRST {
save.FIRST = false;
TRNLAT(b"EXIT", &mut save.EXIT, ctx);
spicelib::CMPRSS(b" ", 1, &save.EXIT.to_vec(), &mut save.EXIT);
spicelib::LJUST(&save.EXIT.to_vec(), &mut save.EXIT);
save.R = spicelib::RTRIM(&save.EXIT);
}
//
// If the input command is shorter than the non-blank
// length of EXIT, then this cannot be the exit command.
// There is more to do.
//
// Note we assign a value to CMMORE so that the compiler
// won't have a fit about having a function unassigned.
// The if conditions below ensure that we assign a value
// but most compilers aren't smart enough to figure that
// out.
//
save.CMMORE = true;
save.LC = intrinsics::LEN(COMMND);
if (save.LC < save.R) {
save.CMMORE = true;
return save.CMMORE;
}
//
// Check to see if the input command matches the exit command.
// We do this a character at a time. We search from the
// left to right, because most commands are not EXIT and this
// allows us to quit early in the process.
//
for I in 1..=save.R {
if spicelib::NECHR(
fstr::substr(COMMND, I..=I),
fstr::substr(&save.EXIT, I..=I),
ctx,
) {
save.CMMORE = true;
return save.CMMORE;
}
}
//
// It's looking like this might be it. See if the rest of
// the input command is blank.
//
if (save.LC == save.R) {
//
// We've got an exact match. There are no more commands
// to look at.
//
save.CMMORE = false;
} else if (save.LC > save.R) {
//
// There will be more commands only if the rest of the input
// command is non-blank.
//
save.CMMORE = fstr::ne(fstr::substr(COMMND, (save.R + 1)..), b" ");
}
save.CMMORE
}