diff options
author | Bastien Nocera <hadess@hadess.net> | 2007-11-05 17:35:24 +0000 |
---|---|---|
committer | Bastien Nocera <hadess@src.gnome.org> | 2007-11-05 17:35:24 +0000 |
commit | 085364b191d3c1ec894adc41c5418cb74c89b9d3 (patch) | |
tree | e4170614d3491c823e2d549e3d409b5e41f40a95 | |
parent | 67ef154fd694a32e3a11ccf921c78bd3be42e4c0 (diff) | |
download | totem-085364b191d3c1ec894adc41c5418cb74c89b9d3.tar.gz |
Fix compilation on Solaris, which lacks asprintf, based on patch by Damien
2007-11-05 Bastien Nocera <hadess@hadess.net>
* configure.in:
* lib/Makefile.am:
* lib/asprintf.c: (totem_private_asprintf):
* lib/totem_internal.h:
* src/plparse/Makefile.am:
* src/plparse/xmlparser.c: (xml_parser_get_node_internal):
Fix compilation on Solaris, which lacks asprintf,
based on patch by Damien Carbery <damien.carbery@sun.com>
(Closes: #492074)
svn path=/trunk/; revision=4854
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | configure.in | 7 | ||||
-rw-r--r-- | lib/Makefile.am | 13 | ||||
-rw-r--r-- | lib/asprintf.c | 57 | ||||
-rw-r--r-- | lib/totem_internal.h | 16 | ||||
-rw-r--r-- | src/plparse/Makefile.am | 3 | ||||
-rw-r--r-- | src/plparse/xmlparser.c | 1 |
7 files changed, 107 insertions, 2 deletions
@@ -1,5 +1,17 @@ 2007-11-05 Bastien Nocera <hadess@hadess.net> + * configure.in: + * lib/Makefile.am: + * lib/asprintf.c: (totem_private_asprintf): + * lib/totem_internal.h: + * src/plparse/Makefile.am: + * src/plparse/xmlparser.c: (xml_parser_get_node_internal): + Fix compilation on Solaris, which lacks asprintf, + based on patch by Damien Carbery <damien.carbery@sun.com> + (Closes: #492074) + +2007-11-05 Bastien Nocera <hadess@hadess.net> + * src/plparse/xmllexer.c: (lexer_get_token), (lexer_decode_entities): Fix decoding of decimal entities, useful for Podcasts (see #484768) diff --git a/configure.in b/configure.in index 9e2eb7f19..5527d269f 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ AC_INIT([totem], AC_CONFIG_SRCDIR([src/totem.c]) AC_CONFIG_HEADERS([config.h]) -AM_INIT_AUTOMAKE([1.9 dist-bzip2 no-dist-gzip check-news]) +AM_INIT_AUTOMAKE([1.9 dist-bzip2 no-dist-gzip check-news subdir-objects]) dnl Add the languages which your application supports to po/LINGUAS GETTEXT_PACKAGE=totem @@ -27,6 +27,11 @@ AM_PROG_CC_C_O AC_PROG_LIBTOOL() PKG_PROG_PKG_CONFIG +dnl Use local version of asprintf when not on the current system. +AC_CHECK_FUNCS(asprintf) +AC_CONFIG_LIBOBJ_DIR([lib]) +AC_REPLACE_FUNCS([asprintf]) + AC_PATH_PROG([GLIB_GENMARSHAL],[glib-genmarshal]) AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums]) diff --git a/lib/Makefile.am b/lib/Makefile.am index 2823c9d4a..3db36318c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,5 +1,6 @@ noinst_LTLIBRARIES = \ - libtotemscrsaver.la + libtotemscrsaver.la \ + libtotem_glibc.la common_defines = \ -D_REENTRANT \ @@ -15,15 +16,25 @@ common_defines = \ libtotemscrsaver_la_SOURCES = \ totem-scrsaver.c \ totem-scrsaver.h + libtotemscrsaver_la_CFLAGS = \ $(common_defines) \ $(EXTRA_GNOME_CFLAGS) \ $(WARN_CFLAGS) \ $(DBUS_CFLAGS) \ $(AM_CFLAGS) + libtotemscrsaver_la_LDFLAGS = \ $(AM_LDFLAGS) + libtotemscrsaver_la_LIBADD = \ $(DBUS_LIBS) \ $(XTEST_LIBS) +noinst_HEADERS = totem_internal.h + +libtotem_glibc_la_SOURCES =ยป +libtotem_glibc_la_LIBADD = @LTLIBOBJS@ + +EXTRA_DIST = asprintf.c + diff --git a/lib/asprintf.c b/lib/asprintf.c new file mode 100644 index 000000000..da4e515d8 --- /dev/null +++ b/lib/asprintf.c @@ -0,0 +1,57 @@ +#include "config.h" +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <sys/varargs.h> + + +int totem_private_asprintf(char **out, const char *fmt, ...) +{ + va_list ap; + int ret_status = EOF; + char dir_name[2001]; + char file_name[2000]; + FILE *fp = NULL; + char *work = NULL; + + va_start(ap, fmt); + + /* Warning: tmpfile() does not work well on Windows (MinGW) + * if user does not have write access on the drive where + * working dir is? */ +#ifdef __MINGW32__ + /* file_name = G_tempfile(); */ + GetTempPath ( 2000, dir_name ); + GetTempFileName ( dir_name, "asprintf", 0, file_name ); + fp = fopen ( file_name, "w+" ); +#else + fp = tmpfile(); +#endif /* __MINGW32__ */ + + if ( fp ) { + int count; + + count = vfprintf(fp, fmt, ap); + if (count >= 0) { + work = calloc(count + 1, sizeof(char)); + if (work != NULL) { + rewind(fp); + ret_status = fread(work, sizeof(char), count, fp); + if (ret_status != count) { + ret_status = EOF; + free(work); + work = NULL; + } + } + } + fclose(fp); +#ifdef __MINGW32__ + unlink ( file_name ); +#endif /* __MINGW32__ */ + } + va_end(ap); + *out = work; + + return ret_status; +} + diff --git a/lib/totem_internal.h b/lib/totem_internal.h new file mode 100644 index 000000000..9e8f25561 --- /dev/null +++ b/lib/totem_internal.h @@ -0,0 +1,16 @@ + +#include "config.h" + +/* replacement of asprintf & vasprintf */ +#ifndef HAVE_ASPRINTF +#define HAVE_ASPRINTF +#ifdef __GNUC__ + #define asprintf(STRINGPP, FORMAT, ARGS...) totem_private_asprintf((STRINGPP), FORMAT, ##ARGS) +#elif defined (_MSC_VER) + #define asprintf(STRINGPP, FORMATARGS) totem_private_asprintf((STRINGPP), FORMATARGS) +#else + #define asprintf(STRINGPP, FORMAT, ...) totem_private_asprintf((STRINGPP), FORMAT, __VA_ARGS__) +#endif +int totem_private_asprintf(char **string, const char *format, ...); +#endif + diff --git a/src/plparse/Makefile.am b/src/plparse/Makefile.am index 873a5118a..10ed638f8 100644 --- a/src/plparse/Makefile.am +++ b/src/plparse/Makefile.am @@ -74,6 +74,7 @@ libtotem_plparser_la_SOURCES = \ libtotem_plparser_la_CPPFLAGS = \ -I$(top_srcdir) \ + -I$(top_srcdir)/lib \ -I$(top_builddir)/src/plparser \ -DGNOMELOCALEDIR=\""$(datadir)/locale"\"\ $(DISABLE_DEPRECATED) \ @@ -85,10 +86,12 @@ libtotem_plparser_la_CFLAGS = \ $(DBUS_CFLAGS) \ $(WARN_CFLAGS) \ $(AM_CFLAGS) \ + -I$(top_srcdir)/lib \ -D_GNU_SOURCE libtotem_plparser_la_LIBADD = \ $(TOTEM_PLPARSER_LIBS) \ + $(top_builddir)/lib/libtotem_glibc.la \ $(HAL_LIBS) libtotem_plparser_la_LDFLAGS = \ diff --git a/src/plparse/xmlparser.c b/src/plparse/xmlparser.c index 31b01c061..89e449fd7 100644 --- a/src/plparse/xmlparser.c +++ b/src/plparse/xmlparser.c @@ -39,6 +39,7 @@ #define LOG */ +#include <totem_internal.h> #ifdef XINE_COMPILE #include "xineutils.h" #else |