Do not force either double or single quote by default.
If there are no quotes, then they should be treated as unquoted.
* Types for FSS quote.
*
* f_fss_quote_type_*:
+ * - none: Not a quote.
* - single: Quote type is a single quote.
* - double: Quote type is a double quote.
*/
#ifndef _di_f_fss_quote_type_
enum {
- f_fss_quote_type_single_e = 1,
+ f_fss_quote_type_none_e = 0,
+ f_fss_quote_type_single_e,
f_fss_quote_type_double_e,
};
#endif // _di_f_fss_quote_type_
}
const f_array_length_t delimits_used = delimits->used;
+ const f_array_length_t quotes_used = quotes ? quotes->used : 0;
uint8_t content_found = 0;
- f_fss_quote_t quoted = 0;
+ f_fss_quote_t quoted = f_fss_quote_type_none_e;
while (range->start <= range->stop && range->start < buffer.used) {
f_string_range_t content_partial = f_string_range_t_initialize;
- quoted = 0;
+ quoted = f_fss_quote_type_none_e;
status = private_fl_fss_basic_read(buffer, F_false, state, range, &content_partial, "ed, delimits);
if (status == F_fss_found_object || status == F_fss_found_object_content_not) {
+ status_allocate = f_string_ranges_increase(state.step_small, found);
- if (found->used + 1 > found->size) {
- status_allocate = f_string_ranges_increase(state.step_small, found);
-
- if (F_status_is_fine(status_allocate) && quotes) {
- status_allocate = f_uint8s_resize(found->size, quotes);
- }
+ if (F_status_is_error_not(status_allocate) && quotes) {
+ status_allocate = f_uint8s_increase(state.step_small, quotes);
+ }
- if (F_status_is_error(status_allocate)) {
- delimits->used = delimits_used;
+ if (F_status_is_error(status_allocate)) {
+ delimits->used = delimits_used;
- return status_allocate;
+ if (quotes) {
+ quotes->used = quotes_used;
}
+
+ return status_allocate;
}
found->array[found->used++] = content_partial;
if (quotes) {
- quotes->array[quotes->used] = quoted == f_fss_quote_type_double_e ? f_string_ascii_quote_double_s.string[0] : f_string_ascii_quote_single_s.string[0];
+ if (quoted == f_fss_quote_type_double_e) {
+ quotes->array[quotes->used] = f_string_ascii_quote_double_s.string[0];
+ }
+ else if (quoted == f_fss_quote_type_double_e) {
+ quotes->array[quotes->used] = f_string_ascii_quote_single_s.string[0];
+ }
+ else {
+ quotes->array[quotes->used] = 0;
+ }
+
quotes->used = found->used;
}
* Errors (with error bit) from: f_fss_is_zero_width().
* Errors (with error bit) from: f_fss_skip_past_delimit().
* Errors (with error bit) from: f_fss_skip_past_space().
+ * Errors (with error bit) from: f_string_ranges_increase().
+ * Errors (with error bit) from: f_uint8s_increase().
* Errors (with error bit) from: f_utf_buffer_increment().
*
* @see f_array_lengths_increase()
* @see f_fss_is_zero_width()
* @see f_fss_skip_past_delimit()
* @see f_fss_skip_past_space()
+ * @see f_string_ranges_increase()
+ * @see f_uint8s_increase()
* @see f_utf_buffer_increment()
* @see fl_fss_basic_object_read()
* @see fl_fss_extended_object_read()
f_char_t quote_found = 0;
if (quoted) {
- *quoted = 0;
+ *quoted = f_fss_quote_type_none_e;
}
// Identify where the object begins.
else if (quote_found == f_fss_delimit_quote_double_s.string[0]) {
*quoted = f_fss_quote_type_double_e;
}
+ else {
+ *quoted = f_fss_quote_type_none_e;
+ }
}
range->start = first_slash;
else if (quote_found == f_fss_delimit_quote_double_s.string[0]) {
*quoted = f_fss_quote_type_double_e;
}
+ else {
+ *quoted = f_fss_quote_type_none_e;
+ }
}
found->stop = range->start - 1;
status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]);
if (F_status_is_error(status2)) return status2;
- ++contents->used;
+ contents->array[contents->used++].used = 0;
return F_fss_found_object_content_not;
}
status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]);
if (F_status_is_error(status2)) return status2;
- ++contents->used;
+ contents->array[contents->used++].used = 0;
return F_fss_found_object_content_not;
}
status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]);
if (F_status_is_error(status2)) return status2;
- ++contents->used;
+ contents->array[contents->used++].used = 0;
if (contents_quoted) {
status2 = f_uint8s_increase(state.step_small, &contents_quoted->array[contents_quoted->used]);
if (F_status_is_error(status2)) return status2;
- ++contents_quoted->used;
+ contents_quoted->array[contents_quoted->used++].used = 0;
}
return F_fss_found_object_content_not;
if (F_status_is_error(status2)) return status2;
quoted_content = &contents_quoted->array[contents_quoted->used];
+ quoted_content->used = 0;
}
status = fl_fss_extended_content_read(buffer, state, range, &contents->array[contents->used], quoted_content, contents_delimits ? contents_delimits : objects_delimits);
status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]);
if (F_status_is_error(status2)) return status2;
- ++contents->used;
+ contents->array[contents->used++].used = 0;
return F_fss_found_object_content_not;
}
status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]);
if (F_status_is_error(status2)) return status2;
- ++contents->used;
+ contents->array[contents->used++].used = 0;
return status;
}