From 38e77edd7c3cf9a3f8895e92e46debd0467ecc68 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 18 May 2007 13:57:15 -0700 Subject: Make use of iconv() conditional on configure.ac finding it in libc or libiconv --- Clock.c | 24 +++++++++++++++++++----- configure.ac | 3 +++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Clock.c b/Clock.c index 67ef814..0f8c1b7 100644 --- a/Clock.c +++ b/Clock.c @@ -97,7 +97,7 @@ SOFTWARE. #include #include #include -#ifndef NO_I18N +#if !defined(NO_I18N) && defined(HAVE_ICONV) #include #include #include @@ -236,7 +236,9 @@ static void DrawClockFace ( ClockWidget w ); static int clock_round ( double x ); static Boolean SetValues ( Widget gcurrent, Widget grequest, Widget gnew, ArgList args, Cardinal *num_args ); +#if !defined(NO_I18N) && defined(HAVE_ICONV) static char *clock_to_utf8(const char *); +#endif ClockClassRec clockClassRec = { { /* core fields */ @@ -631,16 +633,20 @@ Initialize (Widget request, Widget new, ArgList args, Cardinal *num_args) if (w->clock.render) { XGlyphInfo extents; - char *utf8_str; #ifndef NO_I18N +# ifdef HAVE_ICONV + char *utf8_str; +# endif if (w->clock.utf8) XftTextExtentsUtf8 (XtDisplay (w), w->clock.face, (FcChar8 *) str, len, &extents); +# ifdef HAVE_ICONV else if ((utf8_str = clock_to_utf8(str)) != NULL) { XftTextExtentsUtf8 (XtDisplay (w), w->clock.face, (FcChar8 *)utf8_str, strlen(utf8_str), &extents); free(utf8_str); } +# endif else #endif XftTextExtents8 (XtDisplay (w), w->clock.face, @@ -811,9 +817,11 @@ RenderTextBounds (ClockWidget w, char *str, int off, int len, { XGlyphInfo head, tail; int x, y; - char *utf8_str; #ifndef NO_I18N +# ifdef HAVE_ICONV + char *utf8_str; +# endif if (w->clock.utf8) { XftTextExtentsUtf8 (XtDisplay (w), w->clock.face, @@ -821,6 +829,7 @@ RenderTextBounds (ClockWidget w, char *str, int off, int len, XftTextExtentsUtf8 (XtDisplay (w), w->clock.face, (FcChar8 *) str + off, len - off, &tail); } +# ifdef HAVE_ICONV else if ((utf8_str = clock_to_utf8(str)) != NULL) { XftTextExtentsUtf8 (XtDisplay (w), w->clock.face, @@ -829,6 +838,7 @@ RenderTextBounds (ClockWidget w, char *str, int off, int len, (FcChar8 *)utf8_str + off, strlen(utf8_str) - off, &tail); free(utf8_str); } +# endif else #endif { @@ -1298,7 +1308,9 @@ clock_tic(XtPointer client_data, XtIntervalId *id) { XRectangle old_tail, new_tail, head; int x, y; +#if !defined(NO_I18N) && defined(HAVE_ICONV) char *utf8_str; +#endif RenderTextBounds (w, w->clock.prev_time_string, i, prev_len, &old_tail, 0, 0); @@ -1325,7 +1337,8 @@ clock_tic(XtPointer client_data, XtIntervalId *id) x, y, (FcChar8 *) time_ptr + i, len - i); - } + } +# ifdef HAVE_ICONV else if ((utf8_str = clock_to_utf8(time_ptr + i)) != NULL) { XftDrawStringUtf8 (w->clock.draw, @@ -1335,6 +1348,7 @@ clock_tic(XtPointer client_data, XtIntervalId *id) (FcChar8 *)utf8_str, strlen(utf8_str) - i); free(utf8_str); } +# endif else #endif { @@ -2079,7 +2093,7 @@ SetValues(Widget gcurrent, Widget grequest, Widget gnew, } -#ifndef NO_I18N +#if !defined(NO_I18N) && defined(HAVE_ICONV) static char * clock_to_utf8(const char *str) { diff --git a/configure.ac b/configure.ac index 3ab38fb..6f8a7d0 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,9 @@ AC_PROG_INSTALL AC_CHECK_FUNCS([strlcpy]) +AC_SEARCH_LIBS([iconv], [iconv], + [AC_DEFINE(HAVE_ICONV, 1, [Define to 1 if iconv() is available.])]) + dnl Required dependencies PKG_CHECK_MODULES(XCLOCK_X11, x11) XAW_CHECK_XPRINT_SUPPORT(XAW) -- cgit v1.2.3