summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2021-04-18 09:54:53 -0600
committerEduardo Chappa <chappa@washington.edu>2021-04-18 09:54:53 -0600
commit43f4dca2ead9fb8f65778c2772228dff554e1c75 (patch)
treec70773789fcac9fb86baf4451a57ec75548a75cb
parent2807fa1f8a4125bc4fd1992f3e2d6c0a12005c62 (diff)
downloadalpine-43f4dca2ead9fb8f65778c2772228dff554e1c75.tar.xz
* Addition of testing for wctomb(), which will be used in systems that
do not have wcrtomb(). Work in collaboration with professor Martin Trusler.
-rwxr-xr-xconfigure1
-rw-r--r--configure.ac1
-rw-r--r--include/config.h.in3
-rw-r--r--pith/charconv/utf8.c10
-rw-r--r--pith/pine.hlp7
5 files changed, 21 insertions, 1 deletions
diff --git a/configure b/configure
index de7219f..4acb272 100755
--- a/configure
+++ b/configure
@@ -21249,6 +21249,7 @@ for ac_func in strchr \
wcwidth \
mbstowcs \
wcrtomb \
+ wctomb \
putenv \
setenv
do :
diff --git a/configure.ac b/configure.ac
index 00421c3..dfc83dd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1998,6 +1998,7 @@ AC_CHECK_FUNCS([strchr \
wcwidth \
mbstowcs \
wcrtomb \
+ wctomb \
putenv \
setenv])
diff --git a/include/config.h.in b/include/config.h.in
index 7d978e6..cf6e4c2 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -469,6 +469,9 @@
/* Define to 1 if you have the `wcrtomb' function. */
#undef HAVE_WCRTOMB
+/* Define to 1 if you have the `wctomb' function. */
+#undef HAVE_WCTOMB
+
/* Define to 1 if you have the `wcwidth' function. */
#undef HAVE_WCWIDTH
diff --git a/pith/charconv/utf8.c b/pith/charconv/utf8.c
index 1651252..42a364b 100644
--- a/pith/charconv/utf8.c
+++ b/pith/charconv/utf8.c
@@ -125,6 +125,7 @@ pith_ucs4width(UCS ucs)
int
wtomb(char *dest, UCS ucs)
{
+ int rv;
/*
* We believe that on modern unix systems wchar_t is a UCS-4 character.
* That's the assumption here.
@@ -150,7 +151,14 @@ wtomb(char *dest, UCS ucs)
return(ret);
}
else
- return(wcrtomb(dest, (wchar_t) ucs, NULL));
+#if defined(HAVE_WCRTOMB)
+ rv = wcrtomb(dest, (wchar_t) ucs, NULL);
+#elif defined(HAVE_WCTOMB)
+ rv = wctomb(dest, (wchar_t) ucs);
+#else
+ rv = -1;
+#endif
+ return rv;
}
diff --git a/pith/pine.hlp b/pith/pine.hlp
index 2605ae0..a226e99 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -35312,7 +35312,14 @@ To convert from Unicode to multi-byte the routine
<CENTER><SAMP>wcrtomb</SAMP></CENTER>
<P>
+is used, if available, otherwise
+
+<P>
+<CENTER><SAMP>wctomb</SAMP></CENTER>
+<P>
+
is used.
+
And to find the screen width a particular Unicode character will
occupy the routine used is