not_created:
print
- print context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"error"
+ print 'context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"reset"'
exit failure
not_created:
print
- print context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"error"
+ print 'context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"reset"'
exit failure
not_created:
print
- print context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"error"
+ print 'context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"reset"'
exit failure
not_created:
print
- print context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"error"
+ print 'context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"reset"'
exit failure
not_created:
print
- print context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"error"
+ print 'context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"reset"'
exit failure
not_created:
print
- print context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"error"
+ print 'context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"reset"'
exit failure
const f_array_length_t size = strnlen(result, f_environment_max_length);
if (size) {
- const f_status_t status = f_string_dynamic_increase_by(size, value);
+ const f_status_t status = f_string_dynamic_increase_by(size + 1, value);
if (F_status_is_error(status)) return status;
memcpy(value->string + value->used, result, size);
+
value->used += size;
+ value->string[value->used] = 0;
}
else {
+ const f_status_t status = f_string_dynamic_increase_by(1, value);
+ if (F_status_is_error(status)) return status;
+
+ value->string[0] = 0;
value->used = 0;
}
* The name must be NULL terminated.
* @param value
* The value associated with name.
- * The value will not be null terminated.
- * The value will be appended (set value->used to 0 to replace).
+ * The value is be null terminated.
+ * The value is be appended (set value->used to 0 before calling this to fully replace).
*
* @return
* F_none on success.
not_created:
print
- print context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"error"
+ print 'context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"reset"'
exit failure
#define macro_f_string_t_clear(string) string = 0;
- #define macro_f_string_t_resize(status, string, length_old, length_new) status = f_memory_resize(length_old, length_new, sizeof(char), (void **) & string);
- #define macro_f_string_t_adjust(status, string, length_old, length_new) status = f_memory_adjust(length_old, length_new, sizeof(char), (void **) & string);
+ #define macro_f_string_t_resize(status, string, length_old, length_new) status = f_memory_resize(length_old, length_new, 1, (void **) & string);
+ #define macro_f_string_t_adjust(status, string, length_old, length_new) status = f_memory_adjust(length_old, length_new, 1, (void **) & string);
- #define macro_f_string_t_delete_simple(string, length) f_memory_resize(length, 0, sizeof(char), (void **) & string);
- #define macro_f_string_t_destroy_simple(string, length) f_memory_adjust(length, 0, sizeof(char), (void **) & string);
+ #define macro_f_string_t_delete_simple(string, length) f_memory_resize(length, 0, 1, (void **) & string);
+ #define macro_f_string_t_destroy_simple(string, length) f_memory_adjust(length, 0, 1, (void **) & string);
#define F_string_t_size_d F_number_t_size_positive_d
#endif // _di_f_string_t_
return F_status_set_error(F_string_too_large);
}
- const f_array_length_t total = destination->used + 1;
-
- if (total > destination->size) {
- const f_status_t status = private_f_string_dynamic_resize(total, destination);
+ if (destination->used + 1 > destination->size) {
+ const f_status_t status = private_f_string_dynamic_resize(destination->used + (destination->used + 1 == F_string_t_size_d ? 1 : F_memory_default_allocation_small_d), destination);
if (F_status_is_error(status)) return status;
}
- destination->string[destination->used] = 0;
- destination->used = total;
+ destination->string[destination->used++] = 0;
return F_none;
}
if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (destination->used) {
- for (; destination->used; --destination->used) {
-
- if (!destination->string[destination->used - 1]) continue;
-
- break;
- } // for
+ if (destination->used < destination->size) {
+ if (!destination->string[destination->used]) {
+ return F_none;
+ }
}
if (destination->used == F_string_t_size_d) {
}
if (destination->used + 1 > destination->size) {
- const f_status_t status = private_f_string_dynamic_resize(destination->used + F_memory_default_allocation_small_d, destination);
+ const f_status_t status = private_f_string_dynamic_resize(destination->used + (destination->used + 1 == F_string_t_size_d ? 1 : F_memory_default_allocation_small_d), destination);
if (F_status_is_error(status)) return status;
}
not_created:
print
- print context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"error"
+ print 'context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"reset"'
exit failure
#endif
#ifndef _fl_console_parameter_to_string_dynamic_directory_
- f_status_t fl_console_parameter_to_string_dynamic_directory(const f_string_t argument, f_string_dynamic_t *directory) {
+ f_status_t fl_console_parameter_to_string_dynamic_directory(const f_string_static_t argument, f_string_dynamic_t *directory) {
#ifndef _di_level_1_parameter_checking_
- if (!argument) return F_status_set_error(F_parameter);
+ if (!directory) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- f_status_t status = F_none;
- f_array_length_t length = strlen(argument);
+ f_array_length_t length = argument.used;
if (!length) {
directory->used = 0;
return F_none;
}
+ f_status_t status = F_none;
+
if (length > 1) {
- while (length > 1 && argument[length - 1] == f_path_separator_s.string[0]) {
+ while (length > 1 && argument.string[length - 1] == f_path_separator_s.string[0]) {
--length;
} // while
- if (argument[0] == f_path_separator_s.string[0]) {
+ if (argument.string[0] == f_path_separator_s.string[0]) {
f_array_length_t begin = 1;
- while (begin < length && argument[begin] == f_path_separator_s.string[0]) {
+ while (begin < length && argument.string[begin] == f_path_separator_s.string[0]) {
++begin;
} // while
length -= begin;
+ directory->used = 0;
- if (length > 0) {
- length += 2;
+ if (length) {
+ directory->used = 0;
- macro_f_string_dynamic_t_clear((*directory))
- macro_f_string_dynamic_t_resize(status, (*directory), length)
+ status = f_string_dynamic_increase_by(length + 3, directory);
if (F_status_is_error(status)) return status;
- memcpy(directory->string + 1, argument + begin, length - 2);
+ memcpy(directory->string + 1, argument.string + begin, length);
- directory->used = length;
- directory->size = length;
directory->string[0] = f_path_separator_s.string[0];
- directory->string[length - 1] = f_path_separator_s.string[0];
+ directory->string[length + 1] = f_path_separator_s.string[0];
+ directory->string[length + 2] = 0;
+ directory->used = length + 2;
}
else {
- macro_f_string_dynamic_t_clear((*directory))
- macro_f_string_dynamic_t_resize(status, (*directory), 1)
+ status = f_string_dynamic_increase_by(2, directory);
if (F_status_is_error(status)) return status;
- directory->used = 1;
- directory->size = 1;
directory->string[0] = f_path_separator_s.string[0];
+ directory->string[length + 1] = 0;
+ directory->used = length + 1;
}
}
- else if (length > 3 && argument[0] == f_path_separator_current_s.string[0] && argument[1] == f_path_separator_current_s.string[0] && argument[2] == f_path_separator_s.string[0]) {
+ else if (length > 3 && argument.string[0] == f_path_separator_current_s.string[0] && argument.string[1] == f_path_separator_current_s.string[0] && argument.string[2] == f_path_separator_s.string[0]) {
f_array_length_t begin = 3;
- while (begin < length && argument[begin] == f_path_separator_s.string[0]) {
+ while (begin < length && argument.string[begin] == f_path_separator_s.string[0]) {
++begin;
} // while
length -= begin;
+ directory->used = 0;
- if (length > 0) {
- length += 4;
-
- macro_f_string_dynamic_t_clear((*directory))
- macro_f_string_dynamic_t_resize(status, (*directory), length);
+ if (length) {
+ status = f_string_dynamic_increase_by(length + 5, directory);
if (F_status_is_error(status)) return status;
- memcpy(directory->string + 3, argument + begin, length - 4);
+ memcpy(directory->string + 3, argument.string + begin, length);
- directory->used = length;
- directory->size = length;
directory->string[0] = f_path_separator_current_s.string[0];
directory->string[1] = f_path_separator_current_s.string[0];
directory->string[2] = f_path_separator_s.string[0];
- directory->string[length - 1] = f_path_separator_s.string[0];
+ directory->string[length] = f_path_separator_s.string[0];
+ directory->string[length + 4] = 0;
+ directory->used = length + 4;
}
else {
- macro_f_string_dynamic_t_clear((*directory))
- macro_f_string_dynamic_t_resize(status, (*directory), 3)
+ status = f_string_dynamic_increase_by(5, directory);
if (F_status_is_error(status)) return status;
- directory->used = 3;
- directory->size = 3;
directory->string[0] = f_path_separator_current_s.string[0];
directory->string[1] = f_path_separator_current_s.string[0];
directory->string[2] = f_path_separator_s.string[0];
+ directory->string[3] = f_path_separator_s.string[0];
+ directory->string[4] = 0;
+ directory->used = 4;
}
}
- else if (length > 2 && argument[0] == f_path_separator_current_s.string[0] && argument[1] == f_path_separator_s.string[0]) {
+ else if (length > 2 && argument.string[0] == f_path_separator_current_s.string[0] && argument.string[1] == f_path_separator_s.string[0]) {
f_array_length_t begin = 2;
- while (begin < length && argument[begin] == f_path_separator_s.string[0]) {
+ while (begin < length && argument.string[begin] == f_path_separator_s.string[0]) {
++begin;
} // while
length -= begin;
+ directory->used = 0;
- if (length > 0) {
- length += 3;
-
- macro_f_string_dynamic_t_clear((*directory))
- macro_f_string_dynamic_t_resize(status, (*directory), length)
+ if (length) {
+ status = f_string_dynamic_increase_by(length + 4, directory);
if (F_status_is_error(status)) return status;
- memcpy(directory->string + 2, argument + begin, length - 3);
+ memcpy(directory->string + 2, argument.string + begin, length);
- directory->used = length;
- directory->size = length;
directory->string[0] = f_path_separator_current_s.string[0];
directory->string[1] = f_path_separator_s.string[0];
- directory->string[length - 1] = f_path_separator_s.string[0];
+ directory->string[length] = f_path_separator_s.string[0];
+ directory->string[length + 3] = 0;
+ directory->used = length + 3;
}
else {
- macro_f_string_dynamic_t_clear((*directory))
- macro_f_string_dynamic_t_resize(status, (*directory), 2)
+ status = f_string_dynamic_increase_by(4, directory);
if (F_status_is_error(status)) return status;
- directory->used = 2;
- directory->size = 2;
directory->string[0] = f_path_separator_current_s.string[0];
directory->string[1] = f_path_separator_s.string[0];
+ directory->string[2] = f_path_separator_s.string[0];
+ directory->string[3] = 0;
+ directory->used = 3;
}
}
else {
- ++length;
+ directory->used = 0;
- macro_f_string_dynamic_t_clear((*directory))
- macro_f_string_dynamic_t_resize(status, (*directory), length)
+ status = f_string_dynamic_increase_by(length + 2, directory);
if (F_status_is_error(status)) return status;
- memcpy(directory->string, argument, length - 1);
+ memcpy(directory->string, argument.string, length);
- directory->used = length;
- directory->size = length;
- directory->string[length - 1] = f_path_separator_s.string[0];
+ directory->string[length] = f_path_separator_s.string[0];
+ directory->string[length + 1] = 0;
+ directory->used = length + 1;
}
}
- else if (argument[0] != f_path_separator_s.string[0]) {
- macro_f_string_dynamic_t_clear((*directory))
- macro_f_string_dynamic_t_resize(status, (*directory), 2)
- if (F_status_is_error(status)) return status;
+ else if (argument.string[0] != f_path_separator_s.string[0]) {
+ directory->used = 0;
- memcpy(directory->string, argument, 2);
+ status = f_string_dynamic_increase_by(2, directory);
+ if (F_status_is_error(status)) return status;
- directory->used = 2;
- directory->size = 2;
- directory->string[1] = f_path_separator_s.string[0];
+ directory->string[0] = f_path_separator_s.string[0];
+ directory->string[1] = 0;
+ directory->used = 1;
}
else {
- macro_f_string_dynamic_t_clear((*directory))
- macro_f_string_dynamic_t_resize(status, (*directory), 1)
- if (F_status_is_error(status)) return status;
+ directory->used = 0;
- memcpy(directory->string, argument, 1);
+ status = f_string_dynamic_increase_by(2, directory);
+ if (F_status_is_error(status)) return status;
+ directory->string[0] = argument.string[0];
+ directory->string[1] = 0;
directory->used = 1;
- directory->size = 1;
}
return F_none;
* - Ensures that multiple '/' following './' at the start of the string is reduced to only './' ('.////' would become './').
* - Ensures that multiple '/' following '../' at the start of the string is reduced to only '../' ('..////' would become '../').
*
+ * The directory string will be NULL terminated after directory.used.
+ *
* This does not perform complex cleanup, such as '..///..///' to '../../'.
*
* The purpose of the cleanups is to ensure/enforce a consistent beginning and ending of the path strings.
*
* @param argv
* The argument string expected to be a number.
- * This is generally passed from the argv[].
* @param directory
* The dynamically allocated processed directory string.
+ * The string will be replaced on success.
*
* @return
* F_none on success.
* F_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _fl_console_parameter_to_string_dynamic_directory_
- extern f_status_t fl_console_parameter_to_string_dynamic_directory(const f_string_t argument, f_string_dynamic_t *directory);
+ extern f_status_t fl_console_parameter_to_string_dynamic_directory(const f_string_static_t argument, f_string_dynamic_t *directory);
#endif // _fl_console_parameter_to_string_dynamic_directory_
#ifdef __cplusplus
environment->array[environment->used].name.used = 0;
environment->array[environment->used].value.used = 0;
- status = f_string_dynamic_append_nulless(name, &environment->array[environment->used].name);
- if (F_status_is_error(status)) return status;
+ status = f_string_dynamic_increase_by(name.used + 1, &environment->array[environment->used].name);
+
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append_nulless(name, &environment->array[environment->used].name);
+ }
+
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_terminate_after(&environment->array[environment->used].name);
+ }
- status = f_environment_get(name, &environment->array[environment->used].value);
+ if (F_status_is_error_not(status)) {
+ status = f_environment_get(name, &environment->array[environment->used].value);
+ }
if (F_status_is_error(status) || status == F_data_not || status == F_exist_not) {
environment->array[environment->used].name.used = 0;
+ environment->array[environment->used].value.used = 0;
return status;
}
environment->array[environment->used].name.used = 0;
environment->array[environment->used].value.used = 0;
- status = f_string_dynamic_append_nulless(names.array[i], &environment->array[environment->used].name);
- if (F_status_is_error(status)) return status;
+ status = f_string_dynamic_increase_by(names.array[i].used + 1, &environment->array[environment->used].name);
- status = f_environment_get(names.array[i], &environment->array[environment->used].value);
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append_nulless(names.array[i], &environment->array[environment->used].name);
+ }
- if (F_status_is_error(status)) {
- environment->array[environment->used].name.used = 0;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_terminate_after(&environment->array[environment->used].name);
+ }
- return status;
+ if (F_status_is_error_not(status)) {
+ status = f_environment_get(names.array[i], &environment->array[environment->used].value);
}
- if (status == F_data_not || status == F_exist_not) {
+ if (F_status_is_error(status)) {
environment->array[environment->used].name.used = 0;
+ environment->array[environment->used].value.used = 0;
- continue;
+ return status;
}
+ if (status == F_data_not || status == F_exist_not) continue;
+
++environment->used;
} // for
* If the environment variable name is not found, then it is not added to the map.
* If the environment variable name is found but has an empty value, then it is added to the map with an empty value.
*
+ * Each name and value in the map is NULL terminated after the name.used or size.used.
+ *
* This does not check for uniqueness in the map.
*
* @param name
*
* Errors (with error bit) from: f_environment_get().
* Errors (with error bit) from: f_string_dynamic_append_nulless().
+ * Errors (with error bit) from: f_string_dynamic_increase_by().
+ * Errors (with error bit) from: f_string_dynamic_terminate_after().
* Errors (with error bit) from: f_string_maps_increase_by().
*
* @see f_environment_get()
* @see f_string_dynamic_append_nulless()
+ * @see f_string_dynamic_increase_by()
+ * @see f_string_dynamic_terminate_after()
* @see f_string_maps_increase_by()
*/
#ifndef _di_fl_environment_load_name_
* If the environment variable name is not found, then it is not added to the map.
* If the environment variable name is found but has an empty value, then it is added to the map with an empty value.
*
+ * Each name and value in the map is NULL terminated after the name.used or size.used.
+ *
* This does not check for uniqueness in the map.
*
* @param names
// Create a string array that is compatible with execv() calls.
f_string_t fixed_arguments[arguments.used + 2];
-
f_string_static_t program_name = f_string_static_t_initialize;
const f_string_t last_slash = strrchr(program.used ? program.string : arguments.array[0].string, f_path_separator_s.string[0]);
void private_fll_execute_path_arguments_fixate(const f_string_static_t program_path, const f_string_statics_t arguments, const f_string_t last_slash, const bool fixated_is, f_string_static_t program_name, f_string_t fixed_arguments[]) {
memset(program_name.string, 0, program_name.used + 1);
- memset(fixed_arguments, 0, sizeof(char) * (arguments.used + 2));
+ memset(fixed_arguments, 0, sizeof(f_string_t) * (arguments.used + 2));
memcpy(program_name.string, last_slash ? last_slash + 1 : program_path.string, program_name.used);
if (!contents.used) return F_data_not;
f_status_t status = F_none;
- f_string_dynamics_t *value = 0;
f_fss_content_t *content = 0;
f_array_length_t i = 0;
if (F_status_is_error(status)) return status;
if (status == F_equal_to_not) continue;
- value = values[j];
content = &contents.array[i];
if (matches) {
return F_status_set_error(F_array_too_large);
}
- macro_f_string_dynamics_t_resize(status, (*value), (values[j]->used + content->used));
+ status = f_string_dynamics_increase_by(content->used, values[j]);
if (F_status_is_error(status)) return status;
if (indexs) {
- macro_f_array_lengths_t_resize(status, (*indexs[j]), (indexs[j]->used + content->used));
+ status = f_type_array_lengths_increase_by(content->used, indexs[j]);
if (F_status_is_error(status)) return status;
}
}
status = f_string_dynamic_partial_append_nulless(buffer, contents.array[i].array[k], &values[j]->array[values[j]->used]);
if (F_status_is_error(status)) return status;
+ status = f_string_dynamic_terminate_after(&values[j]->array[values[j]->used]);
+ if (F_status_is_error(status)) return status;
+
++values[j]->used;
if (indexs) {
- indexs[j]->array[indexs[j]->used] = i;
- ++indexs[j]->used;
+ indexs[j]->array[indexs[j]->used++] = i;
}
} // for
} // for
*
* @param arguments
* The program argument array to parse.
- * The caller must guarantee that the values.used does not exceed the argv length.
+ * The caller must guarantee that the indexes within values do not exceed the arguments array length.
* @param values
* The string locations where the console parameters are found.
* @param destination
* A string to append between the source and destination, such as a space: ' '.
* @param arguments
* The program argument array to parse.
- * The caller must guarantee that the values.used does not exceed the argv length.
+ * The caller must guarantee that the indexes within values do not exceed the arguments array length.
* @param values
* The string locations where the console parameters are found.
* @param destination
*
* @param arguments
* The program argument array to parse.
- * The caller must guarantee that the values.used does not exceed the argv length.
+ * The caller must guarantee that the indexes within values do not exceed the arguments array length.
* @param values
* The string locations where the console parameters are found.
* @param destination
* A string to append between the source and destination, such as a space: ' '.
* @param arguments
* The program argument array to parse.
+ * The caller must guarantee that the indexes within values do not exceed the arguments array length.
* @param values
* The string locations where the console parameters are found.
* @param destination
* Set to at least 4 to provide a UTF-8 friendly allocation step.
*/
#ifndef _di_fake_default_allocation_step_
- #define fake_default_allocation_small_d 4
#define fake_default_allocation_large_d 64
+ #define fake_default_allocation_small_d 8
#endif // _di_fake_default_allocation_step_
/**
if (operations_length) {
bool validate_parameter_directories = F_true;
- status = fake_process_console_parameters(arguments, main);
+ status = fake_process_console_parameters(main);
if (F_status_is_error_not(status)) {
status = fake_path_generate(main);
if (main->operation == fake_operation_build_e) {
if (validate_parameter_directories) {
- status = fake_validate_parameter_directories(arguments, main);
+ status = fake_validate_parameter_directories(main);
validate_parameter_directories = F_false;
}
}
else if (main->operation == fake_operation_clean_e) {
if (validate_parameter_directories) {
- status = fake_validate_parameter_directories(arguments, main);
+ status = fake_validate_parameter_directories(main);
validate_parameter_directories = F_false;
}
}
else if (main->operation == fake_operation_make_e) {
if (validate_parameter_directories) {
- status = fake_validate_parameter_directories(arguments, main);
+ status = fake_validate_parameter_directories(main);
validate_parameter_directories = F_false;
}
#if !defined(_di_fake_clean_operate_)
int fake_clean_remove_recursively_verbosely(const char *path, const struct stat *file_stat, int type, struct FTW *entity) {
- if (!entity->level) return 0;
+ if (!entity->level || !path) return 0;
const int result = remove(path);
const f_string_static_t fake_file_data_build_process_pre_s = macro_f_string_static_t_initialize(FAKE_file_data_build_process_pre_s, 0, FAKE_file_data_build_process_pre_s_length);
#endif // _di_fake_file_data_build_strings_
+#ifndef _di_fake_make_data_delete_
+ f_status_t fake_make_data_delete(fake_make_data_t * const data) {
+
+ macro_fake_build_setting_t_delete_simple(data->setting_build);
+ macro_fake_make_setting_t_delete_simple(data->setting_make);
+
+ f_string_maps_resize(0, &data->environment);
+
+ macro_fake_make_parameter_delete_simple(data->parameter);
+ macro_fake_make_parameter_delete_simple(data->parameter_option);
+ macro_fake_make_parameter_delete_simple(data->parameter_value);
+ macro_fake_make_path_delete_simple(data->path);
+
+ f_fss_nameds_resize(0, &data->fakefile);
+
+ f_string_dynamic_resize(0, &data->buffer);
+ f_string_dynamic_resize(0, &data->cache_1);
+ f_string_dynamic_resize(0, &data->cache_2);
+ f_string_dynamic_resize(0, &data->path_cache);
+
+ return F_none;
+ }
+#endif // _di_fake_make_data_delete_
+
#ifndef _di_fake_signal_received_
f_status_t fake_signal_received(fake_main_t * const main) {
f_fss_nameds_t fakefile;
f_string_dynamic_t buffer;
+ f_string_dynamic_t cache_1;
+ f_string_dynamic_t cache_2;
f_string_dynamic_t path_cache;
f_array_length_t id_main;
f_fss_nameds_t_initialize, \
f_string_dynamic_t_initialize, \
f_string_dynamic_t_initialize, \
+ f_string_dynamic_t_initialize, \
+ f_string_dynamic_t_initialize, \
0, \
0, \
}
-
- #define macro_fake_make_data_t_delete_simple(structure) \
- macro_fake_build_setting_t_delete_simple(structure.setting_build) \
- macro_fake_make_setting_t_delete_simple(structure.setting_make) \
- macro_f_string_maps_t_delete_simple(structure.environment) \
- macro_fake_make_parameter_delete_simple(structure.parameter) \
- macro_fake_make_parameter_delete_simple(structure.parameter_option) \
- macro_fake_make_parameter_delete_simple(structure.parameter_value) \
- macro_fake_make_path_delete_simple(structure.path) \
- macro_f_fss_nameds_t_delete_simple(structure.fakefile) \
- macro_f_string_dynamic_t_delete_simple(structure.buffer) \
- macro_f_string_dynamic_t_delete_simple(structure.path_cache)
#endif // _di_fake_make_data_t_
/**
#endif // _di_fake_file_data_build_strings_
/**
+ * Deallocate make data.
+ *
+ * @param data
+ * The make data.
+ *
+ * @return
+ * F_none on success.
+ *
+ * @see f_fss_nameds_resize()
+ * @see f_string_dynamic_resize()
+ * @see f_string_maps_resize()
+ */
+#ifndef _di_fake_make_data_delete_
+ extern f_status_t fake_make_data_delete(fake_make_data_t * const data) F_attribute_visibility_internal_d;
+#endif // _di_fake_make_data_delete_
+
+/**
* Check to see if a process signal is received.
*
* Only signals that are blocked via main.signal will be received.
#endif // _di_fake_file_buffer_
#ifndef _di_fake_process_console_parameters_
- f_status_t fake_process_console_parameters(const f_console_arguments_t *arguments, fake_main_t *main) {
+ f_status_t fake_process_console_parameters(fake_main_t * const main) {
f_status_t status = F_none;
f_array_length_t index = main->parameters.array[parameters_id[i]].values.array[0];
- if (argv[index].used) {
+ if (main->parameters.arguments.array[index].used) {
if (parameters_validate_word[i]) {
f_array_length_t j = 0;
f_array_length_t width_max = 0;
- for (j = 0; j < argv[index].used; ++j) {
+ for (j = 0; j < main->parameters.arguments.array[index].used; ++j) {
- width_max = argv[index].used - j;
+ width_max = main->parameters.arguments.array[index].used - j;
- status = f_utf_is_word_dash_plus(argv[index] + j, width_max, F_false);
+ status = f_utf_is_word_dash_plus(main->parameters.arguments.array[index].string + j, width_max, F_false);
if (F_status_is_error(status)) {
if (fll_error_print(main->error, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_known_not && main->error.verbosity != f_console_verbosity_quiet_e) {
fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context);
fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fake_long_process_s, main->error.notable);
fl_print_format("%[' parameters value '%]", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s);
- fl_print_format("%[%S%]", main->error.to.stream, main->error.notable, argv[index], main->error.notable);
+ fl_print_format("%[%Q%]", main->error.to.stream, main->error.notable, main->parameters.arguments.array[index], main->error.notable);
fl_print_format("%[' contains non-word, non-dash, and non-plus characters.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s);
funlockfile(main->error.to.stream);
} // for
}
- status = f_string_append(argv[index], argv[index].used, parameters_value[i]);
+ status = f_string_dynamic_increase_by(main->parameters.arguments.array[index].used + 1, parameters_value[i]);
+
+ if (F_status_is_error(status)) {
+ fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true);
+
+ return status;
+ }
+
+ status = f_string_dynamic_append(main->parameters.arguments.array[index], parameters_value[i]);
if (F_status_is_error(status)) {
if (status == F_status_set_error(F_string_too_large)) {
}
}
- if (!argv[index].used || status == F_data_not) {
+ if (!main->parameters.arguments.array[index].used || status == F_data_not) {
if (main->error.verbosity != f_console_verbosity_quiet_e) {
flockfile(main->error.to.stream);
else if (parameter_defaults[i].used) {
parameters_value[i]->used = 0;
+ status = f_string_dynamic_increase_by(parameter_defaults[i].used + 1, parameters_value[i]);
+
+ if (F_status_is_error(status)) {
+ fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true);
+
+ return status;
+ }
+
status = f_string_dynamic_append(parameter_defaults[i], parameters_value[i]);
if (F_status_is_error(status)) {
return status;
}
}
+
+ status = f_string_dynamic_terminate_after(parameters_value[i]);
+
+ if (F_status_is_error(status)) {
+ fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
+
+ return status;
+ }
} // for
}
return F_status_set_error(F_parameter);
}
- status = fl_console_parameter_to_string_dynamic_directory(argv[main->parameters.array[parameters_id[i]].values.array[0]], parameters_value[i]);
+ const f_array_length_t index = main->parameters.array[parameters_id[i]].values.array[main->parameters.array[parameters_id[i]].values.used - 1];
+
+ status = f_string_dynamic_increase_by(main->parameters.arguments.array[index].used + 1, parameters_value[i]);
+
+ if (F_status_is_error(status)) {
+ fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true);
+
+ return status;
+ }
+
+ status = fl_console_parameter_to_string_dynamic_directory(main->parameters.arguments.array[index], parameters_value[i]);
if (F_status_is_error(status)) {
if (fll_error_print(main->error, F_status_set_fine(status), "fl_console_parameter_to_string_dynamic_directory", F_false) == F_known_not && main->error.verbosity != f_console_verbosity_quiet_e) {
else if (parameter_defaults[i].used) {
parameters_value[i]->used = 0;
+ status = f_string_dynamic_increase_by(parameter_defaults[i].used + 1, parameters_value[i]);
+
+ if (F_status_is_error(status)) {
+ fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_increase_by", F_true);
+
+ return status;
+ }
+
status = f_string_dynamic_append(parameter_defaults[i], parameters_value[i]);
if (F_status_is_error(status)) {
return status;
}
}
+
+ status = f_string_dynamic_terminate_after(parameters_value[i]);
+
+ if (F_status_is_error(status)) {
+ fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
+
+ return status;
+ }
} // for
}
if (main->parameters.array[fake_parameter_define_e].result == f_console_result_additional_e) {
- status = fll_program_parameter_additional_rip(argv, main->parameters.array[fake_parameter_define_e].values, &main->define);
+ status = fll_program_parameter_additional_rip(main->parameters.arguments.array, main->parameters.array[fake_parameter_define_e].values, &main->define);
if (F_status_is_error(status)) {
if (fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_known_not && main->error.verbosity != f_console_verbosity_quiet_e) {
if (main->parameters.array[fake_parameter_mode_e].result == f_console_result_found_e) {
fake_print_error_parameter_missing_value(main, fake_long_mode_s);
+
return F_status_set_error(F_parameter);
}
else if (main->parameters.array[fake_parameter_mode_e].result == f_console_result_additional_e) {
- status = fll_program_parameter_additional_rip(argv, main->parameters.array[fake_parameter_mode_e].values, &main->mode);
+ status = fll_program_parameter_additional_rip(main->parameters.arguments.array, main->parameters.array[fake_parameter_mode_e].values, &main->mode);
if (F_status_is_error(status)) {
if (fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_known_not && main->error.verbosity != f_console_verbosity_quiet_e) {
#endif // _di_fake_signal_state_interrupt_iki_
#ifndef _di_fake_validate_directories_
- f_status_t fake_validate_parameter_directories(const f_console_arguments_t *arguments, fake_main_t * const main) {
+ f_status_t fake_validate_parameter_directories(fake_main_t * const main) {
if (fake_signal_received(main)) {
return F_status_set_error(F_interrupt);
fake_long_path_work_s,
};
- const f_string_dynamic_t *parameters_value[] = {
- &main->path_build,
- &main->path_data,
- &main->path_work,
+ const f_string_dynamic_t parameters_value[] = {
+ main->path_build,
+ main->path_data,
+ main->path_work,
};
const bool parameters_required[] = {
for (uint8_t i = 0; i < 3; ++i) {
- if (parameters_value[i]->used) {
+ if (parameters_value[i].used) {
memset(&directory_stat, 0, sizeof(struct stat));
- status = f_file_stat(*parameters_value[i], F_true, &directory_stat);
+ status = f_file_stat(parameters_value[i], F_true, &directory_stat);
if (status == F_status_set_error(F_file_found_not)) status = F_status_set_error(F_directory_found_not);
if (F_status_is_error(status)) {
if (F_status_set_fine(status) != F_directory_found_not || parameters_required[i]) {
- fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stat", F_true, *parameters_value[i], f_file_operation_access_s, fll_error_file_type_directory_e);
+ fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stat", F_true, parameters_value[i], f_file_operation_access_s, fll_error_file_type_directory_e);
return status;
}
#ifndef _di_fake_verbose_print_clone_
void fake_verbose_print_clone(const f_file_t output, const f_string_static_t source, const f_string_static_t destination) {
- fll_print_format("Cloned '%S' to '%S'.%r", output.stream, source, destination, f_string_eol_s);
+ fll_print_format("Cloned '%Q' to '%Q'.%r", output.stream, source, destination, f_string_eol_s);
}
#endif // _di_fake_verbose_print_clone_
#ifndef _di_fake_verbose_print_copy_
void fake_verbose_print_copy(const f_file_t output, const f_string_static_t source, const f_string_static_t destination) {
- fll_print_format("Copied '%S' to '%S'.%r", output.stream, source, destination, f_string_eol_s);
+ fll_print_format("Copied '%Q' to '%Q'.%r", output.stream, source, destination, f_string_eol_s);
}
#endif // _di_fake_verbose_print_copy_
#ifndef _di_fake_verbose_print_move_
void fake_verbose_print_move(const f_file_t output, const f_string_static_t source, const f_string_static_t destination) {
- fll_print_format("Moved '%S' to '%S'.%r", output.stream, source, destination, f_string_eol_s);
+ fll_print_format("Moved '%Q' to '%Q'.%r", output.stream, source, destination, f_string_eol_s);
}
#endif // _di_fake_verbose_print_move_
/**
* Validate console arguments and print any relating error messages.
*
- * @param arguments
- * The parameters passed to the process.
* @param main
* The main program data.
*
* Status codes (with error bit) are returned on any problem.
*/
#ifndef _di_fake_process_console_parameters_
- extern f_status_t fake_process_console_parameters(const f_console_arguments_t *arguments, fake_main_t *main) F_attribute_visibility_internal_d;
+ extern f_status_t fake_process_console_parameters(fake_main_t * const main) F_attribute_visibility_internal_d;
#endif // _di_validate_console_parameters_
/**
*
* This should not be called for skeleton as in that case the directories probably do not exist.
*
- * @param arguments
- * The parameters passed to the process.
* @param main
* The main program data.
*
* Status codes (with error bit) are returned on any problem.
*/
#ifndef _di_fake_validate_parameter_directories_
- extern f_status_t fake_validate_parameter_directories(const f_console_arguments_t *arguments, fake_main_t * const main) F_attribute_visibility_internal_d;
+ extern f_status_t fake_validate_parameter_directories(fake_main_t * const main) F_attribute_visibility_internal_d;
#endif // _di_fake_validate_parameter_directories_
/**
{
f_string_t function_name = "macro_f_string_map_multis_t_resize";
- macro_f_string_map_multis_t_resize(*status, data_make->setting_make.parameter, F_memory_default_allocation_small_d);
+ macro_f_string_map_multis_t_resize(*status, data_make->setting_make.parameter, fake_default_allocation_small_d);
if (F_status_is_error_not(*status)) {
data_make->setting_make.parameter.used = 1;
} // for
if (j == data_make->setting_build.environment.used) {
- status = f_string_dynamics_increase(F_memory_default_allocation_small_d, &data_make->setting_build.environment);
+ status = f_string_dynamics_increase(fake_default_allocation_small_d, &data_make->setting_build.environment);
if (F_status_is_error(status)) {
fll_error_print(data_make->main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true);
data_make.main = main;
- status = f_string_dynamics_increase(F_memory_default_allocation_small_d, &data_make.path.stack);
+ status = f_string_dynamics_increase(fake_default_allocation_small_d, &data_make.path.stack);
if (F_status_is_error(status)) {
fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true);
if (F_status_is_error(status)) {
fll_error_print(main->error, F_status_set_fine(status), "f_path_current", F_true);
- macro_fake_make_data_t_delete_simple(data_make);
+ fake_make_data_delete(&data_make);
return status;
}
if (F_status_is_error(status)) {
fll_error_print(main->error, F_status_set_fine(status), "f_directory_open", F_true);
- macro_fake_make_data_t_delete_simple(data_make);
+ fake_make_data_delete(&data_make);
return status;
}
fake_make_load_fakefile(&data_make, &status);
if (F_status_is_error(status)) {
- macro_fake_make_data_t_delete_simple(data_make)
+ fake_make_data_delete(&data_make);
return status;
}
f_file_stream_close(F_true, &data_make.path.top);
f_type_array_lengths_resize(0, §ion_stack);
- macro_fake_make_data_t_delete_simple(data_make)
+ fake_make_data_delete(&data_make);
return status;
}
}
}
else {
- *status = f_string_append("0", 1, &arguments->array[arguments->used]);
+ *status = f_string_dynamic_append(f_string_ascii_0_s, &arguments->array[arguments->used]);
if (F_status_is_error(*status)) {
- fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_append", F_true);
+ fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_dynamic_append", F_true);
break;
}
unmatched = F_false;
- *status = f_string_dynamics_increase(F_memory_default_allocation_small_d, arguments);
+ *status = f_string_dynamics_increase(fake_default_allocation_small_d, arguments);
if (F_status_is_error(*status)) {
fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_dynamics_increase", F_true);
} // for
}
else {
- *status = f_string_dynamics_increase_by(F_memory_default_allocation_small_d, arguments);
+ *status = f_string_dynamics_increase_by(fake_default_allocation_small_d, arguments);
if (F_status_is_error(*status)) {
fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true);
status = f_string_dynamic_append_nulless(value, &arguments->array[arguments->used]);
}
else {
- status = f_string_dynamics_increase_by(F_memory_default_allocation_small_d, arguments);
+ status = f_string_dynamics_increase_by(fake_default_allocation_small_d, arguments);
if (F_status_is_error_not(status)) {
status = f_string_dynamic_append_nulless(value, &arguments->array[arguments->used]);
status = f_string_dynamic_append_nulless(*context, &arguments->array[arguments->used]);
}
else {
- status = f_string_dynamics_increase_by(F_memory_default_allocation_small_d, arguments);
+ status = f_string_dynamics_increase_by(fake_default_allocation_small_d, arguments);
if (F_status_is_error_not(status)) {
status = f_string_dynamic_append_nulless(*context, &arguments->array[arguments->used]);
f_status_t fake_make_operate_expand_environment(fake_make_data_t * const data_make, const f_fss_quote_t quoted, const f_string_range_t range_name, f_string_dynamics_t *arguments) {
f_status_t status = F_none;
- f_string_dynamic_t value = f_string_dynamic_t_initialize;
-
- bool unmatched = F_false;
-
- {
- f_string_dynamic_t name = f_string_dynamic_t_initialize;
- status = f_string_dynamic_partial_append_nulless(data_make->buffer, range_name, &name);
- if (F_status_is_error(status)) return status;
+ data_make->cache_1.used = 0;
+ data_make->cache_2.used = 0;
- status = f_environment_get(name, &value);
+ status = f_string_dynamic_increase_by((range_name.stop - range_name.start) + 1, &data_make->cache_1);
- f_string_dynamic_resize(0, &name);
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_partial_append_nulless(data_make->buffer, range_name, &data_make->cache_1);
}
- if (F_status_is_error(status)) {
- f_string_dynamic_resize(0, &value);
-
- return status;
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_terminate_after(&data_make->cache_1);
}
- if (status == F_exist_not) {
- f_string_dynamic_resize(0, &value);
-
- return F_false;
+ if (F_status_is_error_not(status)) {
+ status = f_environment_get(data_make->cache_1, &data_make->cache_2);
}
- if (quoted) {
- status = f_string_dynamic_append_nulless(value, &arguments->array[arguments->used]);
- }
- else {
- status = f_string_dynamics_increase_by(F_memory_default_allocation_small_d, arguments);
+ if (F_status_is_error(status)) return status;
+ if (status == F_exist_not) return F_false;
- if (F_status_is_error_not(status)) {
- status = f_string_dynamic_append_nulless(value, &arguments->array[arguments->used]);
+ status = f_string_dynamics_increase(fake_default_allocation_small_d, arguments);
- if (F_status_is_error_not(status)) {
- status = f_string_dynamic_terminate_after(&arguments->array[arguments->used]);
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_increase_by(data_make->cache_2.used + 1, &arguments->array[arguments->used]);
+ }
- if (F_status_is_error_not(status)) {
- ++arguments->used;
- }
- }
- }
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_append_nulless(data_make->cache_2, &arguments->array[arguments->used]);
}
- f_string_dynamic_resize(0, &value);
+ if (F_status_is_error_not(status)) {
+ status = f_string_dynamic_terminate_after(&arguments->array[arguments->used]);
+ }
if (F_status_is_error(status)) return status;
+ if (!quoted) {
+ ++arguments->used;
+ }
+
return F_true;
}
#endif // _di_fake_make_operate_expand_environment_
* F_true on success and match expanded.
* F_false on no matches to expand.
*
- * Status codes (with error bit) are returned on any problem.
+ * Errors (with error bit) from: f_string_dynamic_append_nulless().
+ * Errors (with error bit) from: f_string_dynamic_partial_append_nulless().
+ * Errors (with error bit) from: f_string_dynamic_increase_by().
+ * Errors (with error bit) from: f_string_dynamic_terminate_after().
+ * Errors (with error bit) from: f_string_dynamics_increase().
+ *
+ * @see f_string_dynamic_append_nulless()
+ * @see f_string_dynamic_partial_append_nulless()
+ * @see f_string_dynamic_increase_by()
+ * @see f_string_dynamic_terminate_after()
+ * @see f_string_dynamics_increase()
*/
#ifndef _di_fake_make_operate_expand_environment_
extern f_status_t fake_make_operate_expand_environment(fake_make_data_t * const data_make, const f_fss_quote_t quoted, const f_string_range_t range_name, f_string_dynamics_t *arguments) F_attribute_visibility_internal_d;
f_status_t status = F_none;
- // reset the environment.
+ // Reset the environment.
for (f_array_length_t i = 0; i < data_make->environment.used; ++i) {
data_make->environment.array[i].name.used = 0;
funlockfile(data_make->main->output.to.stream);
- // flush to stdout before executing command.
+ // Flush to stdout before executing command.
fflush(data_make->main->output.to.stream);
}
#ifndef _di_fake_make_operate_process_run_
f_status_t fake_make_operate_process_run(fake_make_data_t * const data_make, const f_string_statics_t arguments, const bool as_shell) {
- const f_string_static_t *program = &arguments.array[0];
-
- f_status_t status = F_none;
- f_string_dynamics_t args = f_string_dynamics_t_initialize;
+ f_string_statics_t args = f_string_statics_t_initialize;
if (arguments.used > 1) {
- status = f_string_dynamics_resize(arguments.used - 1, &args);
-
- if (F_status_is_error(status)) {
- fll_error_print(data_make->error, F_status_set_fine(status), "f_string_dynamics_resize", F_true);
- return status;
- }
-
- for (f_array_length_t i = 0; i < args.size; ++i) {
-
- status = f_string_dynamic_append(arguments.array[i + 1], &args.array[i]);
-
- if (F_status_is_error(status)) {
- fll_error_print(data_make->error, F_status_set_fine(status), "f_string_dynamic_append", F_true);
-
- f_string_dynamics_resize(0, &args);
-
- return status;
- }
-
- status = f_string_dynamic_terminate(&args.array[i]);
-
- if (F_status_is_error(status)) {
- fll_error_print(data_make->error, F_status_set_fine(status), "f_string_dynamic_terminate", F_true);
-
- f_string_dynamics_resize(0, &args);
-
- return status;
- }
-
- ++args.used;
- } // for
+ args.array = arguments.array + 1;
+ args.used = arguments.used - 1;
+ args.size = 0;
}
- status = fake_make_operate_process_execute(data_make, *program, args, as_shell);
-
- f_string_dynamics_resize(0, &args);
+ const f_status_t status = fake_make_operate_process_execute(data_make, arguments.array[0], args, as_shell);
return status;
}
}
}
else {
- status = f_string_map_multis_resize(F_memory_default_allocation_small_d, &data_make->setting_make.parameter);
+ status = f_string_map_multis_resize(fake_default_allocation_small_d, &data_make->setting_make.parameter);
if (F_status_is_error(status)) {
fll_error_print(data_make->error, F_status_set_fine(status), "f_string_map_multis_resize", F_true);
fake_print_message_section_operation_path_stack_max(data_make->main, data_make->error, F_status_set_fine(status), "f_path_change", arguments.array[0]);
}
else {
- status = f_string_dynamics_increase_by(F_memory_default_allocation_small_d, &data_make->path.stack);
+ status = f_string_dynamics_increase_by(fake_default_allocation_small_d, &data_make->path.stack);
if (F_status_is_error(status)) {
if (F_status_set_fine(status) == F_array_too_large) {