Skip to content

Commit fa9c053

Browse files
committed
Fix XFD header timestamp not using SOURCE_DATE_EPOCH
1 parent bc928bb commit fa9c053

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

cobc/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
2025-05-20 David Declerck <[email protected]>
3+
4+
* sqlxfdgen.c (output_xfd_file): fix to take
5+
SOURCE_DATE_EPOCH into account
6+
27
2025-05-19 David Declerck <[email protected]>
38

49
* cobc.c (set_compile_date): fix SOURCE_DATE_EPOCH being

cobc/sqlxfdgen.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (C) 2019-2021 Free Software Foundation, Inc.
2+
Copyright (C) 2019-2021,2025 Free Software Foundation, Inc.
33
Written by Ron Norman, Simon Sobisch
44
55
This file is part of GnuCOBOL.
@@ -1316,8 +1316,6 @@ output_xfd_file (struct cb_file *fl)
13161316
char outname[COB_FILE_BUFF], tblname[64], time_stamp[32];
13171317
char ridname[72];
13181318
FILE *fx, *fs;
1319-
struct tm *loctime;
1320-
time_t sectime;
13211319
struct cb_field *f;
13221320
struct cb_alt_key *l;
13231321
struct cb_key_component *c;
@@ -1345,14 +1343,8 @@ output_xfd_file (struct cb_file *fl)
13451343
idx[sub] = 0;
13461344
sub = 0;
13471345
next_lbl = 1;
1348-
sectime = time (NULL);
1349-
loctime = localtime (&sectime);
1350-
if (loctime) {
1351-
strftime (time_stamp, (size_t)COB_MINI_MAX,
1352-
"%b %d %Y %H:%M:%S", loctime);
1353-
} else {
1354-
strcpy(time_stamp,"Time unknown");
1355-
}
1346+
strftime (time_stamp, (size_t)COB_MINI_MAX,
1347+
"%b %d %Y %H:%M:%S", &current_compile_tm);
13561348
if (fl->sql_name) {
13571349
strcpy(tblname,fl->sql_name);
13581350
} else if(fl->assign

tests/testsuite.src/syn_file.at

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,7 +2397,7 @@ AT_CLEANUP
23972397

23982398

23992399
AT_SETUP([XFD directive and creation])
2400-
AT_KEYWORDS([file cobc sql SUPPRESS WHEN])
2400+
AT_KEYWORDS([file cobc sql SUPPRESS WHEN SOURCE_DATE_EPOCH])
24012401

24022402
AT_DATA([prog.cob], [
24032403
IDENTIFICATION DIVISION.
@@ -3090,7 +3090,8 @@ AT_DATA([prog.cob], [
30903090
STOP RUN.
30913091
])
30923092

3093-
AT_CHECK([$COMPILE -Wno-unsupported -fsql prog.cob], [0], [], [])
3093+
AT_CHECK([SOURCE_DATE_EPOCH=1011960000 \
3094+
$COMPILE -Wno-unsupported -fsql prog.cob], [0], [], [])
30943095

30953096
AT_CAPTURE_FILE(./tspfilex.ddl)
30963097

@@ -3133,7 +3134,7 @@ CREATE INDEX k2_tspfilex ON tspfilex (disk,dp_mgr,machine,rid_tspfilex);
31333134
AT_CHECK([$DIFF reference tspfilex.ddl], [0], [], [])
31343135

31353136
AT_DATA([reference],
3136-
[# Generated on MMM DD YYYY HH:MM:SS from prog.cob
3137+
[# Generated on Jan 25 2002 12:00:00 from prog.cob
31373138
H,1,tspfilex,2,',','.',0,3
31383139
D,1,'MMDDYYYY',8,1,0,,0,4:4,0:2,2:2,0:0,0:0,0:0,0:0,0:0
31393140
D,2,'YYMMDDCC',8,1,0,,0,0:2,2:2,4:2,0:0,0:0,0:0,6:2,0:0
@@ -3184,10 +3185,7 @@ K,2,Y,Y,0x2A,disk,dp_mgr,machine,rid_tspfilex
31843185
K,0,R,N,,rid_tspfilex
31853186
])
31863187

3187-
AT_CHECK([$SED -e 's/Generated on ... .. .... ..:..:../Generated on MMM DD YYYY HH:MM:SS/g' \
3188-
tspfilex.xd > tspfilex.sed], [0], [], [])
3189-
3190-
AT_CHECK([$DIFF reference tspfilex.sed], [0], [], [])
3188+
AT_CHECK([$DIFF reference tspfilex.xd], [0], [], [])
31913189

31923190
AT_CLEANUP
31933191

0 commit comments

Comments
 (0)