]> Kevux Git Server - fll/commitdiff
Feature: The fake program should support the "current" parameter.
authorKevin Day <thekevinday@gmail.com>
Sun, 17 Jul 2022 21:35:09 +0000 (16:35 -0500)
committerKevin Day <thekevinday@gmail.com>
Sun, 17 Jul 2022 21:36:42 +0000 (16:36 -0500)
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.

level_3/fake/c/private-common.c
level_3/fake/c/private-common.h
level_3/fake/c/private-make-operate.c
level_3/fake/documents/fakefile.txt
level_3/fake/specifications/fakefile.txt

index 012b53b76ceb0151779d324b38f970a8d84deb79..46559a2a96a971b3d1166221f81609bce23494ed 100644 (file)
@@ -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);
index 446b6057a5976e0774d050d1d215a6c2403848d0..a5299ad7c531764d34d12f581a52162c04fc1143 100644 (file)
@@ -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;
index 3c3a309d9fa9f802fb6191910cb8b67bcaee4364..162d0a5d639fc87be04b1708190f49c0376a8a62 100644 (file)
@@ -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;
index 3255fdf91227638ab989c741a1bdb30b7775cb0e..53e0b76f37212ebe975a7a4cd9d2c7316cb575f9 100644 (file)
@@ -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.
index 9a75a19849ac7671fee83a185ca3a26a35a54b42..5f2bd8889127adbd9e6a4f89f6c47ba5fd6d87ce 100644 (file)
@@ -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".