SHA256
1
0
forked from pool/dateutils

Accepting request 913333 from utilities

- Update to 4.9:
  * allow to specify epochs in nanoseconds, %s%N (#123)
  * fix nanosecond arithmetic (#124)
  * make cross-compilations easier (#128)
  * mention default timezone (#129)
- Drop upstreamed patches:
  * 0144b15dda4b1ea4fdbeca9f3ecb128eb98772fd.patch
  * a0ebd0037df973aed14779b51d59da3edc506b6a.patch

OBS-URL: https://build.opensuse.org/request/show/913333
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/dateutils?expand=0&rev=29
This commit is contained in:
Richard Brown 2021-08-20 14:57:59 +00:00 committed by Git OBS Bridge
commit 0f5c57e07d
8 changed files with 23 additions and 192 deletions

View File

@ -1,88 +0,0 @@
From 0144b15dda4b1ea4fdbeca9f3ecb128eb98772fd Mon Sep 17 00:00:00 2001
From: Sebastian Freundt <freundt@ga-group.nl>
Date: Mon, 22 Feb 2021 12:21:40 +0000
Subject: [PATCH] minor, condense %s%N to DT_SPFL_N_EPOCHNS, fixes issue 123
---
lib/dt-core-strpf.c | 10 ++++++++--
lib/dt-core.c | 2 +-
lib/token.c | 4 ++++
lib/token.h | 2 ++
4 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/lib/dt-core-strpf.c b/lib/dt-core-strpf.c
index 2d460fef..e03f6501 100644
--- a/lib/dt-core-strpf.c
+++ b/lib/dt-core-strpf.c
@@ -277,7 +277,8 @@ __strpdt_card(struct strpdt_s *d, const char *sp, struct dt_spec_s s, char **ep)
res = __strpt_card(&d->st, sp, s, ep);
goto out_direct;
- case DT_SPFL_N_EPOCH: {
+ case DT_SPFL_N_EPOCH:
+ case DT_SPFL_N_EPOCHNS: {
/* read over @ */
const char *tp = sp;
tp += *tp == '@';
@@ -287,6 +288,10 @@ __strpdt_card(struct strpdt_s *d, const char *sp, struct dt_spec_s s, char **ep)
} else {
sp = tp;
}
+ if (s.spfl == DT_SPFL_N_EPOCHNS) {
+ d->st.ns = d->i % 1000000000;
+ d->i /= 1000000000;
+ }
break;
}
@@ -358,7 +363,8 @@ __strfdt_card(
res = __strft_card(buf, bsz, s, &d->st, that.t);
break;
- case DT_SPFL_N_EPOCH: {
+ case DT_SPFL_N_EPOCH:
+ case DT_SPFL_N_EPOCHNS: {
/* convert to sexy */
int64_t sexy = dt_conv_to_sexy(that).sexy;
res = snprintf(buf, bsz, "%" PRIi64, sexy);
diff --git a/lib/dt-core.c b/lib/dt-core.c
index afbd18fa..0232e788 100644
--- a/lib/dt-core.c
+++ b/lib/dt-core.c
@@ -702,7 +702,7 @@ dt_strpdt(const char *str, const char *fmt, char **ep)
if (spec.spfl == DT_SPFL_UNK) {
/* must be literal */
- if (*fp_sav != *sp++) {
+ if (UNLIKELY(*fp_sav != *sp++)) {
goto fucked;
}
} else if (LIKELY(!spec.rom)) {
diff --git a/lib/token.c b/lib/token.c
index e9e06df5..07dd0263 100644
--- a/lib/token.c
+++ b/lib/token.c
@@ -146,6 +146,10 @@ __tok_spec(const char *fp, const char **ep)
break;
case 's':
res.spfl = DT_SPFL_N_EPOCH;
+ if (fp[1U] == '%' && fp[2U] == 'N') {
+ res.spfl = DT_SPFL_N_EPOCHNS;
+ fp += 2U;
+ }
break;
case 'Z':
res.spfl = DT_SPFL_N_ZDIFF;
diff --git a/lib/token.h b/lib/token.h
index caca1dcd..72718fb0 100644
--- a/lib/token.h
+++ b/lib/token.h
@@ -85,6 +85,8 @@ typedef enum {
/* date/time specs */
/* %s epoch spec, non-standard */
DT_SPFL_N_EPOCH,
+ /* %s%N epoch spec, non-standard */
+ DT_SPFL_N_EPOCHNS,
/* %Z zone difference */
DT_SPFL_N_ZDIFF,
DT_SPFL_N_DTLAST = DT_SPFL_N_ZDIFF,

View File

@ -1,91 +0,0 @@
From a0ebd0037df973aed14779b51d59da3edc506b6a Mon Sep 17 00:00:00 2001
From: Sebastian Freundt <freundt@ga-group.nl>
Date: Fri, 5 Mar 2021 08:52:07 +0000
Subject: [PATCH] fix, extend slot to capture INT64_MIN, fixes bug #124
---
lib/dt-core-strpf.c | 4 ++--
lib/dt-core.c | 2 +-
lib/strops.c | 16 ++++++----------
3 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/lib/dt-core-strpf.c b/lib/dt-core-strpf.c
index e03f6501..b09608d6 100644
--- a/lib/dt-core-strpf.c
+++ b/lib/dt-core-strpf.c
@@ -289,8 +289,8 @@ __strpdt_card(struct strpdt_s *d, const char *sp, struct dt_spec_s s, char **ep)
sp = tp;
}
if (s.spfl == DT_SPFL_N_EPOCHNS) {
- d->st.ns = d->i % 1000000000;
- d->i /= 1000000000;
+ d->st.ns = d->i % 1000000000LL;
+ d->i /= 1000000000LL;
}
break;
}
diff --git a/lib/dt-core.c b/lib/dt-core.c
index 0232e788..913ed5c1 100644
--- a/lib/dt-core.c
+++ b/lib/dt-core.c
@@ -85,7 +85,7 @@
struct strpdt_s {
struct strpd_s sd;
struct strpt_s st;
- long int i;
+ int64_t i;
/* use 31 bits for the difference */
int32_t zdiff:31;
diff --git a/lib/strops.c b/lib/strops.c
index 5dd20965..7cc205a0 100644
--- a/lib/strops.c
+++ b/lib/strops.c
@@ -113,7 +113,7 @@ strtoi32(const char *str, const char **ep)
{
const char *sp = str;
bool negp = false;
- int32_t res = 0;
+ int32_t res = INT32_MIN;
if (*str == '-') {
negp = true;
@@ -122,12 +122,10 @@ strtoi32(const char *str, const char **ep)
while (res < INT32_MAX / 10 && (unsigned char)(*sp ^ '0') < 10U) {
res *= 10, res += (unsigned char)(*sp++ ^ '0');
}
- if (UNLIKELY(sp == str)) {
- res = INT32_MIN;
- } else if (negp) {
+ if (negp) {
res = -res;
}
- *ep = (char*)sp;
+ *ep = res > INT32_MIN ? (char*)sp : (char*)str;
return res;
}
@@ -137,7 +135,7 @@ strtoi64(const char *str, const char **ep)
{
const char *sp = str;
bool negp = false;
- int64_t res = 0;
+ int64_t res = INT64_MIN;
if (*str == '-') {
negp = true;
@@ -146,12 +144,10 @@ strtoi64(const char *str, const char **ep)
while (res < INT64_MAX / 10 && (unsigned char)(*sp ^ '0') < 10U) {
res *= 10, res += (unsigned char)(*sp++ ^ '0');
}
- if (UNLIKELY(sp == str)) {
- res = INT64_MIN;
- } else if (negp) {
+ if (negp) {
res = -res;
}
- *ep = (char*)sp;
+ *ep = res > INT64_MIN ? (char*)sp : (char*)str;
return res;
}

View File

@ -1,7 +0,0 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iEYEABECAAYFAmAtMCQACgkQlMmhrILJOQ6JgACfT12reyF+4xElL5iuwg4M56lV
2YIAn0Ni2lp1oyYwQRlPtSsHU9pDYVLA
=wmCz
-----END PGP SIGNATURE-----

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3f7054a24cf3e3ea2c32a6b1f7474334c25b54e9c45c96b03f75eaaecc70c100
size 642316

7
dateutils-0.4.9.tar.asc Normal file
View File

@ -0,0 +1,7 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iEYEABECAAYFAmEfXh8ACgkQlMmhrILJOQ4QGQCeJRUiwob06OkTyHh/MyKX9M3q
zQsAoIZbj4MJFV4MVNYsdHIPh3Uonmn7
=3TPe
-----END PGP SIGNATURE-----

3
dateutils-0.4.9.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:790256d9949b96001fdcc3f7c42226dde4fcc87eb580717c7aabf51a1334c9c3
size 651024

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Fri Aug 20 12:15:31 UTC 2021 - Michael Vetter <mvetter@suse.com>
- Update to 4.9:
* allow to specify epochs in nanoseconds, %s%N (#123)
* fix nanosecond arithmetic (#124)
* make cross-compilations easier (#128)
* mention default timezone (#129)
- Drop upstreamed patches:
* 0144b15dda4b1ea4fdbeca9f3ecb128eb98772fd.patch
* a0ebd0037df973aed14779b51d59da3edc506b6a.patch
-------------------------------------------------------------------
Mon May 17 09:48:34 UTC 2021 - Dominique Leuenberger <dimstar@opensuse.org>

View File

@ -17,7 +17,7 @@
Name: dateutils
Version: 0.4.8
Version: 0.4.9
Release: 0
Summary: Command line date and time utilities
License: BSD-3-Clause
@ -26,8 +26,6 @@ URL: https://github.com/hroptatyr/dateutils/
Source0: https://github.com/hroptatyr/dateutils/releases/download/v%{version}/%{name}-%{version}.tar.xz
Source1: https://github.com/hroptatyr/dateutils/releases/download/v%{version}/%{name}-%{version}.tar.asc
Source2: %{name}.keyring
Patch0: https://github.com/hroptatyr/dateutils/commit/0144b15dda4b1ea4fdbeca9f3ecb128eb98772fd.patch
Patch1: https://github.com/hroptatyr/dateutils/commit/a0ebd0037df973aed14779b51d59da3edc506b6a.patch
BuildRequires: octave-devel
BuildRequires: pkgconfig
BuildRequires: timezone