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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
/// Same character --- case insensitive
///
/// Determine if two characters from different strings are the
/// same when the case of the characters is ignored.
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// STR1 I A character string
/// L1 I The location (index) of a character in STR1
/// STR2 I A character string
/// L2 I The location (index) of a character in STR2
///
/// The function returns .TRUE. if the two characters are the
/// same up to case.
/// ```
///
/// # Detailed Input
///
/// ```text
/// STR1 is a character string
///
/// L1 is the location (index) of a character in STR1
///
/// STR2 is a character string
///
/// L2 is the location (index) of a character in STR2
/// ```
///
/// # Detailed Output
///
/// ```text
/// The function returns .TRUE. if the characters STR1(L1:L1) and
/// STR2(L2:L2) are the same when the case of the characters is
/// ignored.
///
/// If the characters are different or L1 or L2 is out of range the
/// function returns .FALSE.
/// ```
///
/// # Exceptions
///
/// ```text
/// Error free.
///
/// 1) If either L1 or L2 is out of range the function returns
/// .FALSE.
/// ```
///
/// # Particulars
///
/// ```text
/// This is a utility function for determining whether or not
/// two characters in different strings are the same up to case.
/// This function is intended for situation in which you need
/// to search two strings for a match (or mismatch).
/// ```
///
/// # Examples
///
/// ```text
/// Often you need to scan through two string comparing
/// character by character until a case insensitive mismatch
/// occurs. The usual way to code this is
///
/// DO WHILE ( L1 .LE. LEN(STR1)
/// .AND. L2 .LE. LEN(STR2)
/// .AND. EQCHR( STR1(L1:L1),STR2(L2:L2) ) )
///
/// L1 = L1 + 1
/// L2 = L2 + 1
///
/// END DO
///
/// Check L1, L2 to make sure we are still in range, etc.
///
/// The problem with this loop is that even though the check to make
/// sure that L1 and L2 are in range is performed, FORTRAN may
/// go ahead and compute the equality condition even though one of the
/// first two steps failed. This can lead to out of range errors
/// and possible halting of your program depending upon how
/// the routine is compiled. An alternative way to code this is
///
/// IF ( L1 .LE. LEN(STR1) .AND. L2 .LE. LEN(STR2) ) THEN
/// ALIKE = EQCHR( STR1(L1:L1),STR2(L2:L2) )
/// ELSE
/// ALIKE = .FALSE.
/// END IF
///
/// DO WHILE ( ALIKE )
///
/// L1 = L1 + 1
/// L2 = L2 + 1
///
/// IF ( L1 .LE. LEN(STR1) .AND. L2 .LE. LEN(STR2) ) THEN
/// ALIKE = EQCHR( STR1(L1:L1), STR2(L2:L2) )
/// ELSE
/// ALIKE = .FALSE.
/// END IF
/// END DO
///
/// However this is a much more complicated section of code. This
/// routine allows you to code the above loops as:
///
///
/// DO WHILE ( SAMCHI ( STR1,L1, STR2,L2 ) )
/// L1 = L1 + 1
/// L2 = L2 + 1
/// END DO
///
/// The boundary checks are automatically performed and out
/// of range errors are avoided.
/// ```
///
/// # Author and Institution
///
/// ```text
/// J. Diaz del Rio (ODC Space)
/// W.L. Taber (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.0.1, 12-AUG-2021 (JDR)
///
/// Edited the header to comply with NAIF standard.
///
/// - SPICELIB Version 1.0.0, 31-MAR-1995 (WLT)
/// ```
pub fn samchi(ctx: &mut SpiceContext, str1: &str, l1: i32, str2: &str, l2: i32) -> bool {
let ret = SAMCHI(str1.as_bytes(), l1, str2.as_bytes(), l2, ctx.raw_context());
ret
}
//$Procedure SAMCHI ( Same character --- case insensitive )
pub fn SAMCHI(STR1: &[u8], L1: i32, STR2: &[u8], L2: i32, ctx: &mut Context) -> bool {
let mut SAMCHI: bool = false;
//
// Spicelib Functions
//
if ((((L1 < 1) || (L2 < 1)) || (L1 > intrinsics::LEN(STR1))) || (L2 > intrinsics::LEN(STR2))) {
SAMCHI = false;
return SAMCHI;
}
SAMCHI = EQCHR(
fstr::substr(STR1, L1..=L1),
fstr::substr(STR2, L2..=L2),
ctx,
);
SAMCHI
}