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
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
struct SaveVars {
PLACE: i32,
B: i32,
E: i32,
BPAD: i32,
FILL: Vec<u8>,
PAD: i32,
EMARK: Vec<u8>,
BMARK: Vec<u8>,
}
impl SaveInit for SaveVars {
fn new() -> Self {
let mut PLACE: i32 = 0;
let mut B: i32 = 0;
let mut E: i32 = 0;
let mut BPAD: i32 = 0;
let mut FILL = vec![b' '; 80];
let mut PAD: i32 = 0;
let mut EMARK = vec![b' '; 16];
let mut BMARK = vec![b' '; 16];
fstr::assign(&mut FILL, b" ");
PAD = 1;
fstr::assign(&mut BMARK, b".....<");
fstr::assign(&mut EMARK, b">.....");
Self {
PLACE,
B,
E,
BPAD,
FILL,
PAD,
EMARK,
BMARK,
}
}
}
//$Procedure M2DIAG ( META/2 diagnostics formatting utility. )
pub fn M2DIAG(
FILLER: &[u8],
BEGMRK: &[u8],
ENDMRK: &[u8],
STRING: &[u8],
SB: i32,
SE: i32,
MESSGE: &[u8],
) {
//
// Entry points
//
// M2MARK
// M2SERR
//
//
// SPICELIB functions
//
//
// Local variables
//
}
//$Procedure M2SERR ( Set the META/2 error markers )
pub fn M2SERR(FILLER: &[u8], BEGMRK: &[u8], ENDMRK: &[u8], ctx: &mut Context) {
let save = ctx.get_vars::<SaveVars>();
let save = &mut *save.borrow_mut();
save.PAD = intrinsics::MIN0(&[80, intrinsics::LEN(FILLER)]);
fstr::assign(&mut save.BMARK, BEGMRK);
fstr::assign(&mut save.EMARK, ENDMRK);
fstr::assign(&mut save.FILL, FILLER);
}
//$Procedure M2MARK (META/2 Error Marking Utility)
pub fn M2MARK(STRING: &[u8], SB: i32, SE: i32, MESSGE: &mut [u8], ctx: &mut Context) {
let save = ctx.get_vars::<SaveVars>();
let save = &mut *save.borrow_mut();
//
// The end of MESSGE looks like
//
// . . . xxx xxxxxx
// ^
// |
// PLACE = LASTNB(CAUSE)+PAD
//
//
// After suffixing STRING to CAUSE with one space
// it will look like:
//
//
// . . . xx x xxxxxx string beginning
// ^
// |
// PLACE + 1
//
// and the beginning and end of the marked string
// will be at PLACE + SB and PLACE+SE respectively.
//
save.B = spicelib::LASTNB(&save.BMARK);
save.E = spicelib::LASTNB(&save.EMARK);
save.BPAD = (spicelib::LASTNB(MESSGE) + 1);
if (save.PAD < 1) {
save.PLACE = spicelib::LASTNB(MESSGE);
} else {
save.PLACE = (spicelib::LASTNB(MESSGE) + save.PAD);
spicelib::SUFFIX(STRING, save.PAD, MESSGE);
fstr::assign(
fstr::substr_mut(MESSGE, save.BPAD..=save.PLACE),
fstr::substr(&save.FILL, 1..=save.PAD),
);
}
if (save.E > 0) {
spicelib::ZZINSSUB(
&MESSGE.to_vec(),
fstr::substr(&save.EMARK, 1..=save.E),
((save.PLACE + SE) + 1),
MESSGE,
);
}
if (save.B > 0) {
spicelib::ZZINSSUB(
&MESSGE.to_vec(),
fstr::substr(&save.BMARK, 1..=save.B),
(save.PLACE + SB),
MESSGE,
);
}
}