]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
column: pass control struct to local_wcstok()
authorSami Kerola <kerolasa@iki.fi>
Sat, 17 Aug 2019 20:05:39 +0000 (21:05 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 21 Aug 2019 13:00:16 +0000 (15:00 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
text-utils/column.c

index 9d56e514c30586c80507afab58965346ec495415..33c7f1f554ca82b1e77c6c5d2653882c228d3420 100644 (file)
@@ -158,15 +158,16 @@ static char *wcs_to_mbs(const wchar_t *s)
 #endif
 }
 
-static wchar_t *local_wcstok(wchar_t *p, const wchar_t *separator, int greedy, wchar_t **state)
+static wchar_t *local_wcstok(struct column_control const *const ctl, wchar_t *p,
+                            wchar_t **state)
 {
        wchar_t *result = NULL;
 
-       if (greedy)
+       if (ctl->greedy)
 #ifdef HAVE_WIDECHAR
-               return wcstok(p, separator, state);
+               return wcstok(p, ctl->input_separator, state);
 #else
-               return strtok_r(p, separator, state);
+               return strtok_r(p, ctl->input_separator, state);
 #endif
        if (!p) {
                if (!*state)
@@ -175,9 +176,9 @@ static wchar_t *local_wcstok(wchar_t *p, const wchar_t *separator, int greedy, w
        }
        result = p;
 #ifdef HAVE_WIDECHAR
-       p = wcspbrk(result, separator);
+       p = wcspbrk(result, ctl->input_separator);
 #else
-       p = strpbrk(result, separator);
+       p = strpbrk(result, ctl->input_separator);
 #endif
        if (!p)
                *state = NULL;
@@ -435,7 +436,7 @@ static int add_line_to_table(struct column_control *ctl, wchar_t *wcs)
        if (!ctl->tab)
                init_table(ctl);
 
-       while ((wcdata = local_wcstok(wcs, ctl->input_separator, ctl->greedy, &sv))) {
+       while ((wcdata = local_wcstok(ctl, wcs, &sv))) {
                char *data;
 
                if (scols_table_get_ncols(ctl->tab) < n + 1) {