From: Kevin Day Date: Sun, 28 May 2023 20:25:26 +0000 (-0500) Subject: Bugfix: Comments are being included when processing --total and --at. X-Git-Tag: 0.6.6~32 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=49cf0437d22e3d65564de1aa58934f37571a0c8a;p=fll Bugfix: Comments are being included when processing --total and --at. Valid comments should be ignored. Lines representing a valid comment must not be counted as a line. --- diff --git a/level_3/fss_basic_list_read/c/private-read.c b/level_3/fss_basic_list_read/c/private-read.c index 5b7e6f4..74c80ac 100644 --- a/level_3/fss_basic_list_read/c/private-read.c +++ b/level_3/fss_basic_list_read/c/private-read.c @@ -490,6 +490,7 @@ extern "C" { f_string_range_t range = data->contents.array[at].array[0]; f_array_length_t i = 0; + f_array_length_t j = 0; // This content has no data, do not even check "include empty" because it cannot be counted as a line. if (range.start > range.stop) { @@ -508,6 +509,16 @@ extern "C" { main->signal_check = 0; } + if (j < data->comments.used) { + while (data->comments.array[j].stop < i) ++j; + + if (i >= data->comments.array[j].start && i <= data->comments.array[j].stop) { + i = data->comments.array[j++].stop; + + continue; + } + } + if (data->buffer.string[i] == f_string_eol_s.string[0]) { if (*line == data->line) { range.stop = i; @@ -733,6 +744,7 @@ extern "C" { f_array_length_t total = 0; f_string_range_t range = f_string_range_t_initialize; f_array_length_t i = 0; + f_array_length_t j = 0; for (f_array_length_t at = 0; at < data->contents.used; ++at) { @@ -765,6 +777,16 @@ extern "C" { for (i = range.start; i <= range.stop; ++i) { + if (j < data->comments.used) { + while (data->comments.array[j].stop < i) ++j; + + if (i >= data->comments.array[j].start && i <= data->comments.array[j].stop) { + i = data->comments.array[j++].stop; + + continue; + } + } + if (data->buffer.string[i] == f_string_eol_s.string[0]) { range.start = i + 1; diff --git a/level_3/fss_extended_list_read/c/private-read.c b/level_3/fss_extended_list_read/c/private-read.c index b53cf55..808859f 100644 --- a/level_3/fss_extended_list_read/c/private-read.c +++ b/level_3/fss_extended_list_read/c/private-read.c @@ -501,6 +501,7 @@ extern "C" { f_string_range_t range = f_string_range_t_initialize; f_array_length_t i = 0; + f_array_length_t j = 0; range.start = data->contents.array[at].array[0].start; range.stop = data->contents.array[at].array[0].stop; @@ -512,6 +513,16 @@ extern "C" { for (i = range.start; i <= range.stop; ++i) { + if (j < data->comments.used) { + while (data->comments.array[j].stop < i) ++j; + + if (i >= data->comments.array[j].start && i <= data->comments.array[j].stop) { + i = data->comments.array[j++].stop; + + continue; + } + } + if (data->buffer.string[i] == f_string_eol_s.string[0]) { if (*line == data->line) { range.stop = i; @@ -719,6 +730,7 @@ extern "C" { f_array_length_t total = 0; f_string_range_t range = f_string_range_t_initialize; f_array_length_t i = 0; + f_array_length_t j = 0; for (f_array_length_t at = 0; at < data->contents.used; ++at) { @@ -746,6 +758,16 @@ extern "C" { for (i = range.start; i <= range.stop; ++i) { + if (j < data->comments.used) { + while (data->comments.array[j].stop < i) ++j; + + if (i >= data->comments.array[j].start && i <= data->comments.array[j].stop) { + i = data->comments.array[j++].stop; + + continue; + } + } + if (data->buffer.string[i] == f_string_eol_s.string[0]) { range.start = i + 1; diff --git a/level_3/fss_payload_read/c/private-read.c b/level_3/fss_payload_read/c/private-read.c index 2a52585..d930469 100644 --- a/level_3/fss_payload_read/c/private-read.c +++ b/level_3/fss_payload_read/c/private-read.c @@ -687,6 +687,7 @@ extern "C" { f_string_range_t range = f_string_range_t_initialize; f_array_length_t i = 0; + f_array_length_t j = 0; range.start = data->contents.array[at].array[0].start; range.stop = data->contents.array[at].array[0].stop; @@ -708,6 +709,16 @@ extern "C" { main->signal_check = 0; } + if (j < data->comments.used) { + while (data->comments.array[j].stop < i) ++j; + + if (i >= data->comments.array[j].start && i <= data->comments.array[j].stop) { + i = data->comments.array[j++].stop; + + continue; + } + } + if (data->buffer.string[i] == f_string_eol_s.string[0]) { if (*line == data->line) { range.stop = i; @@ -1051,6 +1062,7 @@ extern "C" { f_array_length_t total = 0; f_string_range_t range = f_string_range_t_initialize; f_array_length_t i = 0; + f_array_length_t j = 0; for (f_array_length_t at = 0; at < data->contents.used; ++at) { @@ -1085,6 +1097,16 @@ extern "C" { for (i = range.start; i <= range.stop; ++i) { + if (j < data->comments.used) { + while (data->comments.array[j].stop < i) ++j; + + if (i >= data->comments.array[j].start && i <= data->comments.array[j].stop) { + i = data->comments.array[j++].stop; + + continue; + } + } + if (data->buffer.string[i] == f_string_eol_s.string[0]) { range.start = i + 1;