Commit 73fe9290 73fe9290251b13e7e5d978a6bfbe014499f87e36 by Sergey Poznyakoff

Fix building with fribidi2

* configure.ac: Check for wcwidth and wchar.h.
* frm/common.c (get_charset): Aways allocate output_charset.
Provide a substitution for fribidi_wcwidth if it is not
available.
(puts_bidi): Use mu_fribidi_wcwidth.
1 parent eee2dde2
......@@ -409,7 +409,7 @@ AC_HEADER_DIRENT
AC_CHECK_HEADERS(errno.h fcntl.h inttypes.h libgen.h limits.h\
malloc.h obstack.h paths.h shadow.h socket.h sys/socket.h stdarg.h stdio.h\
stdlib.h string.h strings.h sys/file.h sysexits.h syslog.h termcap.h\
termios.h termio.h sgtty.h utmp.h utmpx.h unistd.h)
termios.h termio.h sgtty.h utmp.h utmpx.h unistd.h wchar.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
......@@ -536,6 +536,8 @@ AH_BOTTOM([
## FriBidi support
AC_CHECK_FUNCS(wcwidth)
AC_SUBST(FRIBIDI_LIBS)
use_fribidi=yes
......
......@@ -62,10 +62,10 @@ static char *output_charset = NULL;
const char *
get_charset ()
{
char *tmp;
if (!output_charset)
{
char *tmp;
const char *str = NULL;
char locale[32];
memset (locale, 0, sizeof (locale));
......@@ -86,16 +86,16 @@ get_charset ()
lang = strtok_r (locale, "_", &sp);
terr = strtok_r (NULL, ".", &sp);
output_charset = strtok_r (NULL, "@", &sp);
str = strtok_r (NULL, "@", &sp);
if (output_charset)
output_charset = xstrdup (output_charset);
else
output_charset = mu_charset_lookup (lang, terr);
if (!str)
str = mu_charset_lookup (lang, terr);
}
if (!output_charset)
output_charset = "ASCII";
if (!str)
str = "ASCII";
output_charset = xstrdup (str);
}
return output_charset;
}
......@@ -104,6 +104,20 @@ get_charset ()
/* BIDI support (will be moved to lib when it's ready) */
#ifdef HAVE_LIBFRIBIDI
# ifdef HAVE_FRIBIDI_WCWIDTH
# define mu_fribidi_wcwidth fribidi_wcwidth
# else
# if defined(HAVE_WCHAR_H) && defined(HAVE_WCWIDTH)
# include <wchar.h>
# define mu_fribidi_wcwidth(c) wcwidth((wchar_t)c)
# else
# undef HAVE_LIBFRIBIDI
# endif
# endif
#endif
#ifdef HAVE_LIBFRIBIDI
static int fb_charset_num = -1;
FriBidiChar *logical;
char *outstring;
......@@ -170,7 +184,7 @@ puts_bidi (char *string)
if (fb_charset_num != FRIBIDI_CHARSET_CAP_RTL)
{
while (wid > 0 && idx < len)
wid -= fribidi_wcwidth (visual[idx++]);
wid -= mu_fribidi_wcwidth (visual[idx++]);
}
else
{
......