Skip to content

Commit

Permalink
csvparser-filterx: extract _fill_array_element()
Browse files Browse the repository at this point in the history
Signed-off-by: László Várady <[email protected]>
  • Loading branch information
MrAnno committed Aug 13, 2024
1 parent 4082672 commit 51831dd
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions modules/csvparser/filterx-func-parse-csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ _fill_object_col(FilterXObject *cols, gint64 index, CSVScanner *scanner, FilterX
return ok;
}

static inline gboolean
_fill_array_element(CSVScanner *scanner, FilterXObject *result)
{
const gchar *current_value = csv_scanner_get_current_value(scanner);
gint current_value_len = csv_scanner_get_current_value_len(scanner);
FilterXObject *val = filterx_string_new(current_value, current_value_len);

gboolean ok = filterx_list_append(result, &val);

filterx_object_unref(val);

return ok;
}

static FilterXObject *
_eval(FilterXExpr *s)
{
Expand Down Expand Up @@ -206,13 +220,7 @@ _eval(FilterXExpr *s)
}
else
{
const gchar *current_value = csv_scanner_get_current_value(&scanner);
gint current_value_len = csv_scanner_get_current_value_len(&scanner);
FilterXObject *val = filterx_string_new(current_value, current_value_len);

ok = filterx_list_append(result, &val);

filterx_object_unref(val);
ok = _fill_array_element(&scanner, result);
}
}

Expand Down

0 comments on commit 51831dd

Please sign in to comment.