summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwlemb <wlemb>2001-07-17 13:17:03 +0000
committerwlemb <wlemb>2001-07-17 13:17:03 +0000
commit776b7cbc82819cc52342c9ddc02c1a117df0a5e4 (patch)
tree764ecd0ac5c56e9d7a0ee92b8675f5713f90dd73
parentcf123e890bce728d294f838b8961a90f5ea00fd2 (diff)
downloadgroff-776b7cbc82819cc52342c9ddc02c1a117df0a5e4.tar.gz
Replace call to `troff' with `groff -Z' to make it aware of
GROFF_BIN_PATH. * src/preproc/html/pre-html.cc (TROFF_COMMAND): New macro. (troff_command, command_prefix): Removed. (alterDeviceTo): Use groff. (addZ): New function. (char_buffer::do_html): Use it. (scanArguments): Use TROFF_COMMAND. (findPrefix): Removed. (main): Updated. * src/roff/groff/groff.cc (main): Handle zflag for preprocessors. * doc/pic.ms: Documentation fixes. Replace atexit() with global destructor. * src/libs/libgroff/tmpfile.cc (xtmpfile_list): Add constructor. (xtmpfile_list_init): New global structure to deallocate xtmpfile_list on exit. Its destructor inherits most code from remove_tmp_files(). (remove_tmp_files): Deleted. (add_tmp_file): Simplified.
-rw-r--r--ChangeLog30
-rw-r--r--doc/pic.ms12
-rw-r--r--src/libs/libgroff/tmpfile.cc54
-rw-r--r--src/preproc/html/pre-html.cc59
-rw-r--r--src/roff/groff/groff.cc2
5 files changed, 97 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index a80fc73c..153eb6c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2001-07-17 Gaius Mulley <gaius@glam.ac.uk>
+
+ Replace call to `troff' with `groff -Z' to make it aware of
+ GROFF_BIN_PATH.
+
+ * src/preproc/html/pre-html.cc (TROFF_COMMAND): New macro.
+ (troff_command, command_prefix): Removed.
+ (alterDeviceTo): Use groff.
+ (addZ): New function.
+ (char_buffer::do_html): Use it.
+ (scanArguments): Use TROFF_COMMAND.
+ (findPrefix): Removed.
+ (main): Updated.
+ * src/roff/groff/groff.cc (main): Handle zflag for preprocessors.
+
+2001-07-17 Eric S. Raymond <esr@snark.thyrsus.com>
+
+ * doc/pic.ms: Documentation fixes.
+
+2001-07-17 Werner LEMBERG <wl@gnu.org>
+
+ Replace atexit() with global destructor.
+
+ * src/libs/libgroff/tmpfile.cc (xtmpfile_list): Add constructor.
+ (xtmpfile_list_init): New global structure to deallocate
+ xtmpfile_list on exit. Its destructor inherits most code from
+ remove_tmp_files().
+ (remove_tmp_files): Deleted.
+ (add_tmp_file): Simplified.
+
2001-07-16 Werner LEMBERG <wl@gnu.org>
Replace strdup() with strsave().
diff --git a/doc/pic.ms b/doc/pic.ms
index 627a84f5..3166a4a8 100644
--- a/doc/pic.ms
+++ b/doc/pic.ms
@@ -10,7 +10,7 @@
.\" This document was written for free use and redistribution by
.\" Eric S. Raymond <esr@thyrsus.com> in August 1995.
.\"
-.\" $Id: pic.ms,v 1.4 2001/06/24 13:03:27 wlemb Exp $
+.\" $Id: pic.ms,v 1.5 2001/07/17 13:17:04 wlemb Exp $
.\"
.\" Set a proper TeX
.ie t .ds tx T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
@@ -654,7 +654,7 @@ has been filled, so that the text will not be obscured by the filling.
.PP
The closed-object modifier \fBsolid\fR is equivalent to \fBfill\fR
with the darkest fill value (DWB \fBpic\fR had this capability but
-mentioned it only in a reference opinion).
+mentioned it only in a reference section).
.NH 1
More About Text Placement
.PP
@@ -1372,10 +1372,12 @@ Various built-in functions are supported: \fBsin(\fIx\fB)\fR,
\fBcos(\fIx\fB)\fR, \fBlog(\fIx\fB)\fR, \fBexp(\fIx\fB)\fR,
\fBsqrt(\fIx\fB)\fR, \fBmax(\fIx\fB,\fIy\fB)\fR,
\fBatan2(\fIx\fB,\fIy\fB)\fR, \fBmin(\fIx\fB,\fIy\fB)\fR,
-\fBint(\fIx\fB)\fR, and \fBrand()\fP.
+\fBint(\fIx\fB)\fR, \fBrand()\fP, and \fBsrand()\fP.
Both \fBexp\fP and \fBlog\fP are
-base 10; \fBint\fP does integer truncation; and \fBrand()\fP returns a
-random number in [0-1).
+base 10; \fBint\fP does integer truncation; \fBrand()\fP returns a
+random number in [0-1), and \fBsrand()\fP sets the seed for
+a new sequence of pseudo-random numbers to be returned by \fBrand()\fP
+(\fBsrand()\fP is a GNU extension).
.PP
GNU \fBgpic\fP also documents a one-argument form or rand,
\fBrand(\fIx\fB)\fR, which returns a random number between 1 and
diff --git a/src/libs/libgroff/tmpfile.cc b/src/libs/libgroff/tmpfile.cc
index 27550994..4a53a06b 100644
--- a/src/libs/libgroff/tmpfile.cc
+++ b/src/libs/libgroff/tmpfile.cc
@@ -117,43 +117,41 @@ char *xtmptemplate(const char *postfix_long, const char *postfix_short)
// The trick with unlinking the temporary file while it is still in
// use is not portable, it will fail on MS-DOS and most MS-Windows
// filesystems. So it cannot be used on non-Posix systems.
-// Instead, we maintain a list of files to be deleted on exit, and
-// register an atexit function that will remove them all in one go.
+// Instead, we maintain a list of files to be deleted on exit.
// This should be portable to all platforms.
-static struct xtmpfile_list {
- struct xtmpfile_list *next;
- char fname[1];
-} *xtmpfiles_to_delete;
+struct xtmpfile_list {
+ const char *fname;
+ xtmpfile_list *next;
+ xtmpfile_list(const char *fn) : fname(fn), next(0) {}
+};
-static void remove_tmp_files()
+xtmpfile_list *xtmpfiles_to_delete = 0;
+
+struct xtmpfile_list_init {
+ ~xtmpfile_list_init();
+} _xtmpfile_list_init;
+
+xtmpfile_list_init::~xtmpfile_list_init()
{
- struct xtmpfile_list *p = xtmpfiles_to_delete;
-
- while (p) {
- if (unlink(p->fname) < 0)
- error("cannot unlink `%1': %2", p->fname, strerror(errno));
- struct xtmpfile_list *old = p;
- p = p->next;
- free(old);
+ xtmpfile_list *x = xtmpfiles_to_delete;
+ while (x != 0) {
+ if (unlink(x->fname) < 0)
+ error("cannot unlink `%1': %2", x->fname, strerror(errno));
+ xtmpfile_list *tmp = x;
+ x = x->next;
+ a_delete tmp->fname;
+ delete tmp;
}
}
static void add_tmp_file(const char *name)
{
- if (xtmpfiles_to_delete == NULL)
- atexit(remove_tmp_files);
-
- struct xtmpfile_list *p
- = (struct xtmpfile_list *)malloc(sizeof(struct xtmpfile_list)
- + strlen (name));
- if (p == NULL) {
- error("cannot unlink `%1': %2", name, strerror(errno));
- return;
- }
- p->next = xtmpfiles_to_delete;
- strcpy(p->fname, name);
- xtmpfiles_to_delete = p;
+ char *s = new char[strlen(name)];
+ strcpy(s, name);
+ xtmpfile_list *x = new xtmpfile_list(s);
+ x->next = xtmpfiles_to_delete;
+ xtmpfiles_to_delete = x;
}
// Open a temporary file and with fatal error on failure.
diff --git a/src/preproc/html/pre-html.cc b/src/preproc/html/pre-html.cc
index dcb234f4..dd9ee0af 100644
--- a/src/preproc/html/pre-html.cc
+++ b/src/preproc/html/pre-html.cc
@@ -72,6 +72,7 @@ extern "C" const char *Version_string;
#define PS_TEMPLATE_LONG "-ps-"
#define REGION_TEMPLATE_SHORT "rg"
#define REGION_TEMPLATE_LONG "-regions-"
+#define TROFF_COMMAND "troff"
#if 0
# define DEBUGGING
@@ -101,8 +102,6 @@ static int image_res = DEFAULT_IMAGE_RES;
static int vertical_offset= DEFAULT_VERTICAL_OFFSET;
static char *image_template = NULL; // image template filename
static int troff_arg = 0; // troff arg index
-static char *command_prefix = NULL; // optional prefix for some installations.
-static char *troff_command = NULL;
static char *image_dir = NULL; // user specified image directory
#if defined(DEBUGGING)
static int debug = FALSE;
@@ -1119,7 +1118,7 @@ static void waitForChild (PID_T pid)
* alterDeviceTo - if toImage is set then the arg list is altered to include
* IMAGE_DEVICE and we invoke groff rather than troff.
* else
- * set -Thtml and troff
+ * set -Thtml and groff
*/
static void alterDeviceTo (int argc, char *argv[], int toImage)
@@ -1141,11 +1140,37 @@ static void alterDeviceTo (int argc, char *argv[], int toImage)
}
i++;
}
- argv[troff_arg] = troff_command; /* use troff */
+ argv[troff_arg] = "groff"; /* use groff -Z */
}
}
/*
+ * addZ - appends -Z onto the command list for groff.
+ */
+
+char **addZ (int argc, char *argv[])
+{
+ char **new_argv = (char **)malloc((argc+2)*sizeof(char *));
+ int i=0;
+
+ if (new_argv == NULL)
+ sys_fatal("malloc");
+
+ while (i<troff_arg) {
+ new_argv[i] = argv[i];
+ i++;
+ }
+ new_argv[i] = "-Z";
+ while (i<argc) {
+ new_argv[i+1] = argv[i];
+ i++;
+ }
+ argc++;
+ new_argv[argc] = NULL;
+ return( new_argv );
+}
+
+/*
* do_html - sets the troff number htmlflip and
* writes out the buffer to troff -Thtml
*/
@@ -1159,8 +1184,10 @@ int char_buffer::do_html(int argc, char *argv[])
sys_fatal("pipe");
alterDeviceTo(argc, argv, 0);
- argv += troff_arg; // skip all arguments up to troff/groff
+ argv += troff_arg; // skip all arguments up to groff
argc -= troff_arg;
+ argv = addZ(argc, argv);
+ argc++;
#if defined(DEBUG_HTML)
write_file_html();
@@ -1327,7 +1354,7 @@ int scanArguments (int argc, char **argv)
|| (strcmp(argv[i], "-?") == 0)) {
usage(stdout);
exit(0);
- } else if (strcmp(argv[i], troff_command) == 0) {
+ } else if (strcmp(argv[i], TROFF_COMMAND) == 0) {
/* remember troff argument number */
troff_arg = i;
#if defined(DEBUGGING)
@@ -1391,25 +1418,6 @@ static void removeTempFiles (void)
#endif
}
-/*
- * findPrefix - finds the optional prefix to the groff utilities.
- * It also builds the 'troff' executable name.
- */
-
-static void findPrefix (void)
-{
- command_prefix = getenv("GROFF_COMMAND_PREFIX");
- if (!command_prefix)
- command_prefix = PROG_PREFIX;
- troff_command = (char *)malloc(strlen("troff")+strlen(command_prefix)+1);
- if (troff_command == NULL)
- sys_fatal("malloc");
-
- strcpy(troff_command, command_prefix);
- strcat(troff_command, "troff");
-}
-
-
int main(int argc, char **argv)
{
program_name = argv[0];
@@ -1417,7 +1425,6 @@ int main(int argc, char **argv)
int found=0;
int ok=1;
- findPrefix();
i = scanArguments(argc, argv);
checkImageDir();
makeFileName();
diff --git a/src/roff/groff/groff.cc b/src/roff/groff/groff.cc
index 7e95c33e..6e45edfa 100644
--- a/src/roff/groff/groff.cc
+++ b/src/roff/groff/groff.cc
@@ -281,7 +281,7 @@ int main(int argc, char **argv)
if (!postdriver)
fatal("no `postpro' command in DESC file for device `%1'", device);
- if (predriver) {
+ if (predriver && !zflag) {
commands[TROFF_INDEX].insert_arg(commands[TROFF_INDEX].get_name());
const char *p = Pargs.contents();
const char *end = p + Pargs.length();