Define f_string_t_length to handle the special case max length.
Make the f_utf_string_t also operate in the same way (even it it might avoid the problem by being a different type than char).
The f_utf_string_t is changed in this way for consistency reasons.
const f_array_length_t length = strlen(result);
if (name->used + length + 1 > name->size) {
- if (name->used + length + 1 > f_array_length_t_size) {
+ if (name->used + length + 1 > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
if (result) {
if (text->used + length + 1 > text->size) {
- if (text->used + length + 1 > f_array_length_t_size) {
+ if (text->used + length + 1 > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
* However, the libc/POSIX appears to limit this to 2^63 (signed).
*/
#ifndef _di_f_console_length_size_
- #define f_console_parameter_size f_type_size_max_64_positive
+ #define f_console_parameter_size f_string_t_size
#endif // _di_f_console_length_size_
/**
* Environment related defines.
*/
#ifndef _di_f_environment_defines_
- #define f_environment_max_length f_array_length_t_size
+ #define f_environment_max_length f_string_t_size
#endif // _di_f_environment_defines_
#ifdef __cplusplus
f_array_length_t size = strnlen(path_to_name, length);
if (name_base->used + size > name_base->size) {
- if (name_base->used + size > f_array_length_t_size) {
+ if (name_base->used + size > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
f_array_length_t size = strnlen(path_to_name, length);
if (name_directory->used + size > name_directory->size) {
- if (name_directory->used + size > f_array_length_t_size) {
+ if (name_directory->used + size > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
for (f_string_t buffer_read = 0; ; ) {
if (buffer->used + file.size_read > buffer->size) {
- if (buffer->size + file.size_read > f_array_length_t_size) {
+ if (buffer->size + file.size_read > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
f_string_t buffer_read = 0;
if (buffer->used + file.size_read > buffer->size) {
- if (buffer->size + file.size_read > f_array_length_t_size) {
+ if (buffer->size + file.size_read > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
}
if (buffer->used + buffer_size > buffer->size) {
- if (buffer->size + buffer_size > f_array_length_t_size) {
+ if (buffer->size + buffer_size > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
for (;;) {
if (buffer->used + file.size_read > buffer->size) {
- if (buffer->size + file.size_read > f_array_length_t_size) {
+ if (buffer->size + file.size_read > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
ssize_t size_read = 0;
if (buffer->used + file.size_read > buffer->size) {
- if (buffer->size + file.size_read > f_array_length_t_size) {
+ if (buffer->size + file.size_read > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
}
if (buffer->used + buffer_size > buffer->size) {
- if (buffer->size + buffer_size > f_array_length_t_size) {
+ if (buffer->size + buffer_size > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
#if !defined(_di_f_string_append_assure_nulless_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_assure_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_string_dynamic_partial_append_nulless_) || !defined(_di_f_string_dynamic_partial_mash_nulless_) || !defined(_di_f_string_mash_nulless_)
f_status_t private_f_string_append_nulless(const f_string_t source, const f_array_length_t length, f_string_dynamic_t *destination) {
- if (destination->used + length > f_array_length_t_size) {
+ if (destination->used + length > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
f_status_t private_f_string_dynamic_increase_by(const f_array_length_t amount, f_string_dynamic_t *dynamic) {
if (dynamic->used + amount > dynamic->size) {
- if (dynamic->used + amount > f_array_length_t_size) {
+ if (dynamic->used + amount > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
#if !defined(_di_f_string_dynamic_mish_) || !defined(_di_f_string_dynamic_partial_mish_) || !defined(_di_f_string_dynamic_partial_prepend_assure_) || !defined(_di_f_string_dynamic_partial_prepend_) || !defined(_di_f_string_dynamic_prepend_assure_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_mish_) || !defined(_di_f_string_prepend_assure_) || !defined(_di_f_string_prepend_)
f_status_t private_f_string_prepend(const f_string_t source, const f_array_length_t length, f_string_dynamic_t *destination) {
- if (destination->used + length > f_array_length_t_size) {
+ if (destination->used + length > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
#if !defined(_di_f_string_dynamic_mish_nulless_) || !defined(_di_f_string_dynamic_partial_mish_nulless_) || !defined(_di_f_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_mish_nulless_) || !defined(_di_f_string_prepend_assure_nulless_) || !defined(_di_f_string_prepend_nulless_)
f_status_t private_f_string_prepend_nulless(const f_string_t source, const f_array_length_t length, f_string_dynamic_t *destination) {
- if (destination->used + length > f_array_length_t_size) {
+ if (destination->used + length > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
* Define the basic string type.
*
* Dynamic allocation macros are provided, but it is recommended to utilize the f_string_dynamic_t for dynamic allocation.
+ *
+ * is provided as a way t have a string max for systems that do not support max string length in 64-bits (when f_array_length_t is set to uint64_t).
+ *
+ * The ideal length for a string is f_array_length_t_size, which generally defaults to 2^64 (unsigned).
+ * However, the libc/POSIX appears to limit this to 2^63 (signed).
+ * f_string_t_size is provided to help safely navigate this.
*/
#ifndef _di_f_string_t_
typedef char *f_string_t;
#define macro_f_string_t_delete_simple(string, length) f_memory_resize(length, 0, sizeof(f_string_t), (void **) & string);
#define macro_f_string_t_destroy_simple(string, length) f_memory_adjust(length, 0, sizeof(f_string_t), (void **) & string);
+
+ // @fixme update all code utilizing f_array_length_t on a string, such as strnlen().
+ #define f_string_t_size f_type_size_64_positive
#endif // _di_f_string_t_
/**
if (dynamic->used + 1 > dynamic->size) {
f_array_length_t size = dynamic->used + step;
- if (size > f_array_length_t_size) {
- if (dynamic->used + 1 > f_array_length_t_size) {
+ if (size > f_string_t_size) {
+ if (dynamic->used + 1 > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
- size = f_array_length_t_size;
+ size = f_string_t_size;
}
return private_f_string_dynamic_resize(size, dynamic);
return F_none;
}
- if (destination->used == f_array_length_t_size) {
+ if (destination->used == f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
} // for
}
- if (destination->used == f_array_length_t_size) {
+ if (destination->used == f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
#if !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_)
f_status_t private_f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) {
- if (destination->used + length > f_array_length_t_size) {
+ if (destination->used + length > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
f_status_t private_f_utf_string_dynamic_increase_by(const f_array_length_t amount, f_utf_string_dynamic_t *dynamic) {
if (dynamic->used + amount > dynamic->size) {
- if (dynamic->used + amount > f_array_length_t_size) {
+ if (dynamic->used + amount > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
#if !defined(_di_f_utf_string_dynamic_mish_) || !defined(_di_f_utf_string_dynamic_partial_mish_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_) || !defined(_di_f_utf_string_dynamic_partial_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_assure_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_mish_) || !defined(_di_f_utf_string_prepend_assure_) || !defined(_di_f_utf_string_prepend_)
f_status_t private_f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) {
- if (destination->used + length > f_array_length_t_size) {
+ if (destination->used + length > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
#if !defined(_di_f_utf_string_dynamic_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_mish_nulless_) || !defined(_di_f_utf_string_prepend_assure_nulless_) || !defined(_di_f_utf_string_prepend_nulless_)
f_status_t private_f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) {
- if (destination->used + length > f_array_length_t_size) {
+ if (destination->used + length > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
if (dynamic->used + 1 > dynamic->size) {
f_array_length_t size = dynamic->used + step;
- if (size > f_array_length_t_size) {
- if (dynamic->used + 1 > f_array_length_t_size) {
+ if (size > f_string_t_size) {
+ if (dynamic->used + 1 > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
- size = f_array_length_t_size;
+ size = f_string_t_size;
}
return private_f_utf_string_dynamic_resize(size, dynamic);
return F_none;
}
- if (destination->used == f_array_length_t_size) {
+ if (destination->used == f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
} // for
}
- if (destination->used == f_array_length_t_size) {
+ if (destination->used == f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
status = f_file_stat(source.string, F_false, &source_stat);
if (F_status_is_error(status)) {
if (status == F_status_set_error(F_string_too_large)) {
- size = f_array_length_t_size - 1;
+ size = f_string_t_size - 1;
}
else {
size = source.used + file.used + 1;
}
else {
if (status == F_status_set_error(F_string_too_large)) {
- size = f_array_length_t_size - 1;
+ size = f_string_t_size - 1;
}
else {
size = destination.used + file.used + 1;
if (F_status_is_error(status)) {
if (status == F_status_set_error(F_string_too_large)) {
- size = f_array_length_t_size - 1;
+ size = f_string_t_size - 1;
}
else {
size = source.used + file.used + 1;
}
else {
if (status == F_status_set_error(F_string_too_large)) {
- size = f_array_length_t_size - 1;
+ size = f_string_t_size - 1;
}
else {
size = destination.used + file.used + 1;
if (F_status_is_error(status)) break;
if (names->array[names->used].used > 0 && names->array[names->used].string[names->array[names->used].used - 1] != 0) {
- if (names->array[names->used].used == f_array_length_t_size) {
+ if (names->array[names->used].used == f_string_t_size) {
status = F_status_set_error(F_string_too_large);
break;
}
total += length_truncated - start;
if (destination->used + total > destination->size) {
- if (destination->used + total > f_array_length_t_size) {
+ if (destination->used + total > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
while ((size_read = read(file.id, buffer_read, file.size_read)) > 0) {
if (buffer->used + size_read > buffer->size) {
- if (buffer->size + size_read > f_array_length_t_size) {
+ if (buffer->size + size_read > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
if ((size_read = read(file.id, buffer_read, file.size_read)) > 0) {
if (buffer->used + size_read > buffer->size) {
- if (buffer->size + size_read > f_array_length_t_size) {
+ if (buffer->size + size_read > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
while (buffer_count < total && (size_read = read(file.id, buffer_read, buffer_size)) > 0) {
if (buffer->used + size_read > buffer->size) {
- if (buffer->size + size_read > f_array_length_t_size) {
+ if (buffer->size + size_read > f_string_t_size) {
return F_status_set_error(F_string_too_large);
}
objects_quoted->used++;
}
- } while (range->start < f_array_length_t_size);
+ } while (range->start < f_string_t_size);
return F_status_is_error(F_number_overflow);
}
objects->used++;
contents->used++;
- } while (range->start < f_array_length_t_size);
+ } while (range->start < f_string_t_size);
return F_status_is_error(F_number_overflow);
}
return F_none_stop;
}
- } while (range->start < f_array_length_t_size);
+ } while (range->start < f_string_t_size);
return F_status_is_error(F_number_overflow);
}
contents_quoted->used++;
}
- } while (range->start < f_array_length_t_size);
+ } while (range->start < f_string_t_size);
return F_status_is_error(F_number_overflow);
}
objects->used++;
contents->used++;
- } while (range->start < f_array_length_t_size);
+ } while (range->start < f_string_t_size);
return F_status_is_error(F_number_overflow);
}
* This does not check if the path exists or not.
* This processes the relative parts: './', '../', and extra '/'.
* This does not process symbolic links.
- * This has a max size of f_array_length_t_size.
+ * This has a max size of f_string_t_size.
*
* @param path
* The source path to determine what the canonical path is.
}
if (environment->used + data_build.setting.environment.used > environment->size) {
- if (environment->used + data_build.setting.environment.used > f_array_length_t_size) {
+ if (environment->used + data_build.setting.environment.used > f_environment_max_length) {
if (main.error.verbosity != f_console_verbosity_quiet) {
fprintf(main.error.to.stream, "%c", f_string_eol_s[0]);
f_color_print(main.error.to.stream, main.context.set.error, "%sThe values for the setting '", fll_error_print_error);