Any line that ends up being a valid comment line may have white space on the left.
For lists, such as FSS Basic List, the leading white space is being printed.
This is not correct at all.
This is easily solved by getting the last new line and add one.
Update the specification to make the expected behavior clear.
Cleanup comment lines and other related code while its convenient.
if (status == F_none_eol) {
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;
return F_data_not_stop;
}
- // begin the search.
+ // Begin the search.
found->start = range->start;
- // ignore all comment lines.
+ // Ignore all comment lines.
if (buffer.string[range->start] == f_fss_comment_s[0]) {
status = f_fss_seek_to_eol(buffer, range);
return F_data_not_stop;
}
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
else if (graph_first && buffer.string[range->start] == f_fss_comment_s[0]) {
graph_first = F_false;
- // comments may only have whitespace before the '#', therefore only the first slash needs to be delimited.
+ // Comments may only have whitespace before the '#', therefore only the first slash needs to be delimited.
macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits));
if (F_status_is_error(status)) break;
continue;
}
- else if (buffer.string[range->start] == f_fss_basic_list_open_s[0]) {
+
+ if (buffer.string[range->start] == f_fss_basic_list_open_s[0]) {
graph_first = F_false;
stop = range->start - 1;
uint8_t graph_first = 0x1; // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set.
- // identify where the content ends.
+ // Identify where the content ends.
while (range->start <= range->stop && range->start < buffer.used) {
if (state.interrupt) {
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (range->start > range->stop || range->start >= buffer.used) break;
- // found a valid object, set stop point to last newline.
+ // Found a valid object, set stop point to last newline.
if (buffer.string[range->start] == f_fss_eol_s[0]) {
if (newline_last == found->array[found->used].start && buffer.string[found->array[found->used].start] != f_fss_eol_s[0]) {
}
if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s[0]) {
- start = range->start;
+ start = newline_last + 1;
status = f_fss_seek_to_eol(buffer, range);
if (F_status_is_error(status)) break;
comments->array[comments->used].start = start;
comments->array[comments->used++].stop = range->start++;
+
continue;
}
return F_data_not_eos;
}
- // ensure that there is room for a slash delimit, the object open character, and the end of line character.
+ // Ensure that there is room for a slash delimit, the object open character, and the end of line character.
status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 3, destination);
if (F_status_is_error(status)) return status;
uint8_t width = 0;
- // find the first graph character.
+ // Find the first graph character.
while (range->start <= range->stop && range->start < object.used) {
if (state.interrupt) {
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (object.string[range->start] == f_fss_comment_s[0]) {
- // when a comment is found, escape it.
+ // When a comment is found, escape it.
status = f_string_dynamic_increase(state.step_large, destination);
if (F_status_is_error(status)) break;
destination->string[destination->used++] = F_fss_delimit_slash_s;
+
break;
}
if (status == F_true) break;
- // objects will not have leading whitespaces, but having this does not result in an invalid object, so just write the provided spaces.
+ // Objects will not have leading whitespaces, but having this does not result in an invalid object, so just write the provided spaces.
if (object.string[range->start] != F_fss_delimit_placeholder_s) {
if (object.string[range->start] == f_fss_eol_s[0]) {
status = F_status_set_error(F_none_eol);
+
break;
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (range->start > range->stop || range->start >= object.used) {
- // slashes at the end of the object must be delimited to avoid delimiting the object close character.
+ // Slashes at the end of the object must be delimited to avoid delimiting the object close character.
slash_count *= 2;
}
if (object.string[range->start] != F_fss_delimit_placeholder_s) {
if (object.string[range->start] == f_fss_eol_s[0]) {
status = F_status_set_error(F_none_eol);
+
break;
}
return F_data_not_eos;
}
- // ensure that there is room for a slash delimit and possibly the end of content character.
+ // Ensure that there is room for a slash delimit and possibly the end of content character.
status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 2, destination);
if (F_status_is_error(status)) return status;
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (content.string[range->start] == f_fss_eol_s[0] || range->start >= content.used || range->start > range->stop) {
- // increase by total slashes + 1, along with the basic list open and possible newline.
+ // Increase by total slashes + 1, along with the basic list open and possible newline.
status = f_string_dynamic_increase_by(slash_count + 3, destination);
if (F_status_is_error(status)) break;
destination->string[destination->used++] = f_fss_basic_list_open_s[0];
range->start = start + 1;
+
continue;
}
}
if (content.string[range->start] == f_fss_eol_s[0] || range->start >= content.used || range->start > range->stop) {
- // increase by slash and basic list open and possible newline.
+ // Increase by slash and basic list open and possible newline.
status = f_string_dynamic_increase_by(3, destination);
if (F_status_is_error(status)) break;
destination->string[destination->used++] = f_fss_basic_list_open_s[0];
range->start = start + 1;
+
continue;
}
else if (content.string[range->start] == f_fss_comment_s[0] && !has_graph) {
status = f_string_dynamic_increase(state.step_large, destination);
if (F_status_is_error(status)) return status;
- // check to see if a newline exists, at the end.
+ // Check to see if a newline exists, at the end.
if (destination->used) {
for (i = destination->used - 1; i > 0; --i) {
if (destination->string[i] != F_fss_delimit_placeholder_s) break;
if (status == F_none_eol) {
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;
return F_data_not_stop;
}
- // return found nothing if this line only contains whitespace and delimit placeholders.
+ // Return found nothing if this line only contains whitespace and delimit placeholders.
if (buffer.string[range->start] == f_fss_eol_s[0]) {
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;
}
- // begin the search.
+ // Begin the search.
found->start = range->start;
- // ignore all comment lines.
+ // Ignore all comment lines.
if (buffer.string[range->start] == f_fss_comment_s[0]) {
status = f_fss_seek_to_eol(buffer, range);
return F_data_not_stop;
}
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;
bool graph_first = F_true;
- // identify where the object ends.
+ // Identify where the object ends.
while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s[0]) {
if (state.interrupt) {
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
else if (graph_first && buffer.string[range->start] == f_fss_comment_s[0]) {
graph_first = F_false;
- // comments may only have whitespace before the '#', therefore only the first slash needs to be delimited.
+ // Comments may only have whitespace before the '#', therefore only the first slash needs to be delimited.
macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits));
if (F_status_is_error(status)) break;
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (buffer.string[range->start] == f_fss_eol_s[0]) {
found->stop = stop;
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object;
return status;
}
- // seek to the end of the line when no valid object is found.
+ // Seek to the end of the line when no valid object is found.
while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s[0]) {
if (state.interrupt) {
uint8_t graph_first = 0x0; // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set.
- // initialize depth 1 start position.
- // positions_start.used is used as a max depth (such that positions_start.used == max depth + 1).
+ // Initialize depth 1 start position.
+ // Positions_start.used is used as a max depth (such that positions_start.used == max depth + 1).
positions_start.array[0] = range->start;
positions_start.used = 1;
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
}
line_start = range->start;
+
continue;
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
}
// All slashes for an open are delimited (because it could represent a slash in the object name).
- // for example 'object {' = valid open, name 'object', 'object \{' represents 'object {', 'object \\{' = valid open, name 'object \', 'object \\\{' represents 'object \{', etc..
+ // For example 'object {' = valid open, name 'object', 'object \{' represents 'object {', 'object \\{' = valid open, name 'object \', 'object \\\{' represents 'object \{', etc..
// Only the first slash before a close is delimited, all others are maintained.
- // for example '}' = valid close, '\}' represents '}', '\\}' represents '\}', '\\\}' represents '\\}', '\\\\}' represents '\\\}', and so on..
+ // 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[0]) {
if (graph_first == 0x2) {
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
newline_last = range->start;
line_start = range->start + 1;
graph_first = 0x1;
+
break;
}
private_macro_fl_fss_nest_return_on_overflow((buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, slashes, F_data_not_eos, F_data_not_stop);
}
- // this is a valid object open/close that has been delimited, save the slash delimit positions.
+ // This is a valid object open/close that has been delimited, save the slash delimit positions.
if (buffer.string[range->start] == f_fss_eol_s[0]) {
newline_last = range->start;
line_start = range->start + 1;
macro_f_fss_delimits_t_increase_by(status, (*delimits), (slashes.array[depth] / 2) + 1);
if (F_status_is_error(status)) break;
- // apply slash delimits, only slashes and placeholders should be present.
+ // Apply slash delimits, only slashes and placeholders should be present.
while (slashes.array[depth]) {
if (buffer.string[range->start] == F_fss_delimit_slash_s) {
if (F_status_is_error(status)) break;
- // when slashes are even, the object is valid and needs to be processed.
+ // When slashes are even, the object is valid and needs to be processed.
if (is_object) {
++depth;
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (depth) {
found->depth[depth].array[position].parent = found->depth[depth - 1].used;
- // only assign object positions for nested objects.
+ // Only assign object positions for nested objects.
found->depth[depth].array[position].object.start = objects.array[depth].start;
found->depth[depth].array[position].object.stop = objects.array[depth].stop;
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
newline_last = range->start;
line_start = range->start + 1;
graph_first = 0x1;
+
break;
}
}
}
else if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s[0]) {
- position = range->start;
+ position = newline_last + 1;
status = f_fss_seek_to_eol(buffer, range);
if (F_status_is_error(status)) break;
comments->array[comments->used].start = position;
comments->array[comments->used++].stop = range->start++;
+
continue;
}
else if (buffer.string[range->start] != f_fss_eol_s[0]) {
return status;
}
- // ensure that there is room for a slash delimit, the object open character, and the end of line character.
+ // Ensure that there is room for a slash delimit, the object open character, and the end of line character.
status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 3, destination);
if (F_status_is_error(status)) return status;
uint8_t width = 0;
- // find the first graph character.
+ // Find the first graph character.
while (range->start <= range->stop && range->start < object.used) {
if (state.interrupt) {
if (object.string[range->start] == f_fss_comment_s[0]) {
- // when a comment is found, escape it.
+ // When a comment is found, escape it.
status = f_string_dynamic_increase(state.step_large, destination);
if (F_status_is_error(status)) break;
if (status == F_true) break;
- // objects will not have leading whitespaces, but having this does not result in an invalid object, so just write the provided spaces.
+ // Objects will not have leading whitespaces, but having this does not result in an invalid object, so just write the provided spaces.
if (object.string[range->start] != F_fss_delimit_placeholder_s) {
if (object.string[range->start] == f_fss_eol_s[0]) {
status = F_status_set_error(F_none_eol);
if (range->start > range->stop || range->start >= object.used) {
- // slashes at the end of the object must be delimited to avoid delimiting the object close character.
+ // Slashes at the end of the object must be delimited to avoid delimiting the object close character.
slash_count *= 2;
}
return status;
}
- // prevent a space from being added post-trimming.
+ // Prevent a space from being added post-trimming.
ends_on_space = F_true;
}
return status;
}
- // ensure that there is room for a slash delimit and possibly the end of content characters.
+ // Ensure that there is room for a slash delimit and possibly the end of content characters.
status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 3, destination);
if (F_status_is_error(status)) return status;
if (range->start >= content.used || range->start > range->stop || content.string[range->start] == f_fss_eol_s[0]) {
- // increase by total slashes + 1 embedded list open/close.
+ // Increase by total slashes + 1 embedded list open/close.
status = f_string_dynamic_increase_by(slash_count + 2, destination);
if (F_status_is_error(status)) break;
continue;
}
- // increase by character at "start" and possible newline.
+ // Increase by character at "start" and possible newline.
status = f_string_dynamic_increase_by(2, destination);
if (F_status_is_error(status)) break;
}
}
- // increase by slash and extended list open and possible newline.
+ // Increase by slash and extended list open and possible newline.
status = f_string_dynamic_increase_by(3, destination);
if (F_status_is_error(status)) break;
if (status == F_none_eol) {
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;
return F_data_not_stop;
}
- // return found nothing if this line only contains whitespace and delimit placeholders.
+ // Return found nothing if this line only contains whitespace and delimit placeholders.
if (buffer.string[range->start] == f_fss_eol_s[0]) {
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;
}
- // begin the search.
+ // Begin the search.
found->start = range->start;
- // ignore all comment lines.
+ // Ignore all comment lines.
if (buffer.string[range->start] == f_fss_comment_s[0]) {
status = f_fss_seek_to_eol(buffer, range);
return F_data_not_stop;
}
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;
bool graph_first = F_true;
- // identify where the object ends.
+ // Identify where the object ends.
while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s[0]) {
if (state.interrupt) {
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (buffer.string[range->start] == F_fss_delimit_slash_s) {
if (slash_count % 2 == 1) {
- delimits->array[delimits->used] = range->start;
- ++delimits->used;
+ delimits->array[delimits->used++] = range->start;
}
--slash_count;
}
range->start = start + 1;
+
return F_fss_found_object_not;
}
}
else if (graph_first && buffer.string[range->start] == f_fss_comment_s[0]) {
graph_first = F_false;
- // comments may only have whitespace before the '#', therefore only the first slash needs to be delimited.
+ // Comments may only have whitespace before the '#', therefore only the first slash needs to be delimited.
macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits));
if (F_status_is_error(status)) break;
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (buffer.string[range->start] == f_fss_eol_s[0]) {
found->stop = stop;
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object;
return status;
}
- // seek to the end of the line when no valid object is found.
+ // Seek to the end of the line when no valid object is found.
while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s[0]) {
if (state.interrupt) {
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
f_array_length_t slash_count = 0;
f_array_length_t start = 0;
- // identify where the content ends.
+ // Identify where the content ends.
while (range->start <= range->stop && range->start < buffer.used) {
if (state.interrupt) {
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_is_error(status)) break;
delimits->array[delimits->used++] = slash_first;
+
continue;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (range->start > range->stop || range->start >= buffer.used) break;
- // found a valid content close, set stop point to last newline.
+ // Found a valid content close, set stop point to last newline.
if (buffer.string[range->start] == f_fss_eol_s[0]) {
++range->start;
}
if (buffer.string[range->start] == f_fss_comment_s[0]) {
- start = range->start;
+ start = newline_last + 1;
status = f_fss_seek_to_eol(buffer, range);
if (F_status_is_error(status)) break;
comments->array[comments->used].start = start;
comments->array[comments->used++].stop = range->start++;
+
continue;
}
return status;
}
- // ensure that there is room for a slash delimit, the object open character, and the end of line character.
+ // Ensure that there is room for a slash delimit, the object open character, and the end of line character.
status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 3, destination);
if (F_status_is_error(status)) return status;
uint8_t width = 0;
- // find the first graph character.
+ // Find the first graph character.
while (range->start <= range->stop && range->start < object.used) {
if (state.interrupt) {
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (object.string[range->start] == f_fss_comment_s[0]) {
- // when a comment is found, escape it.
+ // When a comment is found, escape it.
status = f_string_dynamic_increase(state.step_large, destination);
if (F_status_is_error(status)) break;
destination->string[destination->used++] = F_fss_delimit_slash_s;
+
break;
}
if (status == F_true) break;
- // objects will not have leading whitespaces, but having this does not result in an invalid object, so just write the provided spaces.
+ // Objects will not have leading whitespaces, but having this does not result in an invalid object, so just write the provided spaces.
if (object.string[range->start] != F_fss_delimit_placeholder_s) {
if (object.string[range->start] == f_fss_eol_s[0]) {
status = F_status_set_error(F_none_eol);
+
break;
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
if (range->start > range->stop || range->start >= object.used) {
- // slashes at the end of the object must be delimited to avoid delimiting the object close character.
+ // Slashes at the end of the object must be delimited to avoid delimiting the object close character.
slash_count *= 2;
}
if (range->start > range->stop || range->start >= object.used) {
ends_on_space = F_false;
+
break;
}
}
if (object.string[range->start] != F_fss_delimit_placeholder_s) {
if (object.string[range->start] == f_fss_eol_s[0]) {
status = F_status_set_error(F_none_eol);
+
break;
}
if (F_status_is_error(status)) {
destination->used = used_start;
+
return status;
}
return status;
}
- // prevent a space from being added post-trimming.
+ // Prevent a space from being added post-trimming.
ends_on_space = F_true;
}
return status;
}
- // ensure that there is room for a slash delimit and possibly the end of content characters.
+ // Ensure that there is room for a slash delimit and possibly the end of content characters.
status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 3, destination);
if (F_status_is_error(status)) return status;
if (F_status_set_fine(status) == F_interrupt) {
status = F_status_set_error(F_interrupt);
+
break;
}
}
continue;
}
- // increase by character at "start" and possible newline.
+ // Increase by character at "start" and possible newline.
status = f_string_dynamic_increase_by(2, destination);
if (F_status_is_error(status)) break;
}
range->start = start + 1;
+
continue;
}
}
}
}
- // increase by slash and extended list close.
+ // Increase by slash and extended list close.
status = f_string_dynamic_increase_by(2, destination);
if (F_status_is_error(status)) break;
destination->string[destination->used++] = content.string[start];
range->start = start + 1;
+
continue;
}
else if (content.string[range->start] == f_fss_comment_s[0] && !has_graph) {
uint8_t width = 0;
- // if there are any spaces, then this will be quoted so find the first non-placeholder character.
+ // If there are any spaces, then this will be quoted so find the first non-placeholder character.
for (; destination_range.start < destination->used; ++destination_range.start) {
if (state.interrupt) {
} // for
} // for
- // find the last quote.
+ // Find the last quote.
for (destination_range.start = destination->used - 1; destination_range.start > front; --destination_range.start) {
if (state.interrupt) {
status = f_fss_is_space(*destination, destination_range);
- // when going backwards, getting incomplete UTF-8 sequences is not an error.
+ // When going backwards, getting incomplete UTF-8 sequences is not an error.
if (F_status_set_fine(status) == F_complete_not_utf) continue;
if (F_status_is_error(status)) {
} // for
} // for
- // if there is no whitespace between the quotes, post-trimming, then remove the quotes.
+ // If there is no whitespace between the quotes, post-trimming, then remove the quotes.
for (destination_range.start = front; destination_range.start < rear; ++destination_range.start) {
if (state.interrupt) {
if (status == F_none_eol) {
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;
return F_data_not_stop;
}
- // begin the search.
+ // Begin the search.
found->start = range->start;
- // ignore all comment lines.
+ // Ignore all comment lines.
if (object_as && buffer.string[range->start] == f_fss_comment_s[0]) {
while (buffer.string[range->start] != f_fss_eol_s[0]) {
}
} // while
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;
}
- // handle quoted support.
+ // Handle quoted support.
char quote_found = 0;
if (quote) {
*quote = 0;
}
- // identify where the object begins.
+ // Identify where the object begins.
if (buffer.string[range->start] == F_fss_delimit_slash_s) {
f_array_length_t first_slash = range->start;
status = f_fss_is_space(buffer, *range);
if (F_status_is_error(status)) break;
- // found the end of the object while processing the slash for potential delimits.
+ // Found the end of the object while processing the slash for potential delimits.
if (status == F_true) {
found->stop = range->start - 1;
if (buffer.string[range->start] == F_fss_delimit_quote_single_s || buffer.string[range->start] == F_fss_delimit_quote_double_s || (object_as && buffer.string[range->start] == f_fss_comment_s[0])) {
- // only the first slash before a quoted needs to be escaped (or not) as once there is a slash before a quoted, this cannot ever be a quote object.
- // this simplifies the number of slashes needed.
+ // Only the first slash before a quoted needs to be escaped (or not) as once there is a slash before a quoted, this cannot ever be a quote object.
+ // This simplifies the number of slashes needed.
macro_f_fss_delimits_t_increase(status, state.step_small, (*delimits));
if (F_status_is_error(status)) return status;
found->start = range->start;
}
- // identify where the object ends.
+ // Identify where the object ends.
if (!quote_found) {
status = F_none;
if (buffer.string[range->start] == f_fss_eol_s[0]) {
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_content_not;
if (buffer.string[range->start] == quote_found) {
location = range->start;
- // check to see if there is a whitespace, EOS, or EOL after the quoted, if not, then this is not a closing quoted and delimits do not apply.
+ // Check to see if there is a whitespace, EOS, or EOL after the quoted, if not, then this is not a closing quoted and delimits do not apply.
if (range->start + 1 <= range->stop && range->start + 1 < buffer.used) {
++range->start;
if (buffer.string[range->start] == f_fss_eol_s[0]) {
found->stop = location - 1;
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_content_not;
}
else if (buffer.string[range->start] == quote_found) {
- // check to see if there is a whitespace, EOS, or EOL after the quoted, if not, then this is not a closing quoted.
+ // Check to see if there is a whitespace, EOS, or EOL after the quoted, if not, then this is not a closing quoted.
location = range->start;
if (range->start + 1 <= range->stop && range->start + 1 < buffer.used) {
if (buffer.string[range->start] == f_fss_eol_s[0]) {
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_content_not;
}
else if (buffer.string[range->start] == f_fss_eol_s[0]) {
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;
}
}
- // seek to the EOL when no valid object is found.
+ // Seek to the EOL when no valid object is found.
status = f_fss_seek_to_eol(buffer, range);
if (F_status_is_error(status)) return status;
- // move the start position to after the EOL.
+ // Move the start position to after the EOL.
++range->start;
return F_fss_found_object_not;
return F_data_not_stop;
}
- // ensure that there is room for the potential start and stop quotes, a potential delimit at start, and the potential object open character.
+ // Ensure that there is room for the potential start and stop quotes, a potential delimit at start, and the potential object open character.
status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 4, destination);
if (F_status_is_error(status)) return status;
f_array_length_t item_total = 0;
f_array_length_t i = 0;
- // use placeholders for potential quote and potential delimited quote to avoid doing things such as memmove().
+ // Use placeholders for potential quote and potential delimited quote to avoid doing things such as memmove().
destination->string[destination->used++] = F_fss_delimit_placeholder_s;
destination->string[destination->used++] = F_fss_delimit_placeholder_s;
- // if there is an initial quote, then this must be quoted and the existing quote must be delimited.
+ // If there is an initial quote, then this must be quoted and the existing quote must be delimited.
if (object.string[input_start] == quote) {
quoted = F_true;
}
if (range->start > range->stop || range->start >= object.used) {
- // slashes before the final quote must be escaped when quoted, add the delimit slashes.
+ // Slashes before the final quote must be escaped when quoted, add the delimit slashes.
if (quoted) {
- // if this is the first quote, then only a single delimit slash is needed.
+ // If this is the first quote, then only a single delimit slash is needed.
if (item_first == input_start) {
status = f_string_dynamic_increase(state.step_large, destination);
if (F_status_is_error(status)) break;
status = f_string_dynamic_increase_by(item_total, destination);
if (F_status_is_error(status)) break;
- // add the slashes that delimit the slashes.
+ // Add the slashes that delimit the slashes.
if (item_first == input_start) {
status = f_string_dynamic_increase(state.step_large, destination);
if (F_status_is_error(status)) break;
}
else if (object_as && object.string[range->start] == f_fss_comment_s[0]) {
- // only the first slash needs to be escaped for a comment, and then only if not quoted.
+ // Only the first slash needs to be escaped for a comment, and then only if not quoted.
if (item_first == input_start) {
commented = F_true;
}
}
else {
- // if any space is found, then this must be quoted.
+ // If any space is found, then this must be quoted.
status = f_fss_is_space(object, *range);
if (F_status_is_error(status)) break;
status = f_string_dynamic_increase_by(item_total + width, destination);
if (F_status_is_error(status)) break;
- // there is nothing to delimit, so all slashes should be printed as is.
+ // There is nothing to delimit, so all slashes should be printed as is.
for (i = 0; i < item_total; ++i) {
destination->string[destination->used++] = F_fss_delimit_slash_s;
} // for
else if (object.string[range->start] == quote) {
item_first = range->start++;
- // the very first quote, must be escaped, when quoting is disabled.
+ // The very first quote, must be escaped, when quoting is disabled.
if (item_first == input_start) {
status = f_string_dynamic_increase(state.step_large, destination);
if (F_status_is_error(status)) break;
destination->string[destination->used++] = quote;
- // the next quote must also be checked, so do not increment.
+ // The next quote must also be checked, so do not increment.
continue;
}
- // if any space is found, then this must be quoted.
+ // If any space is found, then this must be quoted.
status = f_fss_is_space(object, *range);
if (F_status_is_error(status)) break;
if (object.string[i] != F_fss_delimit_placeholder_s) break;
} // for
- // only when followed by a space must the start quote be delimited.
+ // Only when followed by a space must the start quote be delimited.
if (i <= range->stop && i < object.used) {
f_string_range_t range_i = *range;
For example, in fss-000 (Basic) the entire Content may be further represented as a single column.
For example, in fss-001 (Extended) the entire Content may be further represented as multiple columns.
- In all cases, specifications that separate Objects from Contents using whitespace, the first whitespace separating the Object and Content must not be considered part of the Object nor part of the Content.
- All spaces after the first separating whitespace is generally ignored until the first non-whitespace character is found, unless otherwise specified.
+ In all cases, specifications that separate Objects from Contents using white space, the first white space separating the Object and Content must not be considered part of the Object nor part of the Content.
+ All spaces after the first separating white space is generally ignored until the first non white space character is found, unless otherwise specified.
Unless otherwise specified, all specifications are newline sensitive ('\n' only).
Newline characters are only '\n' and are never anything else ('\r' is not considered newline in any manner).
Whitespaces characters that are printable, such as tabs and spaces, must be considered the same type for the purposes of parsing.
- Non-printing whitespaces characters (zero-width characters) are ignored, are treated as placeholders for processing, or are considered part of the appropriate character if they are Unicode combining characters (this includes zero-width punctutations characters and similar).
+ Non-printing white spaces characters (zero-width characters) are ignored, are treated as placeholders for processing, or are considered part of the appropriate character if they are Unicode combining characters (this includes zero-width punctutations characters and similar).
In terms of processing, it is recommended that the NULL character is not considered the end of a string, but this is only a suggestion.
Unless otherwise specified, newlines designate the potential start (or end) of an Object or Content.
- Unless otherwise specified, whitespace may exist to the left of the start of Objects.
- Unless otherwise specified, whitespace may exist to the right of the end of Objects, but only if that given Object is properly quoted and the whitespace is after the terminating quote but before any Content.
+ Unless otherwise specified, white space may exist to the left of the start of Objects.
+ Unless otherwise specified, white space may exist to the right of the end of Objects, but only if that given Object is properly quoted and the white space is after the terminating quote but before any Content.
- Unless otherwise specified, whitespace immediately both before (and after, outside of the terminating quote) an Object is not considered part of the Object.
- This simplifies identifying the object, use quoted Objects to support whitespace before/after an object for styling purposes.
+ Unless otherwise specified, white space immediately both before (and after, outside of the terminating quote) an Object is not considered part of the Object.
+ This simplifies identifying the object, use quoted Objects to support white space before/after an object for styling purposes.
Unless otherwise specified, quotes may only be either a single quote (') or a double quote (") and only a backslash '\' may be used as a delimiter.
For example, fss-0000 (Basic)\:
Such as these following three lines\:
"Object 1" "This is a single quoted Content." \"Additional unquoted Content."
Object_2 This is multiple" Contents and the trailing quote does not need to be delimited.
- "Object \"3" 'Wouldn't require delimits if no whitespace or end of string after.'
+ "Object \"3" 'Wouldn't require delimits if no white space or end of string after.'
Unlike this specification, a more traditional delimit process would have the above three lines instead represented as\:
"Object 1" "This is a single quoted Content." \"Additional unquoted Content.\"
Object_2 This is multiple\" Contents and the trailing quote does not need to be delimited.
- "Object \\"3" 'Wouldn\'t require delimits if no whitespace or end of string after.'
+ "Object \\"3" 'Wouldn\'t require delimits if no white space or end of string after.'
These examples would resolve as follows\:
1) Object\:
3) Object\:
- Object \"3
Content\:
- - Wouldn't require delimits if no whitespace or end of string after.
+ - Wouldn't require delimits if no white space or end of string after.
All specifications are expected to support or be of the character encoding UTF-8; however, there is no imposed restriction on supporting or using any other encoding.
Those encodings must only support the appropriate characters required by a given standard for differentiating Objects, Contents, and delimits.
All specifications do assume ASCII and Unicode support.
- Unless otherwise specified, comments are designated by the pound symbol '#' but only if only whitespace is to the left of the pound or the pound '#' is at the start of the line.
+ Unless otherwise specified, comments are designated by the pound symbol '#' but only if only white space is to the left of the pound or the pound '#' is at the start of the line.
There is no support for inline comments.
Unless otherwise specified, the start comment may be delimited by '\' in the same manner as Objects and Contents are.
This delimit only applies to the start of a comment (the pound '#' character) as there is no terminating character for a comment (other than a newline '\n').
+ A line containing a valid comment is in its entirety ignored.
+ This means that if there is white space before the designation symbol (the pound '#' character) then that white space is ignored.
Unless otherwise specified, all designation characters MUST represent ASCII codes.
With designation characters being any character code used to designate how to identify an Object or Content (such as a colon ':' at the end of a basic list).
This keeps the processing and logic simple and safe, for both UTF-8 and ASCII.
- Whitespace used for designation characters MUST include support for UTF-8 whitespace characters, unless otherwise specified.
- However, these whitespace used as a designation character, must be printing whitespace that are not combining whitespace characters.
- Any visible/graph character that is considered a whitespace (such as U+1680 ' ') is not to be considered a whitespace, unless otherwise specified.
+ Whitespace used for designation characters MUST include support for UTF-8 white space characters, unless otherwise specified.
+ However, these white space used as a designation character, must be printing white space that are not combining white space characters.
+ Any visible/graph character that is considered a white space (such as U+1680 ' ') is not to be considered a white space, unless otherwise specified.
When used for syntax matching purposes, zero-width Unicode characters are only to be considered zero-width unless otherwise specified.
For example, the "invisible plus" character (U+2064) is not to be considered as a plus.
One such example is in the case of a URL, where the name could be used to trick a person (http://this-site.com/ vs http://this‐site.com/).
This (potential insecure behavior) is allowed in general because a well written program would be able to detect and communicate the possible misunderstanding and thereby avoid mistakes without imposing any character restrictions.
- This is a common behavior for security reasons, each character used for any special purposes must be visibly distinct, with whitespace and non-printing characters as the exception to the words "visibly distinct".
+ This is a common behavior for security reasons, each character used for any special purposes must be visibly distinct, with white space and non-printing characters as the exception to the words "visibly distinct".
The follow specifications are defined in this project.
Each of these specifications has a common name associated with the specification number.