[Git][reproducible-builds/reproducible-website][master] 3 commits: Document more consise C code for parsing SDE

Holger Levsen gitlab at salsa.debian.org
Mon May 27 13:06:52 UTC 2019



Holger Levsen pushed to branch master at Reproducible Builds / reproducible-website


Commits:
547732f6 by Bernhard M. Wiedemann at 2019-05-27T12:47:21Z
Document more consise C code for parsing SDE

and document that stdlib.h is required for getenv

- - - - -
9fc7e2f6 by Holger Levsen at 2019-05-27T13:06:08Z
Merge branch 'mr-origin-33'

- - - - -
8b293758 by Holger Levsen at 2019-05-27T13:06:42Z
fix typo, assum_p_tion

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -


1 changed file:

- _docs/source-date-epoch.md


Changes:

=====================================
_docs/source-date-epoch.md
=====================================
@@ -154,6 +154,7 @@ endif ()
 ```
 #include <errno.h>
 #include <limits.h>
+#include <stdlib.h>
 
 struct tm *build_time;
 time_t now;
@@ -189,6 +190,18 @@ if (source_date_epoch) {
 build_time = gmtime(&now);
 ```
 
+If you want less verbose code and are happy with the assumption, that the variable will contain a correct, positive integer in the `time_t` range, you can use
+
+```
+#include <stdlib.h>
+
+time_t now;
+char *source_date_epoch;
+if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) == NULL ||
+    (now = (time_t)strtoll(source_date_epoch, NULL, 10)) <= 0)
+        time(&now);
+```
+
 ### C++
 
 ```



View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/compare/d7c4e13e31ce5800d9a87eabdb335331061a20b6...8b2937581b88cd142a00ae804f5ba6d5e2c5b324

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/compare/d7c4e13e31ce5800d9a87eabdb335331061a20b6...8b2937581b88cd142a00ae804f5ba6d5e2c5b324
You're receiving this email because of your account on salsa.debian.org.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20190527/c1faff4d/attachment.html>


More information about the rb-commits mailing list