1 /* Copyright (C) 2015-2018 Free Software Foundation, Inc.
3 This file is part of groff.
5 groff is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
10 groff is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 The GNU General Public License version 2 (GPL2) is available in the
16 internet at <http://www.gnu.org/licenses/gpl-2.0.txt>. */
27 #ifdef LONG_FOR_TIME_T
34 char *source_date_epoch = getenv("SOURCE_DATE_EPOCH");
36 if (source_date_epoch) {
39 long epoch = strtol(source_date_epoch, &endptr, 10);
41 if ((errno == ERANGE && (epoch == LONG_MAX || epoch == LONG_MIN)) ||
42 (errno != 0 && epoch == 0))
43 fatal("$SOURCE_DATE_EPOCH: strtol: %1", strerror(errno));
44 if (endptr == source_date_epoch)
45 fatal("$SOURCE_DATE_EPOCH: no digits found: %1", endptr);
47 fatal("$SOURCE_DATE_EPOCH: trailing garbage: %1", endptr);