On Wed, Aug 27, 2014 at 08:28:53AM +0200, Werner LEMBERG wrote: > Colin Watson wrote: > > 2) Add an option or environment variable or something to suppress > > the inclusion of timestamps. > > This is the way to go, I guess. > > > For bonus points, set this when building groff's own > > documentation. > > Hmm. I rather suggest to provide this as a configuration option so > that builds that need this functionality can access it.
OK. If it's an environment variable then this comes for free by just setting that variable. How about the attached patch? Thanks, -- Colin Watson [cjwat...@debian.org]
>From d4f2151d6964a8d73f873f3e1f46b71af98d9eee Mon Sep 17 00:00:00 2001 From: Colin Watson <cjwat...@debian.org> Date: Wed, 27 Aug 2014 09:06:26 +0100 Subject: [PATCH] Honour GROFF_NO_TIMESTAMPS, for more reproducible builds * src/devices/grohtml/post-html.cpp, src/devices/gropdf/gropdf.pl, src/devices/grops/ps.cpp: Don't emit creation timestamp if the environment variable `GROFF_NO_TIMESTAMPS' is set. * src/devices/grohtml/grohtml.man, src/devices/gropdf/gropdf.man, src/devices/grops/grops.man: Updated. --- ChangeLog | 8 +++++++ src/devices/grohtml/grohtml.man | 6 ++++++ src/devices/grohtml/post-html.cpp | 45 ++++++++++++++++++++++----------------- src/devices/gropdf/gropdf.man | 6 ++++++ src/devices/gropdf/gropdf.pl | 16 ++++++++------ src/devices/grops/grops.man | 6 ++++++ src/devices/grops/ps.cpp | 3 ++- 7 files changed, 63 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0812769..8b956c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-08-27 Colin Watson <cjwat...@debian.org> + + * src/devices/grohtml/post-html.cpp, src/devices/gropdf/gropdf.pl, + src/devices/grops/ps.cpp: Don't emit creation timestamp if the + environment variable `GROFF_NO_TIMESTAMPS' is set. * + src/devices/grohtml/grohtml.man, src/devices/gropdf/gropdf.man, + src/devices/grops/grops.man: Updated. + 2014-08-20 Bernd Warken <groff-bernd.warken...@web.de> * groff.7 (man/groff.man): Add further preprocessor regions. diff --git a/src/devices/grohtml/grohtml.man b/src/devices/grohtml/grohtml.man index 02209e2..f20883d 100644 --- a/src/devices/grohtml/grohtml.man +++ b/src/devices/grohtml/grohtml.man @@ -370,6 +370,12 @@ and for more details. . . +.TP +.SM +.B GROFF_NO_TIMESTAMPS +If set, do not include the creation timestamp in the output file. +. +. .SH BUGS .B Grohtml has been completely redesigned and rewritten. diff --git a/src/devices/grohtml/post-html.cpp b/src/devices/grohtml/post-html.cpp index f4656a0..60fddbc 100644 --- a/src/devices/grohtml/post-html.cpp +++ b/src/devices/grohtml/post-html.cpp @@ -36,6 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #endif +#include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <string.h> @@ -4988,12 +4989,6 @@ void html_printer::do_file_components (void) file_list.move_next(); if (file_list.is_new_output_file()) { -#ifdef LONG_FOR_TIME_T - long t; -#else - time_t t; -#endif - if (fragment_no > 1) write_navigation(top, prev, next, current); prev = current; @@ -5014,10 +5009,18 @@ void html_printer::do_file_components (void) .put_string(Version_string) .end_comment(); - t = time(0); - html.begin_comment("CreationDate: ") - .put_string(ctime(&t), strlen(ctime(&t))-1) - .end_comment(); + if (!getenv("GROFF_NO_TIMESTAMPS")) { +#ifdef LONG_FOR_TIME_T + long t; +#else + time_t t; +#endif + + t = time(0); + html.begin_comment("CreationDate: ") + .put_string(ctime(&t), strlen(ctime(&t))-1) + .end_comment(); + } if (dialect == html4) writeHeadMetaStyle(); @@ -5107,12 +5110,6 @@ void html_printer::writeHeadMetaStyle (void) html_printer::~html_printer() { -#ifdef LONG_FOR_TIME_T - long t; -#else - time_t t; -#endif - if (current_paragraph) current_paragraph->flush_text(); html.end_line(); @@ -5127,10 +5124,18 @@ html_printer::~html_printer() .put_string(Version_string) .end_comment(); - t = time(0); - html.begin_comment("CreationDate: ") - .put_string(ctime(&t), strlen(ctime(&t))-1) - .end_comment(); + if (!getenv("GROFF_NO_TIMESTAMPS")) { +#ifdef LONG_FOR_TIME_T + long t; +#else + time_t t; +#endif + + t = time(0); + html.begin_comment("CreationDate: ") + .put_string(ctime(&t), strlen(ctime(&t))-1) + .end_comment(); + } if (dialect == html4) writeHeadMetaStyle(); diff --git a/src/devices/gropdf/gropdf.man b/src/devices/gropdf/gropdf.man index 426a4d0..f698104 100644 --- a/src/devices/gropdf/gropdf.man +++ b/src/devices/gropdf/gropdf.man @@ -977,6 +977,12 @@ and for more details. . . +.TP +.SM +.B GROFF_NO_TIMESTAMPS +If set, do not include the creation timestamp in the output file. +. +. .SH FILES . .Tp \w'\fB@FONTDIR@/devpdf/download'u+2n diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl index f18bac8..2054c53 100644 --- a/src/devices/gropdf/gropdf.pl +++ b/src/devices/gropdf/gropdf.pl @@ -241,13 +241,17 @@ elsif (exists($ppsz{$papersz})) @defaultmb=@mediabox=(0,0,$ppsz{$papersz}->[0],$ppsz{$papersz}->[1]); } -my (@dt)=localtime(time); -my $dt=PDFDate(\@dt); - my %info=('Creator' => "(groff version $cfg{GROFF_VERSION})", - 'Producer' => "(gropdf version $cfg{GROFF_VERSION})", - 'ModDate' => "($dt)", - 'CreationDate' => "($dt)"); + 'Producer' => "(gropdf version $cfg{GROFF_VERSION})"); + +if (!exists($ENV{GROFF_NO_TIMESTAMPS})) { + my (@dt)=localtime(time); + my $dt=PDFDate(\@dt); + + $info{'ModDate'} = "($dt)"; + $info{'CreationDate'} = "($dt)"; +} + while (<>) { chomp; diff --git a/src/devices/grops/grops.man b/src/devices/grops/grops.man index 50b4696..6ed1c91 100644 --- a/src/devices/grops/grops.man +++ b/src/devices/grops/grops.man @@ -1378,6 +1378,12 @@ and for more details. . . +.TP +.SM +.B GROFF_NO_TIMESTAMPS +If set, do not include the creation timestamp in the output file. +. +. .SH FILES . .Tp \w'\fB@FONTDIR@/devps/download'u+2n diff --git a/src/devices/grops/ps.cpp b/src/devices/grops/ps.cpp index ab1b080..ebea05e 100644 --- a/src/devices/grops/ps.cpp +++ b/src/devices/grops/ps.cpp @@ -32,6 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "paper.h" #include "ps.h" +#include <stdlib.h> #include <time.h> #ifdef NEED_DECLARATION_PUTENV @@ -1385,7 +1386,7 @@ ps_printer::~ps_printer() .comment_arg("version") .comment_arg(Version_string) .end_comment(); - { + if (!getenv("GROFF_NO_TIMESTAMPS")) { fputs("%%CreationDate: ", out.get_file()); #ifdef LONG_FOR_TIME_T long -- 2.1.0