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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
/// Left trim
///
/// Return the maximum of 1 and the location of the first non-blank
/// character in the string.
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
///
/// STRING I String to be trimmed.
///
/// The function returns the maximum of 1 and the location of the
/// first non-blank character in STRING.
/// ```
///
/// # Detailed Input
///
/// ```text
/// STRING is a string to be trimmed: the location of the
/// first non-blank character is desired.
/// ```
///
/// # Detailed Output
///
/// ```text
/// The function returns the maximum of 1 and the location of the
/// first non-blank character in STRING.
///
/// In particular, when STRING is blank, the function returns the
/// value 1.
/// ```
///
/// # Exceptions
///
/// ```text
/// Error free.
/// ```
///
/// # Particulars
///
/// ```text
/// When writing a character string to a file, we may wish to omit
/// leading blanks. We'd like to use FRSTNB as a lower substring
/// bound, but we have to handle the case where FRSTNB returns 0,
/// so we write:
///
///
/// WRITE ( UNIT, '(A)' ), STRING ( MAX (1, FRSTNB (STRING)) : )
///
///
/// This can be simplified using LTRIM:
///
///
/// WRITE ( UNIT, '(A)' ), STRING ( LTRIM (STRING) : )
///
///
/// This routine has a counterpart, RTRIM, which finds the maximum of
/// 1 and the position of the last non-blank character of a string.
/// ```
///
/// # Examples
///
/// ```text
/// 1) Write the non-blank portion of each element of a character
/// cell to file SPUD.DAT:
///
/// DO I = 1, CARDC (CELL)
///
/// CALL WRLINE ( 'SPUD.DAT',
/// . CELL(I) ( LTRIM (CELL) : RTRIM (CELL) ) )
///
/// END DO
///
/// When CELL(I) is blank, the string ' ' will be written.
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// W.L. Taber (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.1, 10-MAR-1992 (WLT)
///
/// Comment section for permuted index source lines was added
/// following the header.
///
/// - SPICELIB Version 1.0.0, 02-MAY-1990 (NJB)
/// ```
pub fn ltrim(string: &str) -> i32 {
let ret = LTRIM(string.as_bytes());
ret
}
//$Procedure LTRIM ( Left trim )
pub fn LTRIM(STRING: &[u8]) -> i32 {
let mut LTRIM: i32 = 0;
//
// SPICELIB functions
//
//
// `Just do it'.
//
LTRIM = intrinsics::MAX0(&[1, FRSTNB(STRING)]);
LTRIM
}