Skip to content

Commit c2c9d84

Browse files
authored
Fix strptime bug with %a conversions (#1533)
* fix strptime bug with %a conversions. * workaround time zone issues with strptime. our strptime ignores %z results because tm_gmtoff is non-standard until POSIX.1-2024.
1 parent f4946d7 commit c2c9d84

File tree

6 files changed

+37
-1
lines changed

6 files changed

+37
-1
lines changed

reference/strptime.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fri Nov 19 19:52:39Z 2021, 50.917162998, 11.573497706

reference/strptime.gpx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<gpx version="1.0" creator="GPSBabel - https://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/0">
3+
<time>1970-01-01T00:00:00Z</time>
4+
<bounds minlat="50.917162998" minlon="11.573497706" maxlat="50.917162998" maxlon="11.573497706"/>
5+
<wpt lat="50.917162998" lon="11.573497706">
6+
<time>2021-11-19T19:52:39Z</time>
7+
<name>WPT001</name>
8+
<cmt>WPT001</cmt>
9+
<desc>WPT001</desc>
10+
</wpt>
11+
</gpx>

strptime/README.GPSBabel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ README
1111

1212
The modified files from glibc.git are:
1313
strptime_l.c
14+
15+
strptime_l.c.patch is a patch for our standalone version of strptime.
16+
bug33858.patch is for a strptime bug reported but not fixed in glibc. see https://sourceware.org/bugzilla/show_bug.cgi?id=33853

strptime/bug33853.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/strptime/strptime_l.c b/strptime/strptime_l.c
2+
index 1a647079..5d2e6b21 100644
3+
--- a/strptime/strptime_l.c
4+
+++ b/strptime/strptime_l.c
5+
@@ -382,7 +382,7 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp,
6+
if (s.decided != loc
7+
&& (((trp = rp, match_string (weekday_name[cnt], trp))
8+
&& trp > rp_longest)
9+
- || ((trp = rp, match_string (ab_weekday_name[cnt], rp))
10+
+ || ((trp = rp, match_string (ab_weekday_name[cnt], trp))
11+
&& trp > rp_longest)))
12+
{
13+
rp_longest = trp;

strptime/strptime_l.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp,
382382
if (s.decided != loc
383383
&& (((trp = rp, match_string (weekday_name[cnt], trp))
384384
&& trp > rp_longest)
385-
|| ((trp = rp, match_string (ab_weekday_name[cnt], rp))
385+
|| ((trp = rp, match_string (ab_weekday_name[cnt], trp))
386386
&& trp > rp_longest)))
387387
{
388388
rp_longest = trp;

testo.d/xcsv.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,11 @@ if command -v tzselect >/dev/null 2>&1 ; then
426426

427427
unset -v TZ
428428
fi
429+
430+
# test for strptime bug https://sourceware.org/bugzilla/show_bug.cgi?id=33853
431+
echo 'FIELD_DELIMITER COMMA' > ${TMPDIR}/strptime.style
432+
echo 'IFIELD GMT_TIME,"","%a %b %d %H:%M:%S%z %Y"' >> ${TMPDIR}/strptime.style
433+
echo 'IFIELD LAT_DECIMAL,"","%f"' >> ${TMPDIR}/strptime.style
434+
echo 'IFIELD LON_DECIMAL,"","%f"' >> ${TMPDIR}/strptime.style
435+
gpsbabel -i xcsv,style=${TMPDIR}/strptime.style -f ${REFERENCE}/strptime.csv -o gpx -F ${TMPDIR}/strptime.gpx
436+
compare ${REFERENCE}/strptime.gpx ${TMPDIR}/strptime.gpx

0 commit comments

Comments
 (0)