@@ -195,30 +195,26 @@ RT_API_ATTRS std::size_t LengthWithoutTrailingSpaces(const Descriptor &d) {
195
195
196
196
// Returns the length of the \p string. Assumes \p string is valid.
197
197
RT_API_ATTRS std::int64_t StringLength (const char *string) {
198
- std::size_t length{std::strlen (string)};
199
- if constexpr (sizeof (std::size_t ) < sizeof (std::int64_t )) {
200
- return static_cast <std::int64_t >(length);
201
- } else {
202
- std::size_t max{std::numeric_limits<std::int64_t >::max ()};
203
- return length > max ? 0 // Just fail.
204
- : static_cast <std::int64_t >(length);
205
- }
198
+ return static_cast <std::int64_t >(std::strlen (string));
206
199
}
207
200
201
+ // Assumes Descriptor \p value is not nullptr.
208
202
RT_API_ATTRS bool IsValidCharDescriptor (const Descriptor *value) {
209
203
return value && value->IsAllocated () &&
210
204
value->type () == TypeCode (TypeCategory::Character, 1 ) &&
211
205
value->rank () == 0 ;
212
206
}
213
207
214
- RT_API_ATTRS bool IsValidIntDescriptor (const Descriptor *length) {
215
- auto typeCode{length->type ().GetCategoryAndKind ()};
208
+ // Assumes Descriptor \p intVal is not nullptr.
209
+ RT_API_ATTRS bool IsValidIntDescriptor (const Descriptor *intVal) {
210
+ auto typeCode{intVal->type ().GetCategoryAndKind ()};
216
211
// Check that our descriptor is allocated and is a scalar integer with
217
212
// kind != 1 (i.e. with a large enough decimal exponent range).
218
- return length ->IsAllocated () && length ->rank () == 0 &&
219
- length ->type ().IsInteger () && typeCode && typeCode->second != 1 ;
213
+ return intVal ->IsAllocated () && intVal ->rank () == 0 &&
214
+ intVal ->type ().IsInteger () && typeCode && typeCode->second != 1 ;
220
215
}
221
216
217
+ // Assume Descriptor \p value is valid: pass IsValidCharDescriptor check.
222
218
RT_API_ATTRS void FillWithSpaces (const Descriptor &value, std::size_t offset) {
223
219
if (offset < value.ElementBytes ()) {
224
220
std::memset (
0 commit comments