]> Kevux Git Server - fll/commitdiff
Update: implement --process parameter
authorKevin Day <thekevinday@gmail.com>
Sun, 7 Jun 2020 21:40:24 +0000 (16:40 -0500)
committerKevin Day <thekevinday@gmail.com>
Sun, 7 Jun 2020 22:00:15 +0000 (17:00 -0500)
Looks like I forgot to implement this.
The --process parameter is a process name that is prepended to stage file names for the purpose of granting the caller additional flexibility.

level_3/fake/c/private-build.c
level_3/fake/c/private-build.h
level_3/fake/c/private-fake.c

index 763e0fc019d3c4487e20d5d12efc7046eb11fc94..462497fdc3fd81572d30fed03fc5074fe12fab26 100644 (file)
@@ -2101,6 +2101,20 @@ extern "C" {
         break;
       }
 
+      if (data.process.used) {
+        *status = fl_string_append(data.process.string, data.process.used, values[i]);
+        if (F_status_is_error(*status)) {
+          fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_append", F_true);
+          break;
+        }
+
+        *status = fl_string_append(fake_build_parameter_stage_separator, fake_build_parameter_stage_separator_length, values[i]);
+        if (F_status_is_error(*status)) {
+          fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_append", F_true);
+          break;
+        }
+      }
+
       *status = fl_string_append_nulless(names[i], lengths[i], values[i]);
       if (F_status_is_error(*status)) {
         fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_dynamic_append_nulless", F_true);
@@ -2607,7 +2621,7 @@ extern "C" {
     *status = f_file_touch(file.string, mode.regular, F_false);
 
     if (F_status_is_error(*status)) {
-      fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "f_file_touch", F_true);
+      fake_print_error_file(data.context, data.verbosity, F_status_set_fine(*status), "f_file_touch", file.string, "touch", F_true, F_true);
     }
   }
 #endif // _di_fake_build_touch_
index 1cb7df5c8838e03843009f563d43ea18612e9116..db2e898e014337cf5ec0f4f048d66893ab75fcb6 100644 (file)
@@ -392,6 +392,10 @@ extern "C" {
   #define fake_build_parameter_object_link_arguments "rcs"
 
   #define fake_build_parameter_object_link_arguments_length 3
+
+  #define fake_build_parameter_stage_separator "-"
+
+  #define fake_build_parameter_stage_separator_length 1
 #endif // _di_fake_build_parameter_
 
 /**
index 3397d3ad26c47511ac2d95858b226455ecfa2259..43447fe311163f8a78c5cff85af29056cd39e591 100644 (file)
@@ -482,6 +482,11 @@ extern "C" {
         &data->settings,
       };
 
+      bool parameters_validate_word[] = {
+        F_true,
+        F_false,
+      };
+
       for (uint8_t i = 0; i < 2; i++) {
         if (data->parameters[parameters_id[i]].result == f_console_result_found) {
           fake_print_error_parameter_missing_value(data->context, data->verbosity, parameters_name[i]);
@@ -497,6 +502,41 @@ extern "C" {
           f_string_length length = strnlen(arguments.argv[location], f_console_length_size);
 
           if (length > 0) {
+            if (parameters_validate_word[i]) {
+              f_string_length j = 0;
+              f_string_length width_max = 0;
+
+              for (j = 0; j < length; j++) {
+                width_max = length - j;
+
+                status = f_utf_is_word_dash_plus(arguments.argv[location] + j, width_max);
+
+                if (F_status_is_error(status)) {
+                  if (fake_print_error(data->context, data->verbosity, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_unknown && data->verbosity != fake_verbosity_quiet) {
+                    fprintf(f_type_error, "%c", f_string_eol[0]);
+                    fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: failed to process the parameter '");
+                    fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_process);
+                    fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'.");
+                  }
+
+                  return status;
+                }
+
+                if (status == F_false) {
+                  if (data->verbosity != fake_verbosity_quiet) {
+                    fprintf(f_type_error, "%c", f_string_eol[0]);
+                    fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the '");
+                    fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_process);
+                    fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameters value '");
+                    fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", arguments.argv[location]);
+                    fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' contains non-word, non-dash, and non-plus characters.");
+                  }
+
+                  return F_status_set_error(F_parameter);
+                }
+              } // for
+            }
+
             status = fl_string_append(arguments.argv[location], length, parameters_value[i]);
 
             if (F_status_is_error(status)) {