dateutils/0001-fix-build-for-compilers-without-anonymous-struct-ini.patch
Ruediger Meier ebe51fdb19 Accepting request 312075 from home:rudi_m
- add fix-dateadd-unix-timestamp-bug.patch

- bump version 0.3.3, this is a feature release.
  * Features:
    - to clarify purpose and avoid name clashes prefix binaries
      with "date". This results in: dateadd, dateconv, ... etc.
    - provide compatibilty through configure switch --with-old-names
    - provide single digit years through %_y
    - allow rounding of ISO-week dates (ywd) to week numbers
  * Bugfixes:
    - dashes behind a date do not count as tz indicator
    - UTC/TAI/GPS special coordinated zones work on systems without
      leap second support
  * See info page examples and/or README 
- add fix-build-for-compilers-without-anonymous-struct-ini.patch
  to support broken compilers (SLE 11, RHEL 6, etc.)

OBS-URL: https://build.opensuse.org/request/show/312075
OBS-URL: https://build.opensuse.org/package/show/utilities/dateutils?expand=0&rev=36
2015-06-29 11:48:55 +00:00

243 lines
6.9 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From e1d38700985ebe944554821e4758b03bf011b18f Mon Sep 17 00:00:00 2001
From: Ruediger Meier <ruediger.meier@ga-group.nl>
Date: Fri, 12 Jun 2015 12:36:49 +0200
Subject: [PATCH] fix build for compilers without anonymous struct
initialisation
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
lib/date-core.h | 6 ++++++
lib/dt-core-strpf.c | 8 ++++++++
lib/dt-core-tz-glue.c | 16 ++++++++++++++++
lib/dt-core.c | 4 ++--
src/dround.c | 15 ++++++++++++++-
src/dseq.c | 27 ++++++++++-----------------
test/dtcore-add.c | 6 +++---
7 files changed, 59 insertions(+), 23 deletions(-)
diff --git a/lib/date-core.h b/lib/date-core.h
index 5b55154..044d69e 100644
--- a/lib/date-core.h
+++ b/lib/date-core.h
@@ -566,7 +566,13 @@ dt_make_ymcw(unsigned int y, unsigned int m, unsigned int c, unsigned int w)
static inline struct dt_ddur_s
dt_make_ddur(dt_durtyp_t typ, dt_dur_t d)
{
+#if defined HAVE_ANON_STRUCTS_INIT
return (struct dt_ddur_s){typ, .dv = d};
+#else
+ struct dt_ddur_s res = {typ};
+ res.dv = d;
+ return res;
+#endif
}
static inline dt_bizda_param_t
diff --git a/lib/dt-core-strpf.c b/lib/dt-core-strpf.c
index 9aec1fd..c19ae3a 100644
--- a/lib/dt-core-strpf.c
+++ b/lib/dt-core-strpf.c
@@ -133,7 +133,15 @@ __fixup_zdiff(struct dt_dt_s dt, int32_t zdiff)
{
/* apply time zone difference */
/* reuse dt for result */
+#if defined HAVE_ANON_STRUCTS_INIT
dt = dt_dtadd(dt, (struct dt_dtdur_s){DT_DURS, .dv = -zdiff});
+#else
+ {
+ struct dt_dtdur_s tmp = {DT_DURS};
+ tmp.dv = -zdiff;
+ dt = dt_dtadd(dt, tmp);
+ }
+#endif
dt.znfxd = 1;
return dt;
}
diff --git a/lib/dt-core-tz-glue.c b/lib/dt-core-tz-glue.c
index ee7d5cd..cb1314d 100644
--- a/lib/dt-core-tz-glue.c
+++ b/lib/dt-core-tz-glue.c
@@ -74,7 +74,15 @@ dtz_forgetz(struct dt_dt_s d, zif_t zone)
d_unix = zif_utc_time(zone, d_locl);
if (LIKELY((zdiff = d_unix - d_locl))) {
/* let dt_dtadd() do the magic */
+#if defined HAVE_ANON_STRUCTS_INIT
d = dt_dtadd(d, (struct dt_dtdur_s){DT_DURS, .dv = zdiff});
+#else
+ {
+ struct dt_dtdur_s tmp = {DT_DURS};
+ tmp.dv = zdiff;
+ d = dt_dtadd(d, tmp);
+ }
+#endif
d.znfxd = 1;
if (zdiff > 0) {
d.neg = 1;
@@ -108,7 +116,15 @@ dtz_enrichz(struct dt_dt_s d, zif_t zone)
d_locl = zif_local_time(zone, d_unix);
if (LIKELY((zdiff = d_locl - d_unix))) {
/* let dt_dtadd() do the magic */
+#if defined HAVE_ANON_STRUCTS_INIT
d = dt_dtadd(d, (struct dt_dtdur_s){DT_DURS, .dv = zdiff});
+#else
+ {
+ struct dt_dtdur_s tmp = {DT_DURS};
+ tmp.dv = zdiff;
+ d = dt_dtadd(d, tmp);
+ }
+#endif
if (zdiff > 0) {
d.zdiff = (uint16_t)(zdiff / ZDIFF_RES);
} else if (zdiff < 0) {
diff --git a/lib/dt-core.c b/lib/dt-core.c
index 76a78fe..99a0169 100644
--- a/lib/dt-core.c
+++ b/lib/dt-core.c
@@ -906,7 +906,7 @@ DEFUN struct dt_dtdur_s
dt_strpdtdur(const char *str, char **ep)
{
/* at the moment we allow only one format */
- struct dt_dtdur_s res = {.durtyp = (dt_dtdurtyp_t)DT_DURUNK};
+ struct dt_dtdur_s res = {(dt_dtdurtyp_t)DT_DURUNK};
const char *sp;
long int tmp;
@@ -1503,7 +1503,7 @@ dt_dtadd(struct dt_dt_s d, struct dt_dtdur_s dur)
DEFUN struct dt_dtdur_s
dt_dtdiff(dt_dtdurtyp_t tgttyp, struct dt_dt_s d1, struct dt_dt_s d2)
{
- struct dt_dtdur_s res = {.durtyp = (dt_dtdurtyp_t)DT_DURUNK};
+ struct dt_dtdur_s res = {(dt_dtdurtyp_t)DT_DURUNK};
int dt = 0;
if (!dt_sandwich_only_d_p(d1) && !dt_sandwich_only_d_p(d2)) {
diff --git a/src/dround.c b/src/dround.c
index 623aaf3..1142164 100644
--- a/src/dround.c
+++ b/src/dround.c
@@ -500,7 +500,7 @@ dt_io_strpdtrnd(struct __strpdtdur_st_s *st, const char *str)
char *sp = NULL;
struct strpd_s d = strpd_initialiser();
struct dt_spec_s s = spec_initialiser();
- struct dt_dtdur_s payload = {.durtyp = (dt_dtdurtyp_t)DT_DURUNK};
+ struct dt_dtdur_s payload = {(dt_dtdurtyp_t)DT_DURUNK};
bool negp = false;
bool coclp = true;
@@ -525,12 +525,19 @@ dt_io_strpdtrnd(struct __strpdtdur_st_s *st, const char *str)
s.spfl = DT_SPFL_S_WDAY;
s.abbr = DT_SPMOD_NORM;
if (__strpd_card(&d, str, s, &sp) >= 0) {
+#if defined HAVE_ANON_STRUCTS_INIT
payload.d = (struct dt_ddur_s){
DT_DURYMCW,
.neg = negp,
.cocl = coclp,
.ymcw.w = d.w,
};
+#else
+ payload.d.durtyp = DT_DURYMCW;
+ payload.d.neg = negp;
+ payload.d.cocl = coclp;
+ payload.d.ymcw.w = d.w;
+#endif
goto out;
}
@@ -538,11 +545,17 @@ dt_io_strpdtrnd(struct __strpdtdur_st_s *st, const char *str)
s.spfl = DT_SPFL_S_MON;
s.abbr = DT_SPMOD_NORM;
if (__strpd_card(&d, str, s, &sp) >= 0) {
+#if defined HAVE_ANON_STRUCTS_INIT
payload.d = (struct dt_ddur_s){
DT_DURYMD,
.neg = negp,
.ymd.m = d.m,
};
+#else
+ payload.d.durtyp = DT_DURYMD;
+ payload.d.neg = negp;
+ payload.d.ymd.m = d.m;
+#endif
goto out;
}
diff --git a/src/dseq.c b/src/dseq.c
index b4bf405..9dc58f1 100644
--- a/src/dseq.c
+++ b/src/dseq.c
@@ -426,29 +426,22 @@ __fixup_fst(struct dseq_clo_s *clo)
static struct dt_dtdur_s
tseq_guess_ite(struct dt_t_s beg, struct dt_t_s end)
{
+ struct dt_dtdur_s res = {0};
+
if (beg.hms.h != end.hms.h &&
- beg.hms.m == 0 && end.hms.m == 0&&
+ beg.hms.m == 0 && end.hms.m == 0 &&
beg.hms.s == 0 && end.hms.s == 0) {
- if (beg.u < end.u) {
- return (struct dt_dtdur_s){DT_DURH, .dv = 1};
- } else {
- return (struct dt_dtdur_s){DT_DURH, .dv = -1};
- }
+ res.durtyp = DT_DURH;
+ res.dv = (beg.u < end.u) ? 1 : -1;
} else if (beg.hms.m != end.hms.m &&
beg.hms.s == 0 && end.hms.s == 0) {
- if (beg.u < end.u) {
- return (struct dt_dtdur_s){DT_DURM, .dv = 1};
- } else {
- return (struct dt_dtdur_s){DT_DURM, .dv = -1};
- }
+ res.durtyp = DT_DURM;
+ res.dv = (beg.u < end.u) ? 1 : -1;
} else {
- if (beg.u < end.u) {
- return (struct dt_dtdur_s){DT_DURS, .dv = 1};
- } else {
- return (struct dt_dtdur_s){DT_DURS, .dv = -1};
- }
+ res.durtyp = DT_DURS;
+ res.dv = (beg.u < end.u) ? 1 : -1;
}
- /* no reach */
+ return res;
}
diff --git a/test/dtcore-add.c b/test/dtcore-add.c
index bfdea28..ff0c49e 100644
--- a/test/dtcore-add.c
+++ b/test/dtcore-add.c
@@ -67,7 +67,7 @@ add_t_only(void)
{
static const char str[] = "12:34:56";
struct dt_dt_s d;
- struct dt_dtdur_s dur = {.durtyp = (dt_dtdurtyp_t)DT_DURUNK};
+ struct dt_dtdur_s dur = {(dt_dtdurtyp_t)DT_DURUNK};
int res = 0;
/* 2012-03-28 (using no format) */
@@ -166,7 +166,7 @@ dt_add_t(void)
{
static const char str[] = "2012-03-28T23:12:01";
struct dt_dt_s d;
- struct dt_dtdur_s dur = {.durtyp = (dt_dtdurtyp_t)DT_DURUNK};
+ struct dt_dtdur_s dur = {(dt_dtdurtyp_t)DT_DURUNK};
int res = 0;
fprintf(stderr, "testing %s +1h ...\n", str);
@@ -221,7 +221,7 @@ dt_add_dt(void)
{
static const char str[] = "2012-03-28T23:55:55";
struct dt_dt_s d;
- struct dt_dtdur_s dur = {.durtyp = (dt_dtdurtyp_t)DT_DURUNK};
+ struct dt_dtdur_s dur = {(dt_dtdurtyp_t)DT_DURUNK};
int res = 0;
fprintf(stderr, "testing %s +1d1h ...\n", str);
--
1.8.4.5