From 2199d086921eb37d249cae0731f334556ec6209d Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Mon, 1 Apr 2013 19:57:13 +1100 Subject: Enable utf8 I/O stuff when compiling with MinGW. --- .gitignore | 1 + configure.ac | 3 +++ include/share/compat.h | 3 ++- include/share/win_utf8_io.h | 2 +- src/Makefile.am | 2 +- src/flac/iffscan.c | 2 +- src/flac/main.c | 2 +- src/flac/vorbiscomment.c | 2 +- src/libFLAC/Makefile.am | 7 ++++++- src/metaflac/main.c | 2 +- src/metaflac/operations_shorthand_vorbiscomment.c | 2 +- src/share/Makefile.am | 11 +++++++++-- src/share/win_utf8_io/win_utf8_io.c | 5 ++--- src/test_libFLAC/Makefile.am | 7 ++++++- src/test_streams/Makefile.am | 6 +++++- 15 files changed, 41 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index d2778450..a24f4e42 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,4 @@ test/metaflac-test-files/out.meta test/metaflac.flac test/picture.diff test/picture.log +.dirstamp diff --git a/configure.ac b/configure.ac index bda568f0..12e29070 100644 --- a/configure.ac +++ b/configure.ac @@ -124,16 +124,19 @@ case "$host" in esac AM_CONDITIONAL(FLaC__CPU_PPC_SPE, test "x$abi_spe" = xtrue) +os_is_windows=no case "$host" in *-*-cygwin|*mingw*|*emx*) # define this variable for enabling strict exports with libtool; for now, it's supported by Win32 and OS/2 LT_NO_UNDEFINED="-no-undefined" + os_is_windows=yes ;; *) LT_NO_UNDEFINED= ;; esac AC_SUBST(LT_NO_UNDEFINED) +AM_CONDITIONAL(OS_IS_WINDOWS, test "x$os_is_windows" = xyes) case "$host" in *-pc-linux-gnu) diff --git a/include/share/compat.h b/include/share/compat.h index 214990c2..cf83bfe5 100644 --- a/include/share/compat.h +++ b/include/share/compat.h @@ -141,7 +141,8 @@ # endif #endif /* defined _MSC_VER */ -#ifdef FLAC__STRINGS_IN_UTF8 /* all char* strings are in UTF-8 format. Added to support Unicode files on Windows */ +#ifdef _WIN32 +/* All char* strings are in UTF-8 format. Added to support Unicode files on Windows */ #include "share/win_utf8_io.h" #define flac_printf printf_utf8 diff --git a/include/share/win_utf8_io.h b/include/share/win_utf8_io.h index caf7cf92..598f187f 100644 --- a/include/share/win_utf8_io.h +++ b/include/share/win_utf8_io.h @@ -1,4 +1,4 @@ -#ifdef FLAC__STRINGS_IN_UTF8 +#ifdef _WIN32 #ifndef flac__win_utf8_io_h #define flac__win_utf8_io_h diff --git a/src/Makefile.am b/src/Makefile.am index e833eb39..22615d78 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,8 +24,8 @@ CPPLIBS_DIRS = libFLAC++ test_libFLAC++ endif SUBDIRS = \ - libFLAC \ share \ + libFLAC \ flac \ metaflac \ monkeys_audio_utilities \ diff --git a/src/flac/iffscan.c b/src/flac/iffscan.c index cf0fb936..2a8a0ce4 100644 --- a/src/flac/iffscan.c +++ b/src/flac/iffscan.c @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) size_t i; FLAC__uint32 size; -#ifdef FLAC__STRINGS_IN_UTF8 +#ifdef _WIN32 if (get_utf8_argv(&argc, &argv) != 0) { fprintf(stderr, "%ERROR: failed to convert command line parameters to UTF-8\n"); return 1; diff --git a/src/flac/main.c b/src/flac/main.c index 7bbe460e..62e54a45 100644 --- a/src/flac/main.c +++ b/src/flac/main.c @@ -304,7 +304,7 @@ int main(int argc, char *argv[]) _response(&argc, &argv); _wildcard(&argc, &argv); #endif -#ifdef FLAC__STRINGS_IN_UTF8 +#ifdef _WIN32 if (get_utf8_argv(&argc, &argv) != 0) { fprintf(stderr, "ERROR: failed to convert command line parameters to UTF-8\n"); return 1; diff --git a/src/flac/vorbiscomment.c b/src/flac/vorbiscomment.c index db6d9ade..5a9f619f 100644 --- a/src/flac/vorbiscomment.c +++ b/src/flac/vorbiscomment.c @@ -170,7 +170,7 @@ static FLAC__bool set_vc_field(FLAC__StreamMetadata *block, const Argument_VcFie } else { FLAC__bool needs_free = false; -#ifdef FLAC__STRINGS_IN_UTF8 /* everything in UTF-8 already. Must not alter */ +#ifdef _WIN32 /* everything in UTF-8 already. Must not alter */ entry.entry = (FLAC__byte *)field->field; #else if(raw) { diff --git a/src/libFLAC/Makefile.am b/src/libFLAC/Makefile.am index 7928abfd..aa0b8b63 100644 --- a/src/libFLAC/Makefile.am +++ b/src/libFLAC/Makefile.am @@ -82,7 +82,11 @@ endif endif endif -libFLAC_la_LIBADD = $(LOCAL_EXTRA_LIBADD) @OGG_LIBS@ -lm +if OS_IS_WINDOWS +win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la +endif + +libFLAC_la_LIBADD = $(win_utf8_lib) $(LOCAL_EXTRA_LIBADD) @OGG_LIBS@ -lm SUBDIRS = $(ARCH_SUBDIRS) include . @@ -106,6 +110,7 @@ extra_ogg_sources = \ ogg_helper.c \ ogg_mapping.c endif + # see 'http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning' for numbering convention libFLAC_la_LDFLAGS = -version-info 11:0:3 $(LOCAL_EXTRA_LDFLAGS) @LT_NO_UNDEFINED@ diff --git a/src/metaflac/main.c b/src/metaflac/main.c index e85d1c29..03e42c7a 100644 --- a/src/metaflac/main.c +++ b/src/metaflac/main.c @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) _response(&argc, &argv); _wildcard(&argc, &argv); #endif -#ifdef FLAC__STRINGS_IN_UTF8 +#ifdef _WIN32 if (get_utf8_argv(&argc, &argv) != 0) { fprintf(stderr, "%ERROR: failed to convert command line parameters to UTF-8\n"); return 1; diff --git a/src/metaflac/operations_shorthand_vorbiscomment.c b/src/metaflac/operations_shorthand_vorbiscomment.c index 61537bf5..3d381a57 100644 --- a/src/metaflac/operations_shorthand_vorbiscomment.c +++ b/src/metaflac/operations_shorthand_vorbiscomment.c @@ -245,7 +245,7 @@ FLAC__bool set_vc_field(const char *filename, FLAC__StreamMetadata *block, const } else { FLAC__bool needs_free = false; -#ifdef FLAC__STRINGS_IN_UTF8 /* do not convert anything or things will break */ +#ifdef _WIN32 /* do not convert anything or things will break */ entry.entry = (FLAC__byte *)field->field; #else if(raw) { diff --git a/src/share/Makefile.am b/src/share/Makefile.am index 8c325889..bb66122c 100644 --- a/src/share/Makefile.am +++ b/src/share/Makefile.am @@ -45,10 +45,18 @@ noinst_LTLIBRARIES = \ getopt/libgetopt.la \ grabbag/libgrabbag.la \ utf8/libutf8.la \ + win_utf8_io/libwin_utf8_io.la \ replaygain_analysis/libreplaygain_analysis.la \ replaygain_synthesis/libreplaygain_synthesis.la +if OS_IS_WINDOWS +win_utf8_io_libwin_utf8_io_la_SOURCES = win_utf8_io/win_utf8_io.c +else +win_utf8_io_libwin_utf8_io_la_SOURCES = +endif + + getopt_libgetopt_la_SOURCES = getopt/getopt.c getopt/getopt1.c grabbag_libgrabbag_la_SOURCES = \ @@ -64,8 +72,7 @@ utf8_libutf8_la_SOURCES = \ utf8/charset.c \ utf8/charset.h \ utf8/iconvert.c \ - utf8/utf8.c \ - win_utf8_io/win_utf8_io.c + utf8/utf8.c replaygain_analysis_libreplaygain_analysis_la_SOURCES = replaygain_analysis/replaygain_analysis.c diff --git a/src/share/win_utf8_io/win_utf8_io.c b/src/share/win_utf8_io/win_utf8_io.c index 0699f19c..12cfd977 100644 --- a/src/share/win_utf8_io/win_utf8_io.c +++ b/src/share/win_utf8_io/win_utf8_io.c @@ -1,4 +1,3 @@ -#ifdef FLAC__STRINGS_IN_UTF8 #include #include @@ -12,6 +11,7 @@ #include "share/win_utf8_io.h" /* convert WCHAR stored Unicode string to UTF-8. Caller is responsible for freeing memory */ +static char *utf8_from_wchar(const wchar_t *wstr) { char *utf8str; @@ -29,6 +29,7 @@ char *utf8_from_wchar(const wchar_t *wstr) } /* convert UTF-8 back to WCHAR. Caller is responsible for freeing memory */ +static wchar_t *wchar_from_utf8(const char *str) { wchar_t *widestr; @@ -256,5 +257,3 @@ int rename_utf8(const char *oldname, const char *newname) return ret; } - -#endif diff --git a/src/test_libFLAC/Makefile.am b/src/test_libFLAC/Makefile.am index e6136e7a..cd754727 100644 --- a/src/test_libFLAC/Makefile.am +++ b/src/test_libFLAC/Makefile.am @@ -22,12 +22,17 @@ EXTRA_DIST = \ AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -I$(top_srcdir)/src/libFLAC/include noinst_PROGRAMS = test_libFLAC + +if OS_IS_WINDOWS +win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la +endif + test_libFLAC_LDADD = \ $(top_builddir)/src/share/grabbag/libgrabbag.la \ $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ $(top_builddir)/src/test_libs_common/libtest_libs_common.la \ $(top_builddir)/src/libFLAC/libFLAC-static.la \ - @OGG_LIBS@ \ + $(win_utf8_lib) @OGG_LIBS@ \ -lm test_libFLAC_SOURCES = \ diff --git a/src/test_streams/Makefile.am b/src/test_streams/Makefile.am index de0d6935..7942dc57 100644 --- a/src/test_streams/Makefile.am +++ b/src/test_streams/Makefile.am @@ -24,6 +24,10 @@ noinst_PROGRAMS = test_streams test_streams_SOURCES = \ main.c -test_streams_LDADD = $(top_builddir)/src/share/grabbag/libgrabbag.la -lm +if OS_IS_WINDOWS +win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la +endif + +test_streams_LDADD = $(win_utf8_lib) $(top_builddir)/src/share/grabbag/libgrabbag.la -lm CLEANFILES = test_streams.exe -- cgit v1.2.1