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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
/// Last printable character
///
/// Return the index of the last printable character in a character
/// string. ASCII characters 33-126 are printable. (Blanks are not
/// considered printable.)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// STRING I Input character string.
///
/// The function returns the index of the last non-blank printable
/// character in STRING.
/// ```
///
/// # Detailed Input
///
/// ```text
/// STRING is the input character string.
/// ```
///
/// # Detailed Output
///
/// ```text
/// The function returns the index of the last printable character in
/// the input string.
///
/// ASCII characters 33-126 are considered to be printable characters.
/// Blanks are not considered printable characters. If the input
/// string contains no printable characters, LASTPC is zero.
/// ```
///
/// # Exceptions
///
/// ```text
/// Error free.
/// ```
///
/// # Particulars
///
/// ```text
/// This works exactly like LASTNB, except that it skips non-printable
/// characters (ASCII control characters) as well as blanks.
/// ```
///
/// # Examples
///
/// ```text
/// The program
///
/// INTEGER FRSTNB
/// INTEGER FRSTPC
/// INTEGER LASTNB
/// INTEGER LASTPC
///
/// CHARACTER*10 S
///
/// S( 1: 1) = ' '
/// S( 2: 2) = CHAR ( 2 )
/// S( 3: 3) = CHAR ( 3 )
/// S( 4: 4) = 'A'
/// S( 5: 5) = 'B'
/// S( 6: 6) = 'C'
/// S( 7: 7) = CHAR ( 7 )
/// S( 8: 8) = CHAR ( 8 )
/// S( 9: 9) = CHAR ( 9 )
/// S(10:10) = ' '
///
/// WRITE (*,*) 'Non-blank from ', FRSTNB(S), ' to ', LASTNB(S)
/// WRITE (*,*) 'Printable from ', FRSTPC(S), ' to ', LASTPC(S)
///
/// END
///
/// produces te following output:
///
/// Non-blank from 2 to 9.
/// Printable from 4 to 6.
/// ```
///
/// # Author and Institution
///
/// ```text
/// J. Diaz del Rio (ODC Space)
/// W.L. Taber (JPL)
/// I.M. Underwood (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.1.0, 08-APR-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard. Removed
/// unnecessary $Revisions section.
///
/// - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)
///
/// Comment section for permuted index source lines was added
/// following the header.
///
/// - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU)
/// ```
pub fn lastpc(string: &str) -> i32 {
let ret = LASTPC(string.as_bytes());
ret
}
//$Procedure LASTPC ( Last printable character )
pub fn LASTPC(STRING: &[u8]) -> i32 {
let mut LASTPC: i32 = 0;
//
// Local variables
//
//
// Look for the last character in the range [33,126], and return
// its index.
//
for I in intrinsics::range(intrinsics::LEN(STRING), 1, -1) {
if ((intrinsics::ICHAR(fstr::substr(STRING, I..=I)) >= 33)
&& (intrinsics::ICHAR(fstr::substr(STRING, I..=I)) <= 126))
{
LASTPC = I;
return LASTPC;
}
}
//
// Still here? No printable characters. Return zero.
//
LASTPC = 0;
LASTPC
}