summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2011-03-12 14:22:54 +0000
committerPádraig Brady <P@draigBrady.com>2011-03-13 23:55:17 +0000
commit0ddfd54b08dfe4e78b8aa2dd74378e5b62c9d68c (patch)
tree56a4ba7d2ffa7beb3f9ccf9291821b8e33084924
parent56e8714e2b3b186c2da52f7c7803875f4d5596d2 (diff)
downloadcoreutils-0ddfd54b08dfe4e78b8aa2dd74378e5b62c9d68c.tar.xz
maint: use wcswidth from gnulib
* gl/lib/mbsalign.c (rpl_wcswidth): Remove this in favor of the equivalent wcswidth replacement in gnulib. * bootstrap.conf: Depend on the wcswidth module. Suggested by Bruno Haible.
-rw-r--r--bootstrap.conf1
-rw-r--r--gl/lib/mbsalign.c23
2 files changed, 2 insertions, 22 deletions
diff --git a/bootstrap.conf b/bootstrap.conf
index e62f7206c..25f90a820 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -232,6 +232,7 @@ gnulib_modules="
verror
version-etc-fsf
wcwidth
+ wcswidth
winsz-ioctl
winsz-termios
write-any-file
diff --git a/gl/lib/mbsalign.c b/gl/lib/mbsalign.c
index d06e6dca1..ef45c35af 100644
--- a/gl/lib/mbsalign.c
+++ b/gl/lib/mbsalign.c
@@ -79,27 +79,6 @@ wc_truncate (wchar_t *wc, size_t width)
return cells;
}
-/* FIXME: move this function to gnulib as it's missing on:
- OpenBSD 3.8, IRIX 5.3, Solaris 2.5.1, mingw, BeOS */
-
-static int
-rpl_wcswidth (const wchar_t *s, size_t n)
-{
- int ret = 0;
-
- while (n-- > 0 && *s != L'\0')
- {
- int nwidth = wcwidth (*s++);
- if (nwidth == -1) /* non printable */
- return -1;
- if (ret > (INT_MAX - nwidth)) /* overflow */
- return -1;
- ret += nwidth;
- }
-
- return ret;
-}
-
/* Write N_SPACES space characters to DEST while ensuring
nothing is written beyond DEST_END. A terminating NUL
is always added to DEST.
@@ -171,7 +150,7 @@ mbsalign (const char *src, char *dest, size_t dest_size,
str_wc[src_chars - 1] = L'\0';
wc_enabled = true;
conversion = wc_ensure_printable (str_wc);
- n_cols = rpl_wcswidth (str_wc, src_chars);
+ n_cols = wcswidth (str_wc, src_chars);
}
}