1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
Description: Honour SOURCE_DATE_EPOCH for embedded timestamps in documentation
Author: Reiner Herrmann <reiner@reiner-h.de>
Index: udo-6.4.1/Source/udo.c
===================================================================
--- udo-6.4.1.orig/Source/udo.c
+++ udo-6.4.1/Source/udo.c
@@ -35,6 +35,7 @@ const char *id_udo_c= "@(#) udo.c
#include <stdarg.h>
#include <time.h>
#include <ctype.h>
+#include <limits.h>
#include "portab.h"
#include "version.h" /* WICHTIGE Makros! */
@@ -10639,9 +10640,21 @@ LOCAL void init_lang_date ( void )
time_t timer;
struct tm *zeit;
int old_charset;
+ char *source_date_epoch;
- time(&timer);
- zeit= localtime(&timer);
+ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch) {
+ char *endptr;
+ timer = strtoull(source_date_epoch, &endptr, 10);
+ if (timer == ULONG_MAX || endptr == source_date_epoch || *endptr != '\0') {
+ fprintf(stderr, "Invalid SOURCE_DATE_EPOCH: %s\n", source_date_epoch);
+ exit(EXIT_FAILURE);
+ }
+ zeit = gmtime(&timer);
+ } else {
+ time(&timer);
+ zeit= localtime(&timer);
+ }
iDateDay= zeit->tm_mday; /* Global sichern z.B. fuer RTF */
iDateMonth= zeit->tm_mon+1;
|