From: Kevin Day Date: Sun, 17 Jul 2022 21:35:09 +0000 (-0500) Subject: Feature: The fake program should support the "current" parameter. X-Git-Tag: 0.6.0~43 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=2a0c65705a969abfb6e8847a23e82c2d415c9330;p=fll Feature: The fake program should support the "current" parameter. This is the compliment to the "top" variable parameter. The current working directory, also known as the present working directory, should be an IKI variable. Use the f_string_dynamic_append_assure() rather than f_string_dynamic_append() to only add the trailing slash if it is not already present. Update the documentation. --- diff --git a/level_3/fake/c/private-common.c b/level_3/fake/c/private-common.c index 012b53b..46559a2 100644 --- a/level_3/fake/c/private-common.c +++ b/level_3/fake/c/private-common.c @@ -251,6 +251,7 @@ extern "C" { const f_string_static_t fake_make_parameter_variable_build_s = macro_f_string_static_t_initialize(FAKE_make_parameter_variable_build_s, 0, FAKE_make_parameter_variable_build_s_length); const f_string_static_t fake_make_parameter_variable_color_s = macro_f_string_static_t_initialize(FAKE_make_parameter_variable_color_s, 0, FAKE_make_parameter_variable_color_s_length); + const f_string_static_t fake_make_parameter_variable_current_s = macro_f_string_static_t_initialize(FAKE_make_parameter_variable_current_s, 0, FAKE_make_parameter_variable_current_s_length); const f_string_static_t fake_make_parameter_variable_data_s = macro_f_string_static_t_initialize(FAKE_make_parameter_variable_data_s, 0, FAKE_make_parameter_variable_data_s_length); const f_string_static_t fake_make_parameter_variable_define_s = macro_f_string_static_t_initialize(FAKE_make_parameter_variable_define_s, 0, FAKE_make_parameter_variable_define_s_length); const f_string_static_t fake_make_parameter_variable_fakefile_s = macro_f_string_static_t_initialize(FAKE_make_parameter_variable_fakefile_s, 0, FAKE_make_parameter_variable_fakefile_s_length); diff --git a/level_3/fake/c/private-common.h b/level_3/fake/c/private-common.h index 446b605..a5299ad 100644 --- a/level_3/fake/c/private-common.h +++ b/level_3/fake/c/private-common.h @@ -1472,6 +1472,7 @@ extern "C" { #define FAKE_make_parameter_variable_build_s "build" #define FAKE_make_parameter_variable_color_s "color" + #define FAKE_make_parameter_variable_current_s "current" #define FAKE_make_parameter_variable_data_s "data" #define FAKE_make_parameter_variable_define_s "define" #define FAKE_make_parameter_variable_fakefile_s "fakefile" @@ -1513,6 +1514,7 @@ extern "C" { #define FAKE_make_parameter_variable_build_s_length 5 #define FAKE_make_parameter_variable_color_s_length 5 + #define FAKE_make_parameter_variable_current_s_length 7 #define FAKE_make_parameter_variable_data_s_length 4 #define FAKE_make_parameter_variable_define_s_length 6 #define FAKE_make_parameter_variable_fakefile_s_length 8 @@ -1554,6 +1556,7 @@ extern "C" { extern const f_string_static_t fake_make_parameter_variable_build_s; extern const f_string_static_t fake_make_parameter_variable_color_s; + extern const f_string_static_t fake_make_parameter_variable_current_s; extern const f_string_static_t fake_make_parameter_variable_data_s; extern const f_string_static_t fake_make_parameter_variable_define_s; extern const f_string_static_t fake_make_parameter_variable_fakefile_s; diff --git a/level_3/fake/c/private-make-operate.c b/level_3/fake/c/private-make-operate.c index 3c3a309..162d0a5 100644 --- a/level_3/fake/c/private-make-operate.c +++ b/level_3/fake/c/private-make-operate.c @@ -385,13 +385,44 @@ extern "C" { } // For safe path handling, always append the trailing slash. - *status = f_string_dynamic_append(f_path_separator_s, &data_make->cache_arguments.array[data_make->cache_arguments.used]); + *status = f_string_dynamic_append_assure(f_path_separator_s, &data_make->cache_arguments.array[data_make->cache_arguments.used]); + + if (F_status_is_error(*status)) { + fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_dynamic_append_assure", F_true); + + break; + } + } + + unmatched = F_false; + } + else if (fl_string_dynamic_partial_compare_string(fake_make_parameter_variable_current_s.string, data_make->buffer, fake_make_parameter_variable_current_s.used, iki_data->content.array[j]) == F_equal_to) { + + if (data_make->path.stack.used) { + *status = f_string_dynamic_increase_by(data_make->path.stack.array[data_make->path.stack.used - 1].used + f_path_separator_s.used + 1, &data_make->cache_arguments.array[data_make->cache_arguments.used]); + + if (F_status_is_error(*status)) { + fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_dynamic_increase_by", F_true); + + break; + } + + *status = f_string_dynamic_append(data_make->path.stack.array[data_make->path.stack.used - 1], &data_make->cache_arguments.array[data_make->cache_arguments.used]); if (F_status_is_error(*status)) { fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_dynamic_append", F_true); break; } + + // For safe path handling, always append the trailing slash. + *status = f_string_dynamic_append_assure(f_path_separator_s, &data_make->cache_arguments.array[data_make->cache_arguments.used]); + + if (F_status_is_error(*status)) { + fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_dynamic_append_assure", F_true); + + break; + } } unmatched = F_false; diff --git a/level_3/fake/documents/fakefile.txt b/level_3/fake/documents/fakefile.txt index 3255fdf..53e0b76 100644 --- a/level_3/fake/documents/fakefile.txt +++ b/level_3/fake/documents/fakefile.txt @@ -313,6 +313,7 @@ Fakefile Documentation: The following are reserved parameters: - build: Associated with -b/--build parameter. - color: Associated with +d/++dark, +l/++light, and +n/++no_color parameters. + - current: The absolute path to the current working directory (present working directory) (Always has a trailing forward slash). - data: Associated with -D/--data parameter. - define: Associated with -d/--define parameter. - fakefile: Associated with -f/--fakefile parameter. diff --git a/level_3/fake/specifications/fakefile.txt b/level_3/fake/specifications/fakefile.txt index 9a75a19..5f2bd88 100644 --- a/level_3/fake/specifications/fakefile.txt +++ b/level_3/fake/specifications/fakefile.txt @@ -116,5 +116,5 @@ Fakefile Specification: - <= The "if" Section Operation condition "parameter"\: - The following reserved words are available for parameter names: build, color, data, define, fakefile, mode, process, return, settings, sources, top, verbosity, and work. + The following reserved words are available for parameter names: build, color, current, data, define, fakefile, mode, process, return, settings, sources, top, verbosity, and work. Each of the reserved words supports having ":option" and ":value" appended, such as: "work:value".