summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2012-11-24 16:27:04 +0900
committerAkira TAGOH <akira@tagoh.org>2012-11-24 16:27:04 +0900
commit4372494fb8230cbf3a9d7de0b979d31bfda0da51 (patch)
tree0c696c825bfe0bbedf59aa24f9d92d69dd928a8f
parent3d17b41abb82488842b99e0485357089ef3a4aa9 (diff)
Fix the build issues on MinGW
-rw-r--r--configure.ac8
-rw-r--r--data/Makefile.am9
-rw-r--r--data/reg2xml.c4
-rw-r--r--liblangtag/lt-error.c13
-rw-r--r--liblangtag/lt-ext-module.c2
-rw-r--r--liblangtag/lt-messages.c4
-rw-r--r--liblangtag/lt-tag.c7
-rw-r--r--liblangtag/lt-utils.c25
-rw-r--r--liblangtag/lt-utils.h2
9 files changed, 63 insertions, 11 deletions
diff --git a/configure.ac b/configure.ac
index e1bf7c3..8bd075a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,6 +69,8 @@ dnl ======================================================================
LANGTAG_MODULEDIR="${libdir}/liblangtag"
AC_SUBST(LANGTAG_MODULEDIR)
+AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
+
dnl check for flavours of varargs macros
AC_MSG_CHECKING(for ISO C99 varargs macros in C)
_save_cflags=$CFLAGS
@@ -189,6 +191,12 @@ AC_CHECK_ALIGNOF(void *)
dnl ======================================================================
dnl functions testing
dnl ======================================================================
+AC_CHECK_HEADERS([execinfo.h langinfo.h stdint.h])
+AC_CHECK_FUNCS([backtrace dlopen strndup])
+
+if test "x$ac_cv_func_dlopen" != xyes; then
+ enable_modules=no
+fi
dnl ======================================================================
dnl gettext stuff
diff --git a/data/Makefile.am b/data/Makefile.am
index c731fe1..fc57794 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -59,9 +59,14 @@ am__v_DL_0 = @echo " DL " $@;
language-subtag-registry:
$(AM_V_DL) wget -O $@ http://www.iana.org/assignments/language-subtag-registry || \
curl -o $@ http://www.iana.org/assignments/language-subtag-registry
-language-subtag-registry.xml: language-subtag-registry reg2xml Makefile
- $(AM_V_GEN) $(builddir)/reg2xml $(srcdir)/language-subtag-registry $@.tmp; \
+if CROSS_COMPILING
+language-subtag-registry.xml: language-subtag-registry reg2xml.c Makefile
+ @echo Warning: Unable to rebuild $@ when cross-compiling
+else
+language-subtag-registry.xml: language-subtag-registry reg2xml$(EXEEXT) Makefile
+ $(AM_V_GEN) $(builddir)/reg2xml$(EXEEXT) $(srcdir)/language-subtag-registry $@.tmp; \
head -1 $@.tmp | grep -E '^<\?xml version'>/dev/null 2>&1 && mv $@.tmp $@ || (echo "E: $@ isn't an expected result"; rm $@.tmp)
+endif
stamp-core-zip:
-rm core.zip
$(AM_V_DL) wget http://unicode.org/Public/cldr/latest/core.zip || \
diff --git a/data/reg2xml.c b/data/reg2xml.c
index 6096af7..cffab86 100644
--- a/data/reg2xml.c
+++ b/data/reg2xml.c
@@ -148,12 +148,12 @@ _parse(const char *filename,
fsetpos(fp, &pos);
}
token = strstr(buffer, ": ");
- tag = strndup(buffer, token - buffer);
+ tag = lt_strndup(buffer, token - buffer);
token += 2;
rtag = strstr(token, "..");
if (rtag && rtag[2] != '.') {
/* the range in tags */
- begin = strndup(token, rtag - token);
+ begin = lt_strndup(token, rtag - token);
rtag += 2;
end = strdup(rtag);
if (strlen(begin) != strlen(end)) {
diff --git a/liblangtag/lt-error.c b/liblangtag/lt-error.c
index 7534b90..f160e23 100644
--- a/liblangtag/lt-error.c
+++ b/liblangtag/lt-error.c
@@ -14,7 +14,9 @@
#include "config.h"
#endif
+#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
+#endif
#include <stdlib.h>
#include "lt-list.h"
#include "lt-mem.h"
@@ -98,9 +100,11 @@ lt_error_set(lt_error_t **error,
...)
{
va_list ap;
+#if HAVE_BACKTRACE
void *traces[1024];
+#endif
lt_error_data_t *d = lt_mem_alloc_object(sizeof (lt_error_data_t));
- int size;
+ int size = 0;
lt_bool_t allocated;
lt_return_val_if_fail (error != NULL, NULL);
@@ -117,13 +121,18 @@ lt_error_set(lt_error_t **error,
d->message = lt_strdup_vprintf(message, ap);
va_end(ap);
+#if HAVE_BACKTRACE
size = backtrace(traces, 1024);
if (size > 0)
d->traces = backtrace_symbols(traces, size);
+#else
+ d->traces = NULL;
+#endif
d->stack_size = size;
lt_mem_add_ref(&d->parent, d->message, free);
- lt_mem_add_ref(&d->parent, d->traces, free);
+ if (d->traces)
+ lt_mem_add_ref(&d->parent, d->traces, free);
allocated = (*error)->data == NULL;
(*error)->data = lt_list_append((*error)->data, d, (lt_destroy_func_t)lt_mem_unref);
diff --git a/liblangtag/lt-ext-module.c b/liblangtag/lt-ext-module.c
index 83a3170..bbb6026 100644
--- a/liblangtag/lt-ext-module.c
+++ b/liblangtag/lt-ext-module.c
@@ -399,7 +399,7 @@ lt_ext_module_new(const char *name)
if (len > suffix_len &&
lt_strcmp0(&filename[prefix_len + len - suffix_len], "." LT_MODULE_SUFFIX) == 0) {
- module = strndup(&filename[prefix_len], len - suffix_len);
+ module = lt_strndup(&filename[prefix_len], len - suffix_len);
module[len - suffix_len] = 0;
}
}
diff --git a/liblangtag/lt-messages.c b/liblangtag/lt-messages.c
index 6ad27df..76a299b 100644
--- a/liblangtag/lt-messages.c
+++ b/liblangtag/lt-messages.c
@@ -17,7 +17,9 @@
#include "config.h"
#endif
+#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -98,6 +100,7 @@ _lt_message_get_prefix(lt_message_type_t type,
static void
_lt_message_stacktrace(void)
{
+#if HAVE_BACKTRACE
void *traces[1024];
char **strings;
int size, i;
@@ -119,6 +122,7 @@ _lt_message_stacktrace(void)
}
free(strings);
}
+#endif
}
static void
diff --git a/liblangtag/lt-tag.c b/liblangtag/lt-tag.c
index d7daadd..0c4061d 100644
--- a/liblangtag/lt-tag.c
+++ b/liblangtag/lt-tag.c
@@ -15,7 +15,6 @@
#endif
#include <ctype.h>
-#include <langinfo.h>
#include <locale.h>
#include <stdint.h>
#include <string.h>
@@ -144,8 +143,8 @@ lt_tag_scanner_get_token(lt_tag_scanner_t *scanner,
if (c == '*') {
if (lt_string_length(string) > 0) {
lt_error_set(&err, LT_ERR_FAIL_ON_SCANNER,
- "Invalid wildcard: positon = %zd",
- scanner->position - 1);
+ "Invalid wildcard: positon = %lu",
+ (unsigned long)scanner->position - 1);
break;
}
} else if (!isalnum(c) && c != '-' && c != 0) {
@@ -196,7 +195,7 @@ static int
_lt_tag_variant_compare(const lt_pointer_t a,
const lt_pointer_t b)
{
- return (unsigned long)a - (unsigned long)b;
+ return (unsigned long long)a - (unsigned long long)b;
}
#define DEFUNC_TAG_FREE(__func__) \
diff --git a/liblangtag/lt-utils.c b/liblangtag/lt-utils.c
index 77b29a7..2163908 100644
--- a/liblangtag/lt-utils.c
+++ b/liblangtag/lt-utils.c
@@ -16,6 +16,7 @@
#include <ctype.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "lt-messages.h"
#include "lt-utils.h"
@@ -139,3 +140,27 @@ lt_strdup_vprintf(const char *format,
return retval;
}
+
+char *
+lt_strndup(const char *s,
+ size_t n)
+{
+#if HAVE_STRNDUP
+ return strndup(s, n);
+#else
+ const char *p = s;
+ char *retval;
+ size_t i = 0;
+
+ while (p && *p && i < n) {
+ p++;
+ i++;
+ }
+ retval = malloc(i + 1);
+ if (!retval)
+ return NULL;
+ retval[i] = 0;
+
+ return memcpy(retval, s, i);
+#endif
+}
diff --git a/liblangtag/lt-utils.h b/liblangtag/lt-utils.h
index f2a766f..2121130 100644
--- a/liblangtag/lt-utils.h
+++ b/liblangtag/lt-utils.h
@@ -30,6 +30,8 @@ char *lt_strdup_printf (const char *format,
...) LT_GNUC_PRINTF (1, 2);
char *lt_strdup_vprintf(const char *format,
va_list args);
+char *lt_strndup (const char *s,
+ size_t n);
LT_END_DECLS