All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlos Santos <casantos@datacom.ind.br>
To: util-linux@vger.kernel.org
Cc: Carlos Santos <casantos@datacom.ind.br>
Subject: [PATCH v2] column: fix compilation when libc lacks wide-character support
Date: Thu, 29 Jun 2017 07:55:42 -0300	[thread overview]
Message-ID: <1498733742-28381-1-git-send-email-casantos@datacom.ind.br> (raw)
In-Reply-To: <1498582242-19840-1-git-send-email-casantos@datacom.ind.br>

Commit 4762ae9d removed mtsafe_strtok() but left behind calls to wcstok
and wcspbrk. This leads to build failures when libc does not have the
wide-character functions, like some uClibc builds.

Solve the problem by using strtok_r and strpbrk when HAVE_WIDECHAR is
not defined.

Fixes:
  http://autobuild.buildroot.net/results/fd8a1a8e0cef3aeed9588540e8e663664f6b43aa
  http://autobuild.buildroot.net/results/5ad73ea8b471321988c50d80a5e50d4504151dd6
  http://autobuild.buildroot.net/results/04411b7280dc51ecd51236967981a42352bbeb3e

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>

---
Changes v1->v2: fix commit message ("problem", not "broblem").
---
 text-utils/column.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/text-utils/column.c b/text-utils/column.c
index be99f94..fb57b47 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -160,14 +160,22 @@ static wchar_t *local_wcstok(wchar_t *p, const wchar_t *separator, int greedy, w
 	wchar_t *result = NULL;
 
 	if (greedy)
+#ifdef HAVE_WIDECHAR
 		return wcstok(p, separator, state);
+#else
+		return strtok_r(p, separator, state);
+#endif
 	if (!p) {
 		if (!*state || !**state)
 			return NULL;
 		p = *state;
 	}
 	result = p;
+#ifdef HAVE_WIDECHAR
 	p = wcspbrk(result, separator);
+#else
+	p = strpbrk(result, separator);
+#endif
 	if (!p)
 		*state = NULL;
 	else {
-- 
2.7.5


  reply	other threads:[~2017-06-29 10:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 16:50 [PATCH] column: fix compilation when libc lacks wide-character support Carlos Santos
2017-06-29 10:55 ` Carlos Santos [this message]
2017-06-29 11:07   ` [PATCH v2] " Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498733742-28381-1-git-send-email-casantos@datacom.ind.br \
    --to=casantos@datacom.ind.br \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.