]> Kevux Git Server - fll/commitdiff
Update: --name and --at in combination should process '--at' relative to '--name'
authorKevin Day <thekevinday@gmail.com>
Sat, 16 Nov 2019 20:50:58 +0000 (14:50 -0600)
committerKevin Day <thekevinday@gmail.com>
Sat, 16 Nov 2019 20:50:58 +0000 (14:50 -0600)
This logic is already done with --line and other parameters.
Doing this same thing with --name and --at makes the code/logic more consistent and reasonable.

level_3/fss_basic_list_read/c/fss_basic_list_read.c
level_3/fss_basic_list_read/c/private-fss_basic_list_read.c
level_3/fss_basic_read/c/fss_basic_read.c
level_3/fss_basic_read/c/private-fss_basic_read.c
level_3/fss_extended_read/c/fss_extended_read.c
level_3/fss_extended_read/c/private-fss_extended_read.c

index fc41070a5ae26076c3fd350497ea800048335a5a..49c97ab71500c561917faad713cf434e879cff8b 100644 (file)
@@ -79,6 +79,18 @@ extern "C" {
 
     printf("%c", f_string_eol);
 
+    printf("  When both ");
+    fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_list_read_long_at);
+    printf(" and ");
+    fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_list_read_long_name);
+    printf(" parameters are specified (at the same depth), the ");
+    fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_list_read_long_at);
+    printf(" parameter value will be treated as a position relative to the specified ");
+    fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_list_read_long_name);
+    printf(" parameter value.%c", f_string_eol);
+
+    printf("%c", f_string_eol);
+
     printf("  This program may support parameters, such as ");
     fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_list_read_long_depth);
     printf(" or ");
index 0ae20df03b20e101697c346f51d9163ed0bcbf97..2d77d0a4d02a8c85b929b58ba3d14cf6d3682c90 100644 (file)
@@ -391,10 +391,20 @@ extern "C" {
       }
 
       if (depths.array[0].index_at > 0) {
-        if (depths.array[0].value_at < data->objects.used && names[depths.array[0].value_at]) {
-          f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[depths.array[0].value_at]);
-          fprintf(f_standard_output, "%c", f_string_eol);
-        }
+        f_array_length at = 0;
+        f_array_length i = 0;
+
+        for (; i < data->objects.used; i++) {
+          if (names[i]) {
+            if (at == depths.array[0].value_at) {
+              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[i]);
+              fprintf(f_standard_output, "%c", f_string_eol);
+              break;
+            }
+
+            at++;
+          }
+        } // for
 
         return f_none;
       }
@@ -410,84 +420,106 @@ extern "C" {
     }
 
     if (depths.array[0].index_at > 0) {
-      if (names[depths.array[0].value_at]) {
-        if (depths.array[0].value_at >= data->objects.used) {
-          if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) {
-            fprintf(f_standard_output, "0%c", f_string_eol);
-          }
-
-          return f_none;
+      if (depths.array[0].value_at >= data->objects.used) {
+        if (names[depths.array[0].value_at] && data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) {
+          fprintf(f_standard_output, "0%c", f_string_eol);
         }
-        else if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) {
-          if (data->contents.array[depths.array[0].value_at].used == 0) {
-            fprintf(f_standard_output, "0%c", f_string_eol);
-          }
-          else {
-            fprintf(f_standard_output, "1%c", f_string_eol);
-          }
 
-          return f_none;
-        }
+        return f_none;
+      }
 
-        if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) {
-          if (data->contents.array[depths.array[0].value_at].used == 0) {
-            if (include_empty && line == 0) {
-              fprintf(f_standard_output, "%c", f_string_eol);
+      f_array_length at = 0;
+      f_array_length i = 0;
+
+      for (; i < data->objects.used; i++) {
+        if (names[i]) {
+          if (at == depths.array[0].value_at) {
+            if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) {
+              if (data->contents.array[i].used == 0) {
+                fprintf(f_standard_output, "0%c", f_string_eol);
+              }
+              else {
+                f_string_length total = 1;
+
+                for (f_string_length j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) {
+                  if (data->buffer.string[j] == f_string_eos) continue;
+
+                  if (data->buffer.string[j] == f_string_eol) {
+                    total++;
+                  }
+                } // for
+
+                fprintf(f_standard_output, "%llu%c", total, f_string_eol);
+              }
+
+              return f_none;
             }
-          }
-          else {
-            f_string_length i = data->contents.array[depths.array[0].value_at].array[0].start;
 
-            if (line == 0) {
-              for (; i <= data->contents.array[depths.array[0].value_at].array[0].stop; i++) {
-                if (data->buffer.string[i] == f_string_eos) continue;
-                if (data->buffer.string[i] == f_string_eol) {
+            if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) {
+              if (data->contents.array[i].used == 0) {
+                if (include_empty && line == 0) {
                   fprintf(f_standard_output, "%c", f_string_eol);
-                  break;
                 }
+              }
+              else {
+                f_string_length i = data->contents.array[i].array[0].start;
+
+                if (line == 0) {
+                  for (; i <= data->contents.array[i].array[0].stop; i++) {
+                    if (data->buffer.string[i] == f_string_eos) continue;
+                    if (data->buffer.string[i] == f_string_eol) {
+                      fprintf(f_standard_output, "%c", f_string_eol);
+                      break;
+                    }
+
+                    fprintf(f_standard_output, "%c", data->buffer.string[i]);
+                  } // for
+                }
+                else {
+                  f_string_length line_current = 0;
 
-                fprintf(f_standard_output, "%c", data->buffer.string[i]);
-              } // for
-            }
-            else {
-              f_string_length line_current = 0;
+                  for (; i <= data->contents.array[i].array[0].stop; i++) {
+                    if (data->buffer.string[i] == f_string_eos) continue;
+
+                    if (data->buffer.string[i] == f_string_eol) {
+                      line_current++;
 
-              for (; i <= data->contents.array[depths.array[0].value_at].array[0].stop; i++) {
-                if (data->buffer.string[i] == f_string_eos) continue;
+                      if (line_current == line) {
+                        i++;
 
-                if (data->buffer.string[i] == f_string_eol) {
-                  line_current++;
+                        for (; i <= data->contents.array[i].array[0].stop; i++) {
+                          if (data->buffer.string[i] == f_string_eos) continue;
+                          if (data->buffer.string[i] == f_string_eol) {
+                            fprintf(f_standard_output, "%c", f_string_eol);
+                            break;
+                          }
 
-                  if (line_current == line) {
-                    i++;
+                          fprintf(f_standard_output, "%c", data->buffer.string[i]);
+                        } // for
 
-                    for (; i <= data->contents.array[depths.array[0].value_at].array[0].stop; i++) {
-                      if (data->buffer.string[i] == f_string_eos) continue;
-                      if (data->buffer.string[i] == f_string_eol) {
-                        fprintf(f_standard_output, "%c", f_string_eol);
                         break;
                       }
+                    }
+                  } // for
+                }
+              }
 
-                      fprintf(f_standard_output, "%c", data->buffer.string[i]);
-                    } // for
+              return f_none;
+            }
 
-                    break;
-                  }
-                }
-              } // for
+            if (data->contents.array[i].used > 0) {
+              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]);
+            }
+            else if (include_empty) {
+              fprintf(f_standard_output, "%c", f_string_eol);
             }
-          }
 
-          return f_none;
-        }
+            break;
+          }
 
-        if (data->contents.array[depths.array[0].value_at].used > 0) {
-          f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[0]);
+          at++;
         }
-        else if (include_empty) {
-          fprintf(f_standard_output, "%c", f_string_eol);
-        }
-      }
+      } // for
 
       return f_none;
     }
@@ -496,15 +528,23 @@ extern "C" {
       f_string_length total = 0;
 
       for (f_string_length i = 0; i < data->objects.used; i++) {
-        if (!names[i]) {
-          continue;
-        }
+        if (!names[i]) continue;
+
+        if (data->contents.array[i].used == 0) {
+          if (include_empty) {
+            total++;
+          }
 
-        if (data->contents.array[i].used == 0 && !include_empty) {
           continue;
         }
 
-        total++;
+        for (f_string_length j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) {
+          if (data->buffer.string[j] == f_string_eos) continue;
+
+          if (data->buffer.string[j] == f_string_eol) {
+            total++;
+          }
+        } // for
       } // for
 
       fprintf(f_standard_output, "%llu%c", total, f_string_eol);
index 5b88a7cff712118c7d859491466788a154aeead2..123b2a3b0a2137f2a7e19c672f0e8faf4118cbe5 100644 (file)
@@ -79,6 +79,18 @@ extern "C" {
 
     printf("%c", f_string_eol);
 
+    printf("  When both ");
+    fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_at);
+    printf(" and ");
+    fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_name);
+    printf(" parameters are specified (at the same depth), the ");
+    fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_at);
+    printf(" parameter value will be treated as a position relative to the specified ");
+    fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_name);
+    printf(" parameter value.%c", f_string_eol);
+
+    printf("%c", f_string_eol);
+
     printf("  This program may support parameters, such as ");
     fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_depth);
     printf(" or ");
index 463431467f2aacab1f90e75809cb15355cdb3e60..69cb1fc90e01033f21164531aa3c89c90263f98d 100644 (file)
@@ -391,15 +391,25 @@ extern "C" {
       }
 
       if (depths.array[0].index_at > 0) {
-        if (depths.array[0].value_at < data->objects.used && names[depths.array[0].value_at]) {
-          f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[depths.array[0].value_at]);
-          fprintf(f_standard_output, "%c", f_string_eol);
-        }
+        f_array_length at = 0;
+        f_array_length i = 0;
+
+        for (; i < data->objects.used; i++) {
+          if (names[i]) {
+            if (at == depths.array[0].value_at) {
+              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[i]);
+              fprintf(f_standard_output, "%c", f_string_eol);
+              break;
+            }
+
+            at++;
+          }
+        } // for
 
         return f_none;
       }
 
-      for (f_string_length i = 0; i < data->objects.used; i++) {
+      for (f_array_length i = 0; i < data->objects.used; i++) {
         if (names[i] == 0) continue;
 
         f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[i]);
@@ -410,47 +420,59 @@ extern "C" {
     }
 
     if (depths.array[0].index_at > 0) {
-      if (names[depths.array[0].value_at]) {
-        if (depths.array[0].value_at >= data->objects.used) {
-          if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
-            fprintf(f_standard_output, "0%c", f_string_eol);
-          }
-
-          return f_none;
+      if (depths.array[0].value_at >= data->objects.used) {
+        if (names[depths.array[0].value_at] && data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
+          fprintf(f_standard_output, "0%c", f_string_eol);
         }
-        else if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
-          if (data->contents.array[depths.array[0].value_at].used == 0) {
-            fprintf(f_standard_output, "0%c", f_string_eol);
-          }
-          else {
-            fprintf(f_standard_output, "1%c", f_string_eol);
-          }
 
+        return f_none;
+      }
+
+      if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
+        if (line > 0) {
           return f_none;
         }
+      }
 
-        if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
-          if (line == 0) {
-            if (data->contents.array[depths.array[0].value_at].used > 0) {
-              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[0]);
-              fprintf(f_standard_output, "%c", f_string_eol);
+      f_array_length at = 0;
+      f_array_length i = 0;
+
+      for (; i < data->objects.used; i++) {
+        if (names[i]) {
+          if (at == depths.array[0].value_at) {
+            if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
+              if (data->contents.array[i].used == 0) {
+                fprintf(f_standard_output, "0%c", f_string_eol);
+              }
+              else {
+                fprintf(f_standard_output, "1%c", f_string_eol);
+              }
             }
-            else if (include_empty) {
-              fprintf(f_standard_output, "%c", f_string_eol);
+            else if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
+              if (data->contents.array[i].used > 0) {
+                f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]);
+                fprintf(f_standard_output, "%c", f_string_eol);
+              }
+              else if (include_empty) {
+                fprintf(f_standard_output, "%c", f_string_eol);
+              }
+            }
+            else {
+              if (data->contents.array[i].used > 0) {
+                f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]);
+                fprintf(f_standard_output, "%c", f_string_eol);
+              }
+              else if (include_empty) {
+                fprintf(f_standard_output, "%c", f_string_eol);
+              }
             }
-          }
 
-          return f_none;
-        }
+            break;
+          }
 
-        if (data->contents.array[depths.array[0].value_at].used > 0) {
-          f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[0]);
-          fprintf(f_standard_output, "%c", f_string_eol);
+          at++;
         }
-        else if (include_empty) {
-          fprintf(f_standard_output, "%c", f_string_eol);
-        }
-      }
+      } // for
 
       return f_none;
     }
index 80ba61e7941acb51de50e7a6d866c244f794bf2c..23b8684208d61f671faa7d3f84dd0f91ba035521 100644 (file)
@@ -79,6 +79,18 @@ extern "C" {
 
     printf("%c", f_string_eol);
 
+    printf("  When both ");
+    fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_extended_read_long_at);
+    printf(" and ");
+    fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_extended_read_long_name);
+    printf(" parameters are specified (at the same depth), the ");
+    fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_extended_read_long_at);
+    printf(" parameter value will be treated as a position relative to the specified ");
+    fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_extended_read_long_name);
+    printf(" parameter value.%c", f_string_eol);
+
+    printf("%c", f_string_eol);
+
     printf("  This program may support parameters, such as ");
     fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_extended_read_long_depth);
     printf(" or ");
index 4e4aa3959940fff3c72b40297152ddc2ea4b4cd0..08cd7601b4f453c9d66a78875f76117c460c593f 100644 (file)
@@ -386,10 +386,20 @@ extern "C" {
       }
 
       if (depths.array[0].index_at > 0) {
-        if (depths.array[0].value_at < data->objects.used && names[depths.array[0].value_at]) {
-          f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[depths.array[0].value_at]);
-          fprintf(f_standard_output, "%c", f_string_eol);
-        }
+        f_array_length at = 0;
+        f_array_length i = 0;
+
+        for (; i < data->objects.used; i++) {
+          if (names[i]) {
+            if (at == depths.array[0].value_at) {
+              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[i]);
+              fprintf(f_standard_output, "%c", f_string_eol);
+              break;
+            }
+
+            at++;
+          }
+        } // for
 
         return f_none;
       }
@@ -405,43 +415,80 @@ extern "C" {
     }
 
     if (depths.array[0].index_at > 0) {
-      if (names[depths.array[0].value_at]) {
-        if (depths.array[0].value_at >= data->objects.used) {
-          if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
-            fprintf(f_standard_output, "0%c", f_string_eol);
-          }
-
-          return f_none;
+      if (depths.array[0].value_at >= data->objects.used) {
+        if (names[depths.array[0].value_at] && data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
+          fprintf(f_standard_output, "0%c", f_string_eol);
         }
-        else if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
-          if (data->contents.array[depths.array[0].value_at].used == 0) {
-            fprintf(f_standard_output, "0%c", f_string_eol);
-          }
-          else {
-            fprintf(f_standard_output, "1%c", f_string_eol);
-          }
 
-          return f_none;
-        }
+        return f_none;
+      }
+
+      f_array_length at = 0;
+      f_array_length i = 0;
+
+      for (; i < data->objects.used; i++) {
+        if (names[i]) {
+          if (at == depths.array[0].value_at) {
+            if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
+              if (data->contents.array[i].used == 0) {
+                fprintf(f_standard_output, "0%c", f_string_eol);
+              }
+              else {
+                fprintf(f_standard_output, "1%c", f_string_eol);
+              }
+
+              return f_none;
+            }
+
+            if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) {
+              if (line == 0) {
+                if (data->contents.array[i].used > 0) {
+                  f_string_length j = 0;
+
+                  if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) {
+                    if (select < data->contents.array[i].used) {
+                      f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[select]);
+                      fprintf(f_standard_output, "%c", f_string_eol);
+                    } else if (include_empty) {
+                      fprintf(f_standard_output, "%c", f_string_eol);
+                    }
+                  }
+                  else {
+                    for (j = 0; j < data->contents.array[i].used; j++) {
+                      f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[j]);
+
+                      if (j + 1 < data->contents.array[i].used) {
+                        printf(" ");
+                      }
+                    } // for
 
-        if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) {
-          if (line == 0) {
-            if (data->contents.array[depths.array[0].value_at].used > 0) {
+                    fprintf(f_standard_output, "%c", f_string_eol);
+                  }
+                }
+                else if (include_empty) {
+                  fprintf(f_standard_output, "%c", f_string_eol);
+                }
+              }
+
+              return f_none;
+            }
+
+            if (data->contents.array[i].used > 0) {
               f_string_length j = 0;
 
               if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) {
-                if (select < data->contents.array[depths.array[0].value_at].used) {
-                  f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[select]);
+                if (select < data->contents.array[i].used) {
+                  f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[select]);
                   fprintf(f_standard_output, "%c", f_string_eol);
                 } else if (include_empty) {
                   fprintf(f_standard_output, "%c", f_string_eol);
                 }
               }
               else {
-                for (j = 0; j < data->contents.array[depths.array[0].value_at].used; j++) {
-                  f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[j]);
+                for (j = 0; j < data->contents.array[i].used; j++) {
+                  f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[j]);
 
-                  if (j + 1 < data->contents.array[depths.array[0].value_at].used) {
+                  if (j + 1 < data->contents.array[i].used) {
                     printf(" ");
                   }
                 } // for
@@ -452,38 +499,13 @@ extern "C" {
             else if (include_empty) {
               fprintf(f_standard_output, "%c", f_string_eol);
             }
-          }
-
-          return f_none;
-        }
-
-        if (data->contents.array[depths.array[0].value_at].used > 0) {
-          f_string_length j = 0;
 
-          if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) {
-            if (select < data->contents.array[depths.array[0].value_at].used) {
-              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[select]);
-              fprintf(f_standard_output, "%c", f_string_eol);
-            } else if (include_empty) {
-              fprintf(f_standard_output, "%c", f_string_eol);
-            }
+            break;
           }
-          else {
-            for (j = 0; j < data->contents.array[depths.array[0].value_at].used; j++) {
-              f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[j]);
-
-              if (j + 1 < data->contents.array[depths.array[0].value_at].used) {
-                printf(" ");
-              }
-            } // for
 
-            fprintf(f_standard_output, "%c", f_string_eol);
-          }
+          at++;
         }
-        else if (include_empty) {
-          fprintf(f_standard_output, "%c", f_string_eol);
-        }
-      }
+      } // for
 
       return f_none;
     }