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
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
struct SaveVars {
BLANK: Vec<u8>,
}
impl SaveInit for SaveVars {
fn new() -> Self {
let mut BLANK = vec![b' '; 132 as usize];
fstr::assign(&mut BLANK, b" ");
Self { BLANK }
}
}
//$Procedure RDSTMT ( Read a statement entered on one or more lines)
pub fn RDSTMT(
PRMPT: &[u8],
DELIM: &[u8],
STMT: &mut [u8],
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let save = ctx.get_vars::<SaveVars>();
let save = &mut *save.borrow_mut();
let DELIM = &DELIM[..1 as usize];
let mut SPACE = [b' '; 1 as usize];
let mut TAB = [b' '; 1 as usize];
let mut PRLEN: i32 = 0;
let mut LINE = [b' '; 132 as usize];
let mut MYPRM = [b' '; 132 as usize];
let mut END: i32 = 0;
//
// SPICELIB functions
//
//
// Local variables
//
//
// Read the first statement. Use the prompt. Return immediately
// if a blank line or an error is encountered.
//
PRLEN = (spicelib::RTRIM(PRMPT) + 1);
fstr::assign(&mut MYPRM, PRMPT);
fstr::assign(&mut LINE, b" ");
fstr::assign(&mut SPACE, b" ");
fstr::assign(&mut TAB, &intrinsics::CHAR(9));
//
// Set up the white-space/line-break accountant.
//
spicelib::PROMPT(fstr::substr(&MYPRM, 1..=PRLEN), &mut LINE, ctx)?;
if fstr::eq(&LINE, b" ") {
fstr::assign(STMT, b" ");
return Ok(());
} else {
fstr::assign(STMT, &LINE);
}
//
// Record the size of the white-space and line-break fields.
//
RSTBUF(ctx);
spicelib::REPLCH(&LINE.clone(), &TAB, &SPACE, &mut LINE);
PUTBUF(&LINE, ctx);
//
// Read succeeding lines. Indent to the length of the original
// prompt. Add the input line to the current statement. Quit when:
//
// - A delimiter is encountered. (Return the statement
// up to the delimiter.)
//
// - A blank line or an error is encountered. (Return
// a blank statement.)
//
while (intrinsics::INDEX(STMT, DELIM) == 0) {
spicelib::PROMPT(fstr::substr(&save.BLANK, 1..=PRLEN), &mut LINE, ctx)?;
spicelib::REPLCH(&LINE.clone(), &TAB, &SPACE, &mut LINE);
PUTBUF(&LINE, ctx);
if fstr::eq(&LINE, b" ") {
DMPBUF(ctx);
fstr::assign(STMT, b" ");
return Ok(());
} else {
spicelib::SUFFIX(&LINE, 1, STMT);
}
}
//
// If we made it to here, we encountered a delimiter. Take the
// entire statement up to the character before the delimiter.
//
END = intrinsics::INDEX(STMT, DELIM);
fstr::assign(fstr::substr_mut(STMT, END..), b" ");
Ok(())
}