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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
/// Enclose in quotes
///
/// Enclose (quote) the non-blank part of a character string
/// between delimiting symbols.
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// IN I Input string.
/// LEFT I Left delimiter.
/// RIGHT I Right delimiter.
/// OUT O Output (quoted) string.
/// ```
///
/// # Detailed Input
///
/// ```text
/// IN is the input string to be quoted.
///
/// LEFT,
/// RIGHT are the left and right delimiters to be used in
/// quoting the input string. These may be the same
/// character (apostrophe, vertical bar), complementary
/// characters (left and right parentheses, brackets,
/// or braces), or two totally unrelated characters.
/// ```
///
/// # Detailed Output
///
/// ```text
/// OUT is the output string. This is the non-blank part
/// of the input string delimited by LEFT and RIGHT.
/// If the output string is not large enough to contain
/// the quoted string, it is truncated on the right.
/// (The right delimiter would be lost in this case.)
///
/// If the input string is blank, the output string is
/// a single quoted blank.
///
/// OUT may overwrite IN.
/// ```
///
/// # Exceptions
///
/// ```text
/// Error free.
/// ```
///
/// # Particulars
///
/// ```text
/// The first character of the output string is the left delimiter,
/// LEFT. This is followed immediately by the non-blank part of the
/// input string, which is in turn followed by the right delimiter,
/// RIGHT.
///
/// If the input string is blank (has no non-blank characters),
/// a single quoted blank is returned.
/// ```
///
/// # Examples
///
/// ```text
/// Let
/// IN = ' This string has leading and trailing blanks '
/// LEFT = '('
/// RIGHT = ')'
///
/// Then
/// OUT = '(This string has leading and trailing blanks) '
///
/// Or, let IN = ' '. Then OUT = '( )'.
/// ```
///
/// # 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, 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, 31-JAN-1990 (IMU)
/// ```
pub fn quote(in_: &str, left: char, right: char, out: &mut str) {
QUOTE(
in_.as_bytes(),
&[u8::try_from(left).unwrap()],
&[u8::try_from(right).unwrap()],
fstr::StrBytes::new(out).as_mut(),
);
}
//$Procedure QUOTE ( Enclose in quotes )
pub fn QUOTE(IN: &[u8], LEFT: &[u8], RIGHT: &[u8], OUT: &mut [u8]) {
let LEFT = &LEFT[..1];
let RIGHT = &RIGHT[..1];
//
// SPICELIB functions
//
//
// Check for blank string first.
//
if fstr::eq(IN, b" ") {
fstr::assign(OUT, LEFT);
SUFFIX(RIGHT, 1, OUT);
} else {
fstr::assign(OUT, fstr::substr(IN, FRSTNB(IN)..=LASTNB(IN)));
PREFIX(LEFT, 0, OUT);
SUFFIX(RIGHT, 0, OUT);
}
}