]> Kevux Git Server - fll/commitdiff
Cleanup: FSS Extended List function variable names and code structure.
authorKevin Day <Kevin@kevux.org>
Tue, 27 Aug 2024 04:30:19 +0000 (23:30 -0500)
committerKevin Day <Kevin@kevux.org>
Tue, 27 Aug 2024 04:30:19 +0000 (23:30 -0500)
Make the variable name more explicit.
This variable name also matches recent 0.7 branch changes.

Move the allocation for the comments range after setting all of the variables.
This should better allow for determining the state should the `f_string_ranges_increase()` fail.

level_1/fl_fss/c/fss/extended_list.c

index 875f104..2823d30 100644 (file)
@@ -31,7 +31,7 @@ extern "C" {
     f_array_length_t newline_last = range->start;
     f_array_length_t slash_first = 0;
     f_array_length_t slash_count = 0;
-    f_array_length_t start = 0;
+    f_array_length_t comment_start = 0;
 
     // Identify where the content ends.
     while (range->start <= range->stop && range->start < buffer.used) {
@@ -187,19 +187,11 @@ extern "C" {
       if (buffer.string[range->start] == f_fss_comment_s.string[0]) {
 
         // The newline_last is initialized to the range->start, which may not actually be a new line.
-        if (buffer.string[newline_last] == f_string_eol_s.string[0]) {
-          start = newline_last + 1;
-        }
-        else {
-          start = newline_last;
-        }
+        comment_start = (buffer.string[newline_last] == f_string_eol_s.string[0]) ? newline_last + 1 : newline_last;
 
         status = f_fss_seek_to_eol(state, buffer, range);
         if (F_status_is_error(status)) break;
 
-        status = f_string_ranges_increase(state.step_small, comments);
-        if (F_status_is_error(status)) break;
-
         if (range->start > range->stop || range->start >= buffer.used) {
           --range->start;
         }
@@ -207,7 +199,10 @@ extern "C" {
           newline_last = range->start;
         }
 
-        comments->array[comments->used].start = start;
+        status = f_string_ranges_increase(state.step_small, comments);
+        if (F_status_is_error(status)) break;
+
+        comments->array[comments->used].start = comment_start;
         comments->array[comments->used++].stop = range->start++;
 
         continue;