[libgweather/ebassi/release-4-1-0: 1/2] metar: Use G_REGEX_OPTIMIZE with older GLib versions
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather/ebassi/release-4-1-0: 1/2] metar: Use G_REGEX_OPTIMIZE with older GLib versions
- Date: Wed, 13 Jul 2022 18:07:16 +0000 (UTC)
commit c67ad46086d82948259dbfe55346834ee116f6d8
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed Jul 13 19:00:36 2022 +0100
metar: Use G_REGEX_OPTIMIZE with older GLib versions
GLib 2.73.2 switched to libpcre2 internally, and deprecated
G_REGEX_OPTIMIZE, among other things. This means we should only
explicitly optimize GRegex compilation if building against older
versions of GLib still linking to libpcre1.
libgweather/weather-metar.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/libgweather/weather-metar.c b/libgweather/weather-metar.c
index 9b6233e3..c0e8a6e5 100644
--- a/libgweather/weather-metar.c
+++ b/libgweather/weather-metar.c
@@ -458,13 +458,18 @@ metar_init_re (void)
return;
initialized = TRUE;
- metar_re[TIME_RE] = g_regex_new (RE_PREFIX TIME_RE_STR RE_SUFFIX, G_REGEX_OPTIMIZE, 0, NULL);
- metar_re[WIND_RE] = g_regex_new (RE_PREFIX WIND_RE_STR RE_SUFFIX, G_REGEX_OPTIMIZE, 0, NULL);
- metar_re[VIS_RE] = g_regex_new (RE_PREFIX VIS_RE_STR RE_SUFFIX, G_REGEX_OPTIMIZE, 0, NULL);
- metar_re[COND_RE] = g_regex_new (RE_PREFIX COND_RE_STR RE_SUFFIX, G_REGEX_OPTIMIZE, 0, NULL);
- metar_re[CLOUD_RE] = g_regex_new (RE_PREFIX CLOUD_RE_STR RE_SUFFIX, G_REGEX_OPTIMIZE, 0, NULL);
- metar_re[TEMP_RE] = g_regex_new (RE_PREFIX TEMP_RE_STR RE_SUFFIX, G_REGEX_OPTIMIZE, 0, NULL);
- metar_re[PRES_RE] = g_regex_new (RE_PREFIX PRES_RE_STR RE_SUFFIX, G_REGEX_OPTIMIZE, 0, NULL);
+ int re_flags = 0;
+#if !GLIB_CHECK_VERSION(2, 73, 2)
+ re_flags |= G_REGEX_OPTIMIZE;
+#endif
+
+ metar_re[TIME_RE] = g_regex_new (RE_PREFIX TIME_RE_STR RE_SUFFIX, re_flags, 0, NULL);
+ metar_re[WIND_RE] = g_regex_new (RE_PREFIX WIND_RE_STR RE_SUFFIX, re_flags, 0, NULL);
+ metar_re[VIS_RE] = g_regex_new (RE_PREFIX VIS_RE_STR RE_SUFFIX, re_flags, 0, NULL);
+ metar_re[COND_RE] = g_regex_new (RE_PREFIX COND_RE_STR RE_SUFFIX, re_flags, 0, NULL);
+ metar_re[CLOUD_RE] = g_regex_new (RE_PREFIX CLOUD_RE_STR RE_SUFFIX, re_flags, 0, NULL);
+ metar_re[TEMP_RE] = g_regex_new (RE_PREFIX TEMP_RE_STR RE_SUFFIX, re_flags, 0, NULL);
+ metar_re[PRES_RE] = g_regex_new (RE_PREFIX PRES_RE_STR RE_SUFFIX, re_flags, 0, NULL);
metar_f[TIME_RE] = metar_tok_time;
metar_f[WIND_RE] = metar_tok_wind;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]