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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
/// Read non-blank line
///
/// Read the next non-blank line of text from a text file.
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// FILE I Input text file.
/// LINE O Next non-blank line from the input text file.
/// EOF O End-of-file indicator.
/// ```
///
/// # Detailed Input
///
/// ```text
/// FILE is the name of the text file from which the next
/// line is to be read. If the file is not currently
/// open, it is opened with a logical unit determined
/// at run time, and the first line of the file is
/// returned. Otherwise, the next line not yet read
/// from the file is read and returned.
/// ```
///
/// # Detailed Output
///
/// ```text
/// LINE is next non-blank line of text in the specified file.
///
/// EOF is .TRUE. when the end of the file is reached, and is
/// otherwise .FALSE.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If either the end of the file is reached or an error occurs
/// before a non-blank line is found, LINE is blank.
/// ```
///
/// # Files
///
/// ```text
/// See input FILES.
/// ```
///
/// # Particulars
///
/// ```text
/// RDNBL simply calls RDTEXT until one of two things happens:
///
/// 1. A non-blank line is found (in which case the line
/// is returned).
///
/// 2. The end of the file is reached (in which case the
/// file is closed, a blank line is returned, and the
/// end-of-file indicator becomes .TRUE.)
/// ```
///
/// # Examples
///
/// ```text
/// Let FILE.1 contain the following lines.
///
/// Mary had a little lamb
///
/// Everywhere that Mary went
///
///
///
/// Its fleece was white as snow.
/// The lamb was sure to go.
///
/// Then the code fragment
///
/// DO I = 1, 4
/// CALL RDNBL ( 'FILE.1', LINE, EOF )
/// WRITE (*,*) LINE
/// END DO
///
/// produces the following output:
///
/// Mary had a little lamb
/// Everywhere that Mary went
/// Its fleece was white as snow.
/// The lamb was sure to go.
///
/// In fact, the following code fragment removes all of the blank
/// lines from an arbitrary text file (FILE).
///
/// CALL RDNBL ( FILE, LINE, EOF )
///
/// DO WHILE ( .NOT. EOF )
/// WRITE (*,*) LINE( : RTRIM(LINE) )
///
/// CALL RDNBL ( FILE, LINE, EOF )
/// END DO
///
/// Note that because RDNBL calls RDTEXT, calls to either routine
/// can be interspersed. For example, RDNBL can be used to skip
/// blank lines at the beginning of the file, leaving the rest to
/// be processed:
///
/// CALL RDNBL ( FILE, LINE, EOF )
///
/// DO WHILE ( .NOT. EOF )
/// < do something with LINE >
///
/// CALL RDTEXT ( FILE, LINE, EOF )
/// END DO
/// ```
///
/// # Restrictions
///
/// ```text
/// 1) Any restrictions that apply to RDTEXT apply to RDNBL as well.
/// ```
///
/// # Author and Institution
///
/// ```text
/// J. Diaz del Rio (ODC Space)
/// I.M. Underwood (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.1.0, 12-AUG-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard.
///
/// - SPICELIB Version 1.0.0, 07-AUG-1994 (IMU)
/// ```
pub fn rdnbl(
ctx: &mut SpiceContext,
file: &str,
line: &mut str,
eof: &mut bool,
) -> crate::Result<()> {
RDNBL(
file.as_bytes(),
fstr::StrBytes::new(line).as_mut(),
eof,
ctx.raw_context(),
)?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure RDNBL ( Read non-blank line )
pub fn RDNBL(
FILE: &[u8],
LINE: &mut [u8],
EOF: &mut bool,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
//
// SPICELIB functions
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
} else {
CHKIN(b"RDNBL", ctx)?;
}
//
// Return as soon as a non-blank line is found. Otherwise, keep
// looking until either the end of the file is reached or RDTEXT
// manages to fail.
//
RDTEXT(FILE, LINE, EOF, ctx)?;
while (!*EOF && !FAILED(ctx)) {
if fstr::ne(LINE, b" ") {
CHKOUT(b"RDNBL", ctx)?;
return Ok(());
} else {
RDTEXT(FILE, LINE, EOF, ctx)?;
}
}
//
// Didn't find anything?
//
fstr::assign(LINE, b" ");
CHKOUT(b"RDNBL", ctx)?;
Ok(())
}