aboutsummaryrefslogtreecommitdiff
path: root/contrib/groff/src/preproc
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2005-10-20 10:45:19 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2005-10-20 10:45:19 +0000
commit1c7b34d8d72dbef698ec688d638d51d5bbce14eb (patch)
tree37609e1685a209a2a273664ce67fc2f20f789996 /contrib/groff/src/preproc
parente3ad728cf2a0c16a1ac4677de65aa80b15e2ef67 (diff)
parent22e7cbb8744990e63e02dc3985780d932c67b1a4 (diff)
downloadsrc-1c7b34d8d72dbef698ec688d638d51d5bbce14eb.tar.gz
src-1c7b34d8d72dbef698ec688d638d51d5bbce14eb.zip
This commit was generated by cvs2svn to compensate for changes in r151497,
which included commits to RCS files with non-trunk default branches.
Notes
Notes: svn path=/head/; revision=151498
Diffstat (limited to 'contrib/groff/src/preproc')
-rw-r--r--contrib/groff/src/preproc/eqn/Makefile.sub6
-rw-r--r--contrib/groff/src/preproc/eqn/box.cpp7
-rw-r--r--contrib/groff/src/preproc/eqn/box.h15
-rw-r--r--contrib/groff/src/preproc/eqn/delim.cpp2
-rw-r--r--contrib/groff/src/preproc/eqn/eqn.h2
-rw-r--r--contrib/groff/src/preproc/eqn/eqn.man442
-rw-r--r--contrib/groff/src/preproc/eqn/eqn.y5
-rw-r--r--contrib/groff/src/preproc/eqn/lex.cpp10
-rw-r--r--contrib/groff/src/preproc/eqn/limit.cpp2
-rw-r--r--contrib/groff/src/preproc/eqn/list.cpp2
-rw-r--r--contrib/groff/src/preproc/eqn/main.cpp2
-rw-r--r--contrib/groff/src/preproc/eqn/mark.cpp2
-rw-r--r--contrib/groff/src/preproc/eqn/other.cpp2
-rw-r--r--contrib/groff/src/preproc/eqn/over.cpp2
-rw-r--r--contrib/groff/src/preproc/eqn/pbox.h2
-rw-r--r--contrib/groff/src/preproc/eqn/pile.cpp18
-rw-r--r--contrib/groff/src/preproc/eqn/script.cpp17
-rw-r--r--contrib/groff/src/preproc/eqn/special.cpp2
-rw-r--r--contrib/groff/src/preproc/eqn/sqrt.cpp2
-rw-r--r--contrib/groff/src/preproc/eqn/text.cpp2
-rw-r--r--contrib/groff/src/preproc/grn/gprint.h2
-rw-r--r--contrib/groff/src/preproc/grn/grn.man38
-rw-r--r--contrib/groff/src/preproc/grn/hdb.cpp33
-rw-r--r--contrib/groff/src/preproc/grn/hgraph.cpp144
-rw-r--r--contrib/groff/src/preproc/grn/hpoint.cpp26
-rw-r--r--contrib/groff/src/preproc/grn/main.cpp42
-rw-r--r--contrib/groff/src/preproc/html/Makefile.sub1
-rw-r--r--contrib/groff/src/preproc/html/pre-html.cpp1253
-rw-r--r--contrib/groff/src/preproc/html/pre-html.h2
-rw-r--r--contrib/groff/src/preproc/html/pushback.cpp30
-rw-r--r--contrib/groff/src/preproc/html/pushback.h24
-rw-r--r--contrib/groff/src/preproc/pic/TODO2
-rw-r--r--contrib/groff/src/preproc/pic/common.cpp155
-rw-r--r--contrib/groff/src/preproc/pic/common.h10
-rw-r--r--contrib/groff/src/preproc/pic/lex.cpp28
-rw-r--r--contrib/groff/src/preproc/pic/main.cpp2
-rw-r--r--contrib/groff/src/preproc/pic/object.cpp197
-rw-r--r--contrib/groff/src/preproc/pic/object.h11
-rw-r--r--contrib/groff/src/preproc/pic/output.h4
-rw-r--r--contrib/groff/src/preproc/pic/pic.h10
-rw-r--r--contrib/groff/src/preproc/pic/pic.man56
-rw-r--r--contrib/groff/src/preproc/pic/pic.y39
-rw-r--r--contrib/groff/src/preproc/pic/position.h2
-rw-r--r--contrib/groff/src/preproc/pic/tex.cpp27
-rw-r--r--contrib/groff/src/preproc/pic/troff.cpp36
-rw-r--r--contrib/groff/src/preproc/refer/command.cpp6
-rw-r--r--contrib/groff/src/preproc/refer/command.h2
-rw-r--r--contrib/groff/src/preproc/refer/label.y34
-rw-r--r--contrib/groff/src/preproc/refer/ref.cpp8
-rw-r--r--contrib/groff/src/preproc/refer/ref.h12
-rw-r--r--contrib/groff/src/preproc/refer/refer.cpp11
-rw-r--r--contrib/groff/src/preproc/refer/refer.h7
-rw-r--r--contrib/groff/src/preproc/refer/refer.man310
-rw-r--r--contrib/groff/src/preproc/refer/token.cpp2
-rw-r--r--contrib/groff/src/preproc/refer/token.h2
-rw-r--r--contrib/groff/src/preproc/soelim/Makefile.sub1
-rw-r--r--contrib/groff/src/preproc/soelim/soelim.cpp85
-rw-r--r--contrib/groff/src/preproc/soelim/soelim.man113
-rw-r--r--contrib/groff/src/preproc/tbl/Makefile.sub1
-rw-r--r--contrib/groff/src/preproc/tbl/main.cpp99
-rw-r--r--contrib/groff/src/preproc/tbl/table.cpp37
-rw-r--r--contrib/groff/src/preproc/tbl/table.h17
-rw-r--r--contrib/groff/src/preproc/tbl/tbl.man50
63 files changed, 2410 insertions, 1105 deletions
diff --git a/contrib/groff/src/preproc/eqn/Makefile.sub b/contrib/groff/src/preproc/eqn/Makefile.sub
index 755464564194..9028f94c8895 100644
--- a/contrib/groff/src/preproc/eqn/Makefile.sub
+++ b/contrib/groff/src/preproc/eqn/Makefile.sub
@@ -1,6 +1,7 @@
PROG=eqn$(EXEEXT)
MAN1=eqn.n neqn.n
XLIBS=$(LIBGROFF)
+MLIB=$(LIBM)
OBJS=\
eqn.$(OBJEXT) \
main.$(OBJEXT) \
@@ -44,11 +45,10 @@ CLEANADD=neqn
all: neqn
-neqn: neqn.sh
+neqn: neqn.sh $(SH_DEPS_SED_SCRIPT)
-rm -f $@
sed -e 's/@g@/$(g)/g' \
- -e 's|@BINDIR@|$(bindir)|g' \
- -e 's|@SEP@|$(SEP)|g' \
+ -f $(SH_DEPS_SED_SCRIPT) \
-e $(SH_SCRIPT_SED_CMD) $(srcdir)/neqn.sh >$@
chmod +x $@
diff --git a/contrib/groff/src/preproc/eqn/box.cpp b/contrib/groff/src/preproc/eqn/box.cpp
index 41d8dff46eff..953218a68da0 100644
--- a/contrib/groff/src/preproc/eqn/box.cpp
+++ b/contrib/groff/src/preproc/eqn/box.cpp
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "pbox.h"
@@ -80,7 +81,7 @@ int matrix_side_sep = 17; // = thin space
int nroff = 0; // should we grok ndefine or tdefine?
-struct {
+struct S {
const char *name;
int *ptr;
} param_table[] = {
diff --git a/contrib/groff/src/preproc/eqn/box.h b/contrib/groff/src/preproc/eqn/box.h
index 01bfe96a4ac3..94842077039a 100644
--- a/contrib/groff/src/preproc/eqn/box.h
+++ b/contrib/groff/src/preproc/eqn/box.h
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2004, 2005
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,9 +17,9 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-struct list_box;
+class list_box;
class box {
private:
@@ -62,6 +63,11 @@ public:
friend class list_box;
};
+// declarations to avoid friend name injection problems
+box *make_script_box(box *, box *, box *);
+box *make_mark_box(box *);
+box *make_lineup_box(box *);
+
class list_box : public box {
int is_script;
box_list list;
@@ -238,9 +244,6 @@ public:
};
box *split_text(char *);
-box *make_script_box(box *, box *, box *);
-box *make_mark_box(box *);
-box *make_lineup_box(box *);
box *make_delim_box(char *, box *, char *);
box *make_sqrt_box(box *);
box *make_prime_box(box *);
diff --git a/contrib/groff/src/preproc/eqn/delim.cpp b/contrib/groff/src/preproc/eqn/delim.cpp
index b7241802288d..9bb7c9b982c4 100644
--- a/contrib/groff/src/preproc/eqn/delim.cpp
+++ b/contrib/groff/src/preproc/eqn/delim.cpp
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "pbox.h"
diff --git a/contrib/groff/src/preproc/eqn/eqn.h b/contrib/groff/src/preproc/eqn/eqn.h
index ee25f034e8b3..fca3e9793a38 100644
--- a/contrib/groff/src/preproc/eqn/eqn.h
+++ b/contrib/groff/src/preproc/eqn/eqn.h
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "lib.h"
diff --git a/contrib/groff/src/preproc/eqn/eqn.man b/contrib/groff/src/preproc/eqn/eqn.man
index 6d0733c4adc6..0f47771c2392 100644
--- a/contrib/groff/src/preproc/eqn/eqn.man
+++ b/contrib/groff/src/preproc/eqn/eqn.man
@@ -1,5 +1,5 @@
.ig
-Copyright (C) 1989-2000, 2001 Free Software Foundation, Inc.
+Copyright (C) 1989-2000, 2001, 2004, 2005 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -16,20 +16,41 @@ versions, except that this permission notice may be included in
translations approved by the Free Software Foundation instead of in
the original English.
..
-.ie \n(.V<\n(.v .ds tx T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
-.el .ds tx TeX
+.
+.
+.ie \n(.V<\n(.v \
+. ds tx T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
+.el \
+. ds tx TeX
+.
+.
.\" Like TP, but if specified indent is more than half
.\" the current line-length - indent, use the default indent.
.de Tp
-.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
-.el .TP "\\$1"
+. ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
+. el .TP "\\$1"
+..
+.
+.
+.de TQ
+. br
+. ns
+. TP \\$1
..
+.
+.
.\" The BSD man macros can't handle " in arguments to font change macros,
.\" so use \(ts instead of ".
.tr \(ts"
+.
+.
.TH @G@EQN @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
+.
+.
.SH NAME
@g@eqn \- format equations for troff
+.
+.
.SH SYNOPSIS
.nr a \n(.j
.ad l
@@ -38,8 +59,8 @@ the original English.
.ti \niu
.B @g@eqn
.de OP
-.ie \\n(.$-1 .RI "[\ \fB\\$1\fP" "\\$2" "\ ]"
-.el .RB "[\ " "\\$1" "\ ]"
+. ie \\n(.$-1 .RI "[\ \fB\\$1\fP" "\\$2" "\ ]"
+. el .RB "[\ " "\\$1" "\ ]"
..
.OP \-rvCNR
.OP \-d xy
@@ -52,9 +73,12 @@ the original English.
.RI "[\ " files\|.\|.\|. "\ ]"
.br
.ad \na
-.PP
+.
+.LP
It is possible to have whitespace between a command line option and its
parameter.
+.
+.
.SH DESCRIPTION
This manual page describes the GNU version of
.BR eqn ,
@@ -69,13 +93,16 @@ Normally, it should be invoked using the
option of
.BR groff .
The syntax is quite compatible with Unix eqn.
-The output of GNU eqn cannot be processed with Unix troff;
+The output of GNU
+.B eqn
+cannot be processed with Unix troff;
it must be processed with GNU troff.
If no files are given on the command line, the standard input
will be read.
A filename of
.B \-
will cause the standard input to be read.
+.
.LP
.B eqn
searches for the file
@@ -87,25 +114,33 @@ option first, then in
.BR @LOCALMACRODIR@ ,
and finally in the standard macro directory
.BR @MACRODIR@ .
-If it exists, eqn will process it before the other input files.
+If it exists,
+.B eqn
+will process it before the other input files.
The
.B \-R
option prevents this.
+.
.LP
-GNU eqn does not provide the functionality of neqn:
+GNU
+.B eqn
+does not provide the functionality of neqn:
it does not support low-resolution, typewriter-like devices
(although it may work adequately for very simple input).
+.
+.
.SH OPTIONS
.TP
.BI \-d xy
Specify delimiters
.I x
-and
+and\~\c
.I y
for the left and right end, respectively, of in-line equations.
Any
.B delim
statements in the source file overrides this.
+.
.TP
.B \-C
Recognize
@@ -119,32 +154,38 @@ Don't allow newlines within delimiters.
This option allows
.B eqn
to recover better from missing closing delimiters.
+.
.TP
.B \-v
Print the version number.
+.
.TP
.B \-r
Only one size reduction.
+.
.TP
.BI \-m n
-The minimum point-size is
+The minimum point-size is\~\c
.IR n .
-eqn will not reduce the size of subscripts or superscripts to
-a smaller size than
+.B eqn
+will not reduce the size of subscripts or superscripts to
+a smaller size than\~\c
.IR n .
+.
.TP
.BI \-T name
The output is for device
.IR name .
The only effect of this is to define a macro
.I name
-with a value of
+with a value of\~\c
.BR 1 .
Typically
.B eqnrc
will use this to provide definitions appropriate for the output device.
The default output device is
.BR @DEVICE@ .
+.
.TP
.BI \-M dir
Search
@@ -152,82 +193,109 @@ Search
for
.B eqnrc
before the default directories.
+.
.TP
.B \-R
Don't load
.BR eqnrc .
+.
.TP
.BI \-f F
This is equivalent to a
.BI gfont\ F
command.
+.
.TP
.BI \-s n
This is equivalent to a
.BI gsize\ n
command.
This option is deprecated.
-eqn will normally set equations at whatever the current point size
+.B eqn
+will normally set equations at whatever the current point size
is when the equation is encountered.
+.
.TP
.BI \-p n
This says that subscripts and superscripts should be
-.I n
+.I n\~\c
points smaller than the surrounding text.
This option is deprecated.
-Normally eqn makes sets subscripts and superscripts at 70%
+Normally
+.B eqn
+makes sets subscripts and superscripts at 70%
of the size of the surrounding text.
+.
+.
.SH USAGE
-Only the differences between GNU eqn and Unix eqn are described here.
+Only the differences between GNU
+.B eqn
+and Unix eqn are described here.
+.
.LP
-Most of the new features of GNU eqn
+Most of the new features of GNU
+.B eqn
are based on \*(tx.
-There are some references to the differences between \*(tx and GNU eqn below;
+There are some references to the differences between \*(tx and GNU
+.B eqn
+below;
these may safely be ignored if you do not know \*(tx.
+.
.SS Automatic spacing
-.LP
.B eqn
gives each component of an equation a type, and adjusts the spacing
between components using that type.
Possible types are:
+.
+.RS
.TP \w'punctuation'u+2n
ordinary
-an ordinary character such as 1 or
-.IR x ;
+an ordinary character such as `1' or `\c
+.IR x ';
+.
.TP
operator
a large operator such as
-.ds Su \s+5\(*S\s0
+.ds Su `\s+5\(*S\s0'
.if \n(.g .if !c\(*S .ds Su the summation operator
\*(Su;
+.
.TP
binary
-a binary operator such as +;
+a binary operator such as `\(pl';
+.
.TP
relation
-a relation such as =;
+a relation such as `=';
+.
.TP
opening
-a opening bracket such as (;
+a opening bracket such as `(';
+.
.TP
closing
-a closing bracket such as );
+a closing bracket such as `)';
+.
.TP
punctuation
-a punctuation character such as ,;
+a punctuation character such as `,';
+.
.TP
inner
a subformula contained within brackets;
.TP
suppress
spacing that suppresses automatic spacing adjustment.
+.RE
+.
.LP
Components of an equation get a type in one of two ways.
+.
.TP
.BI type\ t\ e
-This yields an equation component that contains
+This yields an equation component that contains\~\c
.I e
-but that has type
+but that has type\~\c
.IR t ,
where
.I t
@@ -235,14 +303,17 @@ is one of the types mentioned above.
For example,
.B times
is defined as
+.
.RS
.IP
.B
type "binary" \e(mu
.RE
+.
.IP
The name of the type doesn't have to be quoted, but quoting protects
from macro expansion.
+.
.TP
.BI chartype\ t\ text
Unquoted groups of characters are split up into individual characters,
@@ -250,20 +321,20 @@ and the type of each character is looked up;
this changes the type that is stored for each character;
it says that the characters in
.I text
-from now on have type
+from now on have type\~\c
.IR t .
For example,
+.
.RS
.IP
.B
chartype "punctuation" .,;:
.RE
+.
.IP
-would make the characters
-.B .,;:
-have type punctuation
+would make the characters `.,;:' have type punctuation
whenever they subsequently appeared in an equation.
-The type
+The type\~\c
.I t
can also be
.B letter
@@ -272,7 +343,10 @@ or
in these cases
.B chartype
changes the font type of the characters.
-See the Fonts subsection.
+See the
+.B Fonts
+subsection.
+.
.SS New primitives
.TP
.IB e1\ smallover\ e2
@@ -297,22 +371,25 @@ primitive in display styles;
corresponds to
.B \eover
in non-display styles.
+.
.TP
.BI vcenter\ e
This vertically centers
.I e
about the math axis.
The math axis is the vertical position about which characters
-such as + and - are centered; also it is the vertical position
+such as `\(pl' and `\(mi' are centered; also it is the vertical position
used for the bar of fractions.
For example,
.B sum
is defined as
+.
.RS
.IP
.B
{ type "operator" vcenter size +5 \e(*S }
.RE
+.
.TP
.IB e1\ accent\ e2
This sets
@@ -328,21 +405,24 @@ is taller or shorter than a lowercase letter.
For example,
.B hat
is defined as
+.
.RS
.IP
.B
accent { "^" }
.RE
+.
.IP
.BR dotdot ,
.BR dot ,
.BR tilde ,
-.B vec
+.BR vec ,
and
.B dyad
are also defined using the
.B accent
primitive.
+.
.TP
.IB e1\ uaccent\ e2
This sets
@@ -359,13 +439,16 @@ has a descender.
is pre-defined using
.B uaccent
as a tilde accent below the baseline.
+.
.TP
.BI split\ \(ts text \(ts
This has the same effect as simply
+.
.RS
.IP
.I text
.RE
+.
.IP
but
.I text
@@ -373,13 +456,16 @@ is not subject to macro expansion because it is quoted;
.I text
will be split up and the spacing between individual characters
will be adjusted.
+.
.TP
.BI nosplit\ text
This has the same effect as
+.
.RS
.IP
.BI \(ts text \(ts
.RE
+.
.IP
but because
.I text
@@ -387,11 +473,12 @@ is not quoted it will be subject to macro expansion;
.I text
will not be split up
and the spacing between individual characters will not be adjusted.
+.
.TP
.IB e\ opprime
This is a variant of
.B prime
-that acts as an operator on
+that acts as an operator on\~\c
.IR e .
It produces a different result from
.B prime
@@ -399,14 +486,14 @@ in a case such as
.BR A\ opprime\ sub\ 1 :
with
.B opprime
-the
+the\~\c
.B 1
-will be tucked under the prime as a subscript to the
+will be tucked under the prime as a subscript to the\~\c
.B A
(as is conventional in mathematical typesetting),
whereas with
.B prime
-the
+the\~\c
.B 1
will be a subscript to the prime character.
The precedence of
@@ -419,31 +506,32 @@ which is higher than that of everything except
.B accent
and
.BR uaccent .
-In unquoted text a
+In unquoted text a\~\c
.B '
that is not the first character will be treated like
.BR opprime .
+.
.TP
.BI special\ text\ e
-This constructs a new object from
+This constructs a new object from\~\c
.I e
using a
-.BR @g@troff (@MAN1EXT@)
+.BR @g@troff (@MAN1EXT@)
macro named
.IR text .
When the macro is called,
the string
.B 0s
-will contain the output for
+will contain the output for\~\c
.IR e ,
and the number registers
.BR 0w ,
.BR 0h ,
.BR 0d ,
-.BR 0skern
+.BR 0skern ,
and
.BR 0skew
-will contain the width, height, depth, subscript kern, and skew of
+will contain the width, height, depth, subscript kern, and skew of\~\c
.IR e .
(The
.I "subscript kern"
@@ -459,82 +547,178 @@ point, and increase the current horizontal position by the width
of the object.
The number registers must also be modified so that they correspond to the
result.
-.RS
-.LP
+.
+.IP
For example, suppose you wanted a construct that `cancels' an expression
by drawing a diagonal line through it.
+.
+.RS
.IP
-.nf
.ft B
.if t .ne 6+\n(.Vu
+.br
\&.EQ
+.br
define cancel 'special Ca'
+.br
\&.EN
+.br
\&.de Ca
-\&.ds 0s \eZ'\e\e*(0s'\ev'\e\en(0du'\eD'l \e\en(0wu -\e\en(0hu-\e\en(0du'\ev'\e\en(0hu'
+.br
+\&.\ \ ds 0s \e
+.br
+\eZ'\e\e*(0s'\e
+.br
+\ev'\e\en(0du'\e
+.br
+\eD'l \e\en(0wu -\e\en(0hu-\e\en(0du'\e
+.br
+\ev'\e\en(0hu'
+.br
\&..
.ft
-.fi
-.LP
-Then you could cancel an expression
+.RE
+.
+.IP
+Then you could cancel an expression\~\c
.I e
with
-.BI cancel\ {\ e\ }
-.LP
+.BI \%cancel\ {\ e\ }
+.
+.IP
Here's a more complicated construct that draws a box round an expression:
+.
+.RS
.IP
-.nf
.ft B
.if t .ne 11+\n(.Vu
\&.EQ
+.br
define box 'special Bx'
+.br
\&.EN
+.br
\&.de Bx
-\&.ds 0s \eZ'\eh'1n'\e\e*(0s'\e
-\eZ'\ev'\e\en(0du+1n'\eD'l \e\en(0wu+2n 0'\eD'l 0 -\e\en(0hu-\e\en(0du-2n'\e
-\eD'l -\e\en(0wu-2n 0'\eD'l 0 \e\en(0hu+\e\en(0du+2n''\eh'\e\en(0wu+2n'
-\&.nr 0w +2n
-\&.nr 0d +1n
-\&.nr 0h +1n
+.br
+\&.\ \ ds 0s \e
+.br
+\eZ'\eh'1n'\e\e*(0s'\e
+.br
+\eZ'\e
+.br
+\ev'\e\en(0du+1n'\e
+.br
+\eD'l \e\en(0wu+2n 0'\e
+.br
+\eD'l 0 -\e\en(0hu-\e\en(0du-2n'\e
+.br
+\eD'l -\e\en(0wu-2n 0'\e
+.br
+\eD'l 0 \e\en(0hu+\e\en(0du+2n'\e
+.br
+\&'\e
+.br
+\eh'\e\en(0wu+2n'
+.br
+\&.\ \ nr 0w +2n
+.br
+\&.\ \ nr 0d +1n
+.br
+\&.\ \ nr 0h +1n
+.br
\&..
.ft
-.fi
.RE
+.
+.TP
+.BI space\ n
+A positive value of the integer\~\c
+.I n
+(in hundredths of an em) sets the vertical spacing before the equation,
+a negative value sets the spacing after the equation, replacing the
+default values.
+This primitive provides an interface to
+.BR groff 's
+.B \ex
+escape (but with opposite sign).
+.
+.IP
+This keyword has no effect if the equation is part of a
+.B pic
+picture.
+.
+.SS Extended primitives
+.TP
+.BI col\ n\ {\ .\|.\|.\ }
+.TQ
+.BI ccol\ n\ {\ .\|.\|.\ }
+.TQ
+.BI lcol\ n\ {\ .\|.\|.\ }
+.TQ
+.BI rcol\ n\ {\ .\|.\|.\ }
+.TQ
+.BI pile\ n\ {\ .\|.\|.\ }
+.TQ
+.BI cpile\ n\ {\ .\|.\|.\ }
+.TQ
+.BI lpile\ n\ {\ .\|.\|.\ }
+.TQ
+.BI rpile\ n\ {\ .\|.\|.\ }
+The integer value\~\c
+.I n
+(in hundredths of an em) increases the vertical spacing between rows,
+using
+.BR groff 's
+.B \ex
+escape.
+Negative values are possible but have no effect.
+If there is more than a single value given in a matrix, the biggest one
+is used.
+.
.SS Customization
-The appearance of equations is controlled by
-a large number of parameters. These can be set using
+The appearance of equations is controlled by a large number of parameters.
+These can be set using
the
.B set
command.
+.
.TP
.BI set\ p\ n
-This sets parameter
+This sets parameter\~\c
.I p
-to value
-.I n ;
-.I n
+to value\~\c
+.IR n ;
+.I n\~\c
is an integer.
For example,
+.
.RS
.IP
.B
set x_height 45
.RE
+.
.IP
says that
.B eqn
-should assume an x height of 0.45 ems.
+should assume an x\~height of 0.45\~ems.
+.
.RS
.LP
Possible parameters are as follows.
Values are in units of hundredths of an em unless otherwise stated.
These descriptions are intended to be expository rather than
definitive.
-.TP \w'\fBdefault_rule_thickness'u+2n
+.
+.ie t \
+. TP \w'\fBdefault_rule_thickness'u+2n
+.el \
+. TP
.B minimum_size
.B eqn
will not set anything at a smaller point-size than this.
The value is in points.
+.
.TP
.B fat_offset
The
@@ -542,12 +726,14 @@ The
primitive emboldens an equation
by overprinting two copies of the equation
horizontally offset by this amount.
+.
.TP
.B over_hang
A fraction bar will be longer by twice this amount than
the maximum of the widths of the numerator and denominator;
in other words, it will overhang the numerator and
denominator by at least this amount.
+.
.TP
.B accent_width
When
@@ -563,6 +749,7 @@ or
produces a line whose length is the width of the object to which it applies;
in the case of a single character,
this tends to produce a line that looks too long.
+.
.TP
.B delimiter_factor
Extensible delimiters produced with the
@@ -572,6 +759,7 @@ and
primitives will have a combined height and depth of at least this many
thousandths of twice the maximum amount by which the sub-equation that
the delimiters enclose extends away from the axis.
+.
.TP
.B delimiter_shortfall
Extensible delimiters produced with the
@@ -583,34 +771,42 @@ not less than the difference of
twice the maximum amount by which the sub-equation that
the delimiters enclose extends away from the axis
and this amount.
+.
.TP
.B null_delimiter_space
This much horizontal space is inserted
on each side of a fraction.
+.
.TP
.B script_space
The width of subscripts and superscripts is increased by this amount.
+.
.TP
.B thin_space
This amount of space is automatically inserted after punctuation
characters.
+.
.TP
.B medium_space
This amount of space is automatically inserted on either side
of binary operators.
+.
.TP
.B thick_space
This amount of space is automatically inserted on either side of
relations.
+.
.TP
.B x_height
-The height of lowercase letters without ascenders such as x.
+The height of lowercase letters without ascenders such as `x'.
+.
.TP
.B axis_height
The height above the baseline of the center of characters
-such as \(pl and \(mi.
+such as `\(pl' and `\(mi'.
It is important that this value is correct for the font
you are using.
+.
.TP
.B default_rule_thickness
This should set to the thickness of the
@@ -618,29 +814,35 @@ This should set to the thickness of the
character, or the thickness of horizontal lines produced with the
.B \eD
escape sequence.
+.
.TP
.B num1
The
.B over
command will shift up the numerator by at least this amount.
+.
.TP
.B num2
The
.B smallover
command will shift up the numerator by at least this amount.
+.
.TP
.B denom1
The
.B over
command will shift down the denominator by at least this amount.
+.
.TP
.B denom2
The
.B smallover
command will shift down the denominator by at least this amount.
+.
.TP
.B sup1
Normally superscripts will be shifted up by at least this amount.
+.
.TP
.B sup2
Superscripts within superscripts or upper limits
@@ -649,47 +851,58 @@ or numerators of
fractions
will be shifted up by at least this amount.
This is usually less than sup1.
+.
.TP
.B sup3
Superscripts within denominators or square roots
or subscripts or lower limits will be shifted up by at least
this amount.
This is usually less than sup2.
+.
.TP
.B sub1
Subscripts will normally be shifted down by at least this amount.
+.
.TP
.B sub2
When there is both a subscript and a superscript, the subscript
will be shifted down by at least this amount.
+.
.TP
.B sup_drop
The baseline of a superscript will be no more
than this much amount below the top of the object on
which the superscript is set.
+.
.TP
.B sub_drop
The baseline of a subscript will be at least this much below
the bottom of the object on which the subscript is set.
+.
.TP
.B big_op_spacing1
The baseline of an upper limit will be at least this
much above the top of the object on which the limit is set.
+.
.TP
.B big_op_spacing2
The baseline of a lower limit will be at least this
much below the bottom of the object on which the limit is set.
+.
.TP
.B big_op_spacing3
The bottom of an upper limit will be at least this much above the
top of the object on which the limit is set.
+.
.TP
.B big_op_spacing4
The top of a lower limit will be at least this much below
the bottom of the object on which the limit is set.
+.
.TP
.B big_op_spacing5
This much vertical space will be added above and below limits.
+.
.TP
.B baseline_sep
The baselines of the rows in a pile or matrix will normally be
@@ -698,18 +911,22 @@ In most cases this should be equal to the sum of
.B num1
and
.BR denom1 .
+.
.TP
.B shift_down
The midpoint between the top baseline and the bottom baseline
in a matrix or pile will be shifted down by this much from the axis.
In most cases this should be equal to
.BR axis_height .
+.
.TP
.B column_sep
This much space will be added between columns in a matrix.
+.
.TP
.B matrix_side_sep
This much space will be added at each side of a matrix.
+.
.TP
.B draw_lines
If this is non-zero, lines will be drawn using the
@@ -719,20 +936,23 @@ escape sequence, rather than with the
escape sequence and the
.B \e(ru
character.
+.
.TP
.B body_height
The amount by which the height of the equation exceeds this
will be added as extra space before the line containing the equation
(using
-.BR \ex .)
+.BR \ex ).
The default value is 85.
+.
.TP
.B body_depth
The amount by which the depth of the equation exceeds this
will be added as extra space after the line containing the equation
(using
-.BR \ex .)
+.BR \ex ).
The default value is 35.
+.
.TP
.B nroff
If this is non-zero,
@@ -750,8 +970,8 @@ will behave like
and
.B ndefine
will be ignored.
-The default value is 0
-(This is typically changed to 1 by the
+The default value is\~0
+(This is typically changed to\~1 by the
.B eqnrc
file for the
.BR ascii ,
@@ -760,23 +980,25 @@ file for the
and
.B cp1047
devices.)
+.
.LP
A more precise description of the role of many of these
-parameters can be found in Appendix H of
-.IR The\ \*(txbook .
+parameters can be found in Appendix\~H of
+.IR "The \*(txbook" .
.RE
+.
.SS Macros
Macros can take arguments.
In a macro body,
.BI $ n
where
.I n
-is between 1 and 9,
+is between 1 and\~9,
will be replaced by the
.IR n-th
argument if the macro is called with arguments;
if there are fewer than
-.I n
+.I n\~\c
arguments, it will be replaced by nothing.
A word containing a left parenthesis where the part of the word
before the left parenthesis has been defined using the
@@ -787,6 +1009,7 @@ characters following the left parenthesis
up to a matching right parenthesis will be treated as comma-separated
arguments;
commas inside nested parentheses do not terminate an argument.
+.
.TP
.BI sdefine\ name\ X\ anything\ X
This is like the
@@ -794,10 +1017,17 @@ This is like the
command, but
.I name
will not be recognized if called with arguments.
+.
.TP
.BI include\ \(ts file \(ts
+.TQ
+.BI copy\ \(ts file \(ts
Include the contents of
-.IR file .
+.I file
+.RB ( include
+and
+.B copy
+are synonyms).
Lines of
.I file
beginning with
@@ -805,6 +1035,7 @@ beginning with
or
.B .EN
will be ignored.
+.
.TP
.BI ifdef\ name\ X\ anything\ X
If
@@ -821,6 +1052,29 @@ otherwise ignore
.I X
can be any character not appearing in
.IR anything .
+.
+.TP
+.BI undef\ name
+Remove definition of
+.IR name ,
+making it undefined.
+.
+.LP
+Besides the macros mentioned above, the following definitions are available:
+.BR Alpha ,
+.BR Beta ,
+\&.\|.\|.,
+.B Omega
+(this is the same as
+.BR ALPHA ,
+.BR BETA ,
+\&.\|.\|.,
+.BR OMEGA ),
+.B ldots
+(three dots on the base line),
+and
+.BR dollar .
+.
.SS Fonts
.B eqn
normally uses at least two fonts to set an equation:
@@ -830,16 +1084,18 @@ The existing
.B gfont
command
changes the font that is used as the italic font.
-By default this is
+By default this is\~\c
.BR I .
The font that is used as the roman font can be changed
using the new
.B grfont
command.
+.
.TP
.BI grfont\ f
-Set the roman font to
+Set the roman font to\~\c
.IR f .
+.
.LP
The
.B italic
@@ -867,6 +1123,7 @@ just by using
and
.B gbfont
commands.
+.
.LP
You can control which characters are treated as letters
(and therefore set in italics) by using the
@@ -878,16 +1135,23 @@ will cause a character to be set in italic type.
A type of
.B digit
will cause a character to be set in roman type.
+.
+.
.SH FILES
.Tp \w'\fB@MACRODIR@/eqnrc'u+2n
.B @MACRODIR@/eqnrc
Initialization file.
+.
+.
.SH BUGS
Inline equations will be set at the point size that is current at the
beginning of the input line.
+.
+.
.SH "SEE ALSO"
.BR groff (@MAN1EXT@),
.BR @g@troff (@MAN1EXT@),
+.BR @g@pic (@MAN1EXT@),
.BR groff_font (@MAN5EXT@),
.I The\ \*(txbook
.
diff --git a/contrib/groff/src/preproc/eqn/eqn.y b/contrib/groff/src/preproc/eqn/eqn.y
index 833a0f01072a..85157d6fce4b 100644
--- a/contrib/groff/src/preproc/eqn/eqn.y
+++ b/contrib/groff/src/preproc/eqn/eqn.y
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2004 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -15,7 +15,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
%{
#include <stdio.h>
#include <string.h>
@@ -24,7 +24,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "lib.h"
#include "box.h"
extern int non_empty_flag;
-char *strsave(const char *);
int yylex();
void yyerror(const char *);
%}
diff --git a/contrib/groff/src/preproc/eqn/lex.cpp b/contrib/groff/src/preproc/eqn/lex.cpp
index abc07c9cfd5f..6aa494dbf0d8 100644
--- a/contrib/groff/src/preproc/eqn/lex.cpp
+++ b/contrib/groff/src/preproc/eqn/lex.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2005
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -17,13 +17,19 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "eqn_tab.h"
#include "stringclass.h"
#include "ptable.h"
+
+// declarations to avoid friend name injection problems
+int get_char();
+int peek_char();
+int get_location(char **, int *);
+
struct definition {
char is_macro;
char is_simple;
diff --git a/contrib/groff/src/preproc/eqn/limit.cpp b/contrib/groff/src/preproc/eqn/limit.cpp
index c8b55877d9ec..b9f35f97efc5 100644
--- a/contrib/groff/src/preproc/eqn/limit.cpp
+++ b/contrib/groff/src/preproc/eqn/limit.cpp
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "pbox.h"
diff --git a/contrib/groff/src/preproc/eqn/list.cpp b/contrib/groff/src/preproc/eqn/list.cpp
index 1118fa1b1660..003562afa501 100644
--- a/contrib/groff/src/preproc/eqn/list.cpp
+++ b/contrib/groff/src/preproc/eqn/list.cpp
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "pbox.h"
diff --git a/contrib/groff/src/preproc/eqn/main.cpp b/contrib/groff/src/preproc/eqn/main.cpp
index dabac5fd290c..7971e2c2dc3c 100644
--- a/contrib/groff/src/preproc/eqn/main.cpp
+++ b/contrib/groff/src/preproc/eqn/main.cpp
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "stringclass.h"
diff --git a/contrib/groff/src/preproc/eqn/mark.cpp b/contrib/groff/src/preproc/eqn/mark.cpp
index 99d1b75f2f78..9fa65790c6f1 100644
--- a/contrib/groff/src/preproc/eqn/mark.cpp
+++ b/contrib/groff/src/preproc/eqn/mark.cpp
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "pbox.h"
diff --git a/contrib/groff/src/preproc/eqn/other.cpp b/contrib/groff/src/preproc/eqn/other.cpp
index c052f5239720..9f360df67912 100644
--- a/contrib/groff/src/preproc/eqn/other.cpp
+++ b/contrib/groff/src/preproc/eqn/other.cpp
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "pbox.h"
diff --git a/contrib/groff/src/preproc/eqn/over.cpp b/contrib/groff/src/preproc/eqn/over.cpp
index 279efc8b4306..302c5b5d50c0 100644
--- a/contrib/groff/src/preproc/eqn/over.cpp
+++ b/contrib/groff/src/preproc/eqn/over.cpp
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "pbox.h"
diff --git a/contrib/groff/src/preproc/eqn/pbox.h b/contrib/groff/src/preproc/eqn/pbox.h
index d1f16ac486ae..f100f2165662 100644
--- a/contrib/groff/src/preproc/eqn/pbox.h
+++ b/contrib/groff/src/preproc/eqn/pbox.h
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
extern int fat_offset;
diff --git a/contrib/groff/src/preproc/eqn/pile.cpp b/contrib/groff/src/preproc/eqn/pile.cpp
index 0df5241f0fee..10d1708809af 100644
--- a/contrib/groff/src/preproc/eqn/pile.cpp
+++ b/contrib/groff/src/preproc/eqn/pile.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2004 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
// piles and matrices
#include "eqn.h"
@@ -114,13 +114,13 @@ void pile_box::debug_print()
int matrix_box::compute_metrics(int style)
{
int i, j;
- int maxlen = 0;
+ int max_len = 0;
int space = 0;
for (i = 0; i < len; i++) {
for (j = 0; j < p[i]->len; j++)
p[i]->p[j]->compute_metrics(style);
- if (p[i]->len > maxlen)
- maxlen = p[i]->len;
+ if (p[i]->len > max_len)
+ max_len = p[i]->len;
if (p[i]->space > space)
space = p[i]->space;
}
@@ -145,7 +145,7 @@ int matrix_box::compute_metrics(int style)
printf("/\\n(.V+(\\n(.V/2)*\\n(.V\n");
printf(".nr " SUP_RAISE_FORMAT " \\n[" BASELINE_SEP_FORMAT "]*%d/2"
"+%dM\n",
- uid, uid, maxlen-1, axis_height - shift_down);
+ uid, uid, max_len-1, axis_height - shift_down);
printf(".nr " HEIGHT_FORMAT " 0\\n[" SUP_RAISE_FORMAT "]+(0",
uid, uid);
for (i = 0; i < len; i++)
@@ -153,10 +153,10 @@ int matrix_box::compute_metrics(int style)
printf(")>?0\n");
printf(".nr " DEPTH_FORMAT " \\n[" BASELINE_SEP_FORMAT "]*%d-\\n["
SUP_RAISE_FORMAT "]+(0",
- uid, uid, maxlen-1, uid);
+ uid, uid, max_len-1, uid);
for (i = 0; i < len; i++)
- if (p[i]->len == maxlen)
- printf(">?\\n[" DEPTH_FORMAT "]", p[i]->p[maxlen-1]->uid);
+ if (p[i]->len == max_len)
+ printf(">?\\n[" DEPTH_FORMAT "]", p[i]->p[max_len-1]->uid);
printf(")>?0\n");
return FOUND_NOTHING;
}
diff --git a/contrib/groff/src/preproc/eqn/script.cpp b/contrib/groff/src/preproc/eqn/script.cpp
index 62a05b4f195b..a9de7428718b 100644
--- a/contrib/groff/src/preproc/eqn/script.cpp
+++ b/contrib/groff/src/preproc/eqn/script.cpp
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "pbox.h"
@@ -103,20 +104,20 @@ int script_box::compute_metrics(int style)
else {
// sup != 0
// 18c
- int p;
+ int pos;
if (style == DISPLAY_STYLE)
- p = sup1;
+ pos = sup1;
else if (style & 1) // not cramped
- p = sup2;
+ pos = sup2;
else
- p = sup3;
+ pos = sup3;
printf(".nr " SUP_RAISE_FORMAT " \\n[" SUP_RAISE_FORMAT
"]>?%dM>?(\\n[" DEPTH_FORMAT "]+(%dM/4))\n",
- uid, uid, p, sup->uid, x_height);
+ uid, uid, pos, sup->uid, x_height);
// 18d
if (sub != 0) {
printf(".nr " SUB_LOWER_FORMAT " \\n[" SUB_LOWER_FORMAT "]>?%dM\n",
- uid, uid, sub2);
+ uid, uid, sub2);
// 18e
printf(".nr " TEMP_REG " \\n[" DEPTH_FORMAT "]-\\n["
SUP_RAISE_FORMAT "]+\\n[" HEIGHT_FORMAT "]-\\n["
diff --git a/contrib/groff/src/preproc/eqn/special.cpp b/contrib/groff/src/preproc/eqn/special.cpp
index 310261ae4c59..172686a505b5 100644
--- a/contrib/groff/src/preproc/eqn/special.cpp
+++ b/contrib/groff/src/preproc/eqn/special.cpp
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "pbox.h"
diff --git a/contrib/groff/src/preproc/eqn/sqrt.cpp b/contrib/groff/src/preproc/eqn/sqrt.cpp
index f998ff332063..8f3373ff9cad 100644
--- a/contrib/groff/src/preproc/eqn/sqrt.cpp
+++ b/contrib/groff/src/preproc/eqn/sqrt.cpp
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "pbox.h"
diff --git a/contrib/groff/src/preproc/eqn/text.cpp b/contrib/groff/src/preproc/eqn/text.cpp
index 83e4a764c952..e39221276b58 100644
--- a/contrib/groff/src/preproc/eqn/text.cpp
+++ b/contrib/groff/src/preproc/eqn/text.cpp
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "eqn.h"
#include "pbox.h"
diff --git a/contrib/groff/src/preproc/grn/gprint.h b/contrib/groff/src/preproc/grn/gprint.h
index b9df60eeebc6..ad3be443015d 100644
--- a/contrib/groff/src/preproc/grn/gprint.h
+++ b/contrib/groff/src/preproc/grn/gprint.h
@@ -66,7 +66,7 @@
#define MOD 3
typedef struct point {
- float x, y;
+ double x, y;
struct point *nextpt;
} POINT;
diff --git a/contrib/groff/src/preproc/grn/grn.man b/contrib/groff/src/preproc/grn/grn.man
index 9722145bd8b8..575b4ee70c77 100644
--- a/contrib/groff/src/preproc/grn/grn.man
+++ b/contrib/groff/src/preproc/grn/grn.man
@@ -1,6 +1,6 @@
'\" t
.ig
-Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -17,17 +17,24 @@ versions, except that this permission notice may be included in
translations approved by the Free Software Foundation instead of in
the original English.
..
+.
+.do nr grn_C \n[.C]
+.cp 0
+.
.de TQ
-.br
-.ns
-.TP \\$1
+. br
+. ns
+. TP \\$1
..
+.
.\" Like TP, but if specified indent is more than half
.\" the current line-length - indent, use the default indent.
.de Tp
-.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
-.el .TP "\\$1"
+. ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
+. el .TP "\\$1"
..
+.
+.
.TH @G@GRN @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
.SH NAME
@g@grn \- groff preprocessor for gremlin files
@@ -142,7 +149,7 @@ Recognize
.B .GS
and
.B .GE
-(resp.
+(and
.BR .GF )
even when followed by a character other than space or newline.
.\".TP
@@ -188,7 +195,7 @@ Set
text size number 1 (2, 3, or 4) to
.I N
points.
-The default is 12 (resp. 16, 24, and 36).
+The default is 12 (16, 24, and 36, respectively).
.TP
.BI roman\ f
.TQ
@@ -202,7 +209,7 @@ Set the roman (italics, bold, or special) font to
font
.I f
(either a name or number).
-The default is R (resp. I, B, and S).
+The default is R (I, B, and S, respectively).
.TP
.BI l\ f
.TQ
@@ -242,11 +249,11 @@ may be abbreviated down to `sc'.
.BI thick\ N
Set the thickness of
.IR gremlin 's
-narrow (resp. medium and thick) lines to
+narrow (medium and thick, respectively) lines to
.I N
times 0.15pt (this value can be changed at compile time).
-The default is 1.0 (resp. 3.0 and 5.0), which corresponds to 0.15pt
-(resp. 0.45pt and 0.75pt).
+The default is 1.0 (3.0 and 5.0, respectively), which corresponds to 0.15pt
+(0.45pt and 0.75pt, respectively).
A thickness value of zero selects the smallest available line thickness.
Negative values cause the line thickness to be proportional to the current
point size.
@@ -255,7 +262,10 @@ point size.
Scale text to match the picture.
Gremlin text is usually printed in the point size specified with the
commands
-.BR 1 ,\ 2 ,\ 3 ,\ or\ 4
+.BR 1 ,
+.BR 2 ,
+.BR 3 ,
+.RB or\~ 4 ,
regardless of any scaling factors in the picture.
Setting
.B pointscale
@@ -635,6 +645,8 @@ David Slattengren and Barry Roitblat wrote the original Berkeley
Daniel Senderowicz and Werner Lemberg modified it for
.IR groff .
.
+.cp \n[grn_C]
+.
.\" Local Variables:
.\" mode: nroff
.\" End:
diff --git a/contrib/groff/src/preproc/grn/hdb.cpp b/contrib/groff/src/preproc/grn/hdb.cpp
index c9fbb7dc1a36..5f54040dd5c5 100644
--- a/contrib/groff/src/preproc/grn/hdb.cpp
+++ b/contrib/groff/src/preproc/grn/hdb.cpp
@@ -1,4 +1,4 @@
-/* Last non-groff version: hdb.c 1.8 (Berkeley) 84/10/20
+ /* Last non-groff version: hdb.c 1.8 (Berkeley) 84/10/20
*
* Copyright -C- 1982 Barry S. Roitblat
*
@@ -22,12 +22,13 @@
extern int linenum; /* current line number in input file */
extern char gremlinfile[]; /* name of file currently reading */
extern int SUNFILE; /* TRUE if SUN gremlin file */
-extern void savebounds(float x, float y);
+extern int compatibility_flag; /* TRUE if in compatibility mode */
+extern void savebounds(double x, double y);
/* imports from hpoint.cpp */
extern POINT *PTInit();
-extern POINT *PTMakePoint(float x, float y, POINT ** pplist);
+extern POINT *PTMakePoint(double x, double y, POINT ** pplist);
int DBGetType(register char *s);
@@ -79,12 +80,12 @@ DBRead(register FILE *file)
{
register int i;
register int done; /* flag for input exhausted */
- register float nx; /* x holder so x is not set before orienting */
+ register double nx; /* x holder so x is not set before orienting */
int type; /* element type */
ELT *elist; /* pointer to the file's elements */
POINT *plist; /* pointer for reading in points */
char string[MAXSTRING], *txt;
- float x, y; /* x and y are read in point coords */
+ double x, y; /* x and y are read in point coords */
int len, brush, size;
int lastpoint;
@@ -99,7 +100,7 @@ DBRead(register FILE *file)
SUNFILE = TRUE;
}
- (void) fscanf(file, "%d%f%f\n", &size, &x, &y);
+ (void) fscanf(file, "%d%lf%lf\n", &size, &x, &y);
/* ignore orientation and file positioning point */
done = FALSE;
@@ -115,12 +116,11 @@ DBRead(register FILE *file)
type = DBGetType(string); /* interpret element type */
if (type < 0) { /* no more data */
done = TRUE;
- (void) fclose(file);
} else {
#ifdef UW_FASTSCAN
(void) xscanf(file, &x, &y); /* always one point */
#else
- (void) fscanf(file, "%f%f\n", &x, &y); /* always one point */
+ (void) fscanf(file, "%lf%lf\n", &x, &y); /* always one point */
#endif /* UW_FASTSCAN */
plist = PTInit(); /* NULL point list */
@@ -144,9 +144,13 @@ DBRead(register FILE *file)
if (string[0] == '*') { /* SUN gremlin file */
lastpoint = TRUE;
} else {
- (void) sscanf(string, "%f%f", &x, &y);
+ (void) sscanf(string, "%lf%lf", &x, &y);
if ((x == -1.00 && y == -1.00) && (!SUNFILE))
lastpoint = TRUE;
+ else {
+ if (compatibility_flag)
+ savebounds(xorn(x, y), yorn(x, y));
+ }
}
} while (!lastpoint);
#endif /* UW_FASTSCAN */
@@ -170,7 +174,7 @@ DBRead(register FILE *file)
if (string[0] == '*') { /* SUN gremlin file */
lastpoint = TRUE;
} else {
- (void) sscanf(string, "%f%f", &x, &y);
+ (void) sscanf(string, "%lf%lf", &x, &y);
if ((x == -1.00 && y == -1.00) && (!SUNFILE))
lastpoint = TRUE;
}
@@ -182,7 +186,10 @@ DBRead(register FILE *file)
(void) getc(file); /* eat blank */
txt = (char *) malloc((unsigned) len + 1);
for (i = 0; i < len; ++i) { /* read text */
- txt[i] = getc(file);
+ int c = getc(file);
+ if (c == EOF)
+ break;
+ txt[i] = c;
}
txt[len] = '\0';
(void) DBCreateElt(type, plist, brush, size, txt, &elist);
@@ -281,8 +288,8 @@ DBGetType(register char *s)
*/
int
xscanf(FILE *f,
- float *xp,
- float *yp)
+ double *xp,
+ double *yp)
{
register int c, i, j, m, frac;
int iscale = 1, jscale = 1; /* x = i/scale, y=j/jscale */
diff --git a/contrib/groff/src/preproc/grn/hgraph.cpp b/contrib/groff/src/preproc/grn/hgraph.cpp
index d124c6c0b266..01208951f28f 100644
--- a/contrib/groff/src/preproc/grn/hgraph.cpp
+++ b/contrib/groff/src/preproc/grn/hgraph.cpp
@@ -8,19 +8,13 @@
#include "gprint.h"
-#ifdef NEED_DECLARATION_HYPOT
-extern "C" {
- double hypot(double, double);
-}
-#endif /* NEED_DECLARATION_HYPOT */
-
#define MAXVECT 40
#define MAXPOINTS 200
#define LINELENGTH 1
#define PointsPerInterval 64
#define pi 3.14159265358979324
#define twopi (2.0 * pi)
-#define len(a, b) hypot((double)(b.x-a.x), (double)(b.y-a.y))
+#define len(a, b) groff_hypot((double)(b.x-a.x), (double)(b.y-a.y))
extern int dotshifter; /* for the length of dotted curves */
@@ -43,7 +37,7 @@ extern int ytop;
extern int ybottom;
extern int xleft;
extern int xright;
-extern enum {
+extern enum E {
OUTLINE, FILL, BOTH
} polyfill;
@@ -62,17 +56,17 @@ void tmove(POINT * ptr);
void cr();
void drawwig(POINT * ptr, int type);
void HGtline(int x1, int y1);
-void dx(double x);
-void dy(double y);
+void deltax(double x);
+void deltay(double y);
void HGArc(register int cx, register int cy, int px, int py, int angle);
void picurve(register int *x, register int *y, int npts);
void HGCurve(int *x, int *y, int numpoints);
-void Paramaterize(int x[], int y[], float h[], int n);
-void PeriodicSpline(float h[], int z[],
- float dz[], float d2z[], float d3z[],
+void Paramaterize(int x[], int y[], double h[], int n);
+void PeriodicSpline(double h[], int z[],
+ double dz[], double d2z[], double d3z[],
int npoints);
-void NaturalEndSpline(float h[], int z[],
- float dz[], float d2z[], float d3z[],
+void NaturalEndSpline(double h[], int z[],
+ double dz[], double d2z[], double d3z[],
int npoints);
@@ -166,8 +160,8 @@ HGPrintElt(ELT *element,
* stipple fonts).
* If polyfill=BOTH, just use the \D'p ...' command.
*/
- float firstx = p1->x;
- float firsty = p1->y;
+ double firstx = p1->x;
+ double firsty = p1->y;
length = 0; /* keep track of line length so */
/* single lines don't get long */
@@ -223,8 +217,8 @@ HGPrintElt(ELT *element,
while (!Nullpoint((PTNextPoint(p1)))) {
p1 = PTNextPoint(p1);
- dx((double) p1->x);
- dy((double) p1->y);
+ deltax((double) p1->x);
+ deltay((double) p1->y);
if (length++ > LINELENGTH) {
length = 0;
printf("\\\n");
@@ -233,8 +227,8 @@ HGPrintElt(ELT *element,
/* close polygon if not done so by user */
if ((firstx != p1->x) || (firsty != p1->y)) {
- dx((double) firstx);
- dy((double) firsty);
+ deltax((double) firstx);
+ deltay((double) firsty);
}
putchar('\'');
cr();
@@ -412,7 +406,7 @@ HGSetBrush(int mode)
/*----------------------------------------------------------------------------*
- | Routine: dx (x_destination)
+ | Routine: deltax (x_destination)
|
| Results: Scales and outputs a number for delta x (with a leading
| space) given `lastx' and x_destination.
@@ -421,7 +415,7 @@ HGSetBrush(int mode)
*----------------------------------------------------------------------------*/
void
-dx(double x)
+deltax(double x)
{
register int ix = (int) (x * troffscale);
@@ -431,7 +425,7 @@ dx(double x)
/*----------------------------------------------------------------------------*
- | Routine: dy (y_destination)
+ | Routine: deltay (y_destination)
|
| Results: Scales and outputs a number for delta y (with a leading
| space) given `lastyline' and y_destination.
@@ -441,7 +435,7 @@ dx(double x)
*----------------------------------------------------------------------------*/
void
-dy(double y)
+deltay(double y)
{
register int iy = (int) (y * troffscale);
@@ -600,7 +594,7 @@ HGArc(register int cx,
length = 0;
- resolution = (1.0 + hypot(xs, ys) / res) * PointsPerInterval;
+ resolution = (1.0 + groff_hypot(xs, ys) / res) * PointsPerInterval;
/* mask = (1 << (int) log10(resolution + 1.0)) - 1; */
(void) frexp(resolution, &m); /* A bit more elegant than log10 */
for (mask = 1; mask < m; mask = mask << 1);
@@ -671,13 +665,13 @@ picurve(register int *x,
for (; npts--; x++, y++) { /* traverse the line segments */
xp = x[0] - x[1];
yp = y[0] - y[1];
- nseg = (int) hypot((double) xp, (double) yp);
+ nseg = (int) groff_hypot((double) xp, (double) yp);
xp = x[1] - x[2];
yp = y[1] - y[2];
/* `nseg' is the number of line */
/* segments that will be drawn for */
/* each curve segment. */
- nseg = (int) ((double) (nseg + (int) hypot((double) xp, (double) yp)) /
+ nseg = (int) ((double) (nseg + (int) groff_hypot((double) xp, (double) yp)) /
res * PointsPerInterval);
for (i = 1; i < nseg; i++) {
@@ -713,9 +707,9 @@ HGCurve(int *x,
int *y,
int numpoints)
{
- float h[MAXPOINTS], dx[MAXPOINTS], dy[MAXPOINTS];
- float d2x[MAXPOINTS], d2y[MAXPOINTS], d3x[MAXPOINTS], d3y[MAXPOINTS];
- float t, t2, t3;
+ double h[MAXPOINTS], dx[MAXPOINTS], dy[MAXPOINTS];
+ double d2x[MAXPOINTS], d2y[MAXPOINTS], d3x[MAXPOINTS], d3y[MAXPOINTS];
+ double t, t2, t3;
register int j;
register int k;
register int nx;
@@ -751,7 +745,7 @@ HGCurve(int *x,
if ((x[j] == x[j + 1]) && (y[j] == y[j + 1]))
continue;
for (k = 0; k <= PointsPerInterval; ++k) {
- t = (float) k *h[j] / (float) PointsPerInterval;
+ t = (double) k *h[j] / (double) PointsPerInterval;
t2 = t * t;
t3 = t * t * t;
nx = x[j] + (int) (t * dx[j] + t2 * d2x[j] / 2 + t3 * d3x[j] / 6);
@@ -779,14 +773,14 @@ HGCurve(int *x,
void
Paramaterize(int x[],
int y[],
- float h[],
+ double h[],
int n)
{
register int dx;
register int dy;
register int i;
register int j;
- float u[MAXPOINTS];
+ double u[MAXPOINTS];
for (i = 1; i <= n; ++i) {
u[i] = 0;
@@ -795,7 +789,7 @@ Paramaterize(int x[],
dy = y[j + 1] - y[j];
/* Here was overflowing, so I changed it. */
/* u[i] += sqrt ((double) (dx * dx + dy * dy)); */
- u[i] += hypot((double) dx, (double) dy);
+ u[i] += groff_hypot((double) dx, (double) dy);
}
}
for (i = 1; i < n; ++i)
@@ -814,16 +808,16 @@ Paramaterize(int x[],
*----------------------------------------------------------------------------*/
void
-PeriodicSpline(float h[], /* paramaterization */
+PeriodicSpline(double h[], /* paramaterization */
int z[], /* point list */
- float dz[], /* to return the 1st derivative */
- float d2z[], /* 2nd derivative */
- float d3z[], /* 3rd derivative */
+ double dz[], /* to return the 1st derivative */
+ double d2z[], /* 2nd derivative */
+ double d3z[], /* 3rd derivative */
int npoints) /* number of valid points */
{
- float d[MAXPOINTS];
- float deltaz[MAXPOINTS], a[MAXPOINTS], b[MAXPOINTS];
- float c[MAXPOINTS], r[MAXPOINTS], s[MAXPOINTS];
+ double d[MAXPOINTS];
+ double deltaz[MAXPOINTS], a[MAXPOINTS], b[MAXPOINTS];
+ double c[MAXPOINTS], r[MAXPOINTS], s[MAXPOINTS];
int i;
/* step 1 */
@@ -886,15 +880,15 @@ PeriodicSpline(float h[], /* paramaterization */
*----------------------------------------------------------------------------*/
void
-NaturalEndSpline(float h[], /* parameterization */
+NaturalEndSpline(double h[], /* parameterization */
int z[], /* Point list */
- float dz[], /* to return the 1st derivative */
- float d2z[], /* 2nd derivative */
- float d3z[], /* 3rd derivative */
+ double dz[], /* to return the 1st derivative */
+ double d2z[], /* 2nd derivative */
+ double d3z[], /* 3rd derivative */
int npoints) /* number of valid points */
{
- float d[MAXPOINTS];
- float deltaz[MAXPOINTS], a[MAXPOINTS], b[MAXPOINTS];
+ double d[MAXPOINTS];
+ double deltaz[MAXPOINTS], a[MAXPOINTS], b[MAXPOINTS];
int i;
/* step 1 */
@@ -970,11 +964,11 @@ change(register int x,
*----------------------------------------------------------------------------*/
void
-HGtline(int x1,
- int y1)
+HGtline(int x_1,
+ int y_1)
{
- register int x0 = lastx;
- register int y0 = lasty;
+ register int x_0 = lastx;
+ register int y_0 = lasty;
register int dx;
register int dy;
register int oldcoord;
@@ -986,7 +980,7 @@ HGtline(int x1,
register int dotcounter;
if (linmod == SOLID) {
- line(x1, y1);
+ line(x_1, y_1);
return;
}
@@ -995,11 +989,11 @@ HGtline(int x1,
xinc = 1;
yinc = 1;
- if ((dx = x1 - x0) < 0) {
+ if ((dx = x_1 - x_0) < 0) {
xinc = -xinc;
dx = -dx;
}
- if ((dy = y1 - y0) < 0) {
+ if ((dy = y_1 - y_0) < 0) {
yinc = -yinc;
dy = -dy;
}
@@ -1007,48 +1001,48 @@ HGtline(int x1,
res2 = 0;
visible = 0;
if (dx >= dy) {
- oldcoord = y0;
- while (x0 != x1) {
- if ((x0 & dotcounter) && !visible) {
- change(x0, y0, 0);
+ oldcoord = y_0;
+ while (x_0 != x_1) {
+ if ((x_0 & dotcounter) && !visible) {
+ change(x_0, y_0, 0);
visible = 1;
- } else if (visible && !(x0 & dotcounter)) {
- change(x0 - xinc, oldcoord, 1);
+ } else if (visible && !(x_0 & dotcounter)) {
+ change(x_0 - xinc, oldcoord, 1);
visible = 0;
}
if (res1 > res2) {
- oldcoord = y0;
+ oldcoord = y_0;
res2 += dx - res1;
res1 = 0;
- y0 += yinc;
+ y_0 += yinc;
}
res1 += dy;
- x0 += xinc;
+ x_0 += xinc;
}
} else {
- oldcoord = x0;
- while (y0 != y1) {
- if ((y0 & dotcounter) && !visible) {
- change(x0, y0, 0);
+ oldcoord = x_0;
+ while (y_0 != y_1) {
+ if ((y_0 & dotcounter) && !visible) {
+ change(x_0, y_0, 0);
visible = 1;
- } else if (visible && !(y0 & dotcounter)) {
- change(oldcoord, y0 - yinc, 1);
+ } else if (visible && !(y_0 & dotcounter)) {
+ change(oldcoord, y_0 - yinc, 1);
visible = 0;
}
if (res1 > res2) {
- oldcoord = x0;
+ oldcoord = x_0;
res2 += dy - res1;
res1 = 0;
- x0 += xinc;
+ x_0 += xinc;
}
res1 += dx;
- y0 += yinc;
+ y_0 += yinc;
}
}
if (visible)
- change(x1, y1, 1);
+ change(x_1, y_1, 1);
else
- change(x1, y1, 0);
+ change(x_1, y_1, 0);
}
/* EOF */
diff --git a/contrib/groff/src/preproc/grn/hpoint.cpp b/contrib/groff/src/preproc/grn/hpoint.cpp
index f4e1ca827755..fa24dca7fd47 100644
--- a/contrib/groff/src/preproc/grn/hpoint.cpp
+++ b/contrib/groff/src/preproc/grn/hpoint.cpp
@@ -24,26 +24,26 @@ PTInit()
* into the pointlist.
*/
POINT *
-PTMakePoint(float x,
- float y,
+PTMakePoint(double x,
+ double y,
POINT **pplist)
{
- register POINT *point;
+ register POINT *pt;
- if (Nullpoint(point = *pplist)) { /* empty list */
+ if (Nullpoint(pt = *pplist)) { /* empty list */
*pplist = (POINT *) malloc(sizeof(POINT));
- point = *pplist;
+ pt = *pplist;
} else {
- while (!Nullpoint(point->nextpt))
- point = point->nextpt;
- point->nextpt = (POINT *) malloc(sizeof(POINT));
- point = point->nextpt;
+ while (!Nullpoint(pt->nextpt))
+ pt = pt->nextpt;
+ pt->nextpt = (POINT *) malloc(sizeof(POINT));
+ pt = pt->nextpt;
}
- point->x = x;
- point->y = y;
- point->nextpt = PTInit();
- return (point);
+ pt->x = x;
+ pt->y = y;
+ pt->nextpt = PTInit();
+ return (pt);
} /* end PTMakePoint */
/* EOF */
diff --git a/contrib/groff/src/preproc/grn/main.cpp b/contrib/groff/src/preproc/grn/main.cpp
index 150b78f5772e..c939647f2c9b 100644
--- a/contrib/groff/src/preproc/grn/main.cpp
+++ b/contrib/groff/src/preproc/grn/main.cpp
@@ -90,7 +90,7 @@ extern void HGPrintElt(ELT *element, int baseline);
extern ELT *DBInit();
extern ELT *DBRead(register FILE *file);
extern POINT *PTInit();
-extern POINT *PTMakePoint(float x, float y, POINT **pplist);
+extern POINT *PTMakePoint(double x, double y, POINT **pplist);
#define SUN_SCALEFACTOR 0.70
@@ -125,7 +125,7 @@ int lastyline; /* A line's vertical position is NOT the */
/* `default' command and are reset each time the */
/* start of a picture (.GS) is found. */
-char *deffont[] =
+const char *deffont[] =
{"R", "I", "B", "S"};
int defsize[] =
{10, 16, 24, 36};
@@ -160,7 +160,7 @@ int style[STYLES] =
double scale = 1.0; /* no scaling, default */
int defpoint = 0; /* flag for pointsize scaling */
char *defstipple = (char *) 0;
-enum {
+enum E {
OUTLINE, FILL, BOTH
} polyfill;
@@ -214,7 +214,7 @@ int compatibility_flag = FALSE; /* TRUE if in compatibility mode */
void getres();
-char *doinput(FILE *fp);
+int doinput(FILE *fp);
void conv(register FILE *fp, int baseline);
void savestate();
int has_polygon(register ELT *elist);
@@ -317,7 +317,7 @@ main(int argc,
} else
fp = stdin;
- while (doinput(fp) != NULL) {
+ while (doinput(fp)) {
if (*c1 == '.' && *c2 == 'G' && *c3 == 'S') {
if (compatibility_flag ||
*c4 == '\n' || *c4 == ' ' || *c4 == '\0')
@@ -328,6 +328,8 @@ main(int argc,
fputs(inputline, stdout);
}
}
+
+ return 0;
}
@@ -389,7 +391,7 @@ getres()
/*----------------------------------------------------------------------------*
- | Routine: char * doinput (file_pointer)
+ | Routine: int doinput (file_pointer)
|
| Results: A line of input is read into `inputline'.
|
@@ -399,16 +401,14 @@ getres()
| updating `linenum'.
*----------------------------------------------------------------------------*/
-char *
+int
doinput(FILE *fp)
{
- char *k;
-
- if ((k = fgets(inputline, MAXINLINE, fp)) == NULL)
- return k;
+ if (fgets(inputline, MAXINLINE, fp) == NULL)
+ return 0;
if (strchr(inputline, '\n')) /* ++ only if it's a complete line */
linenum++;
- return (char *) !NULL;
+ return 1;
}
@@ -430,7 +430,7 @@ initpic()
thick[i] = defthick[i];
}
for (i = 0; i < FONTS; i++) { /* font name defaults */
- tfont[i] = deffont[i];
+ tfont[i] = (char *)deffont[i];
}
for (i = 0; i < SIZES; i++) { /* font size defaults */
tsize[i] = defsize[i];
@@ -488,7 +488,7 @@ conv(register FILE *fp,
strcpy(GScommand, inputline); /* save `.GS' line for later */
do {
- done = (doinput(fp) == NULL); /* test for EOF */
+ done = !doinput(fp); /* test for EOF */
flyback = (*c3 == 'F'); /* and .GE or .GF */
compat = (compatibility_flag ||
*c4 == '\n' || *c4 == ' ' || *c4 == '\0');
@@ -518,7 +518,7 @@ conv(register FILE *fp,
if (stipple == (char *) NULL) /* if user forgot stipple */
if (has_polygon(PICTURE)) /* and picture has a polygon */
- stipple = DEFSTIPPLE; /* then set the default */
+ stipple = (char *)DEFSTIPPLE; /* then set the default */
if ((temp = bottompoint - toppoint) < 0.1)
temp = 0.1;
@@ -686,8 +686,8 @@ savestate()
*----------------------------------------------------------------------------*/
void
-savebounds(float x,
- float y)
+savebounds(double x,
+ double y)
{
if (x < leftpoint)
leftpoint = x;
@@ -781,17 +781,17 @@ interpret(char *line)
case 'l': /* l */
if (isdigit(str1[1])) { /* set stipple index */
- int index = atoi(str1 + 1), val;
+ int idx = atoi(str1 + 1), val;
- if (index < 0 || index > NSTIPPLES) {
- error("bad stipple number %1 at line %2", index, linenum);
+ if (idx < 0 || idx > NSTIPPLES) {
+ error("bad stipple number %1 at line %2", idx, linenum);
break;
}
if (!defstipple_index)
defstipple_index = other_stipple_index;
val = atoi(str2);
if (val >= 0 && val < 256)
- stipple_index[index] = val;
+ stipple_index[idx] = val;
else
error("bad stipple index value at line %1", linenum);
break;
diff --git a/contrib/groff/src/preproc/html/Makefile.sub b/contrib/groff/src/preproc/html/Makefile.sub
index 6a9a75707e7e..0763537a94e6 100644
--- a/contrib/groff/src/preproc/html/Makefile.sub
+++ b/contrib/groff/src/preproc/html/Makefile.sub
@@ -2,5 +2,6 @@ PROG=pre-grohtml$(EXEEXT)
# MAN1=pre-grohtml.n
MAN1=
XLIBS=$(LIBGROFF)
+MLIB=$(LIBM)
OBJS=pre-html.$(OBJEXT) pushback.$(OBJEXT)
CCSRCS=$(srcdir)/pre-html.cpp $(srcdir)/pushback.cpp
diff --git a/contrib/groff/src/preproc/html/pre-html.cpp b/contrib/groff/src/preproc/html/pre-html.cpp
index 8869136a6ce7..6f8a46aee0fc 100644
--- a/contrib/groff/src/preproc/html/pre-html.cpp
+++ b/contrib/groff/src/preproc/html/pre-html.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Written by Gaius Mulley (gaius@glam.ac.uk).
This file is part of groff.
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#define PREHTMLC
@@ -34,39 +34,124 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "searchpath.h"
#include "paper.h"
+#include "device.h"
#include "font.h"
#include <errno.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
-#include <unistd.h>
+# include <unistd.h>
#endif
#ifdef _POSIX_VERSION
-#include <sys/wait.h>
-#define PID_T pid_t
+# include <sys/wait.h>
+# define PID_T pid_t
#else /* not _POSIX_VERSION */
-#define PID_T int
+# define PID_T int
#endif /* not _POSIX_VERSION */
#include <stdarg.h>
#include "nonposix.h"
+/* Establish some definitions to facilitate discrimination between
+ differing runtime environments. */
+
+#undef MAY_FORK_CHILD_PROCESS
+#undef MAY_SPAWN_ASYNCHRONOUS_CHILD
+
+#if defined(__MSDOS__) || defined(_WIN32)
+
+// Most MS-DOS and Win32 environments will be missing the `fork' capability
+// (some like Cygwin have it, but it is best avoided).
+
+# define MAY_FORK_CHILD_PROCESS 0
+
+// On these systems, we use `spawn...', instead of `fork' ... `exec...'.
+# include <process.h> // for `spawn...'
+# include <fcntl.h> // for attributes of pipes
+
+# if defined(__CYGWIN__) || defined(_UWIN) || defined(_WIN32)
+
+// These Win32 implementations allow parent and `spawn...'ed child to
+// multitask asynchronously.
+
+# define MAY_SPAWN_ASYNCHRONOUS_CHILD 1
+
+# else
+
+// Others may adopt MS-DOS behaviour where parent must sleep,
+// from `spawn...' until child terminates.
+
+# define MAY_SPAWN_ASYNCHRONOUS_CHILD 0
+
+# endif /* not defined __CYGWIN__, _UWIN, or _WIN32 */
+
+# if defined(DEBUGGING) && !defined(DEBUG_FILE_DIR)
+/* When we are building a DEBUGGING version we need to tell pre-grohtml
+ where to put intermediate files (the DEBUGGING version will preserve
+ these on exit).
+
+ On a UNIX host, we might simply use `/tmp', but MS-DOS and Win32 will
+ probably not have this on all disk drives, so default to using
+ `c:/temp' instead. (Note that user may choose to override this by
+ supplying a definition such as
+
+ -DDEBUG_FILE_DIR=d:/path/to/debug/files
+
+ in the CPPFLAGS to `make'.) */
+
+# define DEBUG_FILE_DIR c:/temp
+# endif
+
+#else /* not __MSDOS__ or _WIN32 */
+
+// For non-Microsoft environments assume UNIX conventions,
+// so `fork' is required and child processes are asynchronous.
+# define MAY_FORK_CHILD_PROCESS 1
+# define MAY_SPAWN_ASYNCHRONOUS_CHILD 1
+
+# if defined(DEBUGGING) && !defined(DEBUG_FILE_DIR)
+/* For a DEBUGGING version, on the UNIX host, we can also usually rely
+ on being able to use `/tmp' for temporary file storage. (Note that,
+ as in the __MSDOS__ or _WIN32 case above, the user may override this
+ by defining
+
+ -DDEBUG_FILE_DIR=/path/to/debug/files
+
+ in the CPPFLAGS.) */
+
+# define DEBUG_FILE_DIR /tmp
+# endif
+
+#endif /* not __MSDOS__ or _WIN32 */
+
+#ifdef DEBUGGING
+// For a DEBUGGING version, we need some additional macros,
+// to direct the captured debug mode output to appropriately named files
+// in the specified DEBUG_FILE_DIR.
+
+# define DEBUG_TEXT(text) #text
+# define DEBUG_NAME(text) DEBUG_TEXT(text)
+# define DEBUG_FILE(name) DEBUG_NAME(DEBUG_FILE_DIR) "/" name
+#endif
+
extern "C" const char *Version_string;
#include "pre-html.h"
#include "pushback.h"
#include "html-strings.h"
-#define DEFAULT_LINE_LENGTH 7 // inches wide
-#define DEFAULT_IMAGE_RES 100 // number of pixels per inch resolution
-#define IMAGE_BOARDER_PIXELS 0
-#define INLINE_LEADER_CHAR '\\'
+#define DEFAULT_LINE_LENGTH 7 // inches wide
+#define DEFAULT_IMAGE_RES 100 // number of pixels per inch resolution
+#define IMAGE_BOARDER_PIXELS 0
+#define INLINE_LEADER_CHAR '\\'
-#define TRANSPARENT "-background white -transparent white"
-#define MIN_ALPHA_BITS 0
-#define MAX_ALPHA_BITS 4
+// Don't use colour names here! Otherwise there is a dependency on
+// a file called `rgb.txt' which maps names to colours.
+#define TRANSPARENT "-background rgb:f/f/f -transparent rgb:f/f/f"
+#define MIN_ALPHA_BITS 0
+#define MAX_ALPHA_BITS 4
#define PAGE_TEMPLATE_SHORT "pg"
#define PAGE_TEMPLATE_LONG "-page-"
@@ -76,78 +161,87 @@ extern "C" const char *Version_string;
#define REGION_TEMPLATE_LONG "-regions-"
#if 0
-# define DEBUGGING
+# define DEBUGGING
#endif
#if !defined(TRUE)
-# define TRUE (1==1)
+# define TRUE (1==1)
#endif
#if !defined(FALSE)
-# define FALSE (1==0)
+# define FALSE (1==0)
#endif
-typedef enum {CENTERED, LEFT, RIGHT, INLINE} IMAGE_ALIGNMENT;
-
-static int postscriptRes =-1; // postscript resolution, dots per inch
-static int stdoutfd = 1; // output file descriptor - normally 1 but might move
- // -1 means closed
-static int copyofstdoutfd =-1; // a copy of stdout, so we can restore stdout when
- // writing to post-html
-static char *psFileName = NULL; // name of postscript file
-static char *psPageName = NULL; // name of file containing postscript current page
-static char *regionFileName = NULL; // name of file containing all image regions
-static char *imagePageName = NULL; // name of bitmap image containing current page
+typedef enum {
+ CENTERED, LEFT, RIGHT, INLINE
+} IMAGE_ALIGNMENT;
+
+static int postscriptRes = -1; // postscript resolution,
+ // dots per inch
+static int stdoutfd = 1; // output file descriptor -
+ // normally 1 but might move
+ // -1 means closed
+static char *psFileName = NULL; // name of postscript file
+static char *psPageName = NULL; // name of file containing
+ // postscript current page
+static char *regionFileName = NULL; // name of file containing all
+ // image regions
+static char *imagePageName = NULL; // name of bitmap image containing
+ // current page
static const char *image_device = "pnmraw";
-static int image_res = DEFAULT_IMAGE_RES;
-static int vertical_offset = 0;
-static char *image_template = NULL; // image template filename
-static char *macroset_template= NULL; // image template passed to troff by -D
-static int troff_arg = 0; // troff arg index
-static char *image_dir = NULL; // user specified image directory
-static int textAlphaBits = MAX_ALPHA_BITS;
-static int graphicAlphaBits = MAX_ALPHA_BITS;
-static char *antiAlias = NULL; // antialias arguments we pass to gs.
-static int show_progress = FALSE; // should we display page numbers as they are processed?
-static int currentPageNo = -1; // current image page number
+static int image_res = DEFAULT_IMAGE_RES;
+static int vertical_offset = 0;
+static char *image_template = NULL; // image template filename
+static char *macroset_template= NULL; // image template passed to troff
+ // by -D
+static int troff_arg = 0; // troff arg index
+static char *image_dir = NULL; // user specified image directory
+static int textAlphaBits = MAX_ALPHA_BITS;
+static int graphicAlphaBits = MAX_ALPHA_BITS;
+static char *antiAlias = NULL; // antialias arguments we pass to gs
+static int show_progress = FALSE; // should we display page numbers as
+ // they are processed?
+static int currentPageNo = -1; // current image page number
#if defined(DEBUGGING)
-static int debug = FALSE;
-static char *troffFileName = NULL; // output of pre-html output which is sent to troff -Tps
-static char *htmlFileName = NULL; // output of pre-html output which is sent to troff -Thtml
+static int debug = FALSE;
+static char *troffFileName = NULL; // output of pre-html output which
+ // is sent to troff -Tps
+static char *htmlFileName = NULL; // output of pre-html output which
+ // is sent to troff -Thtml
#endif
-static char *linebuf = NULL; // for scanning devps/DESC
+static char *linebuf = NULL; // for scanning devps/DESC
static int linebufsize = 0;
+static const char *image_gen = NULL; // the `gs' program
const char *const FONT_ENV_VAR = "GROFF_FONT_PATH";
static search_path font_path(FONT_ENV_VAR, FONTPATH, 0, 0);
/*
- * Images are generated via postscript, gs and the pnm utilities.
+ * Images are generated via postscript, gs, and the pnm utilities.
*/
+#define IMAGE_DEVICE "-Tps"
-#define IMAGE_DEVICE "-Tps"
-/*
- * prototypes
- */
static int do_file(const char *filename);
+
/*
- * sys_fatal - writes a fatal error message.
- * Taken from src/roff/groff/pipeline.c.
+ * sys_fatal - Write a fatal error message.
+ * Taken from src/roff/groff/pipeline.c.
*/
-void sys_fatal (const char *s)
+void sys_fatal(const char *s)
{
fatal("%1: %2", s, strerror(errno));
}
/*
- * get_line - copies a line (w/o newline) from a file to the global line buffer
+ * get_line - Copy a line (w/o newline) from a file to the
+ * global line buffer.
*/
-int get_line (FILE *f)
+int get_line(FILE *f)
{
if (f == 0)
return 0;
@@ -188,10 +282,10 @@ int get_line (FILE *f)
}
/*
- * get_resolution - returns the postscript resolution from devps/DESC
+ * get_resolution - Return the postscript resolution from devps/DESC.
*/
-static unsigned int get_resolution (void)
+static unsigned int get_resolution(void)
{
char *pathp;
FILE *f;
@@ -212,7 +306,7 @@ static unsigned int get_resolution (void)
}
/*
- * html_system - a wrapper for system()
+ * html_system - A wrapper for system().
*/
void html_system(const char *s, int redirect_stdout)
@@ -242,29 +336,28 @@ void html_system(const char *s, int redirect_stdout)
}
/*
- * make_message - taken from man printf(3), creates a string via malloc
- * and places the result of the va args into string.
- * Finally the new string is returned.
+ * make_message - Create a string via malloc and place the result of the
+ * va args into string. Finally the new string is returned.
+ * Taken from man page of printf(3).
*/
-char *
-make_message (const char *fmt, ...)
+char *make_message(const char *fmt, ...)
{
/* Guess we need no more than 100 bytes. */
int n, size = 100;
char *p;
char *np;
va_list ap;
- if ((p = (char *)malloc (size)) == NULL)
+ if ((p = (char *)malloc(size)) == NULL)
return NULL;
while (1) {
/* Try to print in the allocated space. */
va_start(ap, fmt);
- n = vsnprintf (p, size, fmt, ap);
+ n = vsnprintf(p, size, fmt, ap);
va_end(ap);
/* If that worked, return the string. */
- if (n > -1 && n < size) {
- if (size > n+1) {
+ if (n > -1 && n < size - 1) { /* glibc 2.1 and pre-ANSI C 99 */
+ if (size > n + 1) {
np = strsave(p);
free(p);
return np;
@@ -272,15 +365,13 @@ make_message (const char *fmt, ...)
return p;
}
/* Else try again with more space. */
- if (n > -1) /* glibc 2.1 */
- size = n+1; /* precisely what is needed */
- else /* glibc 2.0 */
- size *= 2; /* twice the old size */
- if ((np = (char *)realloc (p, size)) == NULL) {
- free(p); /* realloc failed, free old, p. */
+ else /* glibc 2.0 */
+ size *= 2; /* twice the old size */
+ if ((np = (char *)realloc(p, size)) == NULL) {
+ free(p); /* realloc failed, free old, p. */
return NULL;
}
- p = np; /* use realloc'ed, p */
+ p = np; /* use realloc'ed, p */
}
}
@@ -290,15 +381,15 @@ make_message (const char *fmt, ...)
struct char_block {
enum { SIZE = 256 };
- char buffer[SIZE];
- int used;
- char_block *next;
+ char buffer[SIZE];
+ int used;
+ char_block *next;
char_block();
};
/*
- * char_block - constructor, sets the, used, and, next, fields to zero.
+ * char_block - Constructor. Set the, used, and, next, fields to zero.
*/
char_block::char_block()
@@ -312,22 +403,22 @@ class char_buffer {
public:
char_buffer();
~char_buffer();
- int read_file(FILE *fp);
- int do_html(int argc, char *argv[]);
- int do_image(int argc, char *argv[]);
- void write_file_html(void);
- void write_file_troff(void);
- void write_upto_newline (char_block **t, int *i, int is_html);
- int can_see(char_block **t, int *i, const char *string);
- int skip_spaces(char_block **t, int *i);
+ int read_file(FILE *fp);
+ int do_html(int argc, char *argv[]);
+ int do_image(int argc, char *argv[]);
+ void emit_troff_output(int device_format_selector);
+ void write_upto_newline(char_block **t, int *i, int is_html);
+ int can_see(char_block **t, int *i, const char *string);
+ int skip_spaces(char_block **t, int *i);
void skip_until_newline(char_block **t, int *i);
private:
char_block *head;
char_block *tail;
+ int run_output_filter(int device_format_selector, int argc, char *argv[]);
};
/*
- * char_buffer - constructor
+ * char_buffer - Constructor.
*/
char_buffer::char_buffer()
@@ -336,7 +427,7 @@ char_buffer::char_buffer()
}
/*
- * char_buffer - deconstructor, throws aways the whole buffer list.
+ * char_buffer - Destructor. Throw away the whole buffer list.
*/
char_buffer::~char_buffer()
@@ -349,70 +440,69 @@ char_buffer::~char_buffer()
}
/*
- * read_file - read in a complete file, fp, placing the contents inside char_blocks.
+ * read_file - Read in a complete file, fp, placing the contents inside
+ * char_blocks.
*/
-int char_buffer::read_file (FILE *fp)
+int char_buffer::read_file(FILE *fp)
{
int n;
-
- while (! feof(fp)) {
+ while (!feof(fp)) {
if (tail == NULL) {
tail = new char_block;
head = tail;
- } else {
+ }
+ else {
if (tail->used == char_block::SIZE) {
tail->next = new char_block;
- tail = tail->next;
+ tail = tail->next;
}
}
- // at this point we have a tail which is ready for the next SIZE bytes of the file
-
+ // at this point we have a tail which is ready for the next SIZE
+ // bytes of the file
n = fread(tail->buffer, sizeof(char), char_block::SIZE-tail->used, fp);
- if (n <= 0) {
+ if (n <= 0)
// error
- return( 0 );
- } else {
- tail->used += n*sizeof(char);
- }
+ return 0;
+ else
+ tail->used += n * sizeof(char);
}
- return( 1 );
+ return 1;
}
/*
- * writeNbytes - writes n bytes to stdout.
+ * writeNbytes - Write n bytes to stdout.
*/
-static void writeNbytes (const char *s, int l)
+static void writeNbytes(const char *s, int l)
{
- int n=0;
+ int n = 0;
int r;
- while (n<l) {
- r = write(stdoutfd, s, l-n);
- if (r<0) {
+ while (n < l) {
+ r = write(stdoutfd, s, l - n);
+ if (r < 0)
sys_fatal("write");
- }
n += r;
s += r;
}
}
/*
- * writeString - writes a string to stdout.
+ * writeString - Write a string to stdout.
*/
-static void writeString (const char *s)
+static void writeString(const char *s)
{
writeNbytes(s, strlen(s));
}
/*
- * makeFileName - creates the image filename template
+ * makeFileName - Create the image filename template
* and the macroset image template.
*/
-static void makeFileName (void)
+static void makeFileName(void)
{
if ((image_dir != NULL) && (strchr(image_dir, '%') != NULL)) {
error("cannot use a `%%' within the image directory name");
@@ -424,23 +514,26 @@ static void makeFileName (void)
exit(1);
}
- if (image_dir == NULL) {
- image_dir = "";
- } else if ((strlen(image_dir)>0) && (image_dir[strlen(image_dir)-1] != '/')) {
+ if (image_dir == NULL)
+ image_dir = (char *)"";
+ else if (strlen(image_dir) > 0
+ && image_dir[strlen(image_dir) - 1] != '/') {
image_dir = make_message("%s/", image_dir);
if (image_dir == NULL)
sys_fatal("make_message");
}
-
+
if (image_template == NULL)
- macroset_template = make_message("%sgrohtml-%d", image_dir, (int)getpid());
+ macroset_template = make_message("%sgrohtml-%d", image_dir,
+ (int)getpid());
else
macroset_template = make_message("%s%s", image_dir, image_template);
if (macroset_template == NULL)
sys_fatal("make_message");
- image_template = (char *)malloc(strlen("-%d")+strlen(macroset_template)+1);
+ image_template =
+ (char *)malloc(strlen("-%d") + strlen(macroset_template) + 1);
if (image_template == NULL)
sys_fatal("malloc");
strcpy(image_template, macroset_template);
@@ -448,10 +541,10 @@ static void makeFileName (void)
}
/*
- * setupAntiAlias - sets up the antialias string, used when we call gs.
+ * setupAntiAlias - Set up the antialias string, used when we call gs.
*/
-static void setupAntiAlias (void)
+static void setupAntiAlias(void)
{
if (textAlphaBits == 0 && graphicAlphaBits == 0)
antiAlias = make_message(" ");
@@ -465,23 +558,24 @@ static void setupAntiAlias (void)
}
/*
- * checkImageDir - checks to see whether the image directory is available.
+ * checkImageDir - Check whether the image directory is available.
*/
-static void checkImageDir (void)
+static void checkImageDir(void)
{
- if ((image_dir != NULL) && (strcmp(image_dir, "") != 0))
- if (! ((mkdir(image_dir, 0777) == 0) || (errno == EEXIST))) {
+ if (image_dir != NULL && strcmp(image_dir, "") != 0)
+ if (!(mkdir(image_dir, 0777) == 0 || errno == EEXIST)) {
error("cannot create directory `%1'", image_dir);
exit(1);
}
}
/*
- * write_end_image - ends the image. It writes out the image extents if we are using -Tps.
+ * write_end_image - End the image. Write out the image extents if we
+ * are using -Tps.
*/
-static void write_end_image (int is_html)
+static void write_end_image(int is_html)
{
/*
* if we are producing html then these
@@ -499,18 +593,17 @@ static void write_end_image (int is_html)
}
/*
- * write_start_image - writes the troff which will:
+ * write_start_image - Write troff code which will:
*
* (i) disable html output for the following image
* (ii) reset the max/min x/y registers during postscript
* rendering.
*/
-static void write_start_image (IMAGE_ALIGNMENT pos, int is_html)
+static void write_start_image(IMAGE_ALIGNMENT pos, int is_html)
{
writeString("\\O[5");
switch (pos) {
-
case INLINE:
writeString("i");
break;
@@ -525,7 +618,8 @@ static void write_start_image (IMAGE_ALIGNMENT pos, int is_html)
writeString("c");
break;
}
- writeString(image_template); writeString(".png]");
+ writeString(image_template);
+ writeString(".png]");
if (is_html)
writeString("\\O[0]\\O[3]");
else
@@ -534,24 +628,25 @@ static void write_start_image (IMAGE_ALIGNMENT pos, int is_html)
}
/*
- * write_upto_newline - writes the contents of the buffer until a newline is seen.
- * It checks for HTML_IMAGE_INLINE_BEGIN and HTML_IMAGE_INLINE_END
- * and if they are present it processes them.
+ * write_upto_newline - Write the contents of the buffer until a newline
+ * is seen. Check for HTML_IMAGE_INLINE_BEGIN and
+ * HTML_IMAGE_INLINE_END; process them if they are
+ * present.
*/
-void char_buffer::write_upto_newline (char_block **t, int *i, int is_html)
+void char_buffer::write_upto_newline(char_block **t, int *i, int is_html)
{
- int j=*i;
+ int j = *i;
if (*t) {
- while ((j < (*t)->used) && ((*t)->buffer[j] != '\n') &&
- ((*t)->buffer[j] != INLINE_LEADER_CHAR)) {
+ while (j < (*t)->used
+ && (*t)->buffer[j] != '\n'
+ && (*t)->buffer[j] != INLINE_LEADER_CHAR)
j++;
- }
- if ((j < (*t)->used) && ((*t)->buffer[j] == '\n')) {
+ if (j < (*t)->used
+ && (*t)->buffer[j] == '\n')
j++;
- }
- writeNbytes((*t)->buffer+(*i), j-(*i));
+ writeNbytes((*t)->buffer + (*i), j - (*i));
if ((*t)->buffer[j] == INLINE_LEADER_CHAR) {
if (can_see(t, &j, HTML_IMAGE_INLINE_BEGIN))
write_start_image(INLINE, is_html);
@@ -561,208 +656,225 @@ void char_buffer::write_upto_newline (char_block **t, int *i, int is_html)
if (j < (*t)->used) {
*i = j;
j++;
- writeNbytes((*t)->buffer+(*i), j-(*i));
+ writeNbytes((*t)->buffer + (*i), j - (*i));
}
}
}
if (j == (*t)->used) {
*i = 0;
- if ((*t)->buffer[j-1] == '\n') {
- *t = (*t)->next;
- } else {
- *t = (*t)->next;
+ *t = (*t)->next;
+ if (*t && (*t)->buffer[j - 1] != '\n')
write_upto_newline(t, i, is_html);
- }
- } else {
+ }
+ else
// newline was seen
*i = j;
- }
}
}
/*
- * can_see - returns TRUE if we can see string in t->buffer[i] onwards
+ * can_see - Return TRUE if we can see string in t->buffer[i] onwards.
*/
-int char_buffer::can_see (char_block **t, int *i, const char *string)
+int char_buffer::can_see(char_block **t, int *i, const char *str)
{
- int j = 0;
- int l = strlen(string);
- int k = *i;
+ int j = 0;
+ int l = strlen(str);
+ int k = *i;
char_block *s = *t;
while (s) {
- while ((k<s->used) && (j<l) && (s->buffer[k] == string[j])) {
+ while (k < s->used && j < l && s->buffer[k] == str[j]) {
j++;
k++;
}
if (j == l) {
*i = k;
*t = s;
- return( TRUE );
- } else if ((k<s->used) && (s->buffer[k] != string[j])) {
- return( FALSE );
+ return TRUE;
}
+ else if (k < s->used && s->buffer[k] != str[j])
+ return( FALSE );
s = s->next;
k = 0;
}
- return( FALSE );
+ return FALSE;
}
/*
- * skip_spaces - returns TRUE if we have not run out of data.
- * It also consumes spaces.
+ * skip_spaces - Return TRUE if we have not run out of data.
+ * Consume spaces also.
*/
int char_buffer::skip_spaces(char_block **t, int *i)
{
char_block *s = *t;
- int k = *i;
+ int k = *i;
while (s) {
- while ((k<s->used) && (isspace(s->buffer[k]))) {
+ while (k < s->used && isspace(s->buffer[k]))
k++;
- }
if (k == s->used) {
k = 0;
s = s->next;
- } else {
+ }
+ else {
*i = k;
- return( TRUE );
+ return TRUE;
}
}
- return( FALSE );
+ return FALSE;
}
/*
- * skip_until_newline - skips all characters until a newline is seen.
+ * skip_until_newline - Skip all characters until a newline is seen.
* The newline is not consumed.
*/
-void char_buffer::skip_until_newline (char_block **t, int *i)
+void char_buffer::skip_until_newline(char_block **t, int *i)
{
- int j=*i;
+ int j = *i;
if (*t) {
- while ((j < (*t)->used) && ((*t)->buffer[j] != '\n')) {
+ while (j < (*t)->used && (*t)->buffer[j] != '\n')
j++;
- }
if (j == (*t)->used) {
*i = 0;
*t = (*t)->next;
skip_until_newline(t, i);
- } else {
+ }
+ else
// newline was seen
*i = j;
- }
}
}
+#define DEVICE_FORMAT(filter) (filter == HTML_OUTPUT_FILTER)
+#define HTML_OUTPUT_FILTER 0
+#define IMAGE_OUTPUT_FILTER 1
+#define OUTPUT_STREAM(name) creat((name), S_IWUSR | S_IRUSR)
+#define PS_OUTPUT_STREAM OUTPUT_STREAM(psFileName)
+#define REGION_OUTPUT_STREAM OUTPUT_STREAM(regionFileName)
+
/*
- * write_file_troff - writes the buffer to stdout (troff).
+ * emit_troff_output - Write formatted buffer content to the troff
+ * post-processor data pipeline.
*/
-void char_buffer::write_file_troff (void)
+void char_buffer::emit_troff_output(int device_format_selector)
{
- char_block *t=head;
- int i=0;
+ // Handle output for BOTH html and image device formats
+ // if `device_format_selector' is passed as
+ //
+ // HTML_FORMAT(HTML_OUTPUT_FILTER)
+ // Buffer data is written to the output stream
+ // with template image names translated to actual image names.
+ //
+ // HTML_FORMAT(IMAGE_OUTPUT_FILTER)
+ // Buffer data is written to the output stream
+ // with no translation, for image file creation in the post-processor.
+
+ int idx = 0;
+ char_block *element = head;
+
+ while (element != NULL)
+ write_upto_newline(&element, &idx, device_format_selector);
- if (t != NULL) {
- do {
- write_upto_newline(&t, &i, FALSE);
- } while (t != NULL);
- }
+#if 0
if (close(stdoutfd) < 0)
- sys_fatal("close");
+ sys_fatal ("close");
// now we grab fd=1 so that the next pipe cannot use fd=1
if (stdoutfd == 1) {
- if (dup(2) != stdoutfd) {
- sys_fatal("dup failed to use fd=1");
- }
+ if (dup(2) != stdoutfd)
+ sys_fatal ("dup failed to use fd=1");
}
+#endif /* 0 */
}
/*
- * the image class remembers the position of all images in the postscript file
- * and assigns names for each image.
+ * The image class remembers the position of all images in the
+ * postscript file and assigns names for each image.
*/
struct imageItem {
- imageItem *next;
- int X1;
- int Y1;
- int X2;
- int Y2;
- char *imageName;
- int resolution;
- int maxx;
- int pageNo;
-
- imageItem (int x1, int y1, int x2, int y2, int page, int res, int max_width, char *name);
- ~imageItem ();
+ imageItem *next;
+ int X1;
+ int Y1;
+ int X2;
+ int Y2;
+ char *imageName;
+ int resolution;
+ int maxx;
+ int pageNo;
+
+ imageItem(int x1, int y1, int x2, int y2,
+ int page, int res, int max_width, char *name);
+ ~imageItem();
};
/*
- * imageItem - constructor
+ * imageItem - Constructor.
*/
-imageItem::imageItem (int x1, int y1, int x2, int y2, int page, int res, int max_width, char *name)
+imageItem::imageItem(int x1, int y1, int x2, int y2,
+ int page, int res, int max_width, char *name)
{
- X1 = x1;
- Y1 = y1;
- X2 = x2;
- Y2 = y2;
- pageNo = page;
+ X1 = x1;
+ Y1 = y1;
+ X2 = x2;
+ Y2 = y2;
+ pageNo = page;
resolution = res;
- maxx = max_width;
- imageName = name;
- next = NULL;
+ maxx = max_width;
+ imageName = name;
+ next = NULL;
}
/*
- * imageItem - deconstructor
+ * imageItem - Destructor.
*/
-imageItem::~imageItem ()
+imageItem::~imageItem()
{
if (imageName)
free(imageName);
}
/*
- * imageList - class containing a list of imageItems.
+ * imageList - A class containing a list of imageItems.
*/
class imageList {
private:
imageItem *head;
imageItem *tail;
- int count;
+ int count;
public:
imageList();
~imageList();
- void add(int x1, int y1, int x2, int y2, int page, int res, int maxx, char *name);
- void createImages (void);
- int createPage (int pageno);
- void createImage (imageItem *i);
- int getMaxX (int pageno);
+ void add(int x1, int y1, int x2, int y2,
+ int page, int res, int maxx, char *name);
+ void createImages(void);
+ int createPage(int pageno);
+ void createImage(imageItem *i);
+ int getMaxX(int pageno);
};
/*
- * imageList - constructor.
+ * imageList - Constructor.
*/
-imageList::imageList ()
- : head(0), tail(0), count(0)
+imageList::imageList()
+: head(0), tail(0), count(0)
{
}
/*
- * imageList - deconstructor.
+ * imageList - Destructor.
*/
-imageList::~imageList ()
+imageList::~imageList()
{
while (head != NULL) {
imageItem *i = head;
@@ -772,10 +884,10 @@ imageList::~imageList ()
}
/*
- * createPage - creates one image of, page pageno, from the postscript file.
+ * createPage - Create one image of, page pageno, from the postscript file.
*/
-int imageList::createPage (int pageno)
+int imageList::createPage(int pageno)
{
char *s;
@@ -784,8 +896,9 @@ int imageList::createPage (int pageno)
if (currentPageNo >= 1) {
/*
- * we need to unlink the files which change each time a new page is processed.
- * The final unlink is done by xtmpfile when pre-grohtml exits.
+ * We need to unlink the files which change each time a new page is
+ * processed. The final unlink is done by xtmpfile when pre-grohtml
+ * exits.
*/
unlink(imagePageName);
unlink(psPageName);
@@ -813,13 +926,14 @@ int imageList::createPage (int pageno)
}
#endif
html_system(s, 1);
-
+
s = make_message("echo showpage | "
- "gs%s -q -dBATCH -dSAFER "
+ "%s%s -q -dBATCH -dSAFER "
"-dDEVICEHEIGHTPOINTS=792 "
"-dDEVICEWIDTHPOINTS=%d -dFIXEDMEDIA=true "
"-sDEVICE=%s -r%d %s "
"-sOutputFile=%s %s -\n",
+ image_gen,
EXE_EXT,
(getMaxX(pageno) * image_res) / postscriptRes,
image_device,
@@ -842,39 +956,38 @@ int imageList::createPage (int pageno)
}
/*
- * min - returns the minimum of two numbers.
+ * min - Return the minimum of two numbers.
*/
-int min (int x, int y)
+int min(int x, int y)
{
- if (x < y) {
- return( x );
- } else {
- return( y );
- }
+ if (x < y)
+ return x;
+ else
+ return y;
}
/*
- * max - returns the maximum of two numbers.
+ * max - Return the maximum of two numbers.
*/
-int max (int x, int y)
+int max(int x, int y)
{
- if (x > y) {
- return( x );
- } else {
- return( y );
- }
+ if (x > y)
+ return x;
+ else
+ return y;
}
/*
- * getMaxX - returns the largest right hand position for any image on, pageno
+ * getMaxX - Return the largest right-hand position for any image
+ * on, pageno.
*/
-int imageList::getMaxX (int pageno)
+int imageList::getMaxX(int pageno)
{
imageItem *h = head;
- int x = postscriptRes * DEFAULT_LINE_LENGTH;
+ int x = postscriptRes * DEFAULT_LINE_LENGTH;
while (h != NULL) {
if (h->pageNo == pageno)
@@ -885,21 +998,30 @@ int imageList::getMaxX (int pageno)
}
/*
- * createImage - generates a minimal png file from the set of page images.
+ * createImage - Generate a minimal png file from the set of page images.
*/
-void imageList::createImage (imageItem *i)
+void imageList::createImage(imageItem *i)
{
if (i->X1 != -1) {
char *s;
- int x1 = max(min(i->X1, i->X2)*image_res/postscriptRes-1*IMAGE_BOARDER_PIXELS, 0);
- int y1 = max((image_res*vertical_offset/72)+min(i->Y1, i->Y2)*image_res/postscriptRes-IMAGE_BOARDER_PIXELS, 0);
- int x2 = max(i->X1, i->X2)*image_res/postscriptRes+1*IMAGE_BOARDER_PIXELS;
- int y2 = (image_res*vertical_offset/72)+(max(i->Y1, i->Y2)*image_res/postscriptRes)+1+IMAGE_BOARDER_PIXELS;
+ int x1 = max(min(i->X1, i->X2) * image_res / postscriptRes
+ - IMAGE_BOARDER_PIXELS,
+ 0);
+ int y1 = max(image_res * vertical_offset / 72
+ + min(i->Y1, i->Y2) * image_res / postscriptRes
+ - IMAGE_BOARDER_PIXELS,
+ 0);
+ int x2 = max(i->X1, i->X2) * image_res / postscriptRes
+ + IMAGE_BOARDER_PIXELS;
+ int y2 = image_res * vertical_offset / 72
+ + max(i->Y1, i->Y2) * image_res / postscriptRes
+ + 1 + IMAGE_BOARDER_PIXELS;
if (createPage(i->pageNo) == 0) {
- s = make_message("pnmcut%s %d %d %d %d < %s | pnmcrop -quiet | pnmtopng%s %s > %s \n",
+ s = make_message("pnmcut%s %d %d %d %d < %s "
+ "| pnmcrop -quiet | pnmtopng%s %s > %s\n",
EXE_EXT,
- x1, y1, x2-x1+1, y2-y1+1,
+ x1, y1, x2 - x1 + 1, y2 - y1 + 1,
imagePageName,
EXE_EXT,
TRANSPARENT,
@@ -915,12 +1037,14 @@ void imageList::createImage (imageItem *i)
#endif
html_system(s, 0);
free(s);
- } else {
+ }
+ else {
fprintf(stderr, "failed to generate image of page %d\n", i->pageNo);
fflush(stderr);
}
#if defined(DEBUGGING)
- } else {
+ }
+ else {
if (debug) {
fprintf(stderr, "ignoring image as x1 coord is -1\n");
fflush(stderr);
@@ -930,27 +1054,30 @@ void imageList::createImage (imageItem *i)
}
/*
- * add - an image description to the imageList.
+ * add - Add an image description to the imageList.
*/
-void imageList::add (int x1, int y1, int x2, int y2, int page, int res, int maxx, char *name)
+void imageList::add(int x1, int y1, int x2, int y2,
+ int page, int res, int maxx, char *name)
{
imageItem *i = new imageItem(x1, y1, x2, y2, page, res, maxx, name);
if (head == NULL) {
head = i;
tail = i;
- } else {
+ }
+ else {
tail->next = i;
tail = i;
}
}
/*
- * createImages - foreach image descriptor on the imageList, create the actual image.
+ * createImages - For each image descriptor on the imageList,
+ * create the actual image.
*/
-void imageList::createImages (void)
+void imageList::createImages(void)
{
imageItem *h = head;
@@ -960,72 +1087,42 @@ void imageList::createImages (void)
}
}
-static imageList listOfImages; // list of images defined by the region file.
-
-/*
- * write_file_html - writes the buffer to stdout (troff).
- * It writes out the file replacing template image names with
- * actual image names.
- */
-
-void char_buffer::write_file_html (void)
-{
- char_block *t=head;
- int i=0;
-
- if (t != NULL) {
- do {
- write_upto_newline(&t, &i, TRUE);
- } while (t != NULL);
- }
- if (close(stdoutfd) < 0)
- sys_fatal("close");
-
- // now we grab fd=1 so that the next pipe cannot use fd=1
- if (stdoutfd == 1) {
- if (dup(2) != stdoutfd) {
- sys_fatal("dup failed to use fd=1");
- }
- }
-}
+static imageList listOfImages; // List of images defined by the region file.
/*
- * generateImages - parses the region file and generates images
- * from the postscript file. The region file
- * contains the x1,y1 x2,y2 extents of each
+ * generateImages - Parse the region file and generate images
+ * from the postscript file. The region file
+ * contains the x1,y1--x2,y2 extents of each
* image.
*/
-static void generateImages (char *regionFileName)
+static void generateImages(char *region_file_name)
{
- pushBackBuffer *f=new pushBackBuffer(regionFileName);
+ pushBackBuffer *f=new pushBackBuffer(region_file_name);
while (f->putPB(f->getPB()) != eof) {
if (f->isString("grohtml-info:page")) {
- int page = f->readInt();
- int x1 = f->readInt();
- int y1 = f->readInt();
- int x2 = f->readInt();
- int y2 = f->readInt();
- int maxx = f->readInt();
+ int page = f->readInt();
+ int x1 = f->readInt();
+ int y1 = f->readInt();
+ int x2 = f->readInt();
+ int y2 = f->readInt();
+ int maxx = f->readInt();
char *name = f->readString();
- int res = postscriptRes;
+ int res = postscriptRes;
listOfImages.add(x1, y1, x2, y2, page, res, maxx, name);
- while ((f->putPB(f->getPB()) != '\n') &&
- (f->putPB(f->getPB()) != eof)) {
+ while (f->putPB(f->getPB()) != '\n'
+ && f->putPB(f->getPB()) != eof)
(void)f->getPB();
- }
- if (f->putPB(f->getPB()) == '\n') {
+ if (f->putPB(f->getPB()) == '\n')
(void)f->getPB();
- }
- } else {
- /*
- * write any error messages out to the user
- */
+ }
+ else {
+ /* Write any error messages out to the user. */
fputc(f->getPB(), stderr);
}
}
-
+
listOfImages.createImages();
if (show_progress) {
fprintf(stderr, "done\n");
@@ -1035,84 +1132,97 @@ static void generateImages (char *regionFileName)
}
/*
- * replaceFd - replace a file descriptor, was, with, willbe.
+ * set_redirection - Set up I/O Redirection for handle, was, to refer to
+ * stream on handle, willbe.
*/
-static void replaceFd (int was, int willbe)
+static void set_redirection(int was, int willbe)
{
- int dupres;
-
+ // Nothing to do if `was' and `willbe' already have same handle.
if (was != willbe) {
- if (close(was)<0) {
- sys_fatal("close");
+ // Otherwise attempt the specified redirection.
+ if (dup2 (willbe, was) < 0) {
+ // Redirection failed, so issue diagnostic and bail out.
+ fprintf(stderr, "failed to replace fd=%d with %d\n", was, willbe);
+ if (willbe == STDOUT_FILENO)
+ fprintf(stderr,
+ "likely that stdout should be opened before %d\n", was);
+ sys_fatal("dup2");
}
- dupres = dup(willbe);
- if (dupres != was) {
- sys_fatal("dup");
- fprintf(stderr, "trying to replace fd=%d with %d dup used %d\n", was, willbe, dupres);
- if (willbe == 1) {
- fprintf(stderr, "likely that stdout should be opened before %d\n", was);
- }
- exit(1);
- }
- if (close(willbe) < 0) {
+
+ // When redirection has been successfully completed assume redundant
+ // handle `willbe' is no longer required, so close it.
+ if (close(willbe) < 0)
+ // Issue diagnostic if `close' fails.
sys_fatal("close");
- }
}
}
/*
- * waitForChild - waits for child, pid, to exit.
+ * save_and_redirect - Get duplicate handle for stream, was, then
+ * redirect, was, to refer to, willbe.
*/
-static void waitForChild (PID_T pid)
+static int save_and_redirect(int was, int willbe)
{
- PID_T waitpd;
- int status;
+ if (was == willbe)
+ // No redirection specified so don't do anything but silently bailing out.
+ return (was);
+
+ // Proceeding with redirection so first save and verify our duplicate
+ // handle for `was'.
+ int saved = dup(was);
+ if (saved < 0) {
+ fprintf(stderr, "unable to get duplicate handle for %d\n", was);
+ sys_fatal("dup");
+ }
- waitpd = WAIT(&status, pid, _WAIT_CHILD);
- if (waitpd != pid)
- sys_fatal("wait");
+ // Duplicate handle safely established so complete redirection.
+ set_redirection(was, willbe);
+
+ // Finally return the saved duplicate descriptor for the
+ // original `was' stream.
+ return saved;
}
/*
- * alterDeviceTo - if toImage is set then the arg list is altered to include
+ * alterDeviceTo - If, toImage, is set
+ * the argument list is altered to include
* IMAGE_DEVICE and we invoke groff rather than troff.
- * else
- * set -Thtml and groff
+ * Else
+ * set -Thtml and groff.
*/
-static void alterDeviceTo (int argc, char *argv[], int toImage)
+static void alterDeviceTo(int argc, char *argv[], int toImage)
{
- int i=0;
+ int i = 0;
if (toImage) {
while (i < argc) {
- if (strcmp(argv[i], "-Thtml") == 0) {
- argv[i] = IMAGE_DEVICE;
- }
+ if (strcmp(argv[i], "-Thtml") == 0)
+ argv[i] = (char *)IMAGE_DEVICE;
i++;
}
- argv[troff_arg] = "groff"; /* rather than troff */
- } else {
+ argv[troff_arg] = (char *)"groff"; /* rather than troff */
+ }
+ else {
while (i < argc) {
- if (strcmp(argv[i], IMAGE_DEVICE) == 0) {
- argv[i] = "-Thtml";
- }
+ if (strcmp(argv[i], IMAGE_DEVICE) == 0)
+ argv[i] = (char *)"-Thtml";
i++;
}
- argv[troff_arg] = "groff"; /* use groff -Z */
+ argv[troff_arg] = (char *)"groff"; /* use groff -Z */
}
}
/*
- * addZ - appends -Z onto the command list for groff.
+ * addZ - Append -Z onto the command list for groff.
*/
-char **addZ (int argc, char *argv[])
+char **addZ(int argc, char *argv[])
{
- char **new_argv = (char **)malloc((argc+2)*sizeof(char *));
- int i=0;
+ char **new_argv = (char **)malloc((argc + 2) * sizeof(char *));
+ int i = 0;
if (new_argv == NULL)
sys_fatal("malloc");
@@ -1121,9 +1231,9 @@ char **addZ (int argc, char *argv[])
new_argv[i] = argv[i];
i++;
}
- new_argv[i] = "-Z";
- while (i<argc) {
- new_argv[i+1] = argv[i];
+ new_argv[i] = (char *)"-Z";
+ while (i < argc) {
+ new_argv[i + 1] = argv[i];
i++;
}
argc++;
@@ -1132,18 +1242,19 @@ char **addZ (int argc, char *argv[])
}
/*
- * addRegDef - appends a defined register or string onto the command list for troff.
+ * addRegDef - Append a defined register or string onto the command
+ * list for troff.
*/
-char **addRegDef (int argc, char *argv[], const char *numReg)
+char **addRegDef(int argc, char *argv[], const char *numReg)
{
- char **new_argv = (char **)malloc((argc+2)*sizeof(char *));
- int i=0;
+ char **new_argv = (char **)malloc((argc + 2) * sizeof(char *));
+ int i = 0;
if (new_argv == NULL)
sys_fatal("malloc");
- while (i<argc) {
+ while (i < argc) {
new_argv[i] = argv[i];
i++;
}
@@ -1154,94 +1265,213 @@ char **addRegDef (int argc, char *argv[], const char *numReg)
}
/*
- * dump_args - display the argument list.
+ * dump_args - Display the argument list.
*/
-void dump_args (int argc, char *argv[])
+void dump_args(int argc, char *argv[])
{
fprintf(stderr, " %d arguments:", argc);
- for (int i=0; i<argc; i++)
+ for (int i = 0; i < argc; i++)
fprintf(stderr, " %s", argv[i]);
fprintf(stderr, "\n");
}
+int char_buffer::run_output_filter(int filter, int /* argc */, char **argv)
+{
+ int pipedes[2];
+ PID_T child_pid;
+ int status;
+
+ if (pipe(pipedes) < 0)
+ sys_fatal("pipe");
+
+#if MAY_FORK_CHILD_PROCESS
+ // This is the UNIX process model. To invoke our post-processor,
+ // we must `fork' the current process.
+
+ if ((child_pid = fork()) < 0)
+ sys_fatal("fork");
+
+ else if (child_pid == 0) {
+ // This is the child process fork. We redirect its `stdin' stream
+ // to read data emerging from our pipe. There is no point in saving,
+ // since we won't be able to restore later!
+
+ set_redirection(STDIN_FILENO, pipedes[0]);
+
+ // The parent process will be writing this data, so we should release
+ // the child's writeable handle on the pipe, since we have no use for it.
+
+ if (close(pipedes[1]) < 0)
+ sys_fatal("close");
+
+ // The IMAGE_OUTPUT_FILTER needs special output redirection...
+
+ if (filter == IMAGE_OUTPUT_FILTER) {
+ // with BOTH `stdout' AND `stderr' diverted to files.
+
+ set_redirection(STDOUT_FILENO, PS_OUTPUT_STREAM);
+ set_redirection(STDERR_FILENO, REGION_OUTPUT_STREAM);
+ }
+
+ // Now we are ready to launch the output filter.
+
+ execvp(argv[0], argv);
+
+ // If we get to here then the `exec...' request for the output filter
+ // failed. Diagnose it and bail out.
+
+ error("couldn't exec %1: %2", argv[0], strerror(errno), ((char *)0));
+ fflush(stderr); // just in case error() didn't
+ exit(1);
+ }
+
+ else {
+ // This is the parent process fork. We will be writing data to the
+ // filter pipeline, and the child will be reading it. We have no further
+ // use for our read handle on the pipe, and should close it.
+
+ if (close(pipedes[0]) < 0)
+ sys_fatal("close");
+
+ // Now we redirect the `stdout' stream to the inlet end of the pipe,
+ // and push out the appropiately formatted data to the filter.
+
+ pipedes[1] = save_and_redirect(STDOUT_FILENO, pipedes[1]);
+ emit_troff_output(DEVICE_FORMAT(filter));
+
+ // After emitting all the data we close our connection to the inlet
+ // end of the pipe so the child process will detect end of data.
+
+ set_redirection(STDOUT_FILENO, pipedes[1]);
+
+ // Finally, we must wait for the child process to complete.
+
+ if (WAIT(&status, child_pid, _WAIT_CHILD) != child_pid)
+ sys_fatal("wait");
+ }
+
+#elif MAY_SPAWN_ASYNCHRONOUS_CHILD
+
+ // We do not have `fork', (or we prefer not to use it),
+ // but asynchronous processes are allowed, passing data through pipes.
+ // This should be ok for most Win32 systems and is preferred to `fork'
+ // for starting child processes under Cygwin.
+
+ // Before we start the post-processor we bind its inherited `stdin'
+ // stream to the readable end of our pipe, saving our own `stdin' stream
+ // in `pipedes[0]'.
+
+ pipedes[0] = save_and_redirect(STDIN_FILENO, pipedes[0]);
+
+ // for the Win32 model,
+ // we need special provision for saving BOTH `stdout' and `stderr'.
+
+ int saved_stdout = dup(STDOUT_FILENO);
+ int saved_stderr = STDERR_FILENO;
+
+ // The IMAGE_OUTPUT_FILTER needs special output redirection...
+
+ if (filter == IMAGE_OUTPUT_FILTER) {
+ // with BOTH `stdout' AND `stderr' diverted to files while saving a
+ // duplicate handle for `stderr'.
+
+ set_redirection(STDOUT_FILENO, PS_OUTPUT_STREAM);
+ saved_stderr = save_and_redirect(STDERR_FILENO, REGION_OUTPUT_STREAM);
+ }
+
+ // We then use an asynchronous spawn request to start the post-processor.
+
+ if ((child_pid = spawnvp(_P_NOWAIT, argv[0], argv)) < 0) {
+ // Should the spawn request fail we issue a diagnostic and bail out.
+
+ error("cannot spawn %1: %2", argv[0], strerror(errno), ((char *)0));
+ exit(1);
+ }
+
+ // Once the post-processor has been started we revert our `stdin'
+ // to its original saved source, which also closes the readable handle
+ // for the pipe.
+
+ set_redirection(STDIN_FILENO, pipedes[0]);
+
+ // if we redirected `stderr', for use by the image post-processor,
+ // then we also need to reinstate its original assignment.
+
+ if (filter == IMAGE_OUTPUT_FILTER)
+ set_redirection(STDERR_FILENO, saved_stderr);
+
+ // Now we redirect the `stdout' stream to the inlet end of the pipe,
+ // and push out the appropiately formatted data to the filter.
+
+ set_redirection(STDOUT_FILENO, pipedes[1]);
+ emit_troff_output(DEVICE_FORMAT(filter));
+
+ // After emitting all the data we close our connection to the inlet
+ // end of the pipe so the child process will detect end of data.
+
+ set_redirection(STDOUT_FILENO, saved_stdout);
+
+ // And finally, we must wait for the child process to complete.
+
+ if (WAIT(&status, child_pid, _WAIT_CHILD) != child_pid)
+ sys_fatal("wait");
+
+#else /* can't do asynchronous pipes! */
+
+ // TODO: code to support an MS-DOS style process model
+ // should go here
+
+#endif /* MAY_FORK_CHILD_PROCESS or MAY_SPAWN_ASYNCHRONOUS_CHILD */
+
+ return 0;
+}
+
/*
- * do_html - sets the troff number htmlflip and
- * writes out the buffer to troff -Thtml
+ * do_html - Set the troff number htmlflip and
+ * write out the buffer to troff -Thtml.
*/
int char_buffer::do_html(int argc, char *argv[])
{
- int pdes[2];
- PID_T pid;
string s;
alterDeviceTo(argc, argv, 0);
- argv += troff_arg; // skip all arguments up to groff
+ argv += troff_arg; // skip all arguments up to groff
argc -= troff_arg;
argv = addZ(argc, argv);
argc++;
s = "-dwww-image-template=";
- s += macroset_template; // do not combine these statements otherwise they will not work
- s += '\0'; // the trailing '\0' is ignored
+ s += macroset_template; // do not combine these statements,
+ // otherwise they will not work
+ s += '\0'; // the trailing `\0' is ignored
argv = addRegDef(argc, argv, s.contents());
argc++;
- if (pipe(pdes) < 0)
- sys_fatal("pipe");
-
- pid = fork();
- if (pid < 0)
- sys_fatal("fork");
-
- if (pid == 0) {
- // child
- replaceFd(0, pdes[0]);
- // close end we are not using
- if (close(pdes[1])<0)
- sys_fatal("close");
- replaceFd(1, copyofstdoutfd); // and restore stdout
-
- execvp(argv[0], argv);
- error("couldn't exec %1: %2", argv[0], strerror(errno), (char *)0);
- fflush(stderr); /* just in case error() doesn't */
- exit(1);
- } else {
- // parent
-
#if defined(DEBUGGING)
- /*
- * slight security risk so only enabled if compiled with defined(DEBUGGING)
- */
- if (debug) {
- replaceFd(1, creat(htmlFileName, S_IWUSR|S_IRUSR));
- write_file_html();
- }
+# define HTML_DEBUG_STREAM OUTPUT_STREAM(htmlFileName)
+ // slight security risk so only enabled if compiled with defined(DEBUGGING)
+ if (debug) {
+ int saved_stdout = save_and_redirect(STDOUT_FILENO, HTML_DEBUG_STREAM);
+ emit_troff_output(DEVICE_FORMAT(HTML_OUTPUT_FILTER));
+ set_redirection(STDOUT_FILENO, saved_stdout);
+ }
#endif
- replaceFd(1, pdes[1]);
- // close end we are not using
- if (close(pdes[0])<0)
- sys_fatal("close");
- write_file_html();
- waitForChild(pid);
- }
- return 0;
+ return run_output_filter(HTML_OUTPUT_FILTER, argc, argv);
}
/*
- * do_image - writes out the buffer to troff -Tps
+ * do_image - Write out the buffer to troff -Tps.
*/
int char_buffer::do_image(int argc, char *argv[])
{
- PID_T pid;
- int pdes[2];
string s;
alterDeviceTo(argc, argv, 1);
- argv += troff_arg; // skip all arguments up to troff/groff
+ argv += troff_arg; // skip all arguments up to troff/groff
argc -= troff_arg;
argv = addRegDef(argc, argv, "-rps4html=1");
argc++;
@@ -1256,69 +1486,52 @@ int char_buffer::do_image(int argc, char *argv[])
argv = addRegDef(argc, argv, "-P-pletter");
argc++;
- if (pipe(pdes) < 0)
- sys_fatal("pipe");
-
- pid = fork();
- if (pid == 0) {
- // child
-
- int psFd = creat(psFileName, S_IWUSR|S_IRUSR);
- int regionFd = creat(regionFileName, S_IWUSR|S_IRUSR);
-
- replaceFd(1, psFd);
- replaceFd(0, pdes[0]);
- replaceFd(2, regionFd);
-
- // close end we are not using
- if (close(pdes[1])<0)
- sys_fatal("close");
-
- execvp(argv[0], argv);
- error("couldn't exec %1: %2", argv[0], strerror(errno), (char *)0);
- fflush(stderr); /* just in case error() doesn't */
- exit(1);
- } else {
- // parent
-
#if defined(DEBUGGING)
- /*
- * slight security risk so only enabled if compiled with defined(DEBUGGING)
- */
- if (debug) {
- replaceFd(1, creat(troffFileName, S_IWUSR|S_IRUSR));
- write_file_troff();
- }
-#endif
- replaceFd(1, pdes[1]);
- write_file_troff();
- waitForChild(pid);
+# define IMAGE_DEBUG_STREAM OUTPUT_STREAM(troffFileName)
+ // slight security risk so only enabled if compiled with defined(DEBUGGING)
+ if (debug) {
+ int saved_stdout = save_and_redirect(STDOUT_FILENO, IMAGE_DEBUG_STREAM);
+ emit_troff_output(DEVICE_FORMAT(IMAGE_OUTPUT_FILTER));
+ set_redirection(STDOUT_FILENO, saved_stdout);
}
- return 0;
+#endif
+
+ return run_output_filter(IMAGE_OUTPUT_FILTER, argc, argv);
}
static char_buffer inputFile;
-
/*
- * usage - emit usage arguments.
+ * usage - Emit usage arguments.
*/
-void usage(FILE *stream)
+static void usage(FILE *stream)
{
- fprintf(stream, "usage: %s troffname [-Iimage_name] [-Dimage_directory] [-P-o vertical_image_offset] [-P-i image_resolution] [troff flags] [files]\n", program_name);
- fprintf(stream, " vertical_image_offset (default %d/72 of an inch)\n", vertical_offset);
- fprintf(stream, " image_resolution (default %d) pixels per inch\n", image_res);
- fprintf(stream, " image_name is the name of the stem for all images (default is grohtml-<pid>)\n");
- fprintf(stream, " place all png files into image_directory\n");
+ fprintf(stream,
+ "usage: %s troffname [-Iimage_name] [-Dimage_directory]\n"
+ " [-P-o vertical_image_offset] [-P-i image_resolution]\n"
+ " [troff flags]\n",
+ program_name);
+ fprintf(stream,
+ " vertical_image_offset (default %d/72 of an inch)\n",
+ vertical_offset);
+ fprintf(stream,
+ " image_resolution (default %d) pixels per inch\n",
+ image_res);
+ fprintf(stream,
+ " image_name is the name of the stem for all images\n"
+ " (default is grohtml-<pid>)\n");
+ fprintf(stream,
+ " place all png files into image_directory\n");
}
/*
- * scanArguments - scans for all arguments including -P-i, -P-o, -P-D and -P-I. It returns
- * the argument index of the first non option.
+ * scanArguments - Scan for all arguments including -P-i, -P-o, -P-D,
+ * and -P-I. Return the argument index of the first
+ * non-option.
*/
-int scanArguments (int argc, char **argv)
+static int scanArguments(int argc, char **argv)
{
const char *command_prefix = getenv("GROFF_COMMAND_PREFIX");
if (!command_prefix)
@@ -1332,40 +1545,57 @@ int scanArguments (int argc, char **argv)
{ "version", no_argument, 0, 'v' },
{ NULL, 0, 0, 0 }
};
- while ((c = getopt_long(argc, argv, "+a:g:o:i:I:D:F:vbdhlrnp", long_options, NULL))
+ while ((c = getopt_long(argc, argv, "+a:bdD:F:g:hi:I:j:lno:prs:S:v",
+ long_options, NULL))
!= EOF)
switch(c) {
- case 'v':
- printf("GNU pre-grohtml (groff) version %s\n", Version_string);
- exit(0);
case 'a':
- textAlphaBits = min(max(MIN_ALPHA_BITS, atoi(optarg)), MAX_ALPHA_BITS);
+ textAlphaBits = min(max(MIN_ALPHA_BITS, atoi(optarg)),
+ MAX_ALPHA_BITS);
if (textAlphaBits == 3) {
error("cannot use 3 bits of antialiasing information");
exit(1);
}
break;
+ case 'b':
+ // handled by post-grohtml (set background color to white)
+ break;
+ case 'd':
+#if defined(DEBUGGING)
+ debug = TRUE;
+#endif
+ break;
+ case 'D':
+ image_dir = optarg;
+ break;
+ case 'F':
+ font_path.command_line_dir(optarg);
+ break;
case 'g':
- graphicAlphaBits = min(max(MIN_ALPHA_BITS, atoi(optarg)), MAX_ALPHA_BITS);
+ graphicAlphaBits = min(max(MIN_ALPHA_BITS, atoi(optarg)),
+ MAX_ALPHA_BITS);
if (graphicAlphaBits == 3) {
error("cannot use 3 bits of antialiasing information");
exit(1);
}
break;
- case 'b':
- // handled by post-grohtml (set background color to white)
+ case 'h':
+ // handled by post-grohtml
break;
- case 'D':
- image_dir = optarg;
+ case 'i':
+ image_res = atoi(optarg);
break;
case 'I':
image_template = optarg;
break;
- case 'i':
- image_res = atoi(optarg);
+ case 'j':
+ // handled by post-grohtml (set job name for multiple file output)
break;
- case 'F':
- font_path.command_line_dir(optarg);
+ case 'l':
+ // handled by post-grohtml (no automatic section links)
+ break;
+ case 'n':
+ // handled by post-grohtml (generate simple heading anchors)
break;
case 'o':
vertical_offset = atoi(optarg);
@@ -1373,14 +1603,18 @@ int scanArguments (int argc, char **argv)
case 'p':
show_progress = TRUE;
break;
- case 'd':
-#if defined(DEBUGGING)
- debug = TRUE;
-#endif
+ case 'r':
+ // handled by post-grohtml (no header and footer lines)
break;
- case 'h':
- // handled by post-grohtml
+ case 's':
+ // handled by post-grohtml (use font size n as the html base font size)
+ break;
+ case 'S':
+ // handled by post-grohtml (set file split level)
break;
+ case 'v':
+ printf("GNU pre-grohtml (groff) version %s\n", Version_string);
+ exit(0);
case CHAR_MAX + 1: // --help
usage(stdout);
exit(0);
@@ -1407,19 +1641,19 @@ int scanArguments (int argc, char **argv)
}
/*
- * makeTempFiles - name the temporary files
+ * makeTempFiles - Name the temporary files.
*/
-static int makeTempFiles (void)
+static int makeTempFiles(void)
{
#if defined(DEBUGGING)
- psFileName = "/tmp/prehtml-ps";
- regionFileName = "/tmp/prehtml-region";
- imagePageName = "/tmp/prehtml-page";
- psPageName = "/tmp/prehtml-psn";
- troffFileName = "/tmp/prehtml-troff";
- htmlFileName = "/tmp/prehtml-html";
-#else
+ psFileName = DEBUG_FILE("prehtml-ps");
+ regionFileName = DEBUG_FILE("prehtml-region");
+ imagePageName = DEBUG_FILE("prehtml-page");
+ psPageName = DEBUG_FILE("prehtml-psn");
+ troffFileName = DEBUG_FILE("prehtml-troff");
+ htmlFileName = DEBUG_FILE("prehtml-html");
+#else /* not DEBUGGING */
FILE *f;
/* psPageName contains a single page of postscript */
@@ -1462,7 +1696,7 @@ static int makeTempFiles (void)
}
fclose(f);
-#endif
+#endif /* not DEBUGGING */
return 0;
}
@@ -1470,9 +1704,27 @@ int main(int argc, char **argv)
{
program_name = argv[0];
int i;
- int found=0;
- int ok=1;
-
+ int found = 0;
+ int ok = 1;
+
+#ifdef CAPTURE_MODE
+ FILE *dump;
+ fprintf(stderr, "%s: invoked with %d arguments ...\n", argv[0], argc);
+ for (i = 0; i < argc; i++)
+ fprintf(stderr, "%2d: %s\n", i, argv[i]);
+ if ((dump = fopen(DEBUG_FILE("pre-html-data"), "wb")) != NULL) {
+ while((i = fgetc(stdin)) >= 0)
+ fputc(i, dump);
+ fclose(dump);
+ }
+ exit(1);
+#endif /* CAPTURE_MODE */
+ device = "html";
+ if (!font::load_desc())
+ fatal("cannot find devhtml/DESC exiting");
+ image_gen = font::image_generator;
+ if (image_gen == NULL || (strcmp(image_gen, "") == 0))
+ fatal("devhtml/DESC must set the image_generator field, exiting");
postscriptRes = get_resolution();
i = scanArguments(argc, argv);
setupAntiAlias();
@@ -1482,19 +1734,15 @@ int main(int argc, char **argv)
if (argv[i][0] != '-') {
/* found source file */
ok = do_file(argv[i]);
- if (! ok) {
- return( 0 );
- }
+ if (!ok)
+ return 0;
found = 1;
}
i++;
}
- copyofstdoutfd=dup(stdoutfd);
-
- if (! found) {
+ if (!found)
do_file("-");
- }
if (makeTempFiles())
return 1;
ok = inputFile.do_image(argc, argv);
@@ -1510,9 +1758,9 @@ static int do_file(const char *filename)
FILE *fp;
current_filename = filename;
- if (strcmp(filename, "-") == 0) {
+ if (strcmp(filename, "-") == 0)
fp = stdin;
- } else {
+ else {
fp = fopen(filename, "r");
if (fp == 0) {
error("can't open `%1': %2", filename, strerror(errno));
@@ -1521,6 +1769,7 @@ static int do_file(const char *filename)
}
if (inputFile.read_file(fp)) {
+ // XXX
}
if (fp != stdin)
diff --git a/contrib/groff/src/preproc/html/pre-html.h b/contrib/groff/src/preproc/html/pre-html.h
index f9a590c17b7e..3eedb21c72bb 100644
--- a/contrib/groff/src/preproc/html/pre-html.h
+++ b/contrib/groff/src/preproc/html/pre-html.h
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
/*
* defines functions implemented within pre-html.c
diff --git a/contrib/groff/src/preproc/html/pushback.cpp b/contrib/groff/src/preproc/html/pushback.cpp
index 07a15e36fe87..b71558783508 100644
--- a/contrib/groff/src/preproc/html/pushback.cpp
+++ b/contrib/groff/src/preproc/html/pushback.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
Written by Gaius Mulley (gaius@glam.ac.uk).
This file is part of groff.
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "lib.h"
@@ -83,14 +83,12 @@ pushBackBuffer::pushBackBuffer (char *filename)
pushBackBuffer::~pushBackBuffer ()
{
- int old;
-
if (charStack != 0) {
free(charStack);
}
close(0);
/* restore stdin in file descriptor 0 */
- old = dup(stdIn);
+ dup(stdIn);
close(stdIn);
}
@@ -162,10 +160,8 @@ static int isWhite (char ch)
void pushBackBuffer::skipToNewline (void)
{
- char ch;
-
while ((putPB(getPB()) != '\n') && (! eofFound)) {
- ch = getPB();
+ getPB();
}
}
@@ -274,15 +270,15 @@ int pushBackBuffer::readInt (void)
* convertToFloat - converts integers, a and b into a.b
*/
-static float convertToFloat (int a, int b)
+static double convertToFloat (int a, int b)
{
int c=10;
- float f;
+ double f;
while (b>c) {
c *= 10;
}
- f = ((float)a) + (((float)b)/((float)c));
+ f = ((double)a) + (((double)b)/((double)c));
return( f );
}
@@ -290,7 +286,7 @@ static float convertToFloat (int a, int b)
* readNumber - returns a float representing the word just read.
*/
-float pushBackBuffer::readNumber (void)
+double pushBackBuffer::readNumber (void)
{
int i;
char ch;
@@ -300,7 +296,7 @@ float pushBackBuffer::readNumber (void)
return convertToFloat(i, readInt());
}
putPB(ch);
- return (float)i;
+ return (double)i;
}
/*
@@ -312,7 +308,7 @@ float pushBackBuffer::readNumber (void)
char *pushBackBuffer::readString (void)
{
char buffer[MAXPUSHBACKSTACK];
- char *string = 0;
+ char *str = 0;
int i=0;
char ch=getPB();
@@ -326,8 +322,8 @@ char *pushBackBuffer::readString (void)
}
if (i < MAXPUSHBACKSTACK) {
buffer[i] = (char)0;
- string = (char *)malloc(strlen(buffer)+1);
- strcpy(string, buffer);
+ str = (char *)malloc(strlen(buffer)+1);
+ strcpy(str, buffer);
}
- return( string );
+ return( str );
}
diff --git a/contrib/groff/src/preproc/html/pushback.h b/contrib/groff/src/preproc/html/pushback.h
index 608bac53991e..3fddad66f11d 100644
--- a/contrib/groff/src/preproc/html/pushback.h
+++ b/contrib/groff/src/preproc/html/pushback.h
@@ -1,5 +1,5 @@
// -*- C -*-
-/* Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
Written by Gaius Mulley (gaius@glam.ac.uk).
This file is part of groff.
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#define eof (char)-1
@@ -39,16 +39,16 @@ class pushBackBuffer
int stdIn;
public:
- pushBackBuffer (char *);
- ~ pushBackBuffer ();
- char getPB (void);
- char putPB (char ch);
- void skipUntilToken (void);
- void skipToNewline (void);
- float readNumber (void);
- int readInt (void);
- char *readString (void);
- int isString (const char *string);
+ pushBackBuffer (char *);
+ ~ pushBackBuffer ();
+ char getPB (void);
+ char putPB (char ch);
+ void skipUntilToken (void);
+ void skipToNewline (void);
+ double readNumber (void);
+ int readInt (void);
+ char *readString (void);
+ int isString (const char *string);
};
diff --git a/contrib/groff/src/preproc/pic/TODO b/contrib/groff/src/preproc/pic/TODO
index 2346b575e1de..a1d7554d4529 100644
--- a/contrib/groff/src/preproc/pic/TODO
+++ b/contrib/groff/src/preproc/pic/TODO
@@ -1,5 +1,3 @@
-Dotted and dashed ellipses.
-
In troff mode, dotted and dashed splines.
Make DELIMITED have type lstr; this would allow us to give better
diff --git a/contrib/groff/src/preproc/pic/common.cpp b/contrib/groff/src/preproc/pic/common.cpp
index 5075e936142d..47a23cd920ef 100644
--- a/contrib/groff/src/preproc/pic/common.cpp
+++ b/contrib/groff/src/preproc/pic/common.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2003 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "pic.h"
#include "common.h"
@@ -78,6 +78,157 @@ void common_output::dotted_circle(const position &cent, double rad,
dot(cent + position(cos(ang), sin(ang))*rad, lt);
}
+// recursive function for dash drawing, used by dashed_ellipse
+
+void common_output::ellipse_arc(const position &cent,
+ const position &z0, const position &z1,
+ const distance &dim, const line_type &lt)
+{
+ assert(lt.type == line_type::solid);
+ assert(dim.x != 0 && dim.y != 0);
+ double eps = 0.0001;
+ position zml = (z0 + z1) / 2;
+ // apply affine transformation (from ellipse to circle) to compute angle
+ // of new position, then invert transformation to get exact position
+ double psi = atan2(zml.y / dim.y, zml.x / dim.x);
+ position zm = position(dim.x * cos(psi), dim.y * sin(psi));
+ // to approximate the ellipse arc with one or more circle arcs, we
+ // first compute the radius of curvature in zm
+ double a_2 = dim.x * dim.x;
+ double a_4 = a_2 * a_2;
+ double b_2 = dim.y * dim.y;
+ double b_4 = b_2 * b_2;
+ double e_2 = a_2 - b_2;
+ double temp = a_4 * zm.y * zm.y + b_4 * zm.x * zm.x;
+ double rho = sqrt(temp / a_4 / b_4 * temp / a_4 / b_4 * temp);
+ // compute center of curvature circle
+ position M = position(e_2 * zm.x / a_2 * zm.x / a_2 * zm.x,
+ -e_2 * zm.y / b_2 * zm.y / b_2 * zm.y);
+ // compute distance between circle and ellipse arc at start and end
+ double phi0 = atan2(z0.y - M.y, z0.x - M.x);
+ double phi1 = atan2(z1.y - M.y, z1.x - M.x);
+ position M0 = position(rho * cos(phi0), rho * sin(phi0)) + M;
+ position M1 = position(rho * cos(phi1), rho * sin(phi1)) + M;
+ double dist0 = hypot(z0 - M0) / sqrt(z0 * z0);
+ double dist1 = hypot(z1 - M1) / sqrt(z1 * z1);
+ if (dist0 < eps && dist1 < eps)
+ solid_arc(M + cent, rho, phi0, phi1, lt);
+ else {
+ ellipse_arc(cent, z0, zm, dim, lt);
+ ellipse_arc(cent, zm, z1, dim, lt);
+ }
+}
+
+// output a dashed ellipse as a series of arcs
+
+void common_output::dashed_ellipse(const position &cent, const distance &dim,
+ const line_type &lt)
+{
+ assert(lt.type == line_type::dashed);
+ double dim_x = dim.x / 2;
+ double dim_y = dim.y / 2;
+ line_type slt = lt;
+ slt.type = line_type::solid;
+ double dw = lt.dash_width;
+ // we use an approximation to compute the ellipse length (found in:
+ // Bronstein, Semendjajew, Taschenbuch der Mathematik)
+ double lambda = (dim.x - dim.y) / (dim.x + dim.y);
+ double le = M_PI / 2 * (dim.x + dim.y)
+ * ((64 - 3 * lambda * lambda * lambda * lambda )
+ / (64 - 16 * lambda * lambda));
+ // for symmetry we make nmax a multiple of 8
+ int nmax = 8 * int(le / dw / 8 + 0.5);
+ if (nmax < 8) {
+ nmax = 8;
+ dw = le / 8;
+ }
+ int ndash = nmax / 2;
+ double gapwidth = (le - dw * ndash) / ndash;
+ double l = 0;
+ position z = position(dim_x, 0);
+ position zdot = z;
+ int j = 0;
+ int jmax = int(10 / lt.dash_width);
+ for (int i = 0; i <= nmax; i++) {
+ position zold = z;
+ position zpre = zdot;
+ double ld = (int(i / 2) + 0.5) * dw + int((i + 1) / 2) * gapwidth;
+ double lold = 0;
+ double dl = 1;
+ // find next position for fixed arc length
+ while (l < ld) {
+ j++;
+ lold = l;
+ zold = z;
+ double phi = j * 2 * M_PI / jmax;
+ z = position(dim_x * cos(phi), dim_y * sin(phi));
+ dl = hypot(z - zold);
+ l += dl;
+ }
+ // interpolate linearly between the last two points,
+ // using the length difference as the scaling factor
+ double delta = (ld - lold) / dl;
+ zdot = zold + (z - zold) * delta;
+ // compute angle of new position on the affine circle
+ // and use it to get the exact value on the ellipse
+ double psi = atan2(zdot.y / dim_y, zdot.x / dim_x);
+ zdot = position(dim_x * cos(psi), dim_y * sin(psi));
+ if ((i % 2 == 0) && (i > 1))
+ ellipse_arc(cent, zpre, zdot, dim / 2, slt);
+ }
+}
+
+// output a dotted ellipse as a series of dots
+
+void common_output::dotted_ellipse(const position &cent, const distance &dim,
+ const line_type &lt)
+{
+ assert(lt.type == line_type::dotted);
+ double dim_x = dim.x / 2;
+ double dim_y = dim.y / 2;
+ line_type slt = lt;
+ slt.type = line_type::solid;
+ // we use an approximation to compute the ellipse length (found in:
+ // Bronstein, Semendjajew, Taschenbuch der Mathematik)
+ double lambda = (dim.x - dim.y) / (dim.x + dim.y);
+ double le = M_PI / 2 * (dim.x + dim.y)
+ * ((64 - 3 * lambda * lambda * lambda * lambda )
+ / (64 - 16 * lambda * lambda));
+ // for symmetry we make nmax a multiple of 4
+ int ndots = 4 * int(le / lt.dash_width / 4 + 0.5);
+ if (ndots < 4)
+ ndots = 4;
+ double l = 0;
+ position z = position(dim_x, 0);
+ int j = 0;
+ int jmax = int(10 / lt.dash_width);
+ for (int i = 1; i <= ndots; i++) {
+ position zold = z;
+ double lold = l;
+ double ld = i * le / ndots;
+ double dl = 1;
+ // find next position for fixed arc length
+ while (l < ld) {
+ j++;
+ lold = l;
+ zold = z;
+ double phi = j * 2 * M_PI / jmax;
+ z = position(dim_x * cos(phi), dim_y * sin(phi));
+ dl = hypot(z - zold);
+ l += dl;
+ }
+ // interpolate linearly between the last two points,
+ // using the length difference as the scaling factor
+ double delta = (ld - lold) / dl;
+ position zdot = zold + (z - zold) * delta;
+ // compute angle of new position on the affine circle
+ // and use it to get the exact value on the ellipse
+ double psi = atan2(zdot.y / dim_y, zdot.x / dim_x);
+ zdot = position(dim_x * cos(psi), dim_y * sin(psi));
+ dot(cent + zdot, slt);
+ }
+}
+
// return non-zero iff we can compute a center
int compute_arc_center(const position &start, const position &cent,
diff --git a/contrib/groff/src/preproc/pic/common.h b/contrib/groff/src/preproc/pic/common.h
index 90b65fa9d613..50238344d8a4 100644
--- a/contrib/groff/src/preproc/pic/common.h
+++ b/contrib/groff/src/preproc/pic/common.h
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 1993, 2003
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
class common_output : public output {
private:
@@ -33,8 +34,13 @@ private:
double gap_width, double *offsetp);
protected:
virtual void dot(const position &, const line_type &) = 0;
+ void ellipse_arc(const position &, const position &,
+ const position &, const distance &,
+ const line_type &);
void dashed_circle(const position &, double rad, const line_type &);
void dotted_circle(const position &, double rad, const line_type &);
+ void dashed_ellipse(const position &, const distance &, const line_type &);
+ void dotted_ellipse(const position &, const distance &, const line_type &);
void dashed_arc(const position &, const position &, const position &,
const line_type &);
void dotted_arc(const position &, const position &, const position &,
diff --git a/contrib/groff/src/preproc/pic/lex.cpp b/contrib/groff/src/preproc/pic/lex.cpp
index b8aa9ebcfae1..ceca36854648 100644
--- a/contrib/groff/src/preproc/pic/lex.cpp
+++ b/contrib/groff/src/preproc/pic/lex.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2003
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2003, 2004
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "pic.h"
#include "ptable.h"
@@ -1329,21 +1329,23 @@ void do_undef()
class for_input : public input {
char *var;
char *body;
+ double from;
double to;
int by_is_multiplicative;
double by;
const char *p;
int done_newline;
public:
- for_input(char *, double, int, double, char *);
+ for_input(char *, double, double, int, double, char *);
~for_input();
int get();
int peek();
};
-for_input::for_input(char *vr, double t, int bim, double b, char *bd)
-: var(vr), body(bd), to(t), by_is_multiplicative(bim), by(b), p(body),
- done_newline(0)
+for_input::for_input(char *vr, double f, double t,
+ int bim, double b, char *bd)
+: var(vr), body(bd), from(f), to(t), by_is_multiplicative(bim), by(b),
+ p(body), done_newline(0)
{
}
@@ -1374,7 +1376,8 @@ int for_input::get()
else
val += by;
define_variable(var, val);
- if (val > to) {
+ if ((from <= to && val > to)
+ || (from >= to && val < to)) {
p = 0;
return EOF;
}
@@ -1399,7 +1402,8 @@ int for_input::peek()
return EOF;
}
else {
- if (val + by > to)
+ if ((from <= to && val + by > to)
+ || (from >= to && val + by < to))
return EOF;
}
if (*body == '\0')
@@ -1411,8 +1415,12 @@ void do_for(char *var, double from, double to, int by_is_multiplicative,
double by, char *body)
{
define_variable(var, from);
- if (from <= to)
- input_stack::push(new for_input(var, to, by_is_multiplicative, by, body));
+ if ((by_is_multiplicative && by <= 0)
+ || (by > 0 && from > to)
+ || (by < 0 && from < to))
+ return;
+ input_stack::push(new for_input(var, from, to,
+ by_is_multiplicative, by, body));
}
diff --git a/contrib/groff/src/preproc/pic/main.cpp b/contrib/groff/src/preproc/pic/main.cpp
index 8788fa6d5a9b..0e05f77cd280 100644
--- a/contrib/groff/src/preproc/pic/main.cpp
+++ b/contrib/groff/src/preproc/pic/main.cpp
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "pic.h"
diff --git a/contrib/groff/src/preproc/pic/object.cpp b/contrib/groff/src/preproc/pic/object.cpp
index d5c0d6c06805..aefbd45e3940 100644
--- a/contrib/groff/src/preproc/pic/object.cpp
+++ b/contrib/groff/src/preproc/pic/object.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003
+/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "pic.h"
#include "ptable.h"
@@ -202,7 +202,7 @@ double operator*(const position &a, const position &b)
double hypot(const position &a)
{
- return hypot(a.x, a.y);
+ return groff_hypot(a.x, a.y);
}
struct arrow_head_type {
@@ -233,13 +233,14 @@ void draw_arrow(const position &pos, const distance &dir,
v[2] = pos + base - n;
// fill with outline color
out->set_color(outline_color_for_fill, outline_color_for_fill);
+ // make stroke thin to avoid arrow sticking
+ slt.thickness = 0.1;
out->polygon(v, 3, slt, 1);
}
else {
- position v[2];
- v[0] = pos;
- v[1] = pos + base + n;
- out->line(pos + base - n, v, 2, slt);
+ // use two line segments to avoid arrow sticking
+ out->line(pos + base - n, &pos, 1, slt);
+ out->line(pos + base + n, &pos, 1, slt);
}
}
@@ -716,9 +717,9 @@ void closed_object::set_fill(double f)
fill = f;
}
-void closed_object::set_fill_color(char *fill)
+void closed_object::set_fill_color(char *f)
{
- color_fill = strsave(fill);
+ color_fill = strsave(f);
}
class box_object : public closed_object {
@@ -1258,12 +1259,47 @@ void line_object::print()
if (lt.type == line_type::invisible)
return;
out->set_color(0, graphic_object::get_outline_color());
- out->line(strt, v, n, lt);
- if (arrow_at_start)
- draw_arrow(strt, strt-v[0], aht, lt, graphic_object::get_outline_color());
- if (arrow_at_end)
- draw_arrow(en, v[n-1] - (n > 1 ? v[n - 2] : strt), aht, lt,
- graphic_object::get_outline_color());
+ // shorten line length to avoid arrow sticking.
+ position sp = strt;
+ if (arrow_at_start) {
+ position base = v[0] - strt;
+ double hyp = hypot(base);
+ if (hyp == 0.0) {
+ error("cannot draw arrow on object with zero length");
+ return;
+ }
+ if (aht.solid && out->supports_filled_polygons()) {
+ base *= aht.height / hyp;
+ draw_arrow(strt, strt - v[0], aht, lt,
+ graphic_object::get_outline_color());
+ sp = strt + base;
+ } else {
+ base *= fabs(lt.thickness) / hyp / 72 / 4;
+ sp = strt + base;
+ draw_arrow(sp, sp - v[0], aht, lt,
+ graphic_object::get_outline_color());
+ }
+ }
+ if (arrow_at_end) {
+ position base = v[n-1] - (n > 1 ? v[n-2] : strt);
+ double hyp = hypot(base);
+ if (hyp == 0.0) {
+ error("cannot draw arrow on object with zero length");
+ return;
+ }
+ if (aht.solid && out->supports_filled_polygons()) {
+ base *= aht.height / hyp;
+ draw_arrow(en, v[n-1] - (n > 1 ? v[n-2] : strt), aht, lt,
+ graphic_object::get_outline_color());
+ v[n-1] = en - base;
+ } else {
+ base *= fabs(lt.thickness) / hyp / 72 / 4;
+ v[n-1] = en - base;
+ draw_arrow(v[n-1], v[n-1] - (n > 1 ? v[n-2] : strt), aht, lt,
+ graphic_object::get_outline_color());
+ }
+ }
+ out->line(sp, v, n, lt);
out->reset_color();
}
@@ -1328,12 +1364,47 @@ void spline_object::print()
if (lt.type == line_type::invisible)
return;
out->set_color(0, graphic_object::get_outline_color());
- out->spline(strt, v, n, lt);
- if (arrow_at_start)
- draw_arrow(strt, strt-v[0], aht, lt, graphic_object::get_outline_color());
- if (arrow_at_end)
- draw_arrow(en, v[n-1] - (n > 1 ? v[n - 2] : strt), aht, lt,
- graphic_object::get_outline_color());
+ // shorten line length for spline to avoid arrow sticking
+ position sp = strt;
+ if (arrow_at_start) {
+ position base = v[0] - strt;
+ double hyp = hypot(base);
+ if (hyp == 0.0) {
+ error("cannot draw arrow on object with zero length");
+ return;
+ }
+ if (aht.solid && out->supports_filled_polygons()) {
+ base *= aht.height / hyp;
+ draw_arrow(strt, strt - v[0], aht, lt,
+ graphic_object::get_outline_color());
+ sp = strt + base*0.1; // to reserve spline shape
+ } else {
+ base *= fabs(lt.thickness) / hyp / 72 / 4;
+ sp = strt + base;
+ draw_arrow(sp, sp - v[0], aht, lt,
+ graphic_object::get_outline_color());
+ }
+ }
+ if (arrow_at_end) {
+ position base = v[n-1] - (n > 1 ? v[n-2] : strt);
+ double hyp = hypot(base);
+ if (hyp == 0.0) {
+ error("cannot draw arrow on object with zero length");
+ return;
+ }
+ if (aht.solid && out->supports_filled_polygons()) {
+ base *= aht.height / hyp;
+ draw_arrow(en, v[n-1] - (n > 1 ? v[n-2] : strt), aht, lt,
+ graphic_object::get_outline_color());
+ v[n-1] = en - base*0.1; // to reserve spline shape
+ } else {
+ base *= fabs(lt.thickness) / hyp / 72 / 4;
+ v[n-1] = en - base;
+ draw_arrow(v[n-1], v[n-1] - (n > 1 ? v[n-2] : strt), aht, lt,
+ graphic_object::get_outline_color());
+ }
+ }
+ out->spline(sp, v, n, lt);
out->reset_color();
}
@@ -1542,22 +1613,70 @@ void arc_object::print()
if (lt.type == line_type::invisible)
return;
out->set_color(0, graphic_object::get_outline_color());
- if (clockwise)
- out->arc(en, cent, strt, lt);
- else
- out->arc(strt, cent, en, lt);
+ // handle arrow direction; make shorter line for arc
+ position sp, ep, b;
+ if (clockwise) {
+ sp = en;
+ ep = strt;
+ } else {
+ sp = strt;
+ ep = en;
+ }
if (arrow_at_start) {
- position c = cent - strt;
- draw_arrow(strt,
- (clockwise ? position(c.y, -c.x) : position(-c.y, c.x)),
- aht, lt, graphic_object::get_outline_color());
+ double theta = aht.height / rad;
+ if (clockwise)
+ theta = - theta;
+ b = strt - cent;
+ b = position(b.x*cos(theta) - b.y*sin(theta),
+ b.x*sin(theta) + b.y*cos(theta)) + cent;
+ if (clockwise)
+ ep = b;
+ else
+ sp = b;
+ if (aht.solid && out->supports_filled_polygons()) {
+ draw_arrow(strt, strt - b, aht, lt,
+ graphic_object::get_outline_color());
+ } else {
+ position v = b;
+ theta = fabs(lt.thickness) / 72 / 4 / rad;
+ if (clockwise)
+ theta = - theta;
+ b = strt - cent;
+ b = position(b.x*cos(theta) - b.y*sin(theta),
+ b.x*sin(theta) + b.y*cos(theta)) + cent;
+ draw_arrow(b, b - v, aht, lt,
+ graphic_object::get_outline_color());
+ out->line(b, &v, 1, lt);
+ }
}
if (arrow_at_end) {
- position e = en - cent;
- draw_arrow(en,
- (clockwise ? position(e.y, -e.x) : position(-e.y, e.x)),
- aht, lt, graphic_object::get_outline_color());
+ double theta = aht.height / rad;
+ if (!clockwise)
+ theta = - theta;
+ b = en - cent;
+ b = position(b.x*cos(theta) - b.y*sin(theta),
+ b.x*sin(theta) + b.y*cos(theta)) + cent;
+ if (clockwise)
+ sp = b;
+ else
+ ep = b;
+ if (aht.solid && out->supports_filled_polygons()) {
+ draw_arrow(en, en - b, aht, lt,
+ graphic_object::get_outline_color());
+ } else {
+ position v = b;
+ theta = fabs(lt.thickness) / 72 / 4 / rad;
+ if (!clockwise)
+ theta = - theta;
+ b = en - cent;
+ b = position(b.x*cos(theta) - b.y*sin(theta),
+ b.x*sin(theta) + b.y*cos(theta)) + cent;
+ draw_arrow(b, b - v, aht, lt,
+ graphic_object::get_outline_color());
+ out->line(b, &v, 1, lt);
+ }
}
+ out->arc(sp, cent, ep, lt);
out->reset_color();
}
@@ -1587,21 +1706,21 @@ void arc_object::update_bounding_box(bounding_box *p)
start_quad += 4.0;
while (end_quad <= start_quad)
end_quad += 4.0;
- double radius = max(hypot(start_offset), hypot(end_offset));
+ double r = max(hypot(start_offset), hypot(end_offset));
for (int q = int(start_quad) + 1; q < end_quad; q++) {
position offset;
switch (q % 4) {
case 0:
- offset.x = radius;
+ offset.x = r;
break;
case 1:
- offset.y = radius;
+ offset.y = r;
break;
case 2:
- offset.x = -radius;
+ offset.x = -r;
break;
case 3:
- offset.y = -radius;
+ offset.y = -r;
break;
}
p->encompass(cent + offset);
@@ -1753,7 +1872,7 @@ object *object_spec::make_object(position *curpos, direction *dirp)
obj->set_thickness(th);
if (flags & IS_OUTLINED)
obj->set_outline_color(outlined);
- if (flags & (IS_DEFAULT_FILLED|IS_FILLED)) {
+ if (flags & (IS_DEFAULT_FILLED | IS_FILLED)) {
if (flags & IS_SHADED)
obj->set_fill_color(shaded);
else {
diff --git a/contrib/groff/src/preproc/pic/object.h b/contrib/groff/src/preproc/pic/object.h
index 98937f933287..9f7f4bc33708 100644
--- a/contrib/groff/src/preproc/pic/object.h
+++ b/contrib/groff/src/preproc/pic/object.h
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
struct place;
@@ -163,9 +164,9 @@ struct segment {
segment(const position &, int, segment *);
};
-struct rectangle_object;
-struct graphic_object;
-struct linear_object;
+class rectangle_object;
+class graphic_object;
+class linear_object;
struct object_spec {
unsigned long flags;
diff --git a/contrib/groff/src/preproc/pic/output.h b/contrib/groff/src/preproc/pic/output.h
index a0a8331f883d..aa03e776bb00 100644
--- a/contrib/groff/src/preproc/pic/output.h
+++ b/contrib/groff/src/preproc/pic/output.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2001 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
struct line_type {
enum { invisible, solid, dotted, dashed } type;
diff --git a/contrib/groff/src/preproc/pic/pic.h b/contrib/groff/src/preproc/pic/pic.h
index 166e4e759a2b..e3b850a96ef0 100644
--- a/contrib/groff/src/preproc/pic/pic.h
+++ b/contrib/groff/src/preproc/pic/pic.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2003
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2003, 2005
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "lib.h"
@@ -25,12 +25,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stdlib.h>
#include <errno.h>
-#ifdef NEED_DECLARATION_HYPOT
-extern "C" {
- double hypot(double, double);
-}
-#endif /* NEED_DECLARATION_HYPOT */
-
#ifdef NEED_DECLARATION_RAND
#undef rand
extern "C" {
diff --git a/contrib/groff/src/preproc/pic/pic.man b/contrib/groff/src/preproc/pic/pic.man
index c12e93ab2b2c..c54cfbef5911 100644
--- a/contrib/groff/src/preproc/pic/pic.man
+++ b/contrib/groff/src/preproc/pic/pic.man
@@ -1,5 +1,5 @@
.ig
-Copyright (C) 1989-2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+Copyright (C) 1989-2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -322,6 +322,16 @@ then
.I variable
will instead be multiplied by
.IR expr3 .
+The value of
+.I expr3
+can be negative for the additive case;
+.I variable
+is then tested whether it is greater than or equal to
+.IR expr2 .
+For the multiplicative case,
+.I expr3
+must be greater than zero.
+If the constraints aren't met, the loop isn't executed.
.I X
can be any character not occurring in
.IR body .
@@ -362,6 +372,25 @@ This has a similar effect to a line beginning with
or
.BR \e ,
but allows the values of variables to be passed through.
+For example,
+.RS
+.IP
+.ft B
+.nf
+\&.PS
+x = 14
+command ".ds string x is " x "."
+\&.PE
+\e*[string]
+.ft
+.fi
+.RE
+.IP
+prints
+.RS
+.IP
+.B x is 14.
+.RE
.
.TP
\fBsh\fR \fIX\fR \fIcommand\fR \fIX\fR
@@ -522,7 +551,10 @@ print x " " y
.RE
.IP
prints
-.BR 5\ 3 .
+.RS
+.IP
+.B 5 3
+.RE
.
.LP
Arguments of the form
@@ -625,8 +657,10 @@ where
.I dir
is the current direction.
For example
-.IP
+.LP
+.RS
.B line 2i
+.RE
.LP
means draw a line 2\ inches long in the current direction.
The `i' (or `I') character is ignored; to use another measurement unit,
@@ -645,6 +679,7 @@ Initially these have values 8.5 and 11.
Scientific notation is allowed for numbers.
For example
.RS
+.LP
.B
x = 5e\-2
.RE
@@ -653,21 +688,25 @@ x = 5e\-2
Text attributes can be compounded.
For example,
.RS
+.LP
.B
"foo" above ljust
.RE
-is legal.
+.LP
+is valid.
.
.LP
There is no limit to the depth to which blocks can be examined.
For example,
.RS
+.LP
.B
[A: [B: [C: box ]]] with .A.B.C.sw at 1,2
.br
.B
circle at last [\^].A.B.C
.RE
+.LP
is acceptable.
.
.LP
@@ -675,8 +714,8 @@ Arcs now have compass points
determined by the circle of which the arc is a part.
.
.LP
-Circles and arcs can be dotted or dashed.
-In \*(tx mode splines can be dotted or dashed.
+Circles, ellipses, and arcs can be dotted or dashed.
+In \*(tx mode splines can be dotted or dashed also.
.
.LP
Boxes can have rounded corners.
@@ -805,7 +844,7 @@ Three additional modifiers are available to specify colored objects:
sets the color of the outline,
.B shaded
the fill color, and
-.BR colo [ u ] r [ ed ]
+.B colo\fR[\fPu\fR]\fPr\fR[\fPed\fR]
sets both.
All three keywords expect a suffix specifying the color, for example
.RS
@@ -974,6 +1013,7 @@ has built-in graphics conversion devices that are called with the option
.RE
.LP
Call
+.LP
.RS
.B gs --help
.RE
@@ -1052,7 +1092,7 @@ W. Richard Stevens - Examples of picMacros
.
Input characters that are invalid for
.B groff
-(ie those with
+(i.e., those with
.SM ASCII
code 0, or 013 octal, or between 015 and 037 octal, or between 0200 and 0237
octal) are rejected even in \*(tx mode.
diff --git a/contrib/groff/src/preproc/pic/pic.y b/contrib/groff/src/preproc/pic/pic.y
index 2ee1decf829f..83d0fe0222ad 100644
--- a/contrib/groff/src/preproc/pic/pic.y
+++ b/contrib/groff/src/preproc/pic/pic.y
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -16,14 +16,13 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
%{
#include "pic.h"
#include "ptable.h"
#include "object.h"
extern int delim_flag;
-extern void do_copy(const char *);
extern void copy_rest_thru(const char *, const char *);
extern void copy_file_thru(const char *, const char *, const char *);
extern void push_body(const char *);
@@ -1109,8 +1108,16 @@ sprintf_args:
else {
double *oldv = $$.v;
$$.maxv *= 2;
+#if 0
$$.v = new double[$$.maxv];
memcpy($$.v, oldv, $$.nv*sizeof(double));
+#else
+ // workaround for bug in Compaq C++ V6.5-033
+ // for Compaq Tru64 UNIX V5.1A (Rev. 1885)
+ double *foo = new double[$$.maxv];
+ memcpy(foo, oldv, $$.nv*sizeof(double));
+ $$.v = foo;
+#endif
a_delete oldv;
}
}
@@ -1128,6 +1135,12 @@ position:
$$.x = pos.x;
$$.y = pos.y;
}
+ | '(' place ')'
+ {
+ position pos = $2;
+ $$.x = pos.x;
+ $$.y = pos.y;
+ }
;
position_not_place:
@@ -1138,11 +1151,21 @@ position_not_place:
$$.x = $1.x + $3.x;
$$.y = $1.y + $3.y;
}
+ | '(' position '+' expr_pair ')'
+ {
+ $$.x = $2.x + $4.x;
+ $$.y = $2.y + $4.y;
+ }
| position '-' expr_pair
{
$$.x = $1.x - $3.x;
$$.y = $1.y - $3.y;
}
+ | '(' position '-' expr_pair ')'
+ {
+ $$.x = $2.x - $4.x;
+ $$.y = $2.y - $4.y;
+ }
| '(' position ',' position ')'
{
$$.x = $2.x;
@@ -1153,11 +1176,21 @@ position_not_place:
$$.x = (1.0 - $1)*$3.x + $1*$5.x;
$$.y = (1.0 - $1)*$3.y + $1*$5.y;
}
+ | '(' expr between position AND position ')'
+ {
+ $$.x = (1.0 - $2)*$4.x + $2*$6.x;
+ $$.y = (1.0 - $2)*$4.y + $2*$6.y;
+ }
| expr '<' position ',' position '>'
{
$$.x = (1.0 - $1)*$3.x + $1*$5.x;
$$.y = (1.0 - $1)*$3.y + $1*$5.y;
}
+ | '(' expr '<' position ',' position '>' ')'
+ {
+ $$.x = (1.0 - $2)*$4.x + $2*$6.x;
+ $$.y = (1.0 - $2)*$4.y + $2*$6.y;
+ }
;
between:
diff --git a/contrib/groff/src/preproc/pic/position.h b/contrib/groff/src/preproc/pic/position.h
index ab7d5469c006..c62e3e7bd0da 100644
--- a/contrib/groff/src/preproc/pic/position.h
+++ b/contrib/groff/src/preproc/pic/position.h
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
struct place;
struct position {
diff --git a/contrib/groff/src/preproc/pic/tex.cpp b/contrib/groff/src/preproc/pic/tex.cpp
index dbebe4618dd8..f997b868d687 100644
--- a/contrib/groff/src/preproc/pic/tex.cpp
+++ b/contrib/groff/src/preproc/pic/tex.cpp
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "pic.h"
@@ -324,12 +324,25 @@ void tex_output::ellipse(const position &cent, const distance &dim,
printf(" \\special{sh %.3f}%%\n", fill);
}
position c = transform(cent);
- printf(" \\special{%s %d %d %d %d 0 6.28319}%%\n",
- (lt.type == line_type::invisible ? "ia" : "ar"),
- milliinches(c.x),
- milliinches(c.y),
- milliinches(dim.x/(2.0*scale)),
- milliinches(dim.y/(2.0*scale)));
+ switch (lt.type) {
+ case line_type::solid:
+ case line_type::invisible:
+ printf(" \\special{%s %d %d %d %d 0 6.28319}%%\n",
+ (lt.type == line_type::invisible ? "ia" : "ar"),
+ milliinches(c.x),
+ milliinches(c.y),
+ milliinches(dim.x/(2.0*scale)),
+ milliinches(dim.y/(2.0*scale)));
+ break;
+ case line_type::dashed:
+ dashed_ellipse(cent, dim / scale, lt);
+ break;
+ case line_type::dotted:
+ dotted_ellipse(cent, dim / scale, lt);
+ break;
+ default:
+ assert(0);
+ }
}
void tex_output::command(const char *s, const char *, int)
diff --git a/contrib/groff/src/preproc/pic/troff.cpp b/contrib/groff/src/preproc/pic/troff.cpp
index cf8f5eee1938..688ca47b9c47 100644
--- a/contrib/groff/src/preproc/pic/troff.cpp
+++ b/contrib/groff/src/preproc/pic/troff.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2005
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "pic.h"
#include "common.h"
@@ -197,7 +197,11 @@ void simple_output::ellipse(const position &cent, const distance &dim,
case line_type::invisible:
break;
case line_type::dotted:
+ dotted_ellipse(cent, dim, lt);
+ break;
case line_type::dashed:
+ dashed_ellipse(cent, dim, lt);
+ break;
case line_type::solid:
simple_ellipse(0, cent, dim);
break;
@@ -320,7 +324,7 @@ void troff_output::simple_circle(int filled, const position &cent, double rad)
position c = transform(cent);
printf("\\h'%.3fi'"
"\\v'%.3fi'"
- "\\D'%c%.3fi'"
+ "\\D'%c %.3fi'"
"\n.sp -1\n",
c.x - rad/scale,
c.y,
@@ -334,7 +338,7 @@ void troff_output::simple_ellipse(int filled, const position &cent,
position c = transform(cent);
printf("\\h'%.3fi'"
"\\v'%.3fi'"
- "\\D'%c%.3fi %.3fi'"
+ "\\D'%c %.3fi %.3fi'"
"\n.sp -1\n",
c.x - dim.x/(2.0*scale),
c.y,
@@ -351,7 +355,7 @@ void troff_output::simple_arc(const position &start, const distance &cent,
distance ev = transform(end) - c;
printf("\\h'%.3fi'"
"\\v'%.3fi'"
- "\\D'a%.3fi %.3fi %.3fi %.3fi'"
+ "\\D'a %.3fi %.3fi %.3fi %.3fi'"
"\n.sp -1\n",
s.x, s.y, cv.x, cv.y, ev.x, ev.y);
}
@@ -362,7 +366,7 @@ void troff_output::simple_line(const position &start, const position &end)
distance ev = transform(end) - s;
printf("\\h'%.3fi'"
"\\v'%.3fi'"
- "\\D'l%.3fi %.3fi'"
+ "\\D'l %.3fi %.3fi'"
"\n.sp -1\n",
s.x, s.y, ev.x, ev.y);
}
@@ -374,7 +378,7 @@ void troff_output::simple_spline(const position &start,
printf("\\h'%.3fi'"
"\\v'%.3fi'",
pos.x, pos.y);
- fputs("\\D'~", stdout);
+ fputs("\\D'~ ", stdout);
for (int i = 0; i < n; i++) {
position temp = transform(v[i]);
distance d = temp - pos;
@@ -394,7 +398,7 @@ void troff_output::simple_polygon(int filled, const position *v, int n)
printf("\\h'%.3fi'"
"\\v'%.3fi'",
pos.x, pos.y);
- printf("\\D'%c", (filled ? 'P' : 'p'));
+ printf("\\D'%c ", (filled ? 'P' : 'p'));
for (int i = 1; i < n; i++) {
position temp = transform(v[i]);
distance d = temp - pos;
@@ -476,13 +480,15 @@ void troff_output::line_thickness(double p)
void troff_output::set_fill(double f)
{
if (driver_extension_flag && f != last_fill) {
- printf("\\D'Fg %.3f'\n.sp -1\n", 1.0 - f);
+ // \D'Fg ...' emits a node only in compatibility mode,
+ // thus we add a dummy node
+ printf("\\&\\D'Fg %.3f'\n.sp -1\n", 1.0 - f);
last_fill = f;
}
if (last_filled) {
free(last_filled);
last_filled = 0;
- printf("\\M[]\n.sp -1\n");
+ printf(".fcolor\n");
}
}
@@ -492,12 +498,14 @@ void troff_output::set_color(char *color_fill, char *color_outlined)
if (last_filled || last_outlined) {
reset_color();
}
+ // .gcolor and .fcolor emit a node in compatibility mode only,
+ // but that won't work anyway
if (color_fill) {
- printf("\\M[%s]\n.sp -1\n", color_fill);
+ printf(".fcolor %s\n", color_fill);
last_filled = strsave(color_fill);
}
if (color_outlined) {
- printf("\\m[%s]\n.sp -1\n", color_outlined);
+ printf(".gcolor %s\n", color_outlined);
last_outlined = strsave(color_outlined);
}
}
@@ -507,12 +515,12 @@ void troff_output::reset_color()
{
if (driver_extension_flag) {
if (last_filled) {
- printf("\\M[]\n.sp -1\n");
+ printf(".fcolor\n");
a_delete last_filled;
last_filled = 0;
}
if (last_outlined) {
- printf("\\m[]\n.sp -1\n");
+ printf(".gcolor\n");
a_delete last_outlined;
last_outlined = 0;
}
diff --git a/contrib/groff/src/preproc/refer/command.cpp b/contrib/groff/src/preproc/refer/command.cpp
index a7c6bfb89381..441f9534e154 100644
--- a/contrib/groff/src/preproc/refer/command.cpp
+++ b/contrib/groff/src/preproc/refer/command.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002
+/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2004
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "refer.h"
#include "refid.h"
@@ -632,7 +632,7 @@ a single field,
? means that the previous argument is optional, * means that the
previous argument can occur any number of times. */
-struct {
+struct S {
const char *name;
command_t func;
const char *arg_types;
diff --git a/contrib/groff/src/preproc/refer/command.h b/contrib/groff/src/preproc/refer/command.h
index c7085db6927b..f0472ac8b6a7 100644
--- a/contrib/groff/src/preproc/refer/command.h
+++ b/contrib/groff/src/preproc/refer/command.h
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
void process_commands(const char *file);
void process_commands(string &s, const char *file, int lineno);
diff --git a/contrib/groff/src/preproc/refer/label.y b/contrib/groff/src/preproc/refer/label.y
index 2648b98552dc..d76f95ef3c33 100644
--- a/contrib/groff/src/preproc/refer/label.y
+++ b/contrib/groff/src/preproc/refer/label.y
@@ -1,5 +1,6 @@
/* -*- C++ -*-
- Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1989, 1990, 1991, 1992, 2000, 2004
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
%{
@@ -406,6 +407,20 @@ const char *spec_ptr;
const char *spec_end;
const char *spec_cur;
+static char uppercase_array[] = {
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+ 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+ 'Y', 'Z',
+};
+
+static char lowercase_array[] = {
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
+ 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
+ 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
+ 'y', 'z',
+};
+
int yylex()
{
while (spec_ptr < spec_end && csspace(*spec_ptr))
@@ -589,7 +604,8 @@ static const char *format_serial(char c, int n)
d = 26;
n -= d;
n /= 26;
- *p++ = c + d - 1; // ASCII dependent
+ *p++ = c == 'a' ? lowercase_array[d - 1] :
+ uppercase_array[d - 1];
}
*p-- = 0;
// Reverse it.
@@ -970,8 +986,8 @@ label_info *lookup_label(const string &label)
label_table[i] = 0;
for (i = 0; i < old_size; i++)
if (old_table[i]) {
- unsigned h = hash_string(label_pool.contents() + old_table[i]->start,
- old_table[i]->length);
+ h = hash_string(label_pool.contents() + old_table[i]->start,
+ old_table[i]->length);
label_info **p;
for (p = label_table + (h % label_table_size);
*p != 0;
@@ -1073,10 +1089,10 @@ int same_author_last_name(const reference &r1, const reference &r2, int n)
{
const char *ae1;
const char *as1 = r1.get_sort_field(0, n, 0, &ae1);
- assert(as1 != 0);
const char *ae2;
const char *as2 = r2.get_sort_field(0, n, 0, &ae2);
- assert(as2 != 0);
+ if (!as1 && !as2) return 1; // they are the same
+ if (!as1 || !as2) return 0;
return ae1 - as1 == ae2 - as2 && memcmp(as1, as2, ae1 - as1) == 0;
}
@@ -1084,10 +1100,10 @@ int same_author_name(const reference &r1, const reference &r2, int n)
{
const char *ae1;
const char *as1 = r1.get_sort_field(0, n, -1, &ae1);
- assert(as1 != 0);
const char *ae2;
const char *as2 = r2.get_sort_field(0, n, -1, &ae2);
- assert(as2 != 0);
+ if (!as1 && !as2) return 1; // they are the same
+ if (!as1 || !as2) return 0;
return ae1 - as1 == ae2 - as2 && memcmp(as1, as2, ae1 - as1) == 0;
}
diff --git a/contrib/groff/src/preproc/refer/ref.cpp b/contrib/groff/src/preproc/refer/ref.cpp
index 9c040789a82f..59c69d52b616 100644
--- a/contrib/groff/src/preproc/refer/ref.cpp
+++ b/contrib/groff/src/preproc/refer/ref.cpp
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2003
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "refer.h"
#include "refid.h"
@@ -420,8 +421,7 @@ void reference::compute_sort_key()
sort_fields += '\0';
const char *sf = sort_fields.contents();
while (*sf != '\0') {
- if (sf > sort_fields)
- sort_key += SORT_SEP;
+ sort_key += SORT_SEP;
char f = *sf++;
int n = 1;
if (*sf == '+') {
diff --git a/contrib/groff/src/preproc/refer/ref.h b/contrib/groff/src/preproc/refer/ref.h
index 13a984a4c727..ffb81ac86986 100644
--- a/contrib/groff/src/preproc/refer/ref.h
+++ b/contrib/groff/src/preproc/refer/ref.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2005 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +16,15 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
+
+// declarations to avoid friend name injection problems
+int compare_reference(const reference &, const reference &);
+int same_reference(const reference &, const reference &);
+int same_year(const reference &, const reference &);
+int same_date(const reference &, const reference &);
+int same_author_last_name(const reference &, const reference &, int);
+int same_author_name(const reference &, const reference &, int);
struct label_info;
diff --git a/contrib/groff/src/preproc/refer/refer.cpp b/contrib/groff/src/preproc/refer/refer.cpp
index 33df35ca44fe..66afa4b385c3 100644
--- a/contrib/groff/src/preproc/refer/refer.cpp
+++ b/contrib/groff/src/preproc/refer/refer.cpp
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989-1992, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1989-1992, 2000, 2001, 2002, 2004
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "refer.h"
#include "refid.h"
@@ -938,6 +939,12 @@ int rcompare(const void *p1, const void *p2)
void output_references()
{
assert(accumulate);
+ if (!hash_table_size) {
+ error("nothing to reference (probably `bibliography' before `sort')");
+ accumulate = 0;
+ nreferences = 0;
+ return;
+ }
if (nreferences > 0) {
int j = 0;
int i;
diff --git a/contrib/groff/src/preproc/refer/refer.h b/contrib/groff/src/preproc/refer/refer.h
index e1e0c6dfe2d3..ac871cfae76d 100644
--- a/contrib/groff/src/preproc/refer/refer.h
+++ b/contrib/groff/src/preproc/refer/refer.h
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2004
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "lib.h"
@@ -72,6 +73,6 @@ void command_error(const char *,
const errarg &arg2 = empty_errarg,
const errarg &arg3 = empty_errarg);
-struct reference;
+class reference;
void compute_labels(reference **, int);
diff --git a/contrib/groff/src/preproc/refer/refer.man b/contrib/groff/src/preproc/refer/refer.man
index d39d85d8598f..0881657d4044 100644
--- a/contrib/groff/src/preproc/refer/refer.man
+++ b/contrib/groff/src/preproc/refer/refer.man
@@ -1,5 +1,6 @@
.ig
-Copyright (C) 1989-2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+Copyright (C) 1989-2000, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -16,23 +17,37 @@ versions, except that this permission notice may be included in
translations approved by the Free Software Foundation instead of in
the original English.
..
+.
+.
.de TQ
-.br
-.ns
-.TP \\$1
+. br
+. ns
+. TP \\$1
..
+.
+.
.\" Like TP, but if specified indent is more than half
.\" the current line-length - indent, use the default indent.
.de Tp
-.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
-.el .TP "\\$1"
+. ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
+. el .TP "\\$1"
+.
+.
..
.\" The BSD man macros can't handle " in arguments to font change macros,
.\" so use \(ts instead of ".
.tr \(ts"
+.
+.
.TH @G@REFER @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
+.
+.
+.
.SH NAME
@g@refer \- preprocess bibliographic references for groff
+.
+.
+.
.SH SYNOPSIS
.nr a \n(.j
.ad l
@@ -40,10 +55,12 @@ the original English.
.in +\w'\fB@g@refer 'u
.ti \niu
.B @g@refer
+.
.de OP
-.ie \\n(.$-1 .RI "[\ \fB\\$1\fP" "\\$2" "\ ]"
-.el .RB "[\ " "\\$1" "\ ]"
+. ie \\n(.$-1 .RI "[\ \fB\\$1\fP" "\\$2" "\ ]"
+. el .RB "[\ " "\\$1" "\ ]"
..
+.
.OP \-benvCPRS
.OP \-a n
.OP \-c fields
@@ -51,16 +68,20 @@ the original English.
.OP \-i fields
.OP \-k field
.OP \-l m,n
-.OP \-p filename
+.OP \-p \%filename
.OP \-s fields
.OP \-t n
.OP \-B field.macro
-.RI [\ filename \|.\|.\|.\ ]
+.RI [\ \%filename \|.\|.\|.\ ]
.br
.ad \na
-.PP
+.
+.LP
It is possible to have whitespace between a command line option and its
parameter.
+.
+.
+.
.SH DESCRIPTION
This file documents the GNU version of
.BR refer ,
@@ -72,13 +93,14 @@ to the standard output,
except that lines between
.B .[
and
-.B .]
+.B .]\&
are interpreted as citations,
and lines between
.B .R1
and
.B .R2
are interpreted as commands about how citations are to be processed.
+.
.LP
Each citation specifies a reference.
The citation can specify a reference that is contained in
@@ -87,6 +109,7 @@ that only that reference contains.
Alternatively it can specify a reference by supplying a database
record in the citation.
A combination of these alternatives is also possible.
+.
.LP
For each citation,
.B refer
@@ -111,14 +134,17 @@ or the references may be accumulated,
and the commands output at some later point.
If the references are accumulated, then multiple citations of the same
reference will produce a single formatted reference.
+.
.LP
The interpretation of lines between
.B .R1
and
.B .R2
-as commands is a new feature of GNU refer.
+as commands is a new feature of GNU
+.BR refer .
Documents making use of this feature can still be processed by
Unix refer just by adding the lines
+.
.RS
.LP
.nf
@@ -129,6 +155,7 @@ Unix refer just by adding the lines
.ft
.fi
.RE
+.
to the beginning of the document.
This will cause
.B troff
@@ -139,6 +166,7 @@ and
The effect of some commands can also be achieved by options.
These options are supported mainly for compatibility with Unix refer.
It is usually more convenient to use commands.
+.
.LP
.B refer
generates
@@ -154,110 +182,145 @@ so that filenames and line numbers in the messages and
lines that it produces will be accurate even if the input has been
preprocessed by a command such as
.BR @g@soelim (@MAN1EXT@).
+.
+.
+.
.SH OPTIONS
+.
.LP
Most options are equivalent to commands
(for a description of these commands see the
.B Commands
subsection):
+.
+.nr a \n(.j
+.ad l
.TP
.B \-b
-.B
-no-label-in-text; no-label-in-reference
+.B "no-label-in-text; no-label-in-reference"
+.
.TP
.B \-e
.B accumulate
+.
.TP
.B \-n
.B no-default-database
+.
.TP
.B \-C
.B compatible
+.
.TP
.B \-P
.B move-punctuation
+.
.TP
.B \-S
.B
-label "(A.n|Q) ', ' (D.y|D)"; bracket-label " (" ) "; "
+label\ "(A.n|Q)\ ',\ '\ (D.y|D)"; \%bracket-label\ "\ ("\ )\ ";\ "
+.
.TP
.BI \-a n
.B reverse
.BI A n
+.
.TP
.BI \-c fields
.B capitalize
.I fields
+.
.TP
.BI \-f n
.B label
.BI % n
+.
.TP
.BI \-i fields
.B search-ignore
.I fields
+.
.TP
.B \-k
.B label
.B L\(ti%a
+.
.TP
.BI \-k field
.B label
.IB field \(ti%a
+.
.TP
.B \-l
.B label
.BI A.nD.y%a
+.
.TP
.BI \-l m
.B label
.BI A.n+ m D.y%a
+.
.TP
.BI \-l, n
.B label
.BI A.nD.y\- n %a
+.
.TP
.BI \-l m , n
.B label
.BI A.n+ m D.y\- n %a
+.
.TP
.BI \-p filename
.B database
.I filename
+.
.TP
.BI \-s spec
.B sort
.I spec
+.
.TP
.BI \-t n
.B search-truncate
.I n
+.ad \na
+.
.LP
These options are equivalent to the following commands with the
addition that the filenames specified on the command line are
processed as if they were arguments to the
.B bibliography
command instead of in the normal way:
+.
.TP
.B \-B
-.B
-annotate X AP; no-label-in-reference
+.B "annotate X AP; no-label-in-reference"
+.
.TP
.BI \-B field . macro
.B annotate
.I field
.IB macro ;
.B no-label-in-reference
+.
.LP
The following options have no equivalent commands:
+.
.TP
.B \-v
Print the version number.
+.
.TP
.B \-R
Don't recognize lines beginning with
.BR .R1 / .R2 .
+.
+.
+.
.SH USAGE
+.
+.
.SS Bibliographic databases
The bibliographic database is a text file consisting of records
separated by one or more blank lines.
@@ -272,11 +335,12 @@ The name of the field should be followed by exactly one space,
and then by the contents of the field.
Empty fields are ignored.
The conventional meaning of each field is as follows:
+.
.TP
.B A
The name of an author.
If the name contains a title such as
-.B Jr.
+.B Jr.\&
at the end,
it should be separated from the last name by a comma.
There can be multiple occurrences of the
@@ -285,15 +349,18 @@ field.
The order is significant.
It is a good idea always to supply an
.B A
-field or a
+field or a
.B Q
field.
+.
.TP
.B B
For an article that is part of a book, the title of the book.
+.
.TP
.B C
The place (city) of publication.
+.
.TP
.B D
The date of publication.
@@ -308,6 +375,7 @@ if the date is unknown, a value such as
or
.B unknown
can be used.
+.
.TP
.B E
For an article that is part of a book, the name of an editor of the book.
@@ -319,33 +387,42 @@ fields and
or
.B ,\ (eds)
should be appended to the last author.
+.
.TP
.B G
US Government ordering number.
+.
.TP
.B I
The publisher (issuer).
+.
.TP
.B J
For an article in a journal, the name of the journal.
+.
.TP
.B K
Keywords to be used for searching.
+.
.TP
.B L
Label.
+.
.TP
.B N
Journal issue number.
+.
.TP
.B O
Other information.
This is usually printed at the end of the reference.
+.
.TP
.B P
Page number.
A range of pages can be specified as
.IB m \- n\fR.
+.
.TP
.B Q
The name of the author, if the author is not a person.
@@ -355,23 +432,29 @@ fields.
There can only be one
.B Q
field.
+.
.TP
.B R
Technical report number.
+.
.TP
.B S
Series name.
+.
.TP
.B T
Title.
For an article in a book or journal,
this should be the title of the article.
+.
.TP
.B V
Volume number of the journal or book.
+.
.TP
.B X
Annotation.
+.
.LP
For all fields except
.B A
@@ -379,6 +462,7 @@ and
.BR E ,
if there is more than one occurrence of a particular field in a record,
only the last such field will be used.
+.
.LP
If accent strings are used, they should follow the character to be accented.
This means that the
@@ -390,18 +474,21 @@ Accent strings should not be quoted:
use one
.B \e
rather than two.
+.
+.
.SS Citations
The format of a citation is
+.
.RS
.BI .[ opening-text
.br
-.I
-flags keywords
+.I "flags keywords"
.br
.I fields
.br
.BI .] closing-text
.RE
+.
.LP
The
.IR opening-text ,
@@ -414,6 +501,7 @@ Only one of the
and
.I fields
components need be specified.
+.
.LP
The
.I keywords
@@ -421,6 +509,7 @@ component says to search the bibliographic databases for a reference
that contains all the words in
.IR keywords .
It is an error if more than one reference if found.
+.
.LP
The
.I fields
@@ -432,6 +521,7 @@ component is non-empty,
then additional fields should be specified only on the first
occasion that a particular reference is cited,
and will apply to all citations of that reference.
+.
.LP
The
.I opening-text
@@ -451,6 +541,7 @@ and
.B ]
flags.
Note that leading and trailing spaces are significant for these components.
+.
.LP
The
.I flags
@@ -460,6 +551,7 @@ of this particular citation.
Unix refer will treat these flags as part of the keywords and
so will ignore them since they are non-alphanumeric.
The following flags are currently recognized:
+.
.TP
.B #
This says to use the label specified by the
@@ -474,6 +566,7 @@ and consists of only the date and possibly a disambiguating letter;
the
.B #
is supposed to be suggestive of a numeric type of label.
+.
.TP
.B [
Precede
@@ -481,6 +574,7 @@ Precede
with the first string specified in the
.B bracket-label
command.
+.
.TP
.B ]
Follow
@@ -488,6 +582,7 @@ Follow
with the second string specified in the
.B bracket-label
command.
+.
.LP
One advantages of using the
.B [
@@ -503,6 +598,7 @@ you can change the style of bracket used in the document just by changing the
command.
Another advantage is that sorting and merging of citations
will not necessarily be inhibited if the flags are used.
+.
.LP
If a label is to be inserted into the text,
it will be attached to the line preceding the
@@ -511,6 +607,7 @@ line.
If there is no such line, then an extra line will be inserted before the
.B .[
line and a warning will be given.
+.
.LP
There is no special notation for making a citation to multiple references.
Just use a sequence of citations, one for each reference.
@@ -546,6 +643,8 @@ is non-empty.
(If you wish to prevent this just make the first citation's
.I closing-text
.BR \e& .)
+.
+.
.SS Commands
Commands are contained between lines starting with
.B .R1
@@ -564,8 +663,9 @@ nor
lines,
nor anything between them
is output.
+.
.LP
-Commands are separated by newlines or
+Commands are separated by newlines or
.BR ; s.
.B #
introduces a comment that extends to the end of the line
@@ -597,6 +697,7 @@ A line can be continued by ending it with
.BR \e ;
this works everywhere except after a
.BR # .
+.
.LP
.ds n \fR*
Each command
@@ -609,6 +710,7 @@ For example, the
.B no-sort
command specifies that references should not be sorted.
The negative commands take no arguments.
+.
.LP
In the following description each argument must be a single word;
.I field
@@ -623,6 +725,7 @@ are used for a non-negative numbers;
is used for an arbitrary string;
.I filename
is used for the name of a file.
+.
.Tp \w'\fBabbreviate-label-ranges'u+2n
.BI abbreviate\*n\ fields\ string1\ string2\ string3\ string4
Abbreviate the first names of
@@ -647,6 +750,7 @@ No attempt is made to handle any ambiguities that might
result from abbreviation.
Names are abbreviated before sorting and before
label construction.
+.
.TP
.BI abbreviate-label-ranges\*n\ string
Three or more adjacent labels that refer to consecutive references
@@ -659,12 +763,14 @@ If
.I string
is omitted it defaults to
.BR \- .
+.
.TP
.B accumulate\*n
Accumulate references instead of writing out each reference
as it is encountered.
Accumulated references will be written out whenever a reference
of the form
+.
.RS
.IP
.B .[
@@ -672,6 +778,7 @@ of the form
.B $LIST$
.br
.B .]
+.
.LP
is encountered,
after all input files hve been processed,
@@ -679,14 +786,17 @@ and whenever
.B .R1
line is recognized.
.RE
+.
.TP
.BI annotate\*n\ field\ string
.I field
is an annotation;
print it at the end of the reference as a paragraph preceded by the line
+.
.RS
.IP
.BI . string
+.
.LP
If
.I macro
@@ -698,9 +808,10 @@ is also omitted it will default to
.BR X .
Only one field can be an annotation.
.RE
+.
.TP
-.BI articles\ string \fR\|.\|.\|.
-.IR string \|.\|.\|.
+.BI articles\ string \fR\|.\|.\|.
+.IR string \|.\|.\|.\&
are definite or indefinite articles, and should be ignored at the beginning of
.B T
fields when sorting.
@@ -709,11 +820,16 @@ Initially,
.B a
and
.B an
-are recognized as articles.
+are recognized as articles.
+.
.TP
.BI bibliography\ filename \fR\|.\|.\|.
Write out all the references contained in the bibliographic databases
.IR filename \|.\|.\|.
+This command should come last in a
+.BR .R1 / .R2
+block.
+.
.TP
.BI bracket-label\ string1\ string2\ string3
In the text, bracket each label
@@ -728,16 +844,19 @@ immediately followed by
will be turned into
.IR string3 .
The default behaviour is
+.
.RS
.IP
.B
bracket-label \e*([. \e*(.] ", "
.RE
+.
.TP
.BI capitalize\ fields
Convert
.I fields
to caps and small caps.
+.
.TP
.B compatible\*n
Recognize
@@ -745,6 +864,7 @@ Recognize
and
.B .R2
even when followed by a character other than space or newline.
+.
.TP
.BI database\ filename \fR\|.\|.\|.
Search the bibliographic databases
@@ -757,6 +877,7 @@ created by
.BR @g@indxbib (@MAN1EXT@)
exists, then it will be searched instead;
each index can cover multiple databases.
+.
.TP
.BI date-as-label\*n\ string
.I string
@@ -775,26 +896,30 @@ In most cases you should also use the
.B no-label-in-reference
command.
For example,
+.
.RS
.IP
-.B
-date-as-label D.+yD.y%a*D.-y
+.B "date-as-label D.+yD.y%a*D.-y"
+.
.LP
would attach a disambiguating letter to the year part of the
.B D
field in the reference.
.RE
+.
.TP
.B default-database\*n
The default database should be searched.
This is the default behaviour, so the negative version of
this command is more useful.
-refer determines whether the default database should be searched
+.B refer
+determines whether the default database should be searched
on the first occasion that it needs to do a search.
Thus a
.B no-default-database
command must be given before then,
in order to be effective.
+.
.TP
.BI discard\*n\ fields
When the reference is read,
@@ -807,11 +932,11 @@ Initially,
.I fields
are
.BR XYZ .
+.
.TP
.BI et-al\*n\ string\ m\ n
Control use of
-.B
-et al
+.B "et al"
in the evaluation of
.B @
expressions in label expressions.
@@ -833,16 +958,19 @@ and
is not less than
.IR n .
The default behaviour is
+.
.RS
.IP
.B
et-al " et al" 2 3
.RE
+.
.TP
.BI include\ filename
Include
.I filename
and interpret the contents as commands.
+.
.TP
.BI join-authors\ string1\ string2\ string3
This says how authors should be joined together.
@@ -863,13 +991,16 @@ if
is also omitted it will also default to
.IR string1 .
For example,
+.
.RS
.IP
.B
join-authors " and " ", " ", and "
+.
.LP
will restore the default method for joining authors.
.RE
+.
.TP
.B label-in-reference\*n
When outputting the reference,
@@ -878,6 +1009,7 @@ define the string
to be the reference's label.
This is the default behaviour; so the negative version
of this command is more useful.
+.
.TP
.B label-in-text\*n
For each reference output a label in the text.
@@ -886,10 +1018,12 @@ The label will be separated from the surrounding text as described in the
command.
This is the default behaviour; so the negative version
of this command is more useful.
+.
.TP
.BI label\ string
.I string
is a label expression describing how to label each reference.
+.
.TP
.BI separate-label-second-parts\ string
When merging two-part labels, separate the second part of the second
@@ -898,11 +1032,13 @@ label from the first label with
See the description of the
.B <>
label expression.
+.
.TP
.B move-punctuation\*n
In the text, move any punctuation at the end of line past the label.
It is usually a good idea to give this command unless you are using
superscripted numbers as labels.
+.
.TP
.BI reverse\*n\ string
Reverse the fields whose names
@@ -911,6 +1047,7 @@ are in
Each field name can be followed by a number which says
how many such fields should be reversed.
If no number is given for a field, all such fields will be reversed.
+.
.TP
.BI search-ignore\*n\ fields
While searching for keys in databases for which no index exists,
@@ -919,6 +1056,7 @@ ignore the contents of
Initially, fields
.B XYZ
are ignored.
+.
.TP
.BI search-truncate\*n\ n
Only require the first
@@ -930,7 +1068,8 @@ words in the database are truncated to the maximum of
and the length of the key.
Initially
.I n
-is 6.
+is\ 6.
+.
.TP
.BI short-label\*n\ string
.I string
@@ -946,6 +1085,7 @@ The
.B short-label
command will typically be used to specify a label containing just
a date and possibly a disambiguating letter.
+.
.TP
.BI sort\*n\ string
Sort references according to
@@ -956,14 +1096,14 @@ should be a list of field names, each followed by a number,
indicating how many fields with the name should be used for sorting.
.B +
can be used to indicate that all the fields with the name should be used.
-Also
-.B .
+Also
+.B .\&
can be used to indicate the references should be sorted using the
(tentative) label.
(The
-.B
-Label expressions
+.B "Label expressions"
subsection describes the concept of a tentative label.)
+.
.TP
.B sort-adjacent-labels\*n
Sort labels that are adjacent in the text according to their
@@ -975,13 +1115,15 @@ or if the label expression contains a
.B <>
expression.
This will have no effect unless references are being accumulated.
+.
+.
.SS Label expressions
+.
.LP
-Label expressions can be evaluated both normally and tentatively.
-The result of normal evaluation is used for output.
+Label expressions can be evaluated both normally and tentatively.
+The result of normal evaluation is used for output.
The result of tentative evaluation, called the
-.I
-tentative label,
+.IR "tentative label" ,
is used to gather the information
that normal evaluation needs to disambiguate the label.
Label expressions specified by the
@@ -995,9 +1137,10 @@ of expression other than
.BR * ,
and
.B %
-expressions.
+expressions.
The description below applies to normal evaluation,
-except where otherwise specified.
+except where otherwise specified.
+.
.TP
.I field
.TQ
@@ -1005,15 +1148,17 @@ except where otherwise specified.
The
.IR n -th
part of
-.IR field .
+.IR field .
If
.I n
-is omitted, it defaults to 1.
+is omitted, it defaults to\ 1.
+.
.TP
.BI ' string '
The characters in
.I string
-literally.
+literally.
+.
.TP
.B @
All the authors joined as specified by the
@@ -1056,6 +1201,7 @@ met before an initial subsequence can be used.
tentatively evaluates to a canonical representation of the authors,
such that authors that compare equally for sorting purpose
will have the same representation.
+.
.TP
.BI % n
.TQ
@@ -1068,10 +1214,11 @@ will have the same representation.
.B %I
The serial number of the reference formatted according to the character
following the
-.BR % .
-The serial number of a reference is 1 plus the number of earlier references
+.BR % .
+The serial number of a reference is\ 1 plus the number of earlier references
with same tentative label as this reference.
These expressions tentatively evaluate to an empty string.
+.
.TP
.IB expr *
If there is another reference with the same tentative label as
@@ -1079,6 +1226,7 @@ this reference, then
.IR expr ,
otherwise an empty string.
It tentatively evaluates to an empty string.
+.
.TP
.IB expr + n
.TQ
@@ -1094,22 +1242,27 @@ Troff special characters (such as
.BR \e('a )
count as a single letter.
Accent strings are retained but do not count towards the total.
+.
.TP
.IB expr .l
.I expr
-converted to lowercase.
+converted to lowercase.
+.
.TP
.IB expr .u
.I expr
-converted to uppercase.
+converted to uppercase.
+.
.TP
.IB expr .c
.I expr
-converted to caps and small caps.
+converted to caps and small caps.
+.
.TP
.IB expr .r
.I expr
reversed so that the last name is first.
+.
.TP
.IB expr .a
.I expr
@@ -1121,10 +1274,12 @@ Thus
.B .a
is useful only when you want a field to be abbreviated in a label
but not in a reference.
+.
.TP
.IB expr .y
The year part of
-.IR expr .
+.IR expr .
+.
.TP
.IB expr .+y
The part of
@@ -1132,6 +1287,7 @@ The part of
before the year, or the whole of
.I expr
if it does not contain a year.
+.
.TP
.IB expr .\-y
The part of
@@ -1139,10 +1295,12 @@ The part of
after the year, or an empty string if
.I expr
does not contain a year.
+.
.TP
.IB expr .n
The last name part of
-.IR expr .
+.IR expr .
+.
.TP
.IB expr1 \(ti expr2
.I expr1
@@ -1151,13 +1309,15 @@ except that if the last character of
is
.B \-
then it will be replaced by
-.IR expr2 .
+.IR expr2 .
+.
.TP
.I expr1\ expr2
The concatenation of
.I expr1
and
-.IR expr2 .
+.IR expr2 .
+.
.TP
.IB expr1 | expr2
If
@@ -1165,7 +1325,8 @@ If
is non-empty then
.I expr1
otherwise
-.IR expr2 .
+.IR expr2 .
+.
.TP
.IB expr1 & expr2
If
@@ -1174,6 +1335,7 @@ is non-empty
then
.I expr2
otherwise an empty string.
+.
.TP
.IB expr1 ? expr2 : expr3
If
@@ -1182,7 +1344,8 @@ is non-empty
then
.I expr2
otherwise
-.IR expr3 .
+.IR expr3 .
+.
.TP
.BI < expr >
The label is in two parts, which are separated by
@@ -1198,11 +1361,13 @@ Note that it is permissible for the first part to be empty;
this maybe desirable for expressions used in the
.B short-label
command.
+.
.TP
.BI ( expr )
The same as
.IR expr .
Used for grouping.
+.
.LP
The above expressions are listed in order of precedence
(highest first);
@@ -1210,6 +1375,8 @@ The above expressions are listed in order of precedence
and
.B |
have the same precedence.
+.
+.
.SS Macro interface
Each reference starts with a call to the macro
.BR ]- .
@@ -1227,7 +1394,7 @@ corresponds to field
.IR X .
The number register
.B [P
-is set to 1 if the
+is set to\ 1 if the
.B P
field contains a range of pages.
The
@@ -1235,7 +1402,7 @@ The
.B [A
and
.B [O
-number registers are set to 1 according as the
+number registers are set to\ 1 according as the
.BR T ,
.B A
and
@@ -1244,7 +1411,7 @@ fields end with one of the characters
.BR .?! .
The
.B [E
-number register will be set to 1 if the
+number register will be set to\ 1 if the
.B [E
string contains more than one name.
The reference is followed by a call to the
@@ -1254,19 +1421,19 @@ The first argument to this macro gives a number representing
the type of the reference.
If a reference contains a
.B J
-field, it will be classified as type 1,
+field, it will be classified as type\ 1,
otherwise if it contains a
.B B
-field, it will type 3,
+field, it will type\ 3,
otherwise if it contains a
.B G
or
.B R
-field it will be type 4,
+field it will be type\ 4,
otherwise if contains a
.B I
-field it will be type 2,
-otherwise it will be type 0.
+field it will be type\ 2,
+otherwise it will be type\ 0.
The second argument is a symbolic name for the type:
.BR other ,
.BR journal-article ,
@@ -1282,22 +1449,37 @@ command are preceded by a call to the
macro and followed by a call to the
.B ]>
macro.
+.
+.
+.
.SH FILES
+.
.Tp \w'\fB@DEFAULT_INDEX@'u+2n
.B @DEFAULT_INDEX@
Default database.
+.
.TP
.IB file @INDEX_SUFFIX@
Index files.
+.
+.
+.
.SH ENVIRONMENT
+.
.Tp \w'\fBREFER'u+2n
.B REFER
If set, overrides the default database.
+.
+.
+.
.SH "SEE ALSO"
.BR @g@indxbib (@MAN1EXT@),
.BR @g@lookbib (@MAN1EXT@),
.BR lkbib (@MAN1EXT@)
.br
+.
+.
+.
.SH BUGS
In label expressions,
.B <>
diff --git a/contrib/groff/src/preproc/refer/token.cpp b/contrib/groff/src/preproc/refer/token.cpp
index e9fac5df3fa2..1eb30062f8a3 100644
--- a/contrib/groff/src/preproc/refer/token.cpp
+++ b/contrib/groff/src/preproc/refer/token.cpp
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "refer.h"
#include "token.h"
diff --git a/contrib/groff/src/preproc/refer/token.h b/contrib/groff/src/preproc/refer/token.h
index 6da430d6abad..7d3404942fa7 100644
--- a/contrib/groff/src/preproc/refer/token.h
+++ b/contrib/groff/src/preproc/refer/token.h
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
enum token_type {
TOKEN_OTHER,
diff --git a/contrib/groff/src/preproc/soelim/Makefile.sub b/contrib/groff/src/preproc/soelim/Makefile.sub
index a43dfc289f2e..2e15c0086e82 100644
--- a/contrib/groff/src/preproc/soelim/Makefile.sub
+++ b/contrib/groff/src/preproc/soelim/Makefile.sub
@@ -1,6 +1,7 @@
PROG=soelim$(EXEEXT)
MAN1=soelim.n
XLIBS=$(LIBGROFF)
+MLIB=$(LIBM)
OBJS=soelim.$(OBJEXT)
CCSRCS=$(srcdir)/soelim.cpp
NAMEPREFIX=$(g)
diff --git a/contrib/groff/src/preproc/soelim/soelim.cpp b/contrib/groff/src/preproc/soelim/soelim.cpp
index 96ad6dd16445..235dfe664430 100644
--- a/contrib/groff/src/preproc/soelim/soelim.cpp
+++ b/contrib/groff/src/preproc/soelim/soelim.cpp
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989-1992, 2000, 2001, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1989-1992, 2000, 2001, 2003, 2004, 2005
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -16,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "lib.h"
@@ -28,38 +29,20 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "error.h"
#include "stringclass.h"
#include "nonposix.h"
+#include "searchpath.h"
-static size_t include_list_length;
-static const char **include_list;
+// The include search path initially contains only the current directory.
+static search_path include_search_path(0, 0, 0, 1);
int compatible_flag = 0;
int raw_flag = 0;
int tex_flag = 0;
-extern int interpret_lf_args(const char *);
extern "C" const char *Version_string;
int do_file(const char *filename);
-static void
-include_path_append(const char *path)
-{
- ++include_list_length;
- size_t nbytes = include_list_length * sizeof(char *);
- if (include_list)
- include_list = (const char **)realloc((void *)include_list, nbytes);
- else
- include_list = (const char **)malloc(nbytes);
- if (include_list == NULL)
- {
- fprintf(stderr, "%s: out of memory\n", program_name);
- exit(2);
- }
- include_list[include_list_length - 1] = path;
-}
-
-
void usage(FILE *stream)
{
fprintf(stream, "usage: %s [ -Crtv ] [ -I file ] [ files ]\n", program_name);
@@ -68,7 +51,6 @@ void usage(FILE *stream)
int main(int argc, char **argv)
{
program_name = argv[0];
- include_path_append(".");
int opt;
static const struct option long_options[] = {
{ "help", no_argument, 0, CHAR_MAX + 1 },
@@ -87,7 +69,7 @@ int main(int argc, char **argv)
compatible_flag = 1;
break;
case 'I':
- include_path_append(optarg);
+ include_search_path.command_line_dir(optarg);
break;
case 'r':
raw_flag = 1;
@@ -172,49 +154,16 @@ void do_so(const char *line)
int do_file(const char *filename)
{
- FILE *fp;
- string whole_filename;
- if (strcmp(filename, "-") == 0) {
- fp = stdin;
- whole_filename = filename;
- whole_filename += '\0';
- }
- else if (IS_ABSOLUTE(filename)) {
- whole_filename = filename;
- whole_filename += '\0';
- errno = 0;
- fp = fopen(filename, "r");
- if (fp == 0) {
- error("can't open `%1': %2", filename, strerror(errno));
- return 0;
- }
- }
- else {
- size_t j;
- for (j = 0; j < include_list_length; ++j)
- {
- const char *path = include_list[j];
- if (0 == strcmp(path, "."))
- whole_filename = filename;
- else
- whole_filename = string(path) + "/" + filename;
- whole_filename += '\0';
- errno = 0;
- fp = fopen(whole_filename.contents(), "r");
- if (fp != 0)
- break;
- if (errno != ENOENT) {
- error("can't open `%1': %2",
- whole_filename.contents(), strerror(errno));
- return 0;
- }
- }
- if (j >= include_list_length)
- {
- errno = ENOENT;
- error("can't open `%1': %2", filename, strerror(errno));
- return 0;
- }
+ char *file_name_in_path = 0;
+ FILE *fp = include_search_path.open_file_cautious(filename,
+ &file_name_in_path);
+ int err = errno;
+ string whole_filename(file_name_in_path ? file_name_in_path : filename);
+ whole_filename += '\0';
+ a_delete file_name_in_path;
+ if (fp == 0) {
+ error("can't open `%1': %2", whole_filename.contents(), strerror(err));
+ return 0;
}
current_filename = whole_filename.contents();
current_lineno = 1;
diff --git a/contrib/groff/src/preproc/soelim/soelim.man b/contrib/groff/src/preproc/soelim/soelim.man
index 7663e3bff532..fb17e3644fca 100644
--- a/contrib/groff/src/preproc/soelim/soelim.man
+++ b/contrib/groff/src/preproc/soelim/soelim.man
@@ -1,5 +1,6 @@
+'\" p
.ig
-Copyright (C) 1989-2000, 2001, 2003 Free Software Foundation, Inc.
+Copyright (C) 1989-2000, 2001, 2003, 2004 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -16,6 +17,9 @@ versions, except that this permission notice may be included in
translations approved by the Free Software Foundation instead of in
the original English.
..
+.
+.mso pic.tmac
+.
.TH @G@SOELIM @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
.
.SH NAME
@@ -80,7 +84,7 @@ even when followed by a character other than space or newline.
This option may be used to specify a directory to search for
files (both those on the command line and those named in
.B \&.so
-lines).
+requests).
The current directory is always searched first.
This option may be specified more than once,
the directories will be searched in the order specified.
@@ -99,6 +103,111 @@ the current file and line number.
.B \-v
Print the version number.
.
+.SH USAGE
+The normal processing sequence of groff is this:
+.
+.PP
+.ie t \{\
+.PS
+box invisible width 0.5 height 0.4 "input" "file";
+move to last box .bottom;
+down;
+arrow 0.3;
+box invisible width 0.8 height 0.2 "preprocessor";
+move to last box .right
+right;
+arrow 0.3;
+A: box invisible width 0.35 height 0.2 "troff";
+move to last box .top;
+up;
+move 0.3;
+box invisible width 0.6 height 0.4 "sourced" "file";
+line <- up 0.3 from A.top;
+move to A.right;
+right;
+arrow 0.3;
+box invisible width 0.85 height 0.2 "postprocessor";
+move to last box .bottom;
+down;
+arrow 0.3;
+box invisible width 0.5 height 0.4 "output" "file"
+.PE
+.\}
+.el \{\
+.nf
+ input sourced
+ file file
+ | |
+ v v
+ preprocessor -> troff -> postprocessor
+ |
+ v
+ output
+ file
+.fi
+.\}
+.PP
+.
+That is, files sourced with
+.B .so
+are normally read
+.I only
+by
+.B troff
+(the actual formatter).
+.B soelim
+is
+.I not
+required for
+.B troff
+to source files.
+.
+.PP
+If a file to be sourced should also be preprocessed, it must
+already be read
+.I before
+the input file passes through the preprocessor.
+This is handled by
+.BR soelim :
+.
+.PP
+.ie t \{\
+.PS
+box invisible width 0.5 height 0.4 "input" "file";
+move to last box .bottom;
+down;
+arrow 0.3;
+A: box invisible width 0.5 height 0.2 "soelim";
+line <- 0.3;
+box invisible width 0.5 height 0.4 "sourced" "file";
+move to A.right;
+right;
+arrow 0.3;
+box invisible width 0.8 height 0.2 "preprocessor";
+arrow 0.3;
+box invisible width 0.35 height 0.2 "troff";
+arrow 0.3
+box invisible width 0.85 height 0.2 "postprocessor";
+move to last box .bottom;
+down;
+arrow 0.3;
+box invisible width 0.5 height 0.4 "output" "file"
+.PE
+.\}
+.el \{\
+.nf
+ input
+ file
+ |
+ v
+ soelim -> preprocessor -> troff -> postprocessor
+ ^ |
+ | v
+ sourced output
+ file file
+.fi
+.\}
+.
.SH "SEE ALSO"
.BR groff (@MAN1EXT@)
.
diff --git a/contrib/groff/src/preproc/tbl/Makefile.sub b/contrib/groff/src/preproc/tbl/Makefile.sub
index 8decd3103a55..bea28b35164d 100644
--- a/contrib/groff/src/preproc/tbl/Makefile.sub
+++ b/contrib/groff/src/preproc/tbl/Makefile.sub
@@ -1,6 +1,7 @@
PROG=tbl$(EXEEXT)
MAN1=tbl.n
XLIBS=$(LIBGROFF)
+MLIB=$(LIBM)
OBJS=\
main.$(OBJEXT) \
table.$(OBJEXT)
diff --git a/contrib/groff/src/preproc/tbl/main.cpp b/contrib/groff/src/preproc/tbl/main.cpp
index fe3aabf9e664..d79adb0bf831 100644
--- a/contrib/groff/src/preproc/tbl/main.cpp
+++ b/contrib/groff/src/preproc/tbl/main.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "table.h"
@@ -26,11 +26,14 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
extern "C" const char *Version_string;
-static int compatible_flag = 0;
+int compatible_flag = 0;
class table_input {
FILE *fp;
- enum { START, MIDDLE, REREAD_T, REREAD_TE, REREAD_E, END, ERROR } state;
+ enum { START, MIDDLE,
+ REREAD_T, REREAD_TE, REREAD_E,
+ LEADER_1, LEADER_2, LEADER_3, LEADER_4,
+ END, ERROR } state;
string unget_stack;
public:
table_input(FILE *);
@@ -117,11 +120,15 @@ int table_input::get()
}
break;
case MIDDLE:
- // handle line continuation
+ // handle line continuation and uninterpreted leader character
if ((c = getc(fp)) == '\\') {
c = getc(fp);
if (c == '\n')
c = getc(fp); // perhaps state ought to be START now
+ else if (c == 'a' && compatible_flag) {
+ state = LEADER_1;
+ return '\\';
+ }
else {
if (c != EOF)
ungetc(c, fp);
@@ -152,6 +159,18 @@ int table_input::get()
case REREAD_E:
state = MIDDLE;
return 'E';
+ case LEADER_1:
+ state = LEADER_2;
+ return '*';
+ case LEADER_2:
+ state = LEADER_3;
+ return '(';
+ case LEADER_3:
+ state = LEADER_4;
+ return PREFIX_CHAR;
+ case LEADER_4:
+ state = MIDDLE;
+ return LEADER_CHAR;
case END:
case ERROR:
return EOF;
@@ -573,6 +592,11 @@ void entry_format::debug_print() const
put_string(font, stderr);
putc(' ', stderr);
}
+ if (!macro.empty()) {
+ putc('m', stderr);
+ put_string(macro, stderr);
+ putc(' ', stderr);
+ }
switch (vertical_alignment) {
case entry_modifier::CENTER:
break;
@@ -886,6 +910,40 @@ format *process_format(table_input &in, options *opt,
}
}
break;
+ case 'x':
+ case 'X':
+ do {
+ c = in.get();
+ } while (c == ' ' || c == '\t');
+ if (c == EOF) {
+ error("missing macro name");
+ break;
+ }
+ if (c == '(') {
+ for (;;) {
+ c = in.get();
+ if (c == EOF || c == ' ' || c == '\t') {
+ error("missing `)'");
+ break;
+ }
+ if (c == ')') {
+ c = in.get();
+ break;
+ }
+ list->macro += char(c);
+ }
+ }
+ else {
+ list->macro = c;
+ char cc = c;
+ c = in.get();
+ if (!csdigit(cc)
+ && c != EOF && c != ' ' && c != '\t' && c != '.' && c != '\n') {
+ list->macro += char(c);
+ c = in.get();
+ }
+ }
+ break;
case 'v':
case 'V':
c = in.get();
@@ -1184,9 +1242,9 @@ table *process_data(table_input &in, format *f, options *opt)
format_index = f->nrows - 1;
// A format row that is all lines doesn't use up a data line.
while (format_index < f->nrows - 1) {
- int c;
- for (c = 0; c < ncolumns; c++) {
- entry_format *e = f->entry[format_index] + c;
+ int cnt;
+ for (cnt = 0; cnt < ncolumns; cnt++) {
+ entry_format *e = f->entry[format_index] + cnt;
if (e->type != FORMAT_HLINE
&& e->type != FORMAT_DOUBLE_HLINE
// Unfortunately tbl treats a span as needing data.
@@ -1194,11 +1252,11 @@ table *process_data(table_input &in, format *f, options *opt)
)
break;
}
- if (c < ncolumns)
+ if (cnt < ncolumns)
break;
- for (c = 0; c < ncolumns; c++)
- tbl->add_entry(current_row, c, input_entry,
- f->entry[format_index] + c, current_filename,
+ for (cnt = 0; cnt < ncolumns; cnt++)
+ tbl->add_entry(current_row, cnt, input_entry,
+ f->entry[format_index] + cnt, current_filename,
current_lineno);
tbl->add_vlines(current_row, f->vline[format_index]);
format_index++;
@@ -1295,13 +1353,19 @@ table *process_data(table_input &in, format *f, options *opt)
}
break;
case GOT_RIGHT_BRACE:
+ if ((opt->flags & table::NOSPACES)) {
+ while (c == ' ')
+ c = in.get();
+ if (c == EOF)
+ break;
+ }
if (c == '\n' || c == tab_char)
state = END;
else {
input_entry += 'T';
input_entry += '}';
input_entry += c;
- state = c == '\n' ? START : MIDDLE;
+ state = MIDDLE;
}
break;
case MIDDLE:
@@ -1428,7 +1492,6 @@ table *process_data(table_input &in, format *f, options *opt)
void process_table(table_input &in)
{
- int c;
options *opt = 0;
format *form = 0;
table *tbl = 0;
@@ -1440,7 +1503,7 @@ void process_table(table_input &in)
}
else {
error("giving up on this table");
- while ((c = in.get()) != EOF)
+ while (in.get() != EOF)
;
}
delete opt;
@@ -1504,10 +1567,8 @@ int main(int argc, char **argv)
else {
errno = 0;
FILE *fp = fopen(argv[i], "r");
- if (fp == 0) {
- current_lineno = -1;
- error("can't open `%1': %2", argv[i], strerror(errno));
- }
+ if (fp == 0)
+ fatal("can't open `%1': %2", argv[i], strerror(errno));
else {
current_lineno = 1;
current_filename = argv[i];
diff --git a/contrib/groff/src/preproc/tbl/table.cpp b/contrib/groff/src/preproc/tbl/table.cpp
index 32068c367ed1..8312386aafee 100644
--- a/contrib/groff/src/preproc/tbl/table.cpp
+++ b/contrib/groff/src/preproc/tbl/table.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2003
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2003, 2004
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "table.h"
@@ -30,7 +30,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
const int DEFAULT_COLUMN_SEPARATION = 3;
#define DELIMITER_CHAR "\\[tbl]"
-#define PREFIX "3"
#define SEPARATION_FACTOR_REG PREFIX "sep"
#define BOTTOM_REG PREFIX "bot"
#define RESET_MACRO_NAME PREFIX "init"
@@ -64,6 +63,8 @@ const int DEFAULT_COLUMN_SEPARATION = 3;
// this must be one character
#define COMPATIBLE_REG PREFIX "c"
+#define LEADER_REG PREFIX LEADER
+
#define BLOCK_WIDTH_PREFIX PREFIX "tbw"
#define BLOCK_DIVERSION_PREFIX PREFIX "tbd"
#define BLOCK_HEIGHT_PREFIX PREFIX "tbh"
@@ -128,14 +129,14 @@ void prints(const string &s)
struct horizontal_span {
horizontal_span *next;
- short start_col;
- short end_col;
+ int start_col;
+ int end_col;
horizontal_span(int, int, horizontal_span *);
};
-struct single_line_entry;
-struct double_line_entry;
-struct simple_entry;
+class single_line_entry;
+class double_line_entry;
+class simple_entry;
class table_entry {
friend class table;
@@ -145,8 +146,8 @@ friend class table;
protected:
int start_row;
int end_row;
- short start_col;
- short end_col;
+ int start_col;
+ int end_col;
const entry_modifier *mod;
public:
void set_location();
@@ -687,8 +688,8 @@ void block_entry::do_divert(int alphabetic, int ncols, const string *mw,
if (alphabetic)
prints("-2n");
prints("\n");
- set_modifier(mod);
prints(".cp \\n(" COMPATIBLE_REG "\n");
+ set_modifier(mod);
set_location();
prints(contents);
prints(".br\n.di\n.cp 0\n");
@@ -965,6 +966,8 @@ void set_modifier(const entry_modifier *m)
prints('-');
printfs("%1\n", as_string(m->vertical_spacing.val));
}
+ if (!m->macro.empty())
+ printfs(".%1\n", m->macro);
}
void set_inline_modifier(const entry_modifier *m)
@@ -1088,7 +1091,7 @@ struct vertical_rule {
vertical_rule *next;
int start_row;
int end_row;
- short col;
+ int col;
char is_double;
string top_adjust;
string bot_adjust;
@@ -1693,6 +1696,8 @@ void table::init_output()
prints(".nr " LINESIZE_REG " \\n[.s]\n");
if (!(flags & CENTER))
prints(".nr " SAVED_CENTER_REG " \\n[.ce]\n");
+ if (compatible_flag)
+ prints(".ds " LEADER_REG " \\a\n");
prints(".de " RESET_MACRO_NAME "\n"
".ft \\n[.f]\n"
".ps \\n[.s]\n"
@@ -2602,8 +2607,14 @@ void table::do_row(int r)
if (e) {
if (e->end_row == r && e->start_row == i) {
simple_entry *simple = e->to_simple_entry();
- if (simple)
+ if (simple) {
+ if (e->end_row != e->start_row) {
+ prints('\n');
+ simple->position_vertically();
+ prints("\\&");
+ }
simple->simple_print(0);
+ }
}
c = e->end_col;
}
diff --git a/contrib/groff/src/preproc/tbl/table.h b/contrib/groff/src/preproc/tbl/table.h
index 69959b899e4c..4b2497e2158e 100644
--- a/contrib/groff/src/preproc/tbl/table.h
+++ b/contrib/groff/src/preproc/tbl/table.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002
+/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "lib.h"
@@ -32,6 +32,14 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "errarg.h"
#include "error.h"
+// PREFIX and PREFIX_CHAR must be the same.
+#define PREFIX "3"
+#define PREFIX_CHAR '3'
+
+// LEADER and LEADER_CHAR must be the same.
+#define LEADER "a"
+#define LEADER_CHAR 'a'
+
struct inc_number {
short inc;
short val;
@@ -41,6 +49,7 @@ struct entry_modifier {
inc_number point_size;
inc_number vertical_spacing;
string font;
+ string macro;
enum { CENTER, TOP, BOTTOM } vertical_alignment;
char zero_width;
char stagger;
@@ -69,7 +78,7 @@ struct entry_format : public entry_modifier {
void debug_print() const;
};
-struct table_entry;
+class table_entry;
struct horizontal_span;
struct stuff;
struct vertical_rule;
@@ -152,3 +161,5 @@ public:
};
void set_troff_location(const char *, int);
+
+extern int compatible_flag;
diff --git a/contrib/groff/src/preproc/tbl/tbl.man b/contrib/groff/src/preproc/tbl/tbl.man
index 7f12bf933e00..00dfe4f83009 100644
--- a/contrib/groff/src/preproc/tbl/tbl.man
+++ b/contrib/groff/src/preproc/tbl/tbl.man
@@ -1,5 +1,6 @@
.ig
-Copyright (C) 1989-1995, 2001, 2002 Free Software Foundation, Inc.
+Copyright (C) 1989-1995, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -62,11 +63,13 @@ will cause the standard input to be read.
.SH OPTIONS
.TP
.B \-C
-Recognize
+Enable compatibility mode to
+recognize
.B .TS
and
.B .TE
even when followed by a character other than space or newline.
+Leader characters (\[rs]a) are handled as interpreted.
.TP
.B \-v
Print the version number.
@@ -287,6 +290,33 @@ If used multiple times to specify the width for a particular column,
the last entry takes effect.
.
.TP
+x,X
+This is a GNU tbl extension.
+Either of these specifiers may be followed by a macro name
+(either one or two characters long),
+or long name in parentheses.
+A one-letter macro name must be separated by one or more blanks
+from whatever follows.
+The macro which name can be specified here
+must be defined before creating the table.
+It is called just before the table's cell text is output.
+As implemented currently, this macro is only called if block input is used,
+that is, text between `T{' and `T}'.
+The macro should contain only simple
+.B troff
+requests to change the text block formatting, like text adjustment,
+hyphenation, size, or font.
+The macro is called
+.I after
+other cell modifications like
+.BR b ,
+.B f
+or
+.B v
+are output.
+Thus the macro can overwrite other modification specifiers.
+.
+.TP
e,E
Make equally-spaced columns.
.
@@ -339,6 +369,19 @@ too long as a simple string between tabs.
It is started with `T{' and closed with `T}'.
The former must end a line, and the latter must start a line, probably
followed by other data columns (separated with tabs).
+By default, the text block is formatted with the settings which were
+active before entering the table, possibly overridden by the
+.B v
+and
+.B w
+tbl specifiers.
+For example, to make all text blocks ragged-right, insert
+.B .na
+right before the starting
+.B .TS
+(and
+.B .ad
+after the table).
.LP
To change the data format within a table, use the
.B .T&
@@ -415,7 +458,8 @@ and use
instead of
.BR bp .
.LP
-Using \ea directly in a table to get leaders will not work.
+Using \ea directly in a table to get leaders will not work (except in
+compatibility mode).
This is correct behaviour: \ea is an
.B uninterpreted
leader.