[libgweather] Revert "Consolidate feature checks and system macros"



commit 1abfa5721e70f8bd631c2bf336adab5bce44799f
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sun Apr 26 17:55:25 2015 -0700

    Revert "Consolidate feature checks and system macros"
    
    This reverts commit 1c9a26ce4d58efeda86a73829cb8d74fe71e89d5.
    
    It broke BSDs badly, and the fixes are worse than the previous
    situation. Just cave and define _BSD_SOURCE everywhere.

 configure.ac                   |   31 +++++++++++++++++++++++++++++++
 libgweather/Makefile.am        |    3 +--
 libgweather/gweather-weather.c |   17 +++++++++++++++++
 libgweather/weather-metar.c    |    6 +++++-
 libgweather/weather-owm.c      |    1 +
 libgweather/weather-yahoo.c    |    1 +
 libgweather/weather-yrno.c     |    1 +
 7 files changed, 57 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 91d4e1c..f5673a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,6 +86,37 @@ AC_CHECK_FUNCS(regexec,,[AC_CHECK_LIB(regex,regexec,
                [AC_MSG_ERROR([No regex library found])])])
 AC_SUBST(REGEX_LIBS)
 
+
+dnl ***************************************************************************
+dnl *** Check for presence of tm.tm_gmtoff on the system                    ***
+dnl ***************************************************************************
+AC_CHECK_MEMBER([struct tm.tm_gmtoff],[struct_tm_tm_gmtoff=true],[struct_tm_tm_gmtoff=false],[#include 
<time.h>])
+case $struct_tm_tm_gmtoff in
+        true)
+                AC_DEFINE_UNQUOTED(HAVE_TM_TM_GMOFF, 1, Have the tm.tm_gmtoff member.)
+                ;;
+        *)
+                AC_CHECK_DECL(timezone,AC_DEFINE(HAVE_TIMEZONE,1,Have timezone),,
+[
+#include <time.h>
+])
+                ;;
+esac
+
+dnl ***************************************************************************
+dnl *** _NL_MEASUREMENT_MEASUREMENT is an enum and not a define             ***
+dnl ***************************************************************************
+AC_MSG_CHECKING([for _NL_MEASUREMENT_MEASUREMENT])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]], [[
+char c;
+c = *((unsigned char *)  nl_langinfo(_NL_MEASUREMENT_MEASUREMENT));
+]])],[gtk_ok=yes],[gtk_ok=no])
+AC_MSG_RESULT($gtk_ok)
+if test "$gtk_ok" = "yes"; then
+  AC_DEFINE([HAVE__NL_MEASUREMENT_MEASUREMENT], [1],
+            [Define if _NL_MEASUREMENT_MEASUREMENT is available])
+fi
+
 dnl ***************************************************************************
 dnl *** Find tzdata                                                         ***
 dnl ***************************************************************************
diff --git a/libgweather/Makefile.am b/libgweather/Makefile.am
index bc3d579..3853f9a 100644
--- a/libgweather/Makefile.am
+++ b/libgweather/Makefile.am
@@ -5,14 +5,13 @@ noinst_LTLIBRARIES = libgweather-internal-3.la
 noinst_PROGRAMS = test_metar test_locations test_sun_moon
 
 AM_CPPFLAGS =                  \
-       -D_XOPEN_SOURCE=700     \
        -DGWEATHER_COMPILATION  \
        $(DEPS_CFLAGS)          \
        -I$(top_srcdir)         \
        -I$(top_builddir)       \
        -I$(srcdir)
 
-AM_CFLAGS = -std=c99 $(WARN_CFLAGS)
+AM_CFLAGS = $(WARN_CFLAGS)
 
 gweather_new_headers = \
        gweather.h \
diff --git a/libgweather/gweather-weather.c b/libgweather/gweather-weather.c
index 60c5499..3fa6453 100644
--- a/libgweather/gweather-weather.c
+++ b/libgweather/gweather-weather.c
@@ -736,6 +736,15 @@ gweather_info_get_conditions (GWeatherInfo *info)
 static gboolean
 is_locale_metric (void)
 {
+    /* Translate to the default units to use for presenting
+     * lengths to the user. Translate to default:inch if you
+     * want inches, otherwise translate to default:mm.
+     * Do *not* translate it to "predefinito:mm", if it
+     * it isn't default:mm or default:inch it will not work
+     */
+    gchar *e = _("default:mm");
+
+#ifdef HAVE__NL_MEASUREMENT_MEASUREMENT
     const char *fmt;
     fmt = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT);
 
@@ -743,6 +752,14 @@ is_locale_metric (void)
        return FALSE;
     else
        return TRUE;
+#endif
+
+    if (strcmp (e, "default:inch")==0)
+        return FALSE;
+    else if (strcmp (e, "default:mm"))
+        g_warning ("Whoever translated default:mm did so wrongly.\n");
+
+    return TRUE;
 }
 
 static GWeatherTemperatureUnit
diff --git a/libgweather/weather-metar.c b/libgweather/weather-metar.c
index 48559be..b8ac2b1 100644
--- a/libgweather/weather-metar.c
+++ b/libgweather/weather-metar.c
@@ -62,8 +62,12 @@ make_time (gint utcDate, gint utcHour, gint utcMin)
     tm.tm_min  = utcMin;
     tm.tm_sec  = 0;
 
-    /* mktime() assumes value is local, not UTC.  Use timezone to compensate */
+    /* mktime() assumes value is local, not UTC.  Use tm_gmtoff to compensate */
+#ifdef HAVE_TM_TM_GMOFF
+    return tm.tm_gmtoff + mktime (&tm);
+#elif defined HAVE_TIMEZONE
     return timezone + mktime (&tm);
+#endif
 }
 
 static void
diff --git a/libgweather/weather-owm.c b/libgweather/weather-owm.c
index 6628653..4ad94e9 100644
--- a/libgweather/weather-owm.c
+++ b/libgweather/weather-owm.c
@@ -20,6 +20,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE /* for strptime */
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
diff --git a/libgweather/weather-yahoo.c b/libgweather/weather-yahoo.c
index 67c305b..77c0b2b 100644
--- a/libgweather/weather-yahoo.c
+++ b/libgweather/weather-yahoo.c
@@ -22,6 +22,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE /* for strptime */
 #include <time.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/libgweather/weather-yrno.c b/libgweather/weather-yrno.c
index da6a943..2e62926 100644
--- a/libgweather/weather-yrno.c
+++ b/libgweather/weather-yrno.c
@@ -22,6 +22,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE /* for strptime */
 #include <time.h>
 #include <stdlib.h>
 #include <string.h>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]