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 ...@@ -409,7 +409,7 @@ AC_HEADER_DIRENT
409 AC_CHECK_HEADERS(errno.h fcntl.h inttypes.h libgen.h limits.h\ 409 AC_CHECK_HEADERS(errno.h fcntl.h inttypes.h libgen.h limits.h\
410 malloc.h obstack.h paths.h shadow.h socket.h sys/socket.h stdarg.h stdio.h\ 410 malloc.h obstack.h paths.h shadow.h socket.h sys/socket.h stdarg.h stdio.h\
411 stdlib.h string.h strings.h sys/file.h sysexits.h syslog.h termcap.h\ 411 stdlib.h string.h strings.h sys/file.h sysexits.h syslog.h termcap.h\
412 termios.h termio.h sgtty.h utmp.h utmpx.h unistd.h) 412 termios.h termio.h sgtty.h utmp.h utmpx.h unistd.h wchar.h)
413 413
414 dnl Checks for typedefs, structures, and compiler characteristics. 414 dnl Checks for typedefs, structures, and compiler characteristics.
415 AC_C_CONST 415 AC_C_CONST
...@@ -536,6 +536,8 @@ AH_BOTTOM([ ...@@ -536,6 +536,8 @@ AH_BOTTOM([
536 536
537 ## FriBidi support 537 ## FriBidi support
538 538
539 AC_CHECK_FUNCS(wcwidth)
540
539 AC_SUBST(FRIBIDI_LIBS) 541 AC_SUBST(FRIBIDI_LIBS)
540 542
541 use_fribidi=yes 543 use_fribidi=yes
......
...@@ -62,10 +62,10 @@ static char *output_charset = NULL; ...@@ -62,10 +62,10 @@ static char *output_charset = NULL;
62 const char * 62 const char *
63 get_charset () 63 get_charset ()
64 { 64 {
65 char *tmp;
66
67 if (!output_charset) 65 if (!output_charset)
68 { 66 {
67 char *tmp;
68 const char *str = NULL;
69 char locale[32]; 69 char locale[32];
70 70
71 memset (locale, 0, sizeof (locale)); 71 memset (locale, 0, sizeof (locale));
...@@ -86,16 +86,16 @@ get_charset () ...@@ -86,16 +86,16 @@ get_charset ()
86 86
87 lang = strtok_r (locale, "_", &sp); 87 lang = strtok_r (locale, "_", &sp);
88 terr = strtok_r (NULL, ".", &sp); 88 terr = strtok_r (NULL, ".", &sp);
89 output_charset = strtok_r (NULL, "@", &sp); 89 str = strtok_r (NULL, "@", &sp);
90 90
91 if (output_charset) 91 if (!str)
92 output_charset = xstrdup (output_charset); 92 str = mu_charset_lookup (lang, terr);
93 else
94 output_charset = mu_charset_lookup (lang, terr);
95 } 93 }
96 94
97 if (!output_charset) 95 if (!str)
98 output_charset = "ASCII"; 96 str = "ASCII";
97
98 output_charset = xstrdup (str);
99 } 99 }
100 return output_charset; 100 return output_charset;
101 } 101 }
...@@ -104,6 +104,20 @@ get_charset () ...@@ -104,6 +104,20 @@ get_charset ()
104 /* BIDI support (will be moved to lib when it's ready) */ 104 /* BIDI support (will be moved to lib when it's ready) */
105 #ifdef HAVE_LIBFRIBIDI 105 #ifdef HAVE_LIBFRIBIDI
106 106
107 # ifdef HAVE_FRIBIDI_WCWIDTH
108 # define mu_fribidi_wcwidth fribidi_wcwidth
109 # else
110 # if defined(HAVE_WCHAR_H) && defined(HAVE_WCWIDTH)
111 # include <wchar.h>
112 # define mu_fribidi_wcwidth(c) wcwidth((wchar_t)c)
113 # else
114 # undef HAVE_LIBFRIBIDI
115 # endif
116 # endif
117 #endif
118
119 #ifdef HAVE_LIBFRIBIDI
120
107 static int fb_charset_num = -1; 121 static int fb_charset_num = -1;
108 FriBidiChar *logical; 122 FriBidiChar *logical;
109 char *outstring; 123 char *outstring;
...@@ -170,7 +184,7 @@ puts_bidi (char *string) ...@@ -170,7 +184,7 @@ puts_bidi (char *string)
170 if (fb_charset_num != FRIBIDI_CHARSET_CAP_RTL) 184 if (fb_charset_num != FRIBIDI_CHARSET_CAP_RTL)
171 { 185 {
172 while (wid > 0 && idx < len) 186 while (wid > 0 && idx < len)
173 wid -= fribidi_wcwidth (visual[idx++]); 187 wid -= mu_fribidi_wcwidth (visual[idx++]);
174 } 188 }
175 else 189 else
176 { 190 {
......