]> Kevux Git Server - fll/commitdiff
Bugfix: -t -n (somename) should show total of (somename) not all objects
authorKevin Day <kevin@kevux.org>
Wed, 7 Mar 2012 04:55:12 +0000 (22:55 -0600)
committerKevin Day <kevin@kevux.org>
Wed, 7 Mar 2012 04:55:12 +0000 (22:55 -0600)
This fixes an oversight or logic flaw where the total count was returned in all cases.
When a specific object name is requested, the total count should be the total number of objects that match the given name.

level_3/fss_basic_list_read/c/fss_basic_list_read.c
level_3/fss_basic_read/c/fss_basic_read.c
level_3/fss_extended_read/c/fss_extended_read.c

index 6cf69b8914dc22c21e08452a72f10c9208cae0b3..90df939868505a966e42efc5ed5321f9b403517a 100644 (file)
@@ -281,7 +281,7 @@ extern "C"{
         }
 
         // now that all of the files have been read, process the objects and contents
-        if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found){
+        if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_name].result == f_console_result_none){
           fprintf(f_standard_output, "%u\n", (unsigned int) data->objects.used);
         } else {
           current = 0;
@@ -377,6 +377,7 @@ extern "C"{
           } else {
             current = 0;
 
+            f_string_length total       = f_string_length_initialize;
             f_string_length name_length = f_string_length_initialize;
             f_string_length argv_length = f_string_length_initialize;
 
@@ -443,9 +444,13 @@ extern "C"{
                         }
                       } else {
                         if (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_list_read_parameter_count].result == f_console_result_additional && found == target)){
-                          if (data->contents.array[current].used > 0){
-                            f_print_partial_dynamic_string(f_standard_output, data->buffer, data->contents.array[current].array[0]);
-                            fprintf(f_standard_output, "\n");
+                          if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found){
+                            total++;
+                          } else {
+                            if (data->contents.array[current].used > 0){
+                              f_print_partial_dynamic_string(f_standard_output, data->buffer, data->contents.array[current].array[0]);
+                              fprintf(f_standard_output, "\n");
+                            }
                           }
                         }
                       }
@@ -460,6 +465,10 @@ extern "C"{
                     }
                   }
                 } // for
+
+                if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_count].result == f_console_result_none){
+                  fprintf(f_standard_output, f_string_length_printf "\n", total);
+                }
               } else {
                 // when and because the object parameter is specified, the name parameter refers to the content instead of the object
                 // therefore, make the search on the content and display the object
index eab61058352d938ecb2985061be90cbd75d7f8b2..189199408bfd1d64b7d0f41f54b4c570606e2205 100644 (file)
@@ -267,7 +267,7 @@ extern "C"{
         }
 
         // now that all of the files have been read, process the objects and contents
-        if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found){
+        if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_name].result == f_console_result_none){
           fprintf(f_standard_output, "%u\n", (unsigned int) data->objects.used);
         } else {
           current = 0;
@@ -312,6 +312,7 @@ extern "C"{
           } else {
             current = 0;
 
+            f_string_length total       = f_string_length_initialize;
             f_string_length name_length = f_string_length_initialize;
             f_string_length argv_length = f_string_length_initialize;
 
@@ -326,12 +327,16 @@ extern "C"{
                     if (fl_compare_strings(data->buffer.string + data->objects.array[current].start, argv[data->parameters[fss_basic_read_parameter_name].additional], name_length, argv_length) == f_equal_to){
 
                       if (data->parameters[fss_basic_read_parameter_count].result == f_console_result_none || (data->parameters[fss_basic_read_parameter_count].result == f_console_result_additional && found == target)){
-                        if (data->contents.array[current].used > 0){
-                          f_print_partial_dynamic_string(f_standard_output, data->buffer, data->contents.array[current].array[0]);
-                          fprintf(f_standard_output, "\n");
+                        if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found){
+                          total++;
                         } else {
-                          // for all objects with no data, print a newline
-                          fprintf(f_standard_output, "\n");
+                          if (data->contents.array[current].used > 0){
+                            f_print_partial_dynamic_string(f_standard_output, data->buffer, data->contents.array[current].array[0]);
+                            fprintf(f_standard_output, "\n");
+                          } else {
+                            // for all objects with no data, print a newline
+                            fprintf(f_standard_output, "\n");
+                          }
                         }
                       }
 
@@ -345,6 +350,10 @@ extern "C"{
                     }
                   }
                 } // for
+
+                if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_count].result == f_console_result_none){
+                  fprintf(f_standard_output, f_string_length_printf "\n", total);
+                }
               } else {
                 // when and because the object parameter is specified, the name parameter refers to the content instead of the object
                 // therefore, make the search on the content and display the object
index 76eef8433445bf150d92c88a1d7baf7c2f1aa9f0..c84783e1cb8c6840f3333dd120e1c0936750ef1c 100644 (file)
@@ -279,7 +279,7 @@ extern "C"{
         }
 
         // now that all of the files have been read, process the objects and contents
-        if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found){
+        if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_name].result == f_console_result_none){
           fprintf(f_standard_output, "%u\n", (unsigned int) data->objects.used);
         } else {
           current = 0;
@@ -324,6 +324,7 @@ extern "C"{
           } else {
             current = 0;
 
+            f_string_length total       = f_string_length_initialize;
             f_string_length name_length = f_string_length_initialize;
             f_string_length argv_length = f_string_length_initialize;
 
@@ -338,12 +339,16 @@ extern "C"{
                     if (fl_compare_strings(data->buffer.string + data->objects.array[current].start, argv[data->parameters[fss_extended_read_parameter_name].additional], name_length, argv_length) == f_equal_to){
 
                       if (data->parameters[fss_extended_read_parameter_count].result == f_console_result_none || (data->parameters[fss_extended_read_parameter_count].result == f_console_result_additional && found == target)){
-                        if (data->contents.array[current].used > select){
-                          f_print_partial_dynamic_string(f_standard_output, data->buffer, data->contents.array[current].array[select]);
-                          fprintf(f_standard_output, "\n");
+                        if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found){
+                          total++;
                         } else {
-                          // for all objects with no data, print a newline
-                          fprintf(f_standard_output, "\n");
+                          if (data->contents.array[current].used > select){
+                            f_print_partial_dynamic_string(f_standard_output, data->buffer, data->contents.array[current].array[select]);
+                            fprintf(f_standard_output, "\n");
+                          } else {
+                            // for all objects with no data, print a newline
+                            fprintf(f_standard_output, "\n");
+                          }
                         }
                       }
 
@@ -357,6 +362,10 @@ extern "C"{
                     }
                   }
                 } // for
+
+                if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found && data->parameters[fss_basic_read_parameter_count].result == f_console_result_none){
+                  fprintf(f_standard_output, f_string_length_printf "\n", total);
+                }
               } else {
                 // when and because the object parameter is specified, the name parameter refers to the content instead of the object
                 // therefore, make the search on the content and display the object