]> Kevux Git Server - fll/commitdiff
Progress: Switch to using fl_flag defines and flag_fl variable. 0.8-combining
authorKevin Day <Kevin@kevux.org>
Mon, 31 Aug 2026 01:53:55 +0000 (20:53 -0500)
committerKevin Day <Kevin@kevux.org>
Mon, 31 Aug 2026 01:53:55 +0000 (20:53 -0500)
This will be easier to read without exposing these defines outside the sources.

level_1/fl_fss/c/fss/basic_list.c
level_1/fl_fss/c/fss/embedded_list.c

index b442de0ae9f11fe8e6e0300050c2fc49c32d1fb4..b6044cb88954ed4f37336ded61d31552f042e004 100644 (file)
@@ -37,6 +37,11 @@ extern "C" {
     state->status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &found->array, &found->used, &found->size);
     if (F_status_is_error(state->status)) return;
 
+    #define ___fl_flag_do_escape___                       0x1
+    #define ___fl_flag_has_graph_first___                 0x2
+    #define ___fl_flag_has_delimit_comment___             0x4
+    #define ___fl_flag_has_delimit_comment_graph_first___ 0x6
+
     const f_number_unsigned_t delimits_used = delimits->used;
     const f_number_unsigned_t comments_used = comments->used;
 
@@ -49,7 +54,7 @@ extern "C" {
     f_number_unsigned_t start = 0;
     f_number_unsigned_t comment_delimit = 0;
 
-    uint8_t graph_first = 0x1; // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set.
+    uint8_t flag_fl = ___fl_flag_has_graph_first___;
 
     // Identify where the content ends.
     while (range->start <= range->stop && range->start < buffer.used) {
@@ -60,7 +65,7 @@ extern "C" {
       }
 
       if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
-        if (graph_first == 0x2) {
+        if (flag_fl & ___fl_flag_has_delimit_comment___) {
           state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
           if (F_status_is_error(state->status)) break;
 
@@ -68,7 +73,7 @@ extern "C" {
         }
 
         newline_last = range->start;
-        graph_first = 0x1;
+        flag_fl |= ___fl_flag_has_graph_first___;
         ++range->start;
 
         continue;
@@ -94,7 +99,7 @@ extern "C" {
         if (range->start > range->stop || range->start >= buffer.used) break;
 
         if (buffer.string[range->start] == f_fss_basic_list_open_s.string[0]) {
-          graph_first = 0x0;
+          flag_fl &= ~___fl_flag_has_delimit_comment_graph_first___;
           ++range->start;
 
           while (range->start <= range->stop && range->start < buffer.used) {
@@ -144,19 +149,19 @@ extern "C" {
 
             if (F_status_is_error(state->status)) break;
 
-            if (graph_first == 0x2) {
+            if (flag_fl & ___fl_flag_has_delimit_comment___) {
               state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
               if (F_status_is_error(state->status)) break;
 
               delimits->array[delimits->used++] = comment_delimit;
             }
 
-            graph_first = 0x1;
+            flag_fl |= ___fl_flag_has_graph_first___;
             range->start = start + 1;
           }
         }
-        else if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) {
-          graph_first = 0x2;
+        else if ((flag_fl & ___fl_flag_has_graph_first___) && buffer.string[range->start] == f_fss_comment_s.string[0]) {
+          flag_fl &= ___fl_flag_has_delimit_comment___;
           comment_delimit = slash_first;
           ++range->start;
         }
@@ -166,7 +171,7 @@ extern "C" {
 
       if (buffer.string[range->start] == f_fss_basic_list_open_s.string[0]) {
         ++range->start;
-        graph_first = 0x0;
+        flag_fl &= ~___fl_flag_has_delimit_comment_graph_first___;
 
         while (range->start <= range->stop && range->start < buffer.used) {
 
@@ -203,7 +208,7 @@ extern "C" {
         }
 
         if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
-          if (graph_first == 0x2) {
+          if (flag_fl & ___fl_flag_has_delimit_comment___) {
             state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
             if (F_status_is_error(state->status)) break;
 
@@ -211,13 +216,13 @@ extern "C" {
           }
 
           newline_last = range->start;
-          graph_first = 0x1;
+          flag_fl |= ___fl_flag_has_graph_first___;
         }
 
         continue;
       }
 
-      if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) {
+      if ((flag_fl & ___fl_flag_has_graph_first___) && 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]) {
@@ -246,11 +251,11 @@ extern "C" {
         continue;
       }
 
-      if (graph_first == 0x1) {
+      if (flag_fl & ___fl_flag_has_graph_first___) {
         if (f_fss_is_space(buffer, *range, state) == F_false) {
           if (F_status_is_error(state->status)) break;
 
-          graph_first = 0x0;
+          flag_fl &= ~___fl_flag_has_delimit_comment_graph_first___;
         }
       }
 
@@ -288,6 +293,11 @@ extern "C" {
     }
 
     state->status = F_fss_found_content;
+
+    #undef ___fl_flag_do_escape___
+    #undef ___fl_flag_has_graph_first___
+    #undef ___fl_flag_has_delimit_comment___
+    #undef ___fl_flag_has_delimit_comment_graph_first___
   }
 #endif // _di_fl_fss_basic_list_content_read_
 
index 2f45465f0d28e8dd976d068c0189fc76b59fc0a3..c9716f5a201afa11397e4037de14d8d4ef6d8d41 100644 (file)
@@ -49,6 +49,16 @@ extern "C" {
 
     if (F_status_is_error(state->status)) return;
 
+    #define ___fl_flag_do_escape___                        0x1
+    #define ___fl_flag_has_graph_first___                  0x2
+    #define ___fl_flag_has_delimit_comment___              0x4
+    #define ___fl_flag_has_delimit_comment_graph_first___  0x6
+    #define ___fl_flag_is_delimit_close___                 0x8
+    #define ___fl_flag_is_delimit_close_delimit_comment___ 0xc
+    #define ___fl_flag_is_object___                        0x10
+    #define ___fl_flag_is_open___                          0x20
+    #define ___fl_flag_is_open_close_graph_first___        0x2a
+
     const f_number_unsigned_t delimits_used = delimits->used;
     const f_number_unsigned_t comments_used = comments->used;
 
@@ -63,8 +73,7 @@ extern "C" {
     f_number_unsigned_t before_list_open = position_previous;
     f_number_unsigned_t close_location = 0;
 
-    // 0x0 = is false for all, 0x1 = is first graph, 0x2 = is delimited comment, 0x4 = is open, 0x8 = is object, 0x10 = is delimited close.
-    uint8_t is_state = 0x1;
+    uint8_t flag_fl = ___fl_flag_has_graph_first___;
 
     // Initialize depth 1 start position.
     // Positions_start.used is used as a max depth (such that cache->positions->used == max depth + 1).
@@ -82,7 +91,7 @@ extern "C" {
       }
 
       if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
-        if (is_state & 0x2) {
+        if (flag_fl & ___fl_flag_has_delimit_comment___) {
           state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
           if (F_status_is_error(state->status)) break;
 
@@ -91,9 +100,9 @@ extern "C" {
 
         newline_last = position_previous = range->start++;
         line_start = range->start;
-        is_state = 0x1;
+        flag_fl |= ___fl_flag_has_graph_first___;
       }
-      else if (buffer.string[range->start] == f_fss_slash_s.string[0] && (is_state & 0x1)) {
+      else if (buffer.string[range->start] == f_fss_slash_s.string[0] && (flag_fl & ___fl_flag_has_graph_first___)) {
         slash_first = slash_last = position_previous = range->start++;
         cache->slashes->array[depth] = 1;
 
@@ -120,7 +129,7 @@ extern "C" {
         // For example '}' = valid close, '\}' represents '}', '\\}' represents '\}', '\\\}' represents '\\}', '\\\\}' represents '\\\}', and so on..
         // When slash is odd and a (delimited) valid open/close is found, then save delimited positions and continue.
         if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
-          if (is_state & 0x2) {
+          if (flag_fl & ___fl_flag_has_delimit_comment___) {
             state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
             if (F_status_is_error(state->status)) break;
 
@@ -129,14 +138,14 @@ extern "C" {
 
           newline_last = position_previous = range->start++;
           line_start = range->start;
-          is_state = 0x1;
+          flag_fl |= ___fl_flag_has_graph_first___;
         }
         else if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0] || buffer.string[range->start] == f_fss_embedded_list_close_s.string[0]) {
           before_list_open = position_previous;
-          is_state &= ~0x15;
+          flag_fl &= ~___fl_flag_is_open_close_graph_first___;
 
           if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) {
-            is_state |= 0x4;
+            flag_fl |= ___fl_flag_is_open___;
           }
 
           position_previous = range->start++;
@@ -167,12 +176,12 @@ extern "C" {
             newline_last = range->start;
             line_start = newline_last + 1;
 
-            if (is_state & 0x4) {
+            if (flag_fl & ___fl_flag_is_open___) {
               if (cache->slashes->array[depth] % 2 == 0) {
-                is_state |= 0x8;
+                flag_fl |= ___fl_flag_is_object___;
               }
               else {
-                is_state &= ~0x8;
+                flag_fl &= ~___fl_flag_is_object___;
               }
 
               range->start = slash_first;
@@ -196,7 +205,7 @@ extern "C" {
               } // while
 
               // When slashes are even, the object is valid and needs to be processed.
-              if (is_state & 0x8) {
+              if (flag_fl & ___fl_flag_is_object___) {
                 if (++depth >= cache->objects->size) {
                   state->status = f_memory_array_resize(depth + 2, sizeof(f_range_t), (void **) &cache->objects->array, &cache->objects->used, &cache->objects->size);
                 }
@@ -234,10 +243,10 @@ extern "C" {
               }
             }
             else {
-              is_state |= 0x10;
+              flag_fl |= ___fl_flag_is_delimit_close___;
             }
 
-            if (is_state & 0x12) {
+            if (flag_fl & ___fl_flag_is_delimit_close_delimit_comment___) {
               state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
               if (F_status_is_error(state->status)) break;
 
@@ -245,20 +254,20 @@ extern "C" {
             }
 
             range->start = line_start;
-            is_state = 0x1;
+            flag_fl |= ___fl_flag_has_graph_first___;
           }
         }
-        else if (buffer.string[range->start] == f_fss_comment_s.string[0] && (is_state & 0x1)) {
-          is_state |= 0x2;
-          is_state &= ~0x1;
+        else if (buffer.string[range->start] == f_fss_comment_s.string[0] && (flag_fl & ___fl_flag_has_graph_first___)) {
+          flag_fl |= ___fl_flag_is_delimit_close___;
+          flag_fl &= ~___fl_flag_has_graph_first___;
           comment_delimit = slash_first;
         }
         else {
-          is_state &= ~0x1;
+          flag_fl &= ~___fl_flag_has_graph_first___;
         }
       }
       else if (buffer.string[range->start] == f_fss_embedded_list_open_s.string[0]) {
-        is_state &= ~0x1;
+        flag_fl &= ~___fl_flag_has_graph_first___;
         before_list_open = position_previous;
         position_previous = range->start;
 
@@ -322,7 +331,7 @@ extern "C" {
             cache->slashes->used = depth + 1;
           }
 
-          if (is_state & 0x2) {
+          if (flag_fl & ___fl_flag_has_delimit_comment___) {
             state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
             if (F_status_is_error(state->status)) break;
 
@@ -331,7 +340,7 @@ extern "C" {
 
           newline_last = range->start;
           line_start = newline_last + 1;
-          is_state = 0x1;
+          flag_fl |= ___fl_flag_has_graph_first___;
         }
         else {
 
@@ -339,7 +348,7 @@ extern "C" {
           f_fss_seek_to_eol(buffer, range, state);
           if (F_status_is_error(state->status)) break;
 
-          if (is_state & 0x2) {
+          if (flag_fl & ___fl_flag_has_delimit_comment___) {
             state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
             if (F_status_is_error(state->status)) break;
 
@@ -348,10 +357,10 @@ extern "C" {
 
           newline_last = range->start;
           line_start = newline_last + 1;
-          is_state = 0x1;
+          flag_fl |= ___fl_flag_has_graph_first___;
         }
       }
-      else if (buffer.string[range->start] == f_fss_embedded_list_close_s.string[0] && (is_state & 0x1)) {
+      else if (buffer.string[range->start] == f_fss_embedded_list_close_s.string[0] && (flag_fl & ___fl_flag_has_graph_first___)) {
         close_location = range->start;
 
         while (range->start <= range->stop && range->start < buffer.used) {
@@ -422,7 +431,7 @@ extern "C" {
             found->used = depth + 1;
           }
 
-          if (is_state & 0x2) {
+          if (flag_fl & ___fl_flag_has_delimit_comment___) {
             state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
             if (F_status_is_error(state->status)) break;
 
@@ -434,7 +443,7 @@ extern "C" {
 
           newline_last = range->start;
           line_start = newline_last + 1;
-          is_state = 0x1;
+          flag_fl |= ___fl_flag_has_graph_first___;
 
           if (!depth) {
             state->status = f_utf_buffer_increment(buffer, range, 1);
@@ -471,7 +480,7 @@ extern "C" {
             }
 
             if (buffer.string[range->start] == f_fss_eol_s.string[0]) {
-              if (is_state & 0x2) {
+              if (flag_fl & ___fl_flag_has_delimit_comment___) {
                 state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
                 if (F_status_is_error(state->status)) break;
 
@@ -480,7 +489,7 @@ extern "C" {
 
               newline_last = range->start;
               line_start = newline_last + 1;
-              is_state = 0x1;
+              flag_fl |= ___fl_flag_has_graph_first___;
 
               break;
             }
@@ -494,7 +503,7 @@ extern "C" {
           if (F_status_is_error(state->status) || state->status == F_interrupt) break;
         }
       }
-      else if (buffer.string[range->start] == f_fss_comment_s.string[0] && (is_state & 0x1)) {
+      else if (buffer.string[range->start] == f_fss_comment_s.string[0] && (flag_fl & ___fl_flag_has_graph_first___)) {
 
         // The newline_last is initialized to the range->start, which may not actually be a new line.
         position = (buffer.string[newline_last] == f_string_eol_s.string[0]) ? newline_last + 1 : newline_last;
@@ -506,7 +515,7 @@ extern "C" {
           --range->start;
         }
         else {
-          if (is_state & 0x2) {
+          if (flag_fl & ___fl_flag_has_delimit_comment___) {
             state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size);
             if (F_status_is_error(state->status)) break;
 
@@ -515,7 +524,7 @@ extern "C" {
 
           newline_last = range->start;
           line_start = newline_last + 1;
-          is_state = 0x1;
+          flag_fl |= ___fl_flag_has_graph_first___;
         }
 
         state->status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &comments->array, &comments->used, &comments->size);
@@ -527,9 +536,9 @@ extern "C" {
       else if (buffer.string[range->start] != f_fss_eol_s.string[0]) {
         position_previous = range->start;
 
-        if (is_state & 0x1) {
+        if (flag_fl & ___fl_flag_has_graph_first___) {
           if (f_fss_is_space(buffer, *range, state) == F_false) {
-            is_state &= ~0x1;
+            flag_fl &= ~___fl_flag_has_graph_first___;
           }
         }
 
@@ -552,6 +561,16 @@ extern "C" {
         state->status = F_status_set_error(depth ? F_end_not_nest_eos : F_end_not_eos);
       }
     }
+
+    #undef ___fl_flag_do_escape___
+    #undef ___fl_flag_has_graph_first___
+    #undef ___fl_flag_has_delimit_comment___
+    #undef ___fl_flag_has_delimit_comment_graph_first___
+    #undef ___fl_flag_is_delimit_close___
+    #undef ___fl_flag_is_delimit_close_delimit_comment___
+    #undef ___fl_flag_is_object___
+    #undef ___fl_flag_is_open___
+    #undef ___fl_flag_is_open_close_graph_first___
   }
 #endif // _di_fl_fss_embedded_list_content_read_