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
209
210
211
212
213
214
215
216
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
const MSGLEN: i32 = 320;
/// Parse integer with error checking
///
/// Parse a string as an integer, encapsulating error handling.
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// STRING I String representing a numeric value.
/// INTVAL O Integer value obtained by parsing STRING.
/// ```
///
/// # Detailed Input
///
/// ```text
/// STRING is a string representing a numeric value. Commas and
/// spaces may be used in this string for ease of reading
/// and writing the number. They are treated as
/// insignificant but non-error-producing characters.
///
/// For exponential representation any of the characters
/// 'E','D','e','d' may be used.
///
/// The following are legitimate numeric expressions
///
/// +12.2 e-1
/// -3. 1415 9276
/// 1e6
/// E8
///
/// The program also recognizes the following mnemonics
///
/// 'PI', 'pi', 'Pi', 'pI'
/// '+PI', '+pi', '+Pi', '+pI'
/// '-PI', '-pi', '-Pi', '-pI'
///
/// and returns the value ( + OR - ) 3 as appropriate.
/// ```
///
/// # Detailed Output
///
/// ```text
/// INTVAL is the integer obtained by parsing STRING. If an error is
/// encountered, INTVAL is not changed from whatever the
/// input value was. If the input string has a fractional
/// part, the fractional part will be truncated. Thus
/// 3.18 is interpreted as 3. -4.98 is interpreted as -4.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If the input string cannot be parsed or if the string
/// represents a number that is outside the range of
/// representable integers, as defined by INTMIN and INTMAX, the
/// error SPICE(NOTANINTEGER) is signaled. The value of INTVAL is
/// not changed from whatever the input value was.
/// ```
///
/// # Particulars
///
/// ```text
/// The purpose of this routine is to enable safe parsing of numeric
/// values into an INTEGER variable without the necessity of in-line
/// error checking.
/// ```
///
/// # Examples
///
/// ```text
/// The numerical results shown for this example may differ across
/// platforms. The results depend on the SPICE kernels used as
/// input, the compiler and supporting libraries, and the machine
/// specific arithmetic implementation.
///
/// 1) Parse into an INTEGER variable a set of strings representing
/// numeric values.
///
///
/// Example code begins here.
///
///
/// PROGRAM PRSINT_EX1
/// IMPLICIT NONE
///
/// C
/// C Local parameters.
/// C
/// INTEGER SETSIZ
/// PARAMETER ( SETSIZ = 10 )
///
/// INTEGER STRLEN
/// PARAMETER ( STRLEN = 11 )
///
/// C
/// C Local variables.
/// C
/// CHARACTER*(STRLEN) STRVAL ( SETSIZ )
///
/// INTEGER I
/// INTEGER INTVAL
///
/// C
/// C Initialize the array of strings.
/// C
/// DATA STRVAL / '100,000,000',
/// . ' -2 690 192',
/// . ' +12.2 e-1',
/// . '-3. 141 592',
/// . ' 1.2e8',
/// . ' E6',
/// . ' Pi',
/// . ' -PI',
/// . '-2147483648',
/// . ' 2147483647' /
///
/// C
/// C Parse each string into an INTEGER variable.
/// C
/// WRITE(*,'(A)') ' STRVAL INTVAL'
/// WRITE(*,'(A)') '----------- ------------'
/// DO I = 1, SETSIZ
///
/// CALL PRSINT ( STRVAL(I), INTVAL )
///
/// WRITE(*,'(A11,2X,I12)') STRVAL(I), INTVAL
///
/// END DO
///
///
/// END
///
///
/// When this program was executed on a Mac/Intel/gfortran/64-bit
/// platform, the output was:
///
///
/// STRVAL INTVAL
/// ----------- ------------
/// 100,000,000 100000000
/// -2 690 192 -2690192
/// +12.2 e-1 1
/// -3. 141 592 -3
/// 1.2e8 120000000
/// E6 1000000
/// Pi 3
/// -PI -3
/// -2147483648 -2147483648
/// 2147483647 2147483647
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.0.1, 04-JUL-2021 (JDR)
///
/// Edited the header to comply with NAIF standard. Added complete
/// code example.
///
/// Updated the header to properly describe its input, output,
/// exceptions and particulars.
///
/// - SPICELIB Version 1.0.0, 22-JUL-1997 (NJB)
/// ```
pub fn prsint(ctx: &mut SpiceContext, string: &str, intval: &mut i32) -> crate::Result<()> {
PRSINT(string.as_bytes(), intval, ctx.raw_context())?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure PRSINT ( Parse integer with error checking )
pub fn PRSINT(STRING: &[u8], INTVAL: &mut i32, ctx: &mut Context) -> f2rust_std::Result<()> {
let mut ERRMSG = [b' '; MSGLEN as usize];
let mut PTR: i32 = 0;
//
// Local parameters
//
//
// Local variables
//
//
// Use discovery check-in.
//
NPARSI(STRING, INTVAL, &mut ERRMSG, &mut PTR, ctx);
if fstr::ne(&ERRMSG, b" ") {
CHKIN(b"PRSINT", ctx)?;
SETMSG(&ERRMSG, ctx);
SIGERR(b"SPICE(NOTANINTEGER)", ctx)?;
CHKOUT(b"PRSINT", ctx)?;
return Ok(());
}
Ok(())
}