Skip to content

Commit

Permalink
Integrate embedded libguess into build system.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlindgren90 committed Jun 7, 2015
1 parent d73fd9d commit a330be9
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 73 deletions.
22 changes: 0 additions & 22 deletions configure.ac
Expand Up @@ -70,27 +70,6 @@ if test "x$HAVE_MSWINDOWS" = "xyes" && test "x$use_text_console" = "xno" ; then
LDFLAGS="$LDFLAGS -Wl,-subsystem,windows"
fi

dnl Character set detection
dnl =======================

AC_ARG_ENABLE(chardet,
AS_HELP_STRING(--enable-chardet, [Disable character set detection (default=auto)]),
USE_CHARDET=$enableval, USE_CHARDET=auto)

if test $USE_CHARDET != no ; then
PKG_CHECK_MODULES(LIBGUESS, libguess >= 1.2, have_libguess=yes, have_libguess=no)
if test $have_libguess = yes ; then
USE_CHARDET=yes
AC_DEFINE(USE_CHARDET, 1, [Define if character set detection enabled])
elif test $USE_CHARDET = yes ; then
AC_MSG_ERROR([Character set detection could not be enabled; check config.log])
else
USE_CHARDET=no
fi
fi

AC_SUBST(USE_CHARDET)

dnl D-Bus support
dnl =============

Expand Down Expand Up @@ -161,7 +140,6 @@ echo "Configuration:"
echo ""
echo " Install path: $prefix"
echo ""
echo " Automatic character code detection: $USE_CHARDET"
echo " D-Bus support: $USE_DBUS"
echo " GTK+ support: $USE_GTK"
echo " Qt support: $USE_QT"
Expand Down
3 changes: 0 additions & 3 deletions extra.mk.in
@@ -1,5 +1,4 @@
HAVE_MSWINDOWS ?= @HAVE_MSWINDOWS@
USE_CHARDET ?= @USE_CHARDET@
USE_DBUS ?= @USE_DBUS@
USE_GTK ?= @USE_GTK@
USE_QT ?= @USE_QT@
Expand All @@ -12,7 +11,5 @@ GMODULE_CFLAGS ?= @GMODULE_CFLAGS@
GMODULE_LIBS ?= @GMODULE_LIBS@
GTK_CFLAGS ?= @GTK_CFLAGS@
GTK_LIBS ?= @GTK_LIBS@
LIBGUESS_CFLAGS ?= @LIBGUESS_CFLAGS@
LIBGUESS_LIBS ?= @LIBGUESS_LIBS@
QT_CFLAGS ?= @QT_CFLAGS@
QT_LIBS ?= @QT_LIBS@
3 changes: 2 additions & 1 deletion src/Makefile
@@ -1,6 +1,6 @@
include ../extra.mk

SUBDIRS := audacious libaudcore libaudtag
SUBDIRS := audacious libaudcore libaudtag libguess

ifeq ($(USE_GTK),yes)
SUBDIRS += libaudgui
Expand All @@ -17,6 +17,7 @@ endif
include ../buildsys.mk

audacious: libaudcore
libaudcore: libguess
libaudtag: libaudcore

ifeq ($(USE_GTK),yes)
Expand Down
5 changes: 2 additions & 3 deletions src/libaudcore/Makefile
Expand Up @@ -89,7 +89,6 @@ CPPFLAGS := -I.. -I../.. \
${CPPFLAGS} \
${GLIB_CFLAGS} \
${GMODULE_CFLAGS} \
${LIBGUESS_CFLAGS} \
${QT_CFLAGS} \
-DHARDCODE_BINDIR=\"${bindir}\" \
-DHARDCODE_DATADIR=\"${datadir}/audacious\" \
Expand All @@ -100,8 +99,8 @@ CPPFLAGS := -I.. -I../.. \

CFLAGS += ${LIB_CFLAGS}

LIBS += -lm \
LIBS := ../libguess/libguess.a \
${LIBS} -lm \
${GLIB_LIBS} \
${GMODULE_LIBS} \
${LIBGUESS_LIBS} \
${QT_LIBS}
13 changes: 1 addition & 12 deletions src/libaudcore/charset.cc
Expand Up @@ -28,11 +28,7 @@

#include <glib.h>

#ifdef USE_CHARDET
extern "C" {
#include <libguess/libguess.h>
}
#endif
#include "libguess/libguess.h"

#include "hook.h"
#include "index.h"
Expand Down Expand Up @@ -133,11 +129,6 @@ static void set_charsets (const char * region, const char * fallbacks)

detect_region = String (region);

#ifdef USE_CHARDET
if (detect_region)
libguess_init ();
#endif

if (fallbacks)
fallback_charsets = str_list_to_index (fallbacks, ", ");
else
Expand All @@ -151,7 +142,6 @@ static StringBuf convert_to_utf8_locked (const char * str, int len)
if (len < 0)
len = strlen (str);

#ifdef USE_CHARDET
if (detect_region)
{
/* prefer libguess-detected charset */
Expand All @@ -163,7 +153,6 @@ static StringBuf convert_to_utf8_locked (const char * str, int len)
return utf8;
}
}
#endif

/* try user-configured fallbacks */
for (const String & fallback : fallback_charsets)
Expand Down
3 changes: 1 addition & 2 deletions src/libaudgui/Makefile
Expand Up @@ -45,8 +45,7 @@ LD = ${CXX}
CPPFLAGS := -I.. -I../.. \
${CPPFLAGS} \
${GLIB_CFLAGS} \
${GTK_CFLAGS} \
${LIBGUESS_CFLAGS}
${GTK_CFLAGS}

CFLAGS += ${LIB_CFLAGS}

Expand Down
10 changes: 2 additions & 8 deletions src/libaudgui/prefs-window.cc
Expand Up @@ -33,14 +33,12 @@
#include <libaudcore/preferences.h>
#include <libaudcore/runtime.h>

#include "libguess/libguess.h"

#include "internal.h"
#include "libaudgui.h"
#include "libaudgui-gtk.h"

#ifdef USE_CHARDET
#include <libguess.h>
#endif

enum CategoryViewCols {
CATEGORY_VIEW_COL_ICON,
CATEGORY_VIEW_COL_NAME,
Expand Down Expand Up @@ -111,7 +109,6 @@ static const TitleFieldTag title_field_tags[] = {
{ N_("Quality") , "${quality}" }
};

#ifdef USE_CHARDET
static const ComboItem chardet_detector_presets[] = {
ComboItem (N_("None"), ""),
ComboItem (N_("Arabic"), GUESS_REGION_AR),
Expand All @@ -126,7 +123,6 @@ static const ComboItem chardet_detector_presets[] = {
ComboItem (N_("Taiwanese"), GUESS_REGION_TW),
ComboItem (N_("Turkish"), GUESS_REGION_TR)
};
#endif

static const ComboItem bitdepth_elements[] = {
ComboItem ("16", 16),
Expand Down Expand Up @@ -241,11 +237,9 @@ static const PreferencesWidget connectivity_page_widgets[] = {
};

static const PreferencesWidget chardet_elements[] = {
#ifdef USE_CHARDET
WidgetCombo (N_("Auto character encoding detector for:"),
WidgetString (0, "chardet_detector"),
{{chardet_detector_presets}}),
#endif
WidgetEntry (N_("Fallback character encodings:"),
WidgetString (0, "chardet_fallback"))
};
Expand Down
3 changes: 1 addition & 2 deletions src/libaudqt/Makefile
Expand Up @@ -32,8 +32,7 @@ LD = ${CXX}

CPPFLAGS := -I.. -I../.. \
${CPPFLAGS} \
${QT_CFLAGS} \
${LIBGUESS_CFLAGS}
${QT_CFLAGS}

CFLAGS += ${LIB_CFLAGS}

Expand Down
10 changes: 2 additions & 8 deletions src/libaudqt/prefs-window.cc
Expand Up @@ -47,13 +47,11 @@
#include <libaudcore/preferences.h>
#include <libaudcore/runtime.h>

#include "libguess/libguess.h"

#include "libaudqt.h"
#include "prefs-pluginlist-model.h"

#ifdef USE_CHARDET
#include <libguess.h>
#endif

namespace audqt {

struct Category {
Expand Down Expand Up @@ -114,7 +112,6 @@ static const TitleFieldTag title_field_tags[] = {
{ N_("Quality") , "${quality}" }
};

#ifdef USE_CHARDET
static const ComboItem chardet_detector_presets[] = {
ComboItem (N_("None"), ""),
ComboItem (N_("Arabic"), GUESS_REGION_AR),
Expand All @@ -129,7 +126,6 @@ static const ComboItem chardet_detector_presets[] = {
ComboItem (N_("Taiwanese"), GUESS_REGION_TW),
ComboItem (N_("Turkish"), GUESS_REGION_TR)
};
#endif

static const ComboItem bitdepth_elements[] = {
ComboItem ("16", 16),
Expand Down Expand Up @@ -244,11 +240,9 @@ static const PreferencesWidget connectivity_page_widgets[] = {
};

static const PreferencesWidget chardet_elements[] = {
#ifdef USE_CHARDET
WidgetCombo (N_("Auto character encoding detector for:"),
WidgetString (0, "chardet_detector"),
{{chardet_detector_presets}}),
#endif
WidgetEntry (N_("Fallback character encodings:"),
WidgetString (0, "chardet_fallback"))
};
Expand Down
12 changes: 12 additions & 0 deletions src/libguess/Makefile
@@ -0,0 +1,12 @@
STATIC_LIB_NOINST = libguess.a

SRCS = dfa.c \
guess.c \
guess_impl.c

include ../../buildsys.mk
include ../../extra.mk

CPPFLAGS := -I../.. ${CPPFLAGS} -DLIBGUESS_CORE

CFLAGS += ${LIB_CFLAGS} -Wno-unused-variable
6 changes: 0 additions & 6 deletions src/libguess/guess.c
Expand Up @@ -41,12 +41,6 @@ guess_find_impl(const char *lang)
return (impl != NULL) ? impl->impl : NULL;
}

void
libguess_init(void)
{
/* provided for API compatibility with older versions */
}

const char *
libguess_determine_encoding(const char *inbuf, int buflen, const char *lang)
{
Expand Down
13 changes: 7 additions & 6 deletions src/libguess/libguess.h
Expand Up @@ -41,11 +41,13 @@
#include <stdlib.h>
#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

/* prototypes */
#ifdef LIBGUESS_CORE

#include "autoconf.h"

const char *guess_jp(const char *buf, int buflen);
const char *guess_tw(const char *buf, int buflen);
const char *guess_cn(const char *buf, int buflen);
Expand Down Expand Up @@ -80,9 +82,8 @@ typedef void (*libguess_result_f)(const char *encodingname, const char *res);

const char *libguess_determine_encoding(const char *buf, int buflen, const char *langset);

/* This function does nothing. It is provided for API-compatibility with
* libguess 1.2, which required calling this before using it from multiple
* threads. */
void libguess_init(void);
#ifdef __cplusplus
}
#endif

#endif

0 comments on commit a330be9

Please sign in to comment.