]> Kevux Git Server - fll/commitdiff
Update: Restructure enum non-alphabetically and detect empty version for a specified...
authorKevin Day <thekevinday@gmail.com>
Wed, 23 Jun 2021 03:43:57 +0000 (22:43 -0500)
committerKevin Day <thekevinday@gmail.com>
Wed, 23 Jun 2021 03:43:57 +0000 (22:43 -0500)
If version_target is set to something, then that something should not be empty.
Detect this requirement.

In the case of the major/minor/micro/nano versioning, having the enum match the major/minor/micro/nano order makes more sense than alphabetical.
This then allows for using the enum as a relative position when detecting if one of these is required to not be empty.

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

index 980b3227ede456ed26c75337449461d293c32973..4e2f778c30fc86a62e89a8ae2ffc91eaf01e7418 100644 (file)
@@ -205,19 +205,19 @@ extern "C" {
 #ifndef _di_fake_build_version_
   enum {
     fake_build_version_type_major = 1,
-    fake_build_version_type_micro,
     fake_build_version_type_minor,
+    fake_build_version_type_micro,
     fake_build_version_type_nano,
   };
 
   #define fake_build_version_major "major"
-  #define fake_build_version_micro "micro"
   #define fake_build_version_minor "minor"
+  #define fake_build_version_micro "micro"
   #define fake_build_version_nano  "nano"
 
   #define fake_build_version_major_length 5
-  #define fake_build_version_micro_length 5
   #define fake_build_version_minor_length 5
+  #define fake_build_version_micro_length 5
   #define fake_build_version_nano_length  4
 #endif // _di_fake_build_version_
 
index 0e8ca4a846df26da1abbc9f06fa93b8f6a0418e4..c496d6b231aca11263bb4b896feb0af9b13f3e4b 100644 (file)
@@ -2188,12 +2188,12 @@ extern "C" {
           if (fl_string_compare_trim(settings_single_source[i]->array[0].string, fake_build_version_major, settings_single_source[i]->array[0].used, fake_build_version_major_length) == F_equal_to) {
             *settings_single_version[i] = fake_build_version_type_major;
           }
-          else if (fl_string_compare_trim(settings_single_source[i]->array[0].string, fake_build_version_micro, settings_single_source[i]->array[0].used, fake_build_version_micro_length) == F_equal_to) {
-            *settings_single_version[i] = fake_build_version_type_micro;
-          }
           else if (fl_string_compare_trim(settings_single_source[i]->array[0].string, fake_build_version_minor, settings_single_source[i]->array[0].used, fake_build_version_minor_length) == F_equal_to) {
             *settings_single_version[i] = fake_build_version_type_minor;
           }
+          else if (fl_string_compare_trim(settings_single_source[i]->array[0].string, fake_build_version_micro, settings_single_source[i]->array[0].used, fake_build_version_micro_length) == F_equal_to) {
+            *settings_single_version[i] = fake_build_version_type_micro;
+          }
           else if (fl_string_compare_trim(settings_single_source[i]->array[0].string, fake_build_version_nano, settings_single_source[i]->array[0].used, fake_build_version_nano_length) == F_equal_to) {
             *settings_single_version[i] = fake_build_version_type_nano;
           }
@@ -2252,7 +2252,7 @@ extern "C" {
 
       // Provide these defaults only if the Object is not defined (this allows for empty Content to exist if the Object is defined).
       // In the case of the version prefixes, if the associated version is empty, then instead clear the associated version prefix.
-      {
+      if (F_status_is_error_not(*status)) {
         f_string_dynamic_t *prefix[] = {
           &setting->version_major_prefix,
           &setting->version_minor_prefix,
@@ -2274,6 +2274,20 @@ extern "C" {
           settings_matches[49], // version_nano_prefix
         };
 
+        const char *name_target[] = {
+          fake_build_version_major,
+          fake_build_version_minor,
+          fake_build_version_micro,
+          fake_build_version_nano,
+        };
+
+        const char *name_object[] = {
+          fake_build_setting_name_version_major,
+          fake_build_setting_name_version_minor,
+          fake_build_setting_name_version_micro,
+          fake_build_setting_name_version_nano,
+        };
+
         for (f_array_length_t i = 0; i < 4; ++i) {
 
           if (version[i]->used) {
@@ -2290,6 +2304,21 @@ extern "C" {
           }
           else {
             prefix[i]->used = 0;
+
+            if (setting->version_target && i + 1 <= setting->version_target) {
+              if (main.error.verbosity != f_console_verbosity_quiet) {
+                fprintf(main.error.to.stream, "%c", f_string_eol_s[0]);
+                f_color_print(main.error.to.stream, main.context.set.error, "%sWhen the version target is set to '", fll_error_print_error);
+                f_color_print(main.error.to.stream, main.context.set.notable, "%s", name_target[setting->version_target - 1]);
+                f_color_print(main.error.to.stream, main.context.set.error, "', then the '");
+                f_color_print(main.error.to.stream, main.context.set.notable, "%s", name_object[i]);
+                f_color_print(main.error.to.stream, main.context.set.error, "' Object must have Content.");
+                fprintf(main.error.to.stream, "%c", f_string_eol_s[0]);
+              }
+
+              *status = F_status_set_error(F_failure);
+              break;
+            }
           }
         } // for
       }