]> Kevux Git Server - fll/commitdiff
Feature: Support passing a fakefile Section name to the main program.
authorKevin Day <thekevinday@gmail.com>
Thu, 5 Jan 2023 03:20:16 +0000 (21:20 -0600)
committerKevin Day <thekevinday@gmail.com>
Thu, 5 Jan 2023 03:20:16 +0000 (21:20 -0600)
This is intuitive and should have already been supported in the project to better transition from GNU Make into Featureless Make.

The unknown parameter error is to no longer be thrown.

Instead, when the make process in being followed, check to see if any Sections exist in the fakefile matching the main program Section parameters.
Fail when this happens.
If the Section exists in the fakefile then that Section is operated on.

This, for example, now allows for doing something like "fake install" in the same way "make install" works.

The "install" Section must exist in the fakefile for this to work.

level_3/fake/c/common.h
level_3/fake/c/fake.c
level_3/fake/c/print.c
level_3/fake/c/private-make-operate.c

index 89f0bc6d2b3348a040b05303a63a3ce3e832bc20..9ef862643b7a114fc041312d2f550ac1ccb4ebdf 100644 (file)
@@ -63,9 +63,9 @@ extern "C" {
  * The program help related data.
  */
 #ifndef _di_fake_program_help_parameter_s_
-  #define FAKE_program_help_parameters_s "operation"
+  #define FAKE_program_help_parameters_s "operation / section"
 
-  #define FAKE_program_help_parameters_s_length 9
+  #define FAKE_program_help_parameters_s_length 19
 
   extern const f_string_static_t fake_program_help_parameters_s;
 #endif // _di_fake_program_help_parameter_s_
index fee309a40e093c5039ea1b05e7589272f8995280..d62322d5d58804a912914e6dab8e917f2c03aa87 100644 (file)
@@ -173,14 +173,6 @@ extern "C" {
     }
     else {
       operations[0] = fake_operation_make_e;
-
-      if (!(main->pipe & fll_program_data_pipe_input_e) && main->parameters.remaining.used) {
-        status = F_status_set_error(F_parameter);
-
-        if (main->error.verbosity > f_console_verbosity_quiet_e) {
-          fll_print_format("%r%[%QYou failed to specify a valid operation.%]%r", main->error.to, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s);
-        }
-      }
     }
 
     if (F_status_is_error_not(status)) {
index 8518b50aec924982e2d7bac17e61f6dd39425651..f12521ddfa3e6b1ecbe75c4c0c29e06ced7d1b5f 100644 (file)
@@ -70,6 +70,8 @@ extern "C" {
     fl_print_format("  When piping data to this program, the piped data is treated as if it were prepended to the %[%r%]", print.to, print.set->notable, fake_make_parameter_variable_fakefile_s, print.set->notable);
     fl_print_format(" or the %[%r%], depending on the operation.%r", print.to, print.set->notable, fake_make_parameter_variable_settings_s, print.set->notable, f_string_eol_s);
 
+    fl_print_format("  A section name from the fakefile that does not conflict with an operation name may be specified when performing the %[%r%] operation.%r%r", file.stream, context.set.notable, fake_other_operation_make_s, context.set.notable, f_string_eol_s, f_string_eol_s);
+
     f_print_dynamic_raw(setting->line_last, print.to);
 
     f_file_stream_flush(output);
index 63b45d8521f3328a74083191800d7d7506165bf3..8a3c59257310b2e165d5e05994dde8c59200bc0f 100644 (file)
@@ -128,27 +128,113 @@ extern "C" {
 
     data_make.error.verbosity = data->main->output.verbosity;
 
-    {
-      const int result = fake_make_operate_section(&data_make, data_make.id_main, &section_stack, &status);
+    if (data->main->parameters.remaining.used) {
+      f_array_length_t i = 0;
+      f_array_length_t j = 0;
+      f_string_range_t range = f_string_range_t_initialize;
+      f_array_length_t index = 0;
+
+      status = F_none;
+
+      // Validate the remaining parameters.
+      for (i = 0; i < data->main->parameters.remaining.used; ++i) {
+
+        index = data->main->parameters.remaining.array[i];
+
+        if (!data->main->parameters.arguments.array[index].used) {
+          status = F_status_set_error(F_parameter);
+
+          break;
+        }
+
+        range.start = 0;
+        range.stop = data->main->parameters.arguments.array[index].used - 1;
+
+        for (j = 0; j < data_make.fakefile.used; ++j) {
+          if (fl_string_dynamic_partial_compare(data->main->parameters.arguments.array[index], data_make.buffer, range, data_make.fakefile.array[j].name) == F_equal_to) break;
+        } // for
+
+        if (j == data_make.fakefile.used) {
+          status = F_status_set_error(F_parameter);
+
+          break;
+        }
+      } // for
+
+      if (F_status_is_error(status)) {
+        if (data->main->error.verbosity != f_console_verbosity_quiet_e) {
+          index = data->main->parameters.remaining.array[i];
+
+          flockfile(data->main->error.to.stream);
+
+          fl_print_format("%r%[%QThe argument '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context);
+          fl_print_format("%[%Q%]", data->main->error.to.stream, data->main->error.notable, data->main->parameters.arguments.array[index], data->main->error.notable);
+          fl_print_format("%[' is not a valid section name.%]%r", data->main->error.to.stream, data->main->error.context, data->main->error.context, f_string_eol_s);
+
+          funlockfile(data->main->error.to.stream);
+        }
+      }
+      else {
+        for (i = 0; i < data->main->parameters.remaining.used; ++i) {
+
+          index = data->main->parameters.remaining.array[i];
+          range.start = 0;
+          range.stop = data->main->parameters.arguments.array[index].used - 1;
+
+          for (j = 0; j < data_make.fakefile.used; ++j) {
+
+            if (fl_string_dynamic_partial_compare(data->main->parameters.arguments.array[index], data_make.buffer, range, data_make.fakefile.array[j].name) == F_equal_to) {
+              {
+                const int result = fake_make_operate_section(&data_make, j, &section_stack, &status);
+
+                if (status == F_child) {
+                  data->main->child = result;
+                }
+              }
+
+              if (status != F_child) {
+                const f_status_t status_path = f_path_change_at(data_make.path.top.id);
+
+                if (F_status_is_error(status_path) && data->main->warning.verbosity >= f_console_verbosity_verbose_e) {
+                  flockfile(data->main->warning.to.stream);
+
+                  fl_print_format("%r%[%QFailed change back to orignal path '%]", data->main->warning.to.stream, f_string_eol_s, data->main->warning.context, data->main->warning.prefix, data->main->warning.context);
+                  fl_print_format("%[%Q%]", data->main->warning.to.stream, data->main->warning.notable, data_make.path.stack.array[0], data->main->warning.notable);
+                  fl_print_format("%[', status code =%] ", data->main->warning.to.stream, data->main->warning.context, data->main->warning.context);
+                  fl_print_format("%[%ui%]", data->main->warning.to.stream, data->main->warning.notable, F_status_set_fine(status_path), data->main->warning.notable);
+                  fl_print_format("%['.%]%r", data->main->warning.to.stream, data->main->warning.context, data->main->warning.context, f_string_eol_s);
 
-      if (status == F_child) {
-        data->main->child = result;
+                  funlockfile(data->main->warning.to.stream);
+                }
+              }
+            }
+          } // for
+        } // for
       }
     }
+    else {
+      {
+        const int result = fake_make_operate_section(&data_make, data_make.id_main, &section_stack, &status);
 
-    if (status != F_child) {
-      const f_status_t status_path = f_path_change_at(data_make.path.top.id);
+        if (status == F_child) {
+          data->main->child = result;
+        }
+      }
 
-      if (F_status_is_error(status_path) && data->main->warning.verbosity >= f_console_verbosity_verbose_e) {
-        f_file_stream_lock(data->main->warning);
+      if (status != F_child) {
+        const f_status_t status_path = f_path_change_at(data_make.path.top.id);
 
-        fl_print_format("%r%[%QFailed change back to orignal path '%]", data->main->warning.to, f_string_eol_s, data->main->warning.context, data->main->warning.prefix, data->main->warning.context);
-        fl_print_format("%[%Q%]", data->main->warning.to, data->main->warning.notable, data_make.path.stack.array[0], data->main->warning.notable);
-        fl_print_format("%[', status code =%] ", data->main->warning.to, data->main->warning.context, data->main->warning.context);
-        fl_print_format("%[%ui%]", data->main->warning.to, data->main->warning.notable, F_status_set_fine(status_path), data->main->warning.notable);
-        fl_print_format("%['.%]%r", data->main->warning.to, data->main->warning.context, data->main->warning.context, f_string_eol_s);
+        if (F_status_is_error(status_path) && data->main->warning.verbosity >= f_console_verbosity_verbose_e) {
+          f_file_stream_lock(data->main->warning);
 
-        f_file_stream_unlock(data->main->warning);
+          fl_print_format("%r%[%QFailed change back to orignal path '%]", data->main->warning.to, f_string_eol_s, data->main->warning.context, data->main->warning.prefix, data->main->warning.context);
+          fl_print_format("%[%Q%]", data->main->warning.to, data->main->warning.notable, data_make.path.stack.array[0], data->main->warning.notable);
+          fl_print_format("%[', status code =%] ", data->main->warning.to, data->main->warning.context, data->main->warning.context);
+          fl_print_format("%[%ui%]", data->main->warning.to, data->main->warning.notable, F_status_set_fine(status_path), data->main->warning.notable);
+          fl_print_format("%['.%]%r", data->main->warning.to, data->main->warning.context, data->main->warning.context, f_string_eol_s);
+
+          f_file_stream_unlock(data->main->warning);
+        }
       }
     }