summaryrefslogtreecommitdiffstats
path: root/contrib/groff/src/preproc
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/groff/src/preproc')
-rw-r--r--contrib/groff/src/preproc/eqn/Makefile.sub36
-rw-r--r--contrib/groff/src/preproc/eqn/box.cc26
-rw-r--r--contrib/groff/src/preproc/eqn/eqn.h7
-rw-r--r--contrib/groff/src/preproc/eqn/eqn.man16
-rw-r--r--contrib/groff/src/preproc/eqn/lex.cc8
-rw-r--r--contrib/groff/src/preproc/eqn/limit.cc12
-rw-r--r--contrib/groff/src/preproc/eqn/main.cc58
-rw-r--r--contrib/groff/src/preproc/eqn/other.cc12
-rw-r--r--contrib/groff/src/preproc/eqn/over.cc13
-rw-r--r--contrib/groff/src/preproc/eqn/script.cc16
-rw-r--r--contrib/groff/src/preproc/eqn/sqrt.cc18
-rw-r--r--contrib/groff/src/preproc/grn/Makefile.sub10
-rw-r--r--contrib/groff/src/preproc/grn/README10
-rw-r--r--contrib/groff/src/preproc/grn/gprint.h2
-rw-r--r--contrib/groff/src/preproc/grn/grn.man29
-rw-r--r--contrib/groff/src/preproc/grn/hdb.cc23
-rw-r--r--contrib/groff/src/preproc/grn/hgraph.cc30
-rw-r--r--contrib/groff/src/preproc/grn/main.cc6
-rw-r--r--contrib/groff/src/preproc/html/Makefile.sub6
-rw-r--r--contrib/groff/src/preproc/html/pre-html.cc1005
-rw-r--r--contrib/groff/src/preproc/html/pushback.cc333
-rw-r--r--contrib/groff/src/preproc/html/pushback.h54
-rw-r--r--contrib/groff/src/preproc/pic/Makefile.sub22
-rw-r--r--contrib/groff/src/preproc/pic/common.cc1
-rw-r--r--contrib/groff/src/preproc/pic/common.h4
-rw-r--r--contrib/groff/src/preproc/pic/lex.cc70
-rw-r--r--contrib/groff/src/preproc/pic/main.cc18
-rw-r--r--contrib/groff/src/preproc/pic/object.cc141
-rw-r--r--contrib/groff/src/preproc/pic/object.h9
-rw-r--r--contrib/groff/src/preproc/pic/output.h8
-rw-r--r--contrib/groff/src/preproc/pic/pic.h8
-rw-r--r--contrib/groff/src/preproc/pic/pic.man221
-rw-r--r--contrib/groff/src/preproc/pic/pic.y196
-rw-r--r--contrib/groff/src/preproc/pic/tex.cc26
-rw-r--r--contrib/groff/src/preproc/pic/troff.cc83
-rw-r--r--contrib/groff/src/preproc/refer/Makefile.sub14
-rw-r--r--contrib/groff/src/preproc/refer/command.cc7
-rw-r--r--contrib/groff/src/preproc/refer/refer.cc22
-rw-r--r--contrib/groff/src/preproc/refer/refer.h7
-rw-r--r--contrib/groff/src/preproc/soelim/Makefile.sub4
-rw-r--r--contrib/groff/src/preproc/soelim/soelim.cc5
-rw-r--r--contrib/groff/src/preproc/tbl/Makefile.sub6
-rw-r--r--contrib/groff/src/preproc/tbl/main.cc34
-rw-r--r--contrib/groff/src/preproc/tbl/table.h10
-rw-r--r--contrib/groff/src/preproc/tbl/tbl.man346
45 files changed, 2054 insertions, 938 deletions
diff --git a/contrib/groff/src/preproc/eqn/Makefile.sub b/contrib/groff/src/preproc/eqn/Makefile.sub
index 20421e1c..6997290 100644
--- a/contrib/groff/src/preproc/eqn/Makefile.sub
+++ b/contrib/groff/src/preproc/eqn/Makefile.sub
@@ -1,22 +1,22 @@
-PROG=eqn
+PROG=eqn$(EXEEXT)
MAN1=eqn.n neqn.n
XLIBS=$(LIBGROFF)
OBJS=\
- eqn.o \
- main.o \
- lex.o \
- box.o \
- limit.o \
- list.o \
- over.o \
- text.o \
- script.o \
- mark.o \
- other.o \
- delim.o \
- sqrt.o \
- pile.o \
- special.o
+ eqn.$(OBJEXT) \
+ main.$(OBJEXT) \
+ lex.$(OBJEXT) \
+ box.$(OBJEXT) \
+ limit.$(OBJEXT) \
+ list.$(OBJEXT) \
+ over.$(OBJEXT) \
+ text.$(OBJEXT) \
+ script.$(OBJEXT) \
+ mark.$(OBJEXT) \
+ other.$(OBJEXT) \
+ delim.$(OBJEXT) \
+ sqrt.$(OBJEXT) \
+ pile.$(OBJEXT) \
+ special.$(OBJEXT)
CCSRCS=\
$(srcdir)/main.cc \
$(srcdir)/lex.cc \
@@ -37,8 +37,8 @@ HDRS=\
$(srcdir)/eqn.h \
$(srcdir)/pbox.h
GRAM=$(srcdir)/eqn.y
-YTABC=$(srcdir)/eqn.cc
-YTABH=$(srcdir)/eqn_tab.h
+YTABC=eqn.cc
+YTABH=eqn_tab.h
NAMEPREFIX=$(g)
CLEANADD=neqn
diff --git a/contrib/groff/src/preproc/eqn/box.cc b/contrib/groff/src/preproc/eqn/box.cc
index 4e61b5d..41d8dff 100644
--- a/contrib/groff/src/preproc/eqn/box.cc
+++ b/contrib/groff/src/preproc/eqn/box.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -232,7 +232,7 @@ void start_string()
void output_string()
{
- printf("\\*[" LINE_STRING "]\n");
+ printf("\\*(" LINE_STRING "\n");
}
void restore_compatibility()
@@ -259,7 +259,7 @@ void set_script_size()
if (script_size_reduction >= 0)
printf(".ps \\n[.s]-%d>?%d\n", script_size_reduction, minimum_size);
else
- printf(".ps (u;\\n[.s]*7+5/10>?%d)*1z\n", minimum_size);
+ printf(".ps (u;\\n[.ps]*7+5/10>?%d)\n", minimum_size);
}
int box::next_uid = 0;
@@ -281,7 +281,7 @@ void box::top_level()
printf(".ft\n");
printf(".nr " SAVED_PREV_FONT_REG " \\n[.f]\n");
printf(".ft %s\n", get_gfont());
- printf(".nr " SAVED_SIZE_REG " \\n[.s]z\n");
+ printf(".nr " SAVED_SIZE_REG " \\n[.ps]\n");
if (gsize > 0) {
char buf[INT_DIGITS + 1];
sprintf(buf, "%d", gsize);
@@ -299,7 +299,7 @@ void box::top_level()
printf(".nr " MARK_WIDTH_REG " 0\\n[" WIDTH_FORMAT "]\n", b->uid);
}
else if (r == FOUND_LINEUP)
- printf(".if r" SAVED_MARK_REG " .as " LINE_STRING " \\h'\\n["
+ printf(".if r" SAVED_MARK_REG " .as1 " LINE_STRING " \\h'\\n["
SAVED_MARK_REG "]u-\\n[" MARK_REG "]u'\n");
else
assert(r == FOUND_NOTHING);
@@ -311,9 +311,9 @@ void box::top_level()
"\\R'" SAVED_INLINE_FONT_REG " \\\\n[.f]'"
"\\fP"
"\\R'" SAVED_INLINE_PREV_FONT_REG " \\\\n[.f]'"
- "\\R'" SAVED_INLINE_SIZE_REG " \\\\n[.s]z'"
+ "\\R'" SAVED_INLINE_SIZE_REG " \\\\n[.ps]'"
"\\s0"
- "\\R'" SAVED_INLINE_PREV_SIZE_REG " \\\\n[.s]z'"
+ "\\R'" SAVED_INLINE_PREV_SIZE_REG " \\\\n[.ps]'"
"\n"
".ds " RESTORE_FONT_STRING " "
"\\f[\\\\n[" SAVED_INLINE_PREV_FONT_REG "]]"
@@ -321,14 +321,14 @@ void box::top_level()
"\\s'\\\\n[" SAVED_INLINE_PREV_SIZE_REG "]u'"
"\\s'\\\\n[" SAVED_INLINE_SIZE_REG "]u'"
"\n");
- printf(".as " LINE_STRING " \\&\\E*[" SAVE_FONT_STRING "]");
+ printf(".as1 " LINE_STRING " \\&\\E*[" SAVE_FONT_STRING "]");
printf("\\f[%s]", get_gfont());
printf("\\s'\\En[" SAVED_SIZE_REG "]u'");
current_roman_font = get_grfont();
b->output();
printf("\\E*[" RESTORE_FONT_STRING "]\n");
if (r == FOUND_LINEUP)
- printf(".if r" SAVED_MARK_REG " .as " LINE_STRING " \\h'\\n["
+ printf(".if r" SAVED_MARK_REG " .as1 " LINE_STRING " \\h'\\n["
MARK_WIDTH_REG "]u-\\n[" SAVED_MARK_REG "]u-(\\n["
WIDTH_FORMAT "]u-\\n[" MARK_REG "]u)'\n",
b->uid);
@@ -351,20 +351,20 @@ void box::extra_space()
if (positive_space >= 0 || negative_space >= 0) {
if (positive_space > 0)
printf(".if !\\n[" EQN_NO_EXTRA_SPACE_REG "] "
- ".as " LINE_STRING " \\x'-%dM'\n", positive_space);
+ ".as1 " LINE_STRING " \\x'-%dM'\n", positive_space);
if (negative_space > 0)
printf(".if !\\n[" EQN_NO_EXTRA_SPACE_REG "] "
- ".as " LINE_STRING " \\x'%dM'\n", negative_space);
+ ".as1 " LINE_STRING " \\x'%dM'\n", negative_space);
positive_space = negative_space = -1;
}
else {
printf(".if !\\n[" EQN_NO_EXTRA_SPACE_REG "] "
- ".if \\n[" HEIGHT_FORMAT "]>%dM .as " LINE_STRING
+ ".if \\n[" HEIGHT_FORMAT "]>%dM .as1 " LINE_STRING
" \\x'-(\\n[" HEIGHT_FORMAT
"]u-%dM)'\n",
uid, body_height, uid, body_height);
printf(".if !\\n[" EQN_NO_EXTRA_SPACE_REG "] "
- ".if \\n[" DEPTH_FORMAT "]>%dM .as " LINE_STRING
+ ".if \\n[" DEPTH_FORMAT "]>%dM .as1 " LINE_STRING
" \\x'\\n[" DEPTH_FORMAT
"]u-%dM'\n",
uid, body_depth, uid, body_depth);
diff --git a/contrib/groff/src/preproc/eqn/eqn.h b/contrib/groff/src/preproc/eqn/eqn.h
index 70b1927..ee25f03 100644
--- a/contrib/groff/src/preproc/eqn/eqn.h
+++ b/contrib/groff/src/preproc/eqn/eqn.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.
@@ -18,15 +18,14 @@ 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. */
-#include <stdio.h>
-#include <string.h>
+#include "lib.h"
+
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include "cset.h"
#include "errarg.h"
#include "error.h"
-#include "lib.h"
#include "box.h"
diff --git a/contrib/groff/src/preproc/eqn/eqn.man b/contrib/groff/src/preproc/eqn/eqn.man
index bc7dc7e..6d0733c 100644
--- a/contrib/groff/src/preproc/eqn/eqn.man
+++ b/contrib/groff/src/preproc/eqn/eqn.man
@@ -42,7 +42,7 @@ the original English.
.el .RB "[\ " "\\$1" "\ ]"
..
.OP \-rvCNR
-.OP \-d cc
+.OP \-d xy
.OP \-T name
.OP \-M dir
.OP \-f F
@@ -97,6 +97,16 @@ 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
+.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
.B .EQ
@@ -456,7 +466,7 @@ by drawing a diagonal line through it.
.IP
.nf
.ft B
-.ne 6+\n(.Vu
+.if t .ne 6+\n(.Vu
\&.EQ
define cancel 'special Ca'
\&.EN
@@ -475,7 +485,7 @@ Here's a more complicated construct that draws a box round an expression:
.IP
.nf
.ft B
-.ne 11+\n(.Vu
+.if t .ne 11+\n(.Vu
\&.EQ
define box 'special Bx'
\&.EN
diff --git a/contrib/groff/src/preproc/eqn/lex.cc b/contrib/groff/src/preproc/eqn/lex.cc
index e14053d..4e62f86 100644
--- a/contrib/groff/src/preproc/eqn/lex.cc
+++ b/contrib/groff/src/preproc/eqn/lex.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -371,8 +371,8 @@ int file_input::read_line()
int c = getc(fp);
if (c == EOF)
break;
- else if (illegal_input_char(c))
- lex_error("illegal input character code %1", c);
+ else if (invalid_input_char(c))
+ lex_error("invalid input character code %1", c);
else {
line += char(c);
if (c == '\n')
@@ -467,7 +467,7 @@ int top_input::get_location(char **fnp, int *lnp)
return 1;
}
-// Character representing $1. Must be illegal input character.
+// Character representing $1. Must be invalid input character.
#define ARG1 14
argument_macro_input::argument_macro_input(const char *body, int ac,
diff --git a/contrib/groff/src/preproc/eqn/limit.cc b/contrib/groff/src/preproc/eqn/limit.cc
index 046885d..c8b5587 100644
--- a/contrib/groff/src/preproc/eqn/limit.cc
+++ b/contrib/groff/src/preproc/eqn/limit.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -55,10 +55,10 @@ limit_box::~limit_box()
int limit_box::compute_metrics(int style)
{
- printf(".nr " SIZE_FORMAT " \\n[.s]\n", uid);
+ printf(".nr " SIZE_FORMAT " \\n[.ps]\n", uid);
if (!(style <= SCRIPT_STYLE && one_size_reduction_flag))
set_script_size();
- printf(".nr " SMALL_SIZE_FORMAT " \\n[.s]\n", uid);
+ printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
int res = 0;
int mark_uid = -1;
if (from != 0) {
@@ -75,7 +75,7 @@ int limit_box::compute_metrics(int style)
res = r;
}
}
- printf(".ps \\n[" SIZE_FORMAT "]\n", uid);
+ printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
int r = p->compute_metrics(style);
p->compute_subscript_kern();
if (res && r)
@@ -139,7 +139,7 @@ int limit_box::compute_metrics(int style)
void limit_box::output()
{
- printf("\\s[\\n[" SMALL_SIZE_FORMAT "]]", uid);
+ printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", uid);
if (to != 0) {
printf("\\Z" DELIMITER_CHAR);
printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
@@ -158,7 +158,7 @@ void limit_box::output()
from->output();
printf(DELIMITER_CHAR);
}
- printf("\\s[\\n[" SIZE_FORMAT "]]", uid);
+ printf("\\s[\\n[" SIZE_FORMAT "]u]", uid);
printf("\\Z" DELIMITER_CHAR);
printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u"
"-(\\n[" WIDTH_FORMAT "]u/2u)'",
diff --git a/contrib/groff/src/preproc/eqn/main.cc b/contrib/groff/src/preproc/eqn/main.cc
index f53ffa3..dabac5f 100644
--- a/contrib/groff/src/preproc/eqn/main.cc
+++ b/contrib/groff/src/preproc/eqn/main.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -24,8 +24,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "device.h"
#include "searchpath.h"
#include "macropath.h"
-#include "htmlindicate.h"
+#include "htmlhint.h"
#include "pbox.h"
+#include "ctype.h"
#define STARTUP_FILE "eqnrc"
@@ -44,9 +45,6 @@ int one_size_reduction_flag = 0;
int compatible_flag = 0;
int no_newline_in_delim_flag = 0;
int html = 0;
-// if we encounter a region marked as an image then we
-// do not mark up inline equations.
-int suppress_html = 0;
int read_line(FILE *fp, string *p)
@@ -54,10 +52,10 @@ int read_line(FILE *fp, string *p)
p->clear();
int c = -1;
while ((c = getc(fp)) != EOF) {
- if (!illegal_input_char(c))
+ if (!invalid_input_char(c))
*p += char(c);
else
- error("illegal input character code `%1'", c);
+ error("invalid input character code `%1'", c);
if (c == '\n')
break;
}
@@ -81,33 +79,12 @@ void do_file(FILE *fp, const char *filename)
if (interpret_lf_args(linebuf.contents() + 3))
current_lineno--;
}
- else if (linebuf.length() >= 12
- && linebuf[0] == '.' && linebuf[1] == 'H' && linebuf[2] == 'T'
- && linebuf[3] == 'M' && linebuf[4] == 'L' && linebuf[5] == '-'
- && linebuf[6] == 'I' && linebuf[7] == 'M' && linebuf[8] == 'A'
- && linebuf[9] == 'G' && linebuf[10] == 'E'
- && linebuf[11] == '\n') {
- put_string(linebuf, stdout);
- suppress_html++;
- }
- else if (linebuf.length() >= 16
- && linebuf[0] == '.' && linebuf[1] == 'H' && linebuf[2] == 'T'
- && linebuf[3] == 'M' && linebuf[4] == 'L' && linebuf[5] == '-'
- && linebuf[6] == 'I' && linebuf[7] == 'M' && linebuf[8] == 'A'
- && linebuf[9] == 'G' && linebuf[10] == 'E' && linebuf[11] == '-'
- && linebuf[12] == 'E' && linebuf[13] == 'N' && linebuf[14] == 'D'
- && linebuf[15] == '\n') {
- put_string(linebuf, stdout);
- suppress_html--;
- }
else if (linebuf.length() >= 4
&& linebuf[0] == '.'
&& linebuf[1] == 'E'
&& linebuf[2] == 'Q'
&& (linebuf[3] == ' ' || linebuf[3] == '\n'
|| compatible_flag)) {
- if (html && (suppress_html == 0))
- graphic_start(0);
put_string(linebuf, stdout);
int start_lineno = current_lineno + 1;
str.clear();
@@ -132,15 +109,13 @@ void do_file(FILE *fp, const char *filename)
non_empty_flag = 0;
inline_flag = 0;
yyparse();
+ restore_compatibility();
if (non_empty_flag) {
printf(".lf %d\n", current_lineno - 1);
output_string();
}
- restore_compatibility();
printf(".lf %d\n", current_lineno);
put_string(linebuf, stdout);
- if (html && (suppress_html == 0))
- graphic_end();
}
else if (start_delim != '\0' && linebuf.search(start_delim) >= 0
&& inline_equation(fp, linebuf, str))
@@ -190,21 +165,22 @@ static int inline_equation(FILE *fp, string &linebuf, string &str)
}
str += ptr;
if (!read_line(fp, &linebuf))
- fatal("end of file before `%1'", end_delim);
+ fatal("unterminated `%1' at line %2, looking for `%3'",
+ start_delim, start_lineno, end_delim);
linebuf += '\0';
ptr = &linebuf[0];
}
str += '\0';
- if (html && (suppress_html == 0)) {
- printf(".as %s ", LINE_STRING);
- graphic_start(1);
+ if (html) {
+ printf(".as1 %s ", LINE_STRING);
+ html_begin_suppress();
printf("\n");
}
init_lex(str.contents(), current_filename, start_lineno);
yyparse();
- if (html && (suppress_html == 0)) {
- printf(".as %s ", LINE_STRING);
- graphic_end();
+ if (html) {
+ printf(".as1 %s ", LINE_STRING);
+ html_end_suppress();
printf("\n");
}
start = delim_search(ptr, start_delim);
@@ -216,9 +192,9 @@ static int inline_equation(FILE *fp, string &linebuf, string &str)
break;
}
}
+ restore_compatibility();
printf(".lf %d\n", current_lineno);
output_string();
- restore_compatibility();
printf(".lf %d\n", current_lineno + 1);
return 1;
}
@@ -311,9 +287,9 @@ int main(int argc, char **argv)
case 'd':
if (optarg[0] == '\0' || optarg[1] == '\0')
error("-d requires two character argument");
- else if (illegal_input_char(optarg[0]))
+ else if (invalid_input_char(optarg[0]))
error("bad delimiter `%1'", optarg[0]);
- else if (illegal_input_char(optarg[1]))
+ else if (invalid_input_char(optarg[1]))
error("bad delimiter `%1'", optarg[1]);
else {
start_delim = optarg[0];
diff --git a/contrib/groff/src/preproc/eqn/other.cc b/contrib/groff/src/preproc/eqn/other.cc
index eb9e50a..c052f52 100644
--- a/contrib/groff/src/preproc/eqn/other.cc
+++ b/contrib/groff/src/preproc/eqn/other.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -392,11 +392,11 @@ size_box::size_box(char *s, box *pp) : pointer_box(pp), size(s)
int size_box::compute_metrics(int style)
{
- printf(".nr " SIZE_FORMAT " \\n[.s]\n", uid);
+ printf(".nr " SIZE_FORMAT " \\n[.ps]\n", uid);
printf(".ps %s\n", size);
- printf(".nr " SMALL_SIZE_FORMAT " \\n[.s]\n", uid);
+ printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
int r = p->compute_metrics(style);
- printf(".ps \\n[" SIZE_FORMAT "]\n", uid);
+ printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
@@ -405,9 +405,9 @@ int size_box::compute_metrics(int style)
void size_box::output()
{
- printf("\\s[\\n[" SMALL_SIZE_FORMAT "]]", uid);
+ printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", uid);
p->output();
- printf("\\s[\\n[" SIZE_FORMAT "]]", uid);
+ printf("\\s[\\n[" SIZE_FORMAT "]u]", uid);
}
size_box::~size_box()
diff --git a/contrib/groff/src/preproc/eqn/over.cc b/contrib/groff/src/preproc/eqn/over.cc
index 4c544d1..279efc8 100644
--- a/contrib/groff/src/preproc/eqn/over.cc
+++ b/contrib/groff/src/preproc/eqn/over.cc
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -61,9 +62,9 @@ int over_box::compute_metrics(int style)
{
if (reduce_size) {
style = script_style(style);
- printf(".nr " SIZE_FORMAT " \\n[.s]\n", uid);
+ printf(".nr " SIZE_FORMAT " \\n[.ps]\n", uid);
set_script_size();
- printf(".nr " SMALL_SIZE_FORMAT " \\n[.s]\n", uid);
+ printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
}
int mark_uid = 0;
int res = num->compute_metrics(style);
@@ -77,7 +78,7 @@ int over_box::compute_metrics(int style)
res = r;
}
if (reduce_size)
- printf(".ps \\n[" SIZE_FORMAT "]\n", uid);
+ printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
printf(".nr " WIDTH_FORMAT " (\\n[" WIDTH_FORMAT "]>?\\n[" WIDTH_FORMAT "]",
uid, num->uid, den->uid);
// allow for \(ru being wider than both the numerator and denominator
@@ -118,7 +119,7 @@ int over_box::compute_metrics(int style)
void over_box::output()
{
if (reduce_size)
- printf("\\s[\\n[" SMALL_SIZE_FORMAT "]]", uid);
+ printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", uid);
#ifdef USE_Z
printf("\\Z" DELIMITER_CHAR);
#endif
@@ -165,7 +166,7 @@ void over_box::output()
printf("\\v'-\\n[" SUB_LOWER_FORMAT "]u'", uid);
#endif
if (reduce_size)
- printf("\\s[\\n[" SIZE_FORMAT "]]", uid);
+ printf("\\s[\\n[" SIZE_FORMAT "]u]", uid);
// draw the line
printf("\\h'%dM'", null_delimiter_space);
printf("\\v'-%dM'", axis_height);
diff --git a/contrib/groff/src/preproc/eqn/script.cc b/contrib/groff/src/preproc/eqn/script.cc
index 7c2e6c2..62a05b4 100644
--- a/contrib/groff/src/preproc/eqn/script.cc
+++ b/contrib/groff/src/preproc/eqn/script.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -73,10 +73,10 @@ int script_box::compute_metrics(int style)
{
int res = p->compute_metrics(style);
p->compute_subscript_kern();
- printf(".nr " SIZE_FORMAT " \\n[.s]\n", uid);
+ printf(".nr " SIZE_FORMAT " \\n[.ps]\n", uid);
if (!(style <= SCRIPT_STYLE && one_size_reduction_flag))
set_script_size();
- printf(".nr " SMALL_SIZE_FORMAT " \\n[.s]\n", uid);
+ printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
if (sub != 0)
sub->compute_metrics(cramped_style(script_style(style)));
if (sup != 0)
@@ -92,7 +92,7 @@ int script_box::compute_metrics(int style)
printf(".nr " SUB_LOWER_FORMAT " \\n[" DEPTH_FORMAT "]+%dM\n",
uid, p->uid, sub_drop);
}
- printf(".ps \\n[" SIZE_FORMAT "]\n", uid);
+ printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
if (sup == 0) {
assert(sub != 0);
// 18b
@@ -171,18 +171,18 @@ void script_box::output()
if (sup != 0) {
printf("\\Z" DELIMITER_CHAR);
printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
- printf("\\s[\\n[" SMALL_SIZE_FORMAT "]]", uid);
+ printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", uid);
sup->output();
- printf("\\s[\\n[" SIZE_FORMAT "]]", uid);
+ printf("\\s[\\n[" SIZE_FORMAT "]u]", uid);
printf(DELIMITER_CHAR);
}
if (sub != 0) {
printf("\\Z" DELIMITER_CHAR);
printf("\\v'\\n[" SUB_LOWER_FORMAT "]u'", uid);
- printf("\\s[\\n[" SMALL_SIZE_FORMAT "]]", uid);
+ printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", uid);
printf("\\h'-\\n[" SUB_KERN_FORMAT "]u'", p->uid);
sub->output();
- printf("\\s[\\n[" SIZE_FORMAT "]]", uid);
+ printf("\\s[\\n[" SIZE_FORMAT "]u]", uid);
printf(DELIMITER_CHAR);
}
printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u'",
diff --git a/contrib/groff/src/preproc/eqn/sqrt.cc b/contrib/groff/src/preproc/eqn/sqrt.cc
index 6109ffe..bffa4f2 100644
--- a/contrib/groff/src/preproc/eqn/sqrt.cc
+++ b/contrib/groff/src/preproc/eqn/sqrt.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -54,7 +54,7 @@ int sqrt_box::compute_metrics(int style)
"]+%dM+(%dM/4)\n",
p->uid, p->uid, default_rule_thickness,
(style > SCRIPT_STYLE ? x_height : default_rule_thickness));
- printf(".nr " SIZE_FORMAT " \\n[.s]\n", uid);
+ printf(".nr " SIZE_FORMAT " \\n[.ps]\n", uid);
printf(".ds " SQRT_STRING_FORMAT " " SQRT_CHAR "\n", uid);
printf(".ds " BAR_STRING " " RADICAL_EXTENSION_CHAR "\n");
printf(".nr " SQRT_WIDTH_FORMAT
@@ -84,8 +84,8 @@ int sqrt_box::compute_metrics(int style)
// Determine the maximum point size
printf(".ps 1000\n");
- printf(".nr " MAX_SIZE_REG " \\n[.s]\n");
- printf(".ps \\n[" SIZE_FORMAT "]\n", uid);
+ printf(".nr " MAX_SIZE_REG " \\n[.ps]\n");
+ printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
// We define a macro that will increase the current point size
// until we get a radical sign that's tall enough or we reach
// the maximum point size.
@@ -93,7 +93,7 @@ int sqrt_box::compute_metrics(int style)
".nr " SQRT_WIDTH_FORMAT
" 0\\w" DELIMITER_CHAR "\\*[" SQRT_STRING_FORMAT "]" DELIMITER_CHAR "\n"
".if \\\\n[rst]-\\\\n[rsb]-%dM<\\n[" TEMP_REG "]"
- "&(\\\\n[.s]<\\n[" MAX_SIZE_REG "]) \\{"
+ "&(\\\\n[.ps]<\\n[" MAX_SIZE_REG "]) \\{"
".ps +1\n"
"." TEMP_MACRO "\n"
".\\}\n"
@@ -103,7 +103,7 @@ int sqrt_box::compute_metrics(int style)
printf(".\\}\\}\n");
- printf(".nr " SMALL_SIZE_FORMAT " \\n[.s]\n", uid);
+ printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
// set TEMP_REG to the amount by which the radical sign is too big
printf(".nr " TEMP_REG " \\n[rst]-\\n[rsb]-%dM-\\n[" TEMP_REG "]\n",
default_rule_thickness);
@@ -143,17 +143,17 @@ int sqrt_box::compute_metrics(int style)
uid, p->uid, uid);
// put a bit of extra space above the bar
printf(".nr " HEIGHT_FORMAT " +%dM\n", uid, default_rule_thickness);
- printf(".ps \\n[" SIZE_FORMAT "]\n", uid);
+ printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
return r;
}
void sqrt_box::output()
{
printf("\\Z" DELIMITER_CHAR);
- printf("\\s[\\n[" SMALL_SIZE_FORMAT "]]", uid);
+ printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", uid);
printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
printf("\\*[" SQRT_STRING_FORMAT "]", uid);
- printf("\\s[\\n[" SIZE_FORMAT "]]", uid);
+ printf("\\s[\\n[" SIZE_FORMAT "]u]", uid);
printf(DELIMITER_CHAR);
printf("\\Z" DELIMITER_CHAR);
diff --git a/contrib/groff/src/preproc/grn/Makefile.sub b/contrib/groff/src/preproc/grn/Makefile.sub
index ffa0ad2..d180803 100644
--- a/contrib/groff/src/preproc/grn/Makefile.sub
+++ b/contrib/groff/src/preproc/grn/Makefile.sub
@@ -1,12 +1,12 @@
-PROG=grn
+PROG=grn$(EXEEXT)
MAN1=grn.n
MLIB=$(LIBM)
XLIBS=$(LIBGROFF)
OBJS=\
- hdb.o \
- hpoint.o \
- hgraph.o \
- main.o
+ hdb.$(OBJEXT) \
+ hpoint.$(OBJEXT) \
+ hgraph.$(OBJEXT) \
+ main.$(OBJEXT)
CCSRCS=\
$(srcdir)/hdb.cc \
$(srcdir)/hpoint.cc \
diff --git a/contrib/groff/src/preproc/grn/README b/contrib/groff/src/preproc/grn/README
index b5b9fc9..7ac685e 100644
--- a/contrib/groff/src/preproc/grn/README
+++ b/contrib/groff/src/preproc/grn/README
@@ -16,7 +16,15 @@ because the gremlin editor uses the conventional spline
algorithm. The Berkeley grn has the choice of different
stipples. Here, only different shades of gray will be painted
depending on the gremlin file. It is possible to upgrade this at
-a later time. (Daniel Senderowicz <daniel@synchrods.com> 12/28/99)
+a later time. (Daniel Senderowicz <daniel@synchrods.com> 12/28/99)
+
+=====================================================================
+
+Gremlin produces three types of curves: B-Splines, interpolated
+curves and Bezier. As the original Berkeley grn, now groff grn
+will honor B-Splines and interpolated curves. Bezier curves will
+be printed as B-Splines. (Daniel Senderowicz <daniel@synchrods.com>
+10/04/02)
=====================================================================
diff --git a/contrib/groff/src/preproc/grn/gprint.h b/contrib/groff/src/preproc/grn/gprint.h
index b25305b..b9df60e 100644
--- a/contrib/groff/src/preproc/grn/gprint.h
+++ b/contrib/groff/src/preproc/grn/gprint.h
@@ -38,6 +38,8 @@
#define ARC 4
#define CURVE 5
#define POLYGON 6
+#define BSPLINE 7
+#define BEZIER 8
#define TOPLEFT 10
#define TOPCENT 11
#define TOPRIGHT 12
diff --git a/contrib/groff/src/preproc/grn/grn.man b/contrib/groff/src/preproc/grn/grn.man
index 82e43cf..9722145 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 Free Software Foundation, Inc.
+Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -46,7 +46,7 @@ the original English.
.BI \-F dir
]
[
-.IR file\.\.\.
+.IR file\.\.\.\&
]
.PP
It is possible to have whitespace between a command line option and its
@@ -131,8 +131,11 @@ for subdirectories
.RI ( name
is the name of the device) for the
.B DESC
-file before the normal
-.BR @FONTDIR@ .
+file before the default font directories
+.BR @LOCALFONTDIR@ ,
+.BR @FONTDIR@ ,
+and
+.BR @LEGACYFONTDIR@ .
.TP
.B \-C
Recognize
@@ -217,7 +220,7 @@ confusion with
There is
.I no
default for stipples (unless one is set by the default command), and it is
-illegal to include a
+invalid to include a
.I gremlin
picture with polygons without specifying a
stipple font.
@@ -408,7 +411,6 @@ format is the use of names for picture objects (e.g., POLYGON, CURVE)
instead of numbers.
Files representing the same picture are shown in Table 1 in each format.
.sp
-.DS
.TS
center, tab(@);
l lw(0.1i) l.
@@ -435,7 +437,6 @@ css.
.sp
Table 1. File examples
.TE
-.DE
.sp
.IP \(bu
The first line of each
@@ -479,6 +480,8 @@ The stuff on this line really isn't all that important; a value of ``1 0.00
.IP \(bu
The rest of the file consists of zero or more element specifications.
After the last element specification is a line containing the string ``-1''.
+.IP \(bu
+Lines longer than 127 characters are chopped to this limit.
.SH ELEMENT SPECIFICATIONS
.IP \(bu
The first line of each element contains a single decimal number giving the
@@ -489,7 +492,6 @@ version) or its ASCII name
version).
See Table 2.
.sp
-.DS
.TS
center, tab(@);
css
@@ -505,6 +507,8 @@ nll.
4@ARC@arc
5@CURVE@curve
6@POLYGON@polygon
+7@BSPLINE@b-spline
+8@BEZIER@B\['e]zier
10@TOPLEFT@top-left-justified text
11@TOPCENT@top-center-justified text
12@TOPRIGHT@top-right-justified text
@@ -517,7 +521,6 @@ css.
Table 2.
Type Specifications in \fIgremlin\fP Files
.TE
-.DE
.sp
.IP \(bu
After the object type comes a variable number of lines, each specifying a
@@ -536,7 +539,6 @@ brush and size for the element.
The brush determines the style in which things are drawn.
For vectors, arcs, and curves there are six legal brush values:
.sp
-.DS
.TS
center, tab(@);
ncw(0.1i)l.
@@ -547,13 +549,11 @@ ncw(0.1i)l.
5 \(mi@@thin solid lines
6 \(mi@@medium solid lines
.TE
-.DE
.sp
For polygons, one more value, 0, is legal.
It specifies a polygon with an invisible border.
For text, the brush selects a font as follows:
.sp
-.DS
.TS
center, tab(@);
ncw(0.1i)l.
@@ -562,7 +562,6 @@ ncw(0.1i)l.
3 \(mi@@bold (B font in groff)
4 \(mi@@special (S font in groff)
.TE
-.DE
.sp
If you're using
.I @g@grn
@@ -570,9 +569,9 @@ to run your pictures through
.IR groff ,
the font is really just a starting font:
The text string can contain formatting sequences like
-``\\fI''
+``\efI''
or
-``\\d''
+``\ed''
which may change the font (as well as do many other things).
For text, the size field is a decimal value between 1 and 4.
It selects the size of the font in which the text will be drawn.
diff --git a/contrib/groff/src/preproc/grn/hdb.cc b/contrib/groff/src/preproc/grn/hdb.cc
index fd5bb48..648a535 100644
--- a/contrib/groff/src/preproc/grn/hdb.cc
+++ b/contrib/groff/src/preproc/grn/hdb.cc
@@ -15,6 +15,7 @@
#include "error.h"
#define MAXSTRING 128
+#define MAXSTRING_S "127"
/* imports from main.cc */
@@ -89,7 +90,7 @@ DBRead(register FILE *file)
SUNFILE = FALSE;
elist = DBInit();
- (void) fscanf(file, "%s\n", string);
+ (void) fscanf(file, "%" MAXSTRING_S "s%*[^\n]\n", string);
if (strcmp(string, "gremlinfile")) {
if (strcmp(string, "sungremlinfile")) {
error("`%1' is not a gremlin file", gremlinfile);
@@ -103,10 +104,10 @@ DBRead(register FILE *file)
done = FALSE;
while (!done) {
- /* if (fscanf(file,"%s\n", string) == EOF) */
+ /* if (fscanf(file,"%" MAXSTRING_S "s\n", string) == EOF) */
/* I changed the scanf format because the element */
/* can have two words (e.g. CURVE SPLINE) */
- if (fscanf(file, "\n%[^\n]\n", string) == EOF) {
+ if (fscanf(file, "\n%" MAXSTRING_S "[^\n]%*[^\n]\n", string) == EOF) {
error("`%1', error in file format", gremlinfile);
return (elist);
}
@@ -210,8 +211,20 @@ DBGetType(register char *s)
case 'A':
return (ARC);
case 'C':
- if (s[1] == 'U')
- return (CURVE);
+ if (s[1] == 'U') {
+ if (s[5] == '\n')
+ return (CURVE);
+ switch (s[7]) {
+ case 'S':
+ return(BSPLINE);
+ case 'E':
+ fprintf(stderr,
+ "Warning: Bezier Curves will be printed as B-Splines\n");
+ return(BSPLINE);
+ default:
+ return(CURVE);
+ }
+ }
switch (s[4]) {
case 'L':
return (CENTLEFT);
diff --git a/contrib/groff/src/preproc/grn/hgraph.cc b/contrib/groff/src/preproc/grn/hgraph.cc
index 7963720..d307faa 100644
--- a/contrib/groff/src/preproc/grn/hgraph.cc
+++ b/contrib/groff/src/preproc/grn/hgraph.cc
@@ -4,6 +4,8 @@
* to troff input.
*/
+#include "lib.h"
+
#include "gprint.h"
#ifdef NEED_DECLARATION_HYPOT
@@ -58,12 +60,13 @@ void tmove2(int px, int py);
void doarc(POINT cp, POINT sp, int angle);
void tmove(POINT * ptr);
void cr();
-void drawwig(POINT * ptr);
+void drawwig(POINT * ptr, int type);
void HGtline(int x1, int y1);
void dx(double x);
void dy(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[],
@@ -126,8 +129,14 @@ HGPrintElt(ELT *element,
break;
case CURVE:
- length = 0; /* keep track of line length */
- drawwig(p1);
+ length = 0; /* keep track of line length */
+ drawwig(p1, CURVE);
+ cr();
+ break;
+
+ case BSPLINE:
+ length = 0; /* keep track of line length */
+ drawwig(p1, BSPLINE);
cr();
break;
@@ -533,16 +542,17 @@ line(int px,
/*----------------------------------------------------------------------------
- | Routine: drawwig (ptr)
+ | Routine: drawwig (ptr, type)
|
| Results: The point sequence found in the structure pointed by ptr is
| placed in integer arrays for further manipulation by the
- | existing routing. With the proper parameters, HGCurve is
- | called.
+ | existing routing. With the corresponding type parameter,
+ | either picurve or HGCurve are called.
*----------------------------------------------------------------------------*/
void
-drawwig(POINT * ptr)
+drawwig(POINT * ptr,
+ int type)
{
register int npts; /* point list index */
int x[MAXPOINTS], y[MAXPOINTS]; /* point list */
@@ -552,8 +562,10 @@ drawwig(POINT * ptr)
y[npts] = (int) (ptr->y * troffscale);
}
if (--npts) {
- /* HGCurve(&x[0], &y[0], npts); */ /*Gremlin looks different, so... */
- picurve(&x[0], &y[0], npts);
+ if (type == CURVE) /* Use the 2 different types of curves */
+ HGCurve(&x[0], &y[0], npts);
+ else
+ picurve(&x[0], &y[0], npts);
}
}
diff --git a/contrib/groff/src/preproc/grn/main.cc b/contrib/groff/src/preproc/grn/main.cc
index efb33a9..9b09ea6 100644
--- a/contrib/groff/src/preproc/grn/main.cc
+++ b/contrib/groff/src/preproc/grn/main.cc
@@ -67,9 +67,10 @@
*/
+#include "lib.h"
+
#include <ctype.h>
#include <stdlib.h>
-#include <string.h>
#include "gprint.h"
#include "device.h"
@@ -77,7 +78,6 @@
#include "searchpath.h"
#include "macropath.h"
-#include "lib.h"
#include "errarg.h"
#include "error.h"
#include "defs.h"
@@ -848,7 +848,7 @@ interpret(char *line)
if (par > 0.0)
xscale *= par;
else
- error("illegal scale value on line %1", linenum);
+ error("invalid scale value on line %1", linenum);
break;
case 'f': /* file */
diff --git a/contrib/groff/src/preproc/html/Makefile.sub b/contrib/groff/src/preproc/html/Makefile.sub
index 8ecd332..5da6d43 100644
--- a/contrib/groff/src/preproc/html/Makefile.sub
+++ b/contrib/groff/src/preproc/html/Makefile.sub
@@ -1,6 +1,6 @@
-PROG=pre-grohtml
+PROG=pre-grohtml$(EXEEXT)
# MAN1=pre-grohtml.n
MAN1=
XLIBS=$(LIBGROFF)
-OBJS=pre-html.o pushbackbuffer.o
-CCSRCS=$(srcdir)/pre-html.cc $(srcdir)/pushbackbuffer.cc
+OBJS=pre-html.$(OBJEXT) pushback.$(OBJEXT)
+CCSRCS=$(srcdir)/pre-html.cc $(srcdir)/pushback.cc
diff --git a/contrib/groff/src/preproc/html/pre-html.cc b/contrib/groff/src/preproc/html/pre-html.cc
index 2a36740..e7364dd 100644
--- a/contrib/groff/src/preproc/html/pre-html.cc
+++ b/contrib/groff/src/preproc/html/pre-html.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
Written by Gaius Mulley (gaius@glam.ac.uk).
This file is part of groff.
@@ -20,18 +20,21 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define PREHTMLC
-#include <stdio.h>
+#include "lib.h"
+
#include <signal.h>
#include <ctype.h>
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
-#include "lib.h"
#include "errarg.h"
#include "error.h"
#include "stringclass.h"
#include "posix.h"
#include "defs.h"
+#include "searchpath.h"
+#include "paper.h"
+#include "font.h"
#include <errno.h>
#include <sys/types.h>
@@ -53,32 +56,27 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
extern "C" const char *Version_string;
#include "pre-html.h"
-#include "pushbackbuffer.h"
+#include "pushback.h"
#include "html-strings.h"
-#define POSTSCRIPTRES 72000 // maybe there is a better way to find this? --fixme--
-#define DEFAULT_IMAGE_RES 80 // 80 pixels per inch resolution
-#define DEFAULT_VERTICAL_OFFSET 45 // DEFAULT_VERTICAL_OFFSET/72 of an inch
+#define DEFAULT_LINE_LENGTH 7 // inches wide
+#define DEFAULT_IMAGE_RES 100 // number of pixels per inch resolution
#define IMAGE_BOARDER_PIXELS 0
-#define MAX_WIDTH 8 // inches
#define INLINE_LEADER_CHAR '\\'
-#define MAX_RETRIES 4096 // number of different page directory names to try before giving up
-#define TRANSPARENT "-background \"#FFF\" -transparent \"#FFF\""
+#define TRANSPARENT "-background white -transparent white"
+#define MIN_ALPHA_BITS 0
+#define MAX_ALPHA_BITS 4
-#ifdef __MSDOS__
-#define PAGE_TEMPLATE "pg"
-#define PS_TEMPLATE "ps"
-#define REGION_TEMPLATE "rg"
-#else
-#define PAGE_TEMPLATE "-page-"
-#define PS_TEMPLATE "-ps-"
-#define REGION_TEMPLATE "-regions-"
-#endif
+#define PAGE_TEMPLATE_SHORT "pg"
+#define PAGE_TEMPLATE_LONG "-page-"
+#define PS_TEMPLATE_SHORT "ps"
+#define PS_TEMPLATE_LONG "-ps-"
+#define REGION_TEMPLATE_SHORT "rg"
+#define REGION_TEMPLATE_LONG "-regions-"
#if 0
# define DEBUGGING
-# define DEBUG_HTML
#endif
#if !defined(TRUE)
@@ -88,31 +86,41 @@ extern "C" const char *Version_string;
# define FALSE (1==0)
#endif
-void stop() {}
-
typedef enum {CENTERED, LEFT, RIGHT, INLINE} IMAGE_ALIGNMENT;
-static int stdoutfd = 1; // output file descriptor - normally 1 but might move
+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
+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 *regionFileName = NULL; // name of file containing all image regions
-static char *imagePageStem = NULL; // stem of all files containing page images
-static char *image_device = "pnmraw";
-static int image_res = DEFAULT_IMAGE_RES;
-static int vertical_offset= DEFAULT_VERTICAL_OFFSET;
-static char *image_template = NULL; // image template filename
-static int troff_arg = 0; // troff arg index
-static char *command_prefix = NULL; // optional prefix for some installations.
-static char *troff_command = NULL;
-static char *image_dir = NULL; // user specified image directory
+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 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
#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
#endif
+static char *linebuf = NULL; // for scanning devps/DESC
+static int linebufsize = 0;
+
+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.
@@ -132,12 +140,80 @@ static int do_file(const char *filename);
void sys_fatal (const char *s)
{
- fprintf(stderr, "%s: %s: %s", program_name, s, strerror(errno));
+ fatal("%1: %2", s, strerror(errno));
+}
+
+/*
+ * get_line - copies a line (w/o newline) from a file to the global line buffer
+ */
+
+int get_line (FILE *f)
+{
+ if (f == 0)
+ return 0;
+ if (linebuf == 0) {
+ linebuf = new char[128];
+ linebufsize = 128;
+ }
+ int i = 0;
+ // skip leading whitespace
+ for (;;) {
+ int c = getc(f);
+ if (c == EOF)
+ return 0;
+ if (c != ' ' && c != '\t') {
+ ungetc(c, f);
+ break;
+ }
+ }
+ for (;;) {
+ int c = getc(f);
+ if (c == EOF)
+ break;
+ if (i + 1 >= linebufsize) {
+ char *old_linebuf = linebuf;
+ linebuf = new char[linebufsize * 2];
+ memcpy(linebuf, old_linebuf, linebufsize);
+ a_delete old_linebuf;
+ linebufsize *= 2;
+ }
+ linebuf[i++] = c;
+ if (c == '\n') {
+ i--;
+ break;
+ }
+ }
+ linebuf[i] = '\0';
+ return 1;
+}
+
+/*
+ * get_resolution - returns the postscript resolution from devps/DESC
+ */
+
+static unsigned int get_resolution (void)
+{
+ char *pathp;
+ FILE *f;
+ unsigned int res;
+ f = font_path.open_file("devps/DESC", &pathp);
+ if (f == 0)
+ fatal("can't open devps/DESC");
+ while (get_line(f)) {
+ int n = sscanf(linebuf, "res %u", &res);
+ if (n >= 1) {
+ fclose(f);
+ return res;
+ }
+ }
+ fatal("can't find `res' keyword in devps/DESC");
+ return 0;
}
/*
* html_system - a wrapper for system()
*/
+
void html_system(const char *s, int redirect_stdout)
{
// Redirect standard error to the null device. This is more
@@ -160,16 +236,10 @@ void html_system(const char *s, int redirect_stdout)
fprintf(stderr, "Calling `%s' failed\n", s);
else if (status)
fprintf(stderr, "Calling `%s' returned status %d\n", s, status);
+ close(save_stderr);
+ close(save_stdout);
}
-#if 0
-
-/*
- * if/when vsnprintf becomes available on all *NIX machines we can use this function,
- * until then we must use the more complex function below which performs hand built
- * %d, %s and %%.
- */
-
/*
* make_message - taken from man printf(3), creates a string via malloc
* and places the result of the va args into string.
@@ -194,9 +264,7 @@ make_message (const char *fmt, ...)
/* If that worked, return the string. */
if (n > -1 && n < size) {
if (size > n+1) {
- np = strdup(p);
- if (np == NULL)
- sys_fatal("strdup");
+ np = strsave(p);
free(p);
return np;
}
@@ -214,142 +282,6 @@ make_message (const char *fmt, ...)
p = np; /* use realloc'ed, p */
}
}
-#else
-
-/*
- * lengthOfintToStr - returns the length of the proposed string value of i.
- * Hand built log10.
- */
-
-int
-lengthOfintToStr (int i)
-{
- int n=0;
-
- if (i < 0)
- sys_fatal("expecting positive integer value");
-
- do {
- i /= 10;
- n++;
- } while (i > 0);
- return n;
-}
-
-/*
- * intToStr - returns a string containing the positive value of i.
- * (int i is assumed to be positive).
- */
-
-char *
-intToStr (int i)
-{
- int n=lengthOfintToStr(i)+1;
- char *p = (char *)malloc(n);
-
- if (p == NULL)
- sys_fatal("malloc");
-
- if (i < 0)
- sys_fatal("expecting positive integer value");
-
- n--;
- p[n] = (char)0;
- do {
- n--;
- p[n] = (char)((i % 10) + (int)'0');
- i /= 10;
- } while (i > 0);
- return( p );
-}
-
-/*
- * make_message - returns a string built from a format specifier.
- * This function does not use vsnprintf; it only
- * understands primitive %%, %s, and %d specifiers.
- */
-
-char *
-make_message (const char *fmt, ...)
-{
- char *p = strdup(fmt); /* so we can splat a nul anywhere in the string */
- char *np;
- char *l;
- char *s;
- char *num;
- int search=0;
- va_list ap;
-
- if (p == NULL)
- sys_fatal("strdup");
-
- va_start(ap, fmt);
- while (p) {
- int lenp=strlen(p);
- char *f = strchr(p+search, '%');
-
- search = f-p;
- np = p;
-
- if (f == NULL) {
- va_end(ap);
- return p;
- }
- switch (*(f+1)) {
-
- case 'd':
- l = strdup(f+2);
- if (l == NULL)
- sys_fatal("strdup");
- *f = (char)0;
- num = intToStr(va_arg(ap, int));
- np = (char *)malloc(strlen(p)+strlen(num)+strlen(l)+1);
- if (np == NULL)
- sys_fatal("malloc");
- strcpy(np, p);
- strcat(np, num);
- strcat(np, l);
- search += strlen(np)-lenp;
- free(num);
- free(l);
- break;
- case 's':
- /* concat */
- l = f+2;
- if (l == NULL)
- sys_fatal("strdup");
- s = va_arg(ap, char *);
- *f = (char)0;
- np = (char *)malloc(strlen(l)+1+strlen(p)+strlen(s));
- if (np == NULL)
- sys_fatal("malloc");
- strcpy(np, p);
- strcat(np, s);
- strcat(np, l);
- search += strlen(s);
- break;
- case '%':
- /* remove one of the two % that we have seen */
- *f = (char)0;
- l = f+1;
- np = (char *)malloc(strlen(l)+1+strlen(p));
- if (np == NULL)
- sys_fatal("malloc");
- strcpy(np, p);
- strcat(np, l);
- search++;
- break;
- default:
- sys_fatal("unexpected format specifier");
- return NULL;
- }
- free(p);
- p = np;
- }
- va_end(ap);
- return NULL;
-}
-#endif
/*
* the class and methods for retaining ascii text
@@ -385,7 +317,7 @@ public:
void write_upto_newline (char_block **t, int *i, int is_html);
int can_see(char_block **t, int *i, char *string);
int skip_spaces(char_block **t, int *i);
- void skip_to_newline(char_block **t, int *i);
+ void skip_until_newline(char_block **t, int *i);
private:
char_block *head;
char_block *tail;
@@ -473,13 +405,12 @@ static void writeString (char *s)
}
/*
- * makeFileName - creates the image filename template.
+ * makeFileName - creates the image filename template
+ * and the macroset image template.
*/
static void makeFileName (void)
{
- char *s;
-
if ((image_dir != NULL) && (strchr(image_dir, '%') != NULL)) {
error("cannot use a `%%' within the image directory name");
exit(1);
@@ -499,19 +430,35 @@ static void makeFileName (void)
}
if (image_template == NULL)
- s = make_message("%sgrohtml-%d", image_dir, (int)getpid());
- else {
- s = make_message("%s%s", image_dir, image_template);
- }
- if (s == NULL)
+ 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(s)+1);
+ image_template = (char *)malloc(strlen("-%d")+strlen(macroset_template)+1);
if (image_template == NULL)
sys_fatal("malloc");
- strcpy(image_template, s);
+ strcpy(image_template, macroset_template);
strcat(image_template, "-%d");
- free(s);
+}
+
+/*
+ * setupAntiAlias - sets up the antialias string, used when we call gs.
+ */
+
+static void setupAntiAlias (void)
+{
+ if (textAlphaBits == 0 && graphicAlphaBits == 0)
+ antiAlias = make_message(" ");
+ else if (textAlphaBits == 0)
+ antiAlias = make_message("-dGraphicsAlphaBits=%d ", graphicAlphaBits);
+ else if (graphicAlphaBits == 0)
+ antiAlias = make_message("-dTextAlphaBits=%d ", textAlphaBits);
+ else
+ antiAlias = make_message("-dTextAlphaBits=%d -dGraphicsAlphaBits=%d ",
+ textAlphaBits, graphicAlphaBits);
}
/*
@@ -521,7 +468,7 @@ static void makeFileName (void)
static void checkImageDir (void)
{
if ((image_dir != NULL) && (strcmp(image_dir, "") != 0))
- if (! ((mkdir(image_dir, 0700) == 0) || (errno == EEXIST))) {
+ if (! ((mkdir(image_dir, 0777) == 0) || (errno == EEXIST))) {
error("cannot create directory `%1'", image_dir);
exit(1);
}
@@ -533,17 +480,19 @@ static void checkImageDir (void)
static void write_end_image (int is_html)
{
- if (is_html) {
- /*
- * emit image name and enable output
- */
- writeString("\\O[2]\\O[1]\\O[4]\n");
- } else {
- /*
- * postscript, therefore emit image boundaries
- */
- writeString("\\O[2]\\O[4]\n");
- }
+ /*
+ * if we are producing html then these
+ * emit image name and enable output
+ * else
+ * we are producing images
+ * in which case these generate image
+ * boundaries
+ */
+ writeString("\\O[4]\\O[2]");
+ if (is_html)
+ writeString("\\O[1]");
+ else
+ writeString("\\O[0]");
}
/*
@@ -556,36 +505,29 @@ static void write_end_image (int is_html)
static void write_start_image (IMAGE_ALIGNMENT pos, int is_html)
{
- if (pos == INLINE) {
- writeString("\\O[3]\\O[5 ");
- writeString(image_template); writeString(".png]");
- } else {
- writeString(".begin \\{\\\n");
- switch (pos) {
-
- case LEFT:
- writeString(". image l ");
- break;
- case RIGHT:
- writeString(". image r ");
- break;
- case CENTERED:
- default:
- writeString(". image c ");
- }
- writeString(image_template); writeString(".png\n");
- if (! is_html) {
- writeString(".bp\n");
- writeString(".tl ''''\n");
- }
- writeString("\\}\n");
+ writeString("\\O[5");
+ switch (pos) {
+
+ case INLINE:
+ writeString("i");
+ break;
+ case LEFT:
+ writeString("l");
+ break;
+ case RIGHT:
+ writeString("r");
+ break;
+ case CENTERED:
+ default:
+ writeString("c");
+ break;
}
- if (is_html) {
- writeString("\\O[0]\n");
- } else {
+ writeString(image_template); writeString(".png]");
+ if (is_html)
+ writeString("\\O[0]\\O[3]");
+ else
// reset min/max registers
- writeString("\\O[0]\\O[1]\n");
- }
+ writeString("\\O[1]\\O[3]");
}
/*
@@ -690,11 +632,11 @@ int char_buffer::skip_spaces(char_block **t, int *i)
}
/*
- * skip_to_newline - skips all characters until a newline is seen.
- * The newline is also consumed.
+ * skip_until_newline - skips all characters until a newline is seen.
+ * The newline is not consumed.
*/
-void char_buffer::skip_to_newline (char_block **t, int *i)
+void char_buffer::skip_until_newline (char_block **t, int *i)
{
int j=*i;
@@ -702,17 +644,10 @@ void char_buffer::skip_to_newline (char_block **t, int *i)
while ((j < (*t)->used) && ((*t)->buffer[j] != '\n')) {
j++;
}
- if ((j < (*t)->used) && ((*t)->buffer[j] == '\n')) {
- j++;
- }
if (j == (*t)->used) {
*i = 0;
- if ((*t)->buffer[j-1] == '\n') {
- *t = (*t)->next;
- } else {
- *t = (*t)->next;
- skip_to_newline(t, i);
- }
+ *t = (*t)->next;
+ skip_until_newline(t, i);
} else {
// newline was seen
*i = j;
@@ -731,24 +666,7 @@ void char_buffer::write_file_troff (void)
if (t != NULL) {
do {
- /*
- * remember to check the shortest string last
- */
- if (can_see(&t, &i, HTML_IMAGE_END)) {
- write_end_image(FALSE);
- skip_to_newline(&t, &i);
- } else if (can_see(&t, &i, HTML_IMAGE_LEFT)) {
- write_start_image(LEFT, FALSE);
- skip_to_newline(&t, &i);
- } else if (can_see(&t, &i, HTML_IMAGE_RIGHT)) {
- write_start_image(RIGHT, FALSE);
- skip_to_newline(&t, &i);
- } else if (can_see(&t, &i, HTML_IMAGE_CENTERED)) {
- write_start_image(CENTERED, FALSE);
- skip_to_newline(&t, &i);
- } else {
- write_upto_newline(&t, &i, FALSE);
- }
+ write_upto_newline(&t, &i, FALSE);
} while (t != NULL);
}
if (close(stdoutfd) < 0)
@@ -820,6 +738,10 @@ 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);
};
/*
@@ -845,82 +767,76 @@ imageList::~imageList ()
}
/*
- * createAllPages - creates a set of images, one per page.
+ * createPage - creates one image of, page pageno, from the postscript file.
*/
-static int createAllPages (void)
+int imageList::createPage (int pageno)
{
- char buffer[4096];
char *s;
- int retries = MAX_RETRIES;
- imagePageStem = xtmptemplate(PAGE_TEMPLATE);
- strcpy(buffer, imagePageStem);
+ if (currentPageNo == pageno)
+ return 0;
- do {
- if (mktemp(imagePageStem) == NULL) {
- sys_fatal("mktemp");
- return -1;
- }
- if (mkdir(imagePageStem, 0700) == 0) break;
- if (errno == EEXIST) {
- // directory already exists, try another name
- retries--;
- if (retries == 0) {
- // time to give up
- sys_fatal("mkdir");
- return -1;
- }
- } else {
- // another error, quit
- sys_fatal("mkdir");
- return -1;
- }
- strcpy(imagePageStem, buffer);
- } while (1);
+ 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.
+ */
+ unlink(imagePageName);
+ unlink(psPageName);
+ }
+
+ if (show_progress) {
+ fprintf(stderr, "[%d] ", pageno);
+ fflush(stderr);
+ }
+#if defined(DEBUGGING)
+ if (debug)
+ fprintf(stderr, "creating page %d\n", pageno);
+#endif
+
+ s = make_message("psselect -q -p%d %s %s\n",
+ pageno, psFileName, psPageName);
+
+ if (s == NULL)
+ sys_fatal("make_message");
+#if defined(DEBUGGING)
+ if (debug) {
+ fwrite(s, sizeof(char), strlen(s), stderr);
+ fflush(stderr);
+ }
+#endif
+ html_system(s, 1);
+
s = make_message("echo showpage | "
- "gs%s -q -dSAFER -sDEVICE=%s -r%d "
- "-sOutputFile=%s/%%d %s -",
+ "gs%s -q -dBATCH -dSAFER "
+ "-dDEVICEHEIGHTPOINTS=792 "
+ "-dDEVICEWIDTHPOINTS=%d -dFIXEDMEDIA=true "
+ "-sDEVICE=%s -r%d %s "
+ "-sOutputFile=%s %s -\n",
EXE_EXT,
+ (getMaxX(pageno) * image_res) / postscriptRes,
image_device,
image_res,
- imagePageStem,
- psFileName);
+ antiAlias,
+ imagePageName,
+ psPageName);
if (s == NULL)
sys_fatal("make_message");
#if defined(DEBUGGING)
- fwrite(s, sizeof(char), strlen(s), stderr);
- fflush(stderr);
+ if (debug) {
+ fwrite(s, sizeof(char), strlen(s), stderr);
+ fflush(stderr);
+ }
#endif
html_system(s, 1);
- free(s);
+ a_delete s;
+ currentPageNo = pageno;
return 0;
}
/*
- * removeAllPages - removes all page images.
- */
-
-static void removeAllPages (void)
-{
-#if !defined(DEBUGGING)
- char *s=NULL;
- int i=1;
-
- do {
- if (s)
- free(s);
- s = make_message("%s/%d", imagePageStem, i);
- if (s == NULL)
- sys_fatal("make_message");
- i++;
- } while (unlink(s) == 0);
- rmdir(imagePageStem);
-#endif
-}
-
-/*
* min - returns the minimum of two numbers.
*/
@@ -947,38 +863,63 @@ int max (int x, int y)
}
/*
+ * getMaxX - returns the largest right hand position for any image on, pageno
+ */
+
+int imageList::getMaxX (int pageno)
+{
+ imageItem *h = head;
+ int x = postscriptRes * DEFAULT_LINE_LENGTH;
+
+ while (h != NULL) {
+ if (h->pageNo == pageno)
+ x = max(h->X2, x);
+ h = h->next;
+ }
+ return x;
+}
+
+/*
* createImage - generates a minimal png file from the set of page images.
*/
-static void 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;
-
- s = make_message("pnmcut%s %d %d %d %d < %s/%d | pnmtopng%s %s > %s \n",
- EXE_EXT,
- x1, y1, x2-x1+1, y2-y1+1,
- imagePageStem,
- i->pageNo,
- EXE_EXT,
- TRANSPARENT,
- i->imageName);
- if (s == NULL)
- sys_fatal("make_message");
+ 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;
+ if (createPage(i->pageNo) == 0) {
+ 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,
+ imagePageName,
+ EXE_EXT,
+ TRANSPARENT,
+ i->imageName);
+ if (s == NULL)
+ sys_fatal("make_message");
#if defined(DEBUGGING)
- fprintf(stderr, s);
+ if (debug) {
+ fprintf(stderr, s);
+ fflush(stderr);
+ }
#endif
- html_system(s, 0);
- free(s);
+ html_system(s, 0);
+ a_delete s;
+ } else {
+ fprintf(stderr, "failed to generate image of page %d\n", i->pageNo);
+ fflush(stderr);
+ }
#if defined(DEBUGGING)
} else {
- fprintf(stderr, "ignoring image as x1 coord is -1\n");
- fflush(stderr);
+ if (debug) {
+ fprintf(stderr, "ignoring image as x1 coord is -1\n");
+ fflush(stderr);
+ }
#endif
}
}
@@ -998,7 +939,20 @@ void imageList::add (int x1, int y1, int x2, int y2, int page, int res, int maxx
tail->next = i;
tail = i;
}
- createImage(i);
+}
+
+/*
+ * createImages - foreach image descriptor on the imageList, create the actual image.
+ */
+
+void imageList::createImages (void)
+{
+ imageItem *h = head;
+
+ while (h != NULL) {
+ createImage(h);
+ h = h->next;
+ }
}
static imageList listOfImages; // list of images defined by the region file.
@@ -1011,31 +965,12 @@ static imageList listOfImages; // list of images defined by the region file.
void char_buffer::write_file_html (void)
{
- char_block *t =head;
+ char_block *t=head;
int i=0;
if (t != NULL) {
- stop();
do {
- /*
- * remember to check the shortest string last
- */
- if (can_see(&t, &i, HTML_IMAGE_END)) {
- write_end_image(TRUE);
- skip_to_newline(&t, &i);
- } else if (can_see(&t, &i, HTML_IMAGE_LEFT)) {
- write_start_image(LEFT, TRUE);
- skip_to_newline(&t, &i);
- } else if (can_see(&t, &i, HTML_IMAGE_RIGHT)) {
- write_start_image(RIGHT, TRUE);
- skip_to_newline(&t, &i);
- } else if (can_see(&t, &i, HTML_IMAGE_CENTERED)) {
- stop();
- write_start_image(CENTERED, TRUE);
- skip_to_newline(&t, &i);
- } else {
- write_upto_newline(&t, &i, TRUE);
- }
+ write_upto_newline(&t, &i, TRUE);
} while (t != NULL);
}
if (close(stdoutfd) < 0)
@@ -1067,9 +1002,9 @@ static void generateImages (char *regionFileName)
int y1 = f->readInt();
int x2 = f->readInt();
int y2 = f->readInt();
- int maxx = max(f->readInt(), MAX_WIDTH*image_res);
+ int maxx = f->readInt();
char *name = f->readString();
- int res = POSTSCRIPTRES; // --fixme-- prefer (f->readInt()) providing that troff can discover the value
+ int res = postscriptRes;
listOfImages.add(x1, y1, x2, y2, page, res, maxx, name);
while ((f->putPB(f->getPB()) != '\n') &&
(f->putPB(f->getPB()) != eof)) {
@@ -1085,6 +1020,13 @@ static void generateImages (char *regionFileName)
fputc(f->getPB(), stderr);
}
}
+
+ listOfImages.createImages();
+ if (show_progress) {
+ fprintf(stderr, "done\n");
+ fflush(stderr);
+ }
+ delete f;
}
/*
@@ -1123,7 +1065,7 @@ static void waitForChild (PID_T pid)
PID_T waitpd;
int status;
- waitpd = wait(&status);
+ waitpd = WAIT(&status, pid, _WAIT_CHILD);
if (waitpd != pid)
sys_fatal("wait");
}
@@ -1132,7 +1074,7 @@ static void waitForChild (PID_T pid)
* alterDeviceTo - if toImage is set then the arg list is altered to include
* IMAGE_DEVICE and we invoke groff rather than troff.
* else
- * set -Thtml and troff
+ * set -Thtml and groff
*/
static void alterDeviceTo (int argc, char *argv[], int toImage)
@@ -1154,8 +1096,68 @@ static void alterDeviceTo (int argc, char *argv[], int toImage)
}
i++;
}
- argv[troff_arg] = troff_command; /* use troff */
+ argv[troff_arg] = "groff"; /* use groff -Z */
+ }
+}
+
+/*
+ * addZ - appends -Z onto the command list for groff.
+ */
+
+char **addZ (int argc, char *argv[])
+{
+ char **new_argv = (char **)malloc((argc+2)*sizeof(char *));
+ int i=0;
+
+ if (new_argv == NULL)
+ sys_fatal("malloc");
+
+ if (argc > 0) {
+ new_argv[i] = argv[i];
+ i++;
+ }
+ new_argv[i] = "-Z";
+ while (i<argc) {
+ new_argv[i+1] = argv[i];
+ i++;
}
+ argc++;
+ new_argv[argc] = NULL;
+ return new_argv;
+}
+
+/*
+ * addRegDef - appends a defined register or string onto the command list for troff.
+ */
+
+char **addRegDef (int argc, char *argv[], const char *numReg)
+{
+ char **new_argv = (char **)malloc((argc+2)*sizeof(char *));
+ int i=0;
+
+ if (new_argv == NULL)
+ sys_fatal("malloc");
+
+ while (i<argc) {
+ new_argv[i] = argv[i];
+ i++;
+ }
+ new_argv[argc] = strdup(numReg);
+ argc++;
+ new_argv[argc] = NULL;
+ return new_argv;
+}
+
+/*
+ * dump_args - display the argument list.
+ */
+
+void dump_args (int argc, char *argv[])
+{
+ fprintf(stderr, " %d arguments:", argc);
+ for (int i=0; i<argc; i++)
+ fprintf(stderr, " %s", argv[i]);
+ fprintf(stderr, "\n");
}
/*
@@ -1167,19 +1169,23 @@ int char_buffer::do_html(int argc, char *argv[])
{
int pdes[2];
PID_T pid;
-
- if (pipe(pdes) < 0)
- sys_fatal("pipe");
+ string s;
alterDeviceTo(argc, argv, 0);
- argv += troff_arg; // skip all arguments up to troff/groff
+ argv += troff_arg; // skip all arguments up to groff
argc -= troff_arg;
+ argv = addZ(argc, argv);
+ argc++;
+
+ s = "-dwww-image-template=";
+ 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");
-#if defined(DEBUG_HTML)
- write_file_html();
- writeString("--------------- troff --------------------------\n");
- write_file_troff();
-#else
pid = fork();
if (pid < 0)
sys_fatal("fork");
@@ -1216,30 +1222,7 @@ int char_buffer::do_html(int argc, char *argv[])
write_file_html();
waitForChild(pid);
}
-#endif
- return( 0 );
-}
-
-/*
- * addps4html - appends -rps4html=1 onto the command list for troff.
- */
-
-char **addps4html (int argc, char *argv[])
-{
- char **new_argv = (char **)malloc((argc+2)*sizeof(char *));
- int i=0;
-
- if (new_argv == NULL)
- sys_fatal("malloc");
-
- while (i<argc) {
- new_argv[i] = argv[i];
- i++;
- }
- new_argv[argc] = "-rps4html=1";
- argc++;
- new_argv[argc] = NULL;
- return( new_argv );
+ return 0;
}
/*
@@ -1250,16 +1233,27 @@ int char_buffer::do_image(int argc, char *argv[])
{
PID_T pid;
int pdes[2];
-
- if (pipe(pdes) < 0)
- sys_fatal("pipe");
+ string s;
alterDeviceTo(argc, argv, 1);
argv += troff_arg; // skip all arguments up to troff/groff
argc -= troff_arg;
- argv = addps4html(argc, argv);
+ argv = addRegDef(argc, argv, "-rps4html=1");
+ argc++;
+
+ s = "-dwww-image-template=";
+ s += macroset_template;
+ s += '\0';
+ argv = addRegDef(argc, argv, s.contents());
+ argc++;
+
+ // override local settings and produce a page size letter postscript file
+ argv = addRegDef(argc, argv, "-P-pletter");
argc++;
+ if (pipe(pdes) < 0)
+ sys_fatal("pipe");
+
pid = fork();
if (pid == 0) {
// child
@@ -1295,7 +1289,7 @@ int char_buffer::do_image(int argc, char *argv[])
write_file_troff();
waitForChild(pid);
}
- return( 0 );
+ return 0;
}
static char_buffer inputFile;
@@ -1315,44 +1309,96 @@ void usage(FILE *stream)
}
/*
- * scanArguments - scans for -P-i, -P-o, -P-D and -P-I arguments.
+ * 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.
*/
int scanArguments (int argc, char **argv)
{
- int i=1;
-
- while (i<argc) {
- if (strncmp(argv[i], "-D", 2) == 0) {
- image_dir = (char *)(argv[i]+2);
- } else if (strncmp(argv[i], "-I", 2) == 0) {
- image_template = (char *)(argv[i]+2);
- } else if (strncmp(argv[i], "-i", 2) == 0) {
- image_res = atoi((char *)(argv[i]+2));
- } else if (strncmp(argv[i], "-o", 2) == 0) {
- vertical_offset = atoi((char *)(argv[i]+2));
- } else if ((strcmp(argv[i], "-v") == 0)
- || (strcmp(argv[i], "--version") == 0)) {
+ const char *command_prefix = getenv("GROFF_COMMAND_PREFIX");
+ if (!command_prefix)
+ command_prefix = PROG_PREFIX;
+ char *troff_name = new char[strlen(command_prefix) + strlen("troff") + 1];
+ strcpy(troff_name, command_prefix);
+ strcat(troff_name, "troff");
+ int c, i;
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "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))
+ != EOF)
+ switch(c) {
+ case 'v':
printf("GNU pre-grohtml (groff) version %s\n", Version_string);
exit(0);
- } else if ((strcmp(argv[i], "-h") == 0)
- || (strcmp(argv[i], "--help") == 0)
- || (strcmp(argv[i], "-?") == 0)) {
- usage(stdout);
- exit(0);
- } else if (strcmp(argv[i], troff_command) == 0) {
- /* remember troff argument number */
- troff_arg = i;
+ case 'a':
+ 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 'g':
+ 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)
+ break;
+ case 'D':
+ image_dir = optarg;
+ break;
+ case 'I':
+ image_template = optarg;
+ break;
+ case 'i':
+ image_res = atoi(optarg);
+ break;
+ case 'F':
+ font_path.command_line_dir(optarg);
+ break;
+ case 'o':
+ vertical_offset = atoi(optarg);
+ break;
+ case 'p':
+ show_progress = TRUE;
+ break;
+ case 'd':
#if defined(DEBUGGING)
- } else if (strcmp(argv[i], "-d") == 0) {
debug = TRUE;
#endif
- } else if (argv[i][0] != '-') {
- return( i );
+ break;
+ case 'h':
+ // handled by post-grohtml
+ break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
+ case '?':
+ usage(stderr);
+ exit(1);
+ break;
+ default:
+ break;
}
+
+ i = optind;
+ while (i < argc) {
+ if (strcmp(argv[i], troff_name) == 0)
+ troff_arg = i;
+ else if (argv[i][0] != '-')
+ return i;
i++;
}
- return( argc );
+ a_delete troff_name;
+
+ return argc;
}
/*
@@ -1364,58 +1410,57 @@ static int makeTempFiles (void)
#if defined(DEBUGGING)
psFileName = "/tmp/prehtml-ps";
regionFileName = "/tmp/prehtml-region";
- imagePageStem = "/tmp/prehtml-page";
+ imagePageName = "/tmp/prehtml-page";
+ psPageName = "/tmp/prehtml-psn";
troffFileName = "/tmp/prehtml-troff";
htmlFileName = "/tmp/prehtml-html";
#else
- int fd;
-
- if ((fd = mkstemp(psFileName = xtmptemplate(PS_TEMPLATE))) == -1) {
- sys_fatal("mkstemp");
+ FILE *f;
+
+ /* psPageName contains a single page of postscript */
+ f = xtmpfile(&psPageName,
+ PS_TEMPLATE_LONG, PS_TEMPLATE_SHORT,
+ TRUE);
+ if (f == NULL) {
+ sys_fatal("xtmpfile");
return -1;
}
- close(fd);
- if ((fd = mkstemp(regionFileName = xtmptemplate(REGION_TEMPLATE))) == -1) {
- sys_fatal("mkstemp");
- unlink(psFileName);
+ fclose(f);
+
+ /* imagePageName contains a bitmap image of the single postscript page */
+ f = xtmpfile(&imagePageName,
+ PAGE_TEMPLATE_LONG, PAGE_TEMPLATE_SHORT,
+ TRUE);
+ if (f == NULL) {
+ sys_fatal("xtmpfile");
return -1;
}
- close(fd);
-#endif
- return 0;
-}
-
-/*
- * removeTempFiles - remove the temporary files
- */
+ fclose(f);
+
+ /* psFileName contains a postscript file of the complete document */
+ f = xtmpfile(&psFileName,
+ PS_TEMPLATE_LONG, PS_TEMPLATE_SHORT,
+ TRUE);
+ if (f == NULL) {
+ sys_fatal("xtmpfile");
+ return -1;
+ }
+ fclose(f);
+
+ /* regionFileName contains a list of the images and their boxed coordinates */
+ f = xtmpfile(&regionFileName,
+ REGION_TEMPLATE_LONG, REGION_TEMPLATE_SHORT,
+ TRUE);
+ if (f == NULL) {
+ sys_fatal("xtmpfile");
+ return -1;
+ }
+ fclose(f);
-static void removeTempFiles (void)
-{
-#if !defined(DEBUGGING)
- unlink(psFileName);
- unlink(regionFileName);
#endif
+ return 0;
}
-/*
- * findPrefix - finds the optional prefix to the groff utilities.
- * It also builds the 'troff' executable name.
- */
-
-static void findPrefix (void)
-{
- command_prefix = getenv("GROFF_COMMAND_PREFIX");
- if (!command_prefix)
- command_prefix = PROG_PREFIX;
- troff_command = (char *)malloc(strlen("troff")+strlen(command_prefix)+1);
- if (troff_command == NULL)
- sys_fatal("malloc");
-
- strcpy(troff_command, command_prefix);
- strcat(troff_command, "troff");
-}
-
-
int main(int argc, char **argv)
{
program_name = argv[0];
@@ -1423,8 +1468,9 @@ int main(int argc, char **argv)
int found=0;
int ok=1;
- findPrefix();
+ postscriptRes = get_resolution();
i = scanArguments(argc, argv);
+ setupAntiAlias();
checkImageDir();
makeFileName();
while (i < argc) {
@@ -1448,14 +1494,9 @@ int main(int argc, char **argv)
return 1;
ok = inputFile.do_image(argc, argv);
if (ok == 0) {
- ok = createAllPages();
- if (ok == 0) {
- generateImages(regionFileName);
- ok = inputFile.do_html(argc, argv);
- removeAllPages();
- }
+ generateImages(regionFileName);
+ ok = inputFile.do_html(argc, argv);
}
- removeTempFiles();
return ok;
}
diff --git a/contrib/groff/src/preproc/html/pushback.cc b/contrib/groff/src/preproc/html/pushback.cc
new file mode 100644
index 0000000..d18c5e2
--- /dev/null
+++ b/contrib/groff/src/preproc/html/pushback.cc
@@ -0,0 +1,333 @@
+// -*- C++ -*-
+/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Written by Gaius Mulley (gaius@glam.ac.uk).
+
+This file is part of groff.
+
+groff is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+groff is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+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. */
+
+#include "lib.h"
+
+#include <signal.h>
+#include <ctype.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <errno.h>
+#include "errarg.h"
+#include "error.h"
+#include "stringclass.h"
+#include "posix.h"
+#include "nonposix.h"
+
+#include <errno.h>
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "pushback.h"
+#include "pre-html.h"
+
+#if !defined(TRUE)
+# define TRUE (1==1)
+#endif
+
+#if !defined(FALSE)
+# define FALSE (1==0)
+#endif
+
+# define ERROR(X) (void)(fprintf(stderr, "%s:%d error %s\n", __FILE__, __LINE__, X) && \
+ (fflush(stderr)) && localexit(1))
+
+
+#define MAXPUSHBACKSTACK 4096 /* maximum number of character that can be pushed back */
+
+
+/*
+ * constructor for pushBackBuffer
+ */
+
+pushBackBuffer::pushBackBuffer (char *filename)
+{
+ charStack = (char *)malloc(MAXPUSHBACKSTACK);
+ if (charStack == 0) {
+ sys_fatal("malloc");
+ }
+ stackPtr = 0; /* index to push back stack */
+ debug = 0;
+ verbose = 0;
+ eofFound = FALSE;
+ lineNo = 1;
+ if (strcmp(filename, "") != 0) {
+ stdIn = dup(0);
+ close(0);
+ if (open(filename, O_RDONLY) != 0) {
+ sys_fatal("when trying to open file");
+ } else {
+ fileName = filename;
+ }
+ }
+}
+
+pushBackBuffer::~pushBackBuffer ()
+{
+ int old;
+
+ if (charStack != 0) {
+ free(charStack);
+ }
+ close(0);
+ /* restore stdin in file descriptor 0 */
+ old = dup(stdIn);
+ close(stdIn);
+}
+
+/*
+ * localexit - wraps exit with a return code to aid the ERROR macro.
+ */
+
+int localexit (int i)
+{
+ exit(i);
+ return( 1 );
+}
+
+/*
+ * getPB - returns a character, possibly a pushed back character.
+ */
+
+char pushBackBuffer::getPB (void)
+{
+ if (stackPtr>0) {
+ stackPtr--;
+ return( charStack[stackPtr] );
+ } else {
+ char ch;
+
+ if (read(0, &ch, 1) == 1) {
+ if (verbose) {
+ printf("%c", ch);
+ }
+ if (ch == '\n') {
+ lineNo++;
+ }
+ return( ch );
+ } else {
+ eofFound = TRUE;
+ return( eof );
+ }
+ }
+}
+
+/*
+ * putPB - pushes a character onto the push back stack.
+ * The same character is returned.
+ */
+
+char pushBackBuffer::putPB (char ch)
+{
+ if (stackPtr<MAXPUSHBACKSTACK) {
+ charStack[stackPtr] = ch ;
+ stackPtr++;
+ } else {
+ ERROR("max push back stack exceeded, increase MAXPUSHBACKSTACK constant");
+ }
+ return( ch );
+}
+
+/*
+ * isWhite - returns TRUE if a white character is found. This character is NOT consumed.
+ */
+
+static int isWhite (char ch)
+{
+ return( (ch==' ') || (ch == '\t') || (ch == '\n') );
+}
+
+/*
+ * skipToNewline - skips characters until a newline is seen.
+ */
+
+void pushBackBuffer::skipToNewline (void)
+{
+ char ch;
+
+ while ((putPB(getPB()) != '\n') && (! eofFound)) {
+ ch = getPB();
+ }
+}
+
+/*
+ * skipUntilToken - skips until a token is seen
+ */
+
+void pushBackBuffer::skipUntilToken (void)
+{
+ char ch;
+
+ while ((isWhite(putPB(getPB())) || (putPB(getPB()) == '#')) && (! eofFound)) {
+ ch = getPB();
+ if (ch == '#') {
+ skipToNewline();
+ }
+ }
+}
+
+/*
+ * isString - returns TRUE if the string, s, matches the pushed back string.
+ * if TRUE is returned then this string is consumed, otherwise it is
+ * left alone.
+ */
+
+int pushBackBuffer::isString (char *s)
+{
+ int length=strlen(s);
+ int i=0;
+
+ while ((i<length) && (putPB(getPB())==s[i])) {
+ if (getPB() != s[i]) {
+ ERROR("assert failed");
+ }
+ i++;
+ }
+ if (i==length) {
+ return( TRUE );
+ } else {
+ i--;
+ while (i>=0) {
+ if (putPB(s[i]) != s[i]) {
+ ERROR("assert failed");
+ }
+ i--;
+ }
+ }
+ return( FALSE );
+}
+
+/*
+ * isDigit - returns TRUE if the character, ch, is a digit.
+ */
+
+static int isDigit (char ch)
+{
+ return( ((ch>='0') && (ch<='9')) );
+}
+
+/*
+ * isHexDigit - returns TRUE if the character, ch, is a hex digit.
+ */
+
+#if 0
+static int isHexDigit (char ch)
+{
+ return( (isDigit(ch)) || ((ch>='a') && (ch<='f')) );
+}
+#endif
+
+/*
+ * readInt - returns an integer from the input stream.
+ */
+
+int pushBackBuffer::readInt (void)
+{
+ int c =0;
+ int i =0;
+ int s =1;
+ char ch=getPB();
+
+ while (isWhite(ch)) {
+ ch=getPB();
+ }
+ // now read integer
+
+ if (ch == '-') {
+ s = -1;
+ ch = getPB();
+ }
+ while (isDigit(ch)) {
+ i *= 10;
+ if ((ch>='0') && (ch<='9')) {
+ i += (int)(ch-'0');
+ }
+ ch = getPB();
+ c++;
+ }
+ if (ch != putPB(ch)) {
+ ERROR("assert failed");
+ }
+ return( i*s );
+}
+
+/*
+ * convertToFloat - converts integers, a and b into a.b
+ */
+
+static float convertToFloat (int a, int b)
+{
+ int c=10;
+ float f;
+
+ while (b>c) {
+ c *= 10;
+ }
+ f = ((float)a) + (((float)b)/((float)c));
+ return( f );
+}
+
+/*
+ * readNumber - returns a float representing the word just read.
+ */
+
+float pushBackBuffer::readNumber (void)
+{
+ int i;
+ char ch;
+
+ i = readInt();
+ if ((ch = getPB()) == '.') {
+ return convertToFloat(i, readInt());
+ }
+ putPB(ch);
+ return (float)i;
+}
+
+/*
+ * readString - reads a string terminated by white space
+ * and returns a malloced area of memory containing
+ * a copy of the characters.
+ */
+
+char *pushBackBuffer::readString (void)
+{
+ char buffer[MAXPUSHBACKSTACK];
+ char *string = 0;
+ int i=0;
+ char ch=getPB();
+
+ while (isWhite(ch)) {
+ ch=getPB();
+ }
+ while ((i < MAXPUSHBACKSTACK) && (! isWhite(ch)) && (! eofFound)) {
+ buffer[i] = ch;
+ i++;
+ ch = getPB();
+ }
+ if (i < MAXPUSHBACKSTACK) {
+ buffer[i] = (char)0;
+ string = (char *)malloc(strlen(buffer)+1);
+ strcpy(string, buffer);
+ }
+ return( string );
+}
diff --git a/contrib/groff/src/preproc/html/pushback.h b/contrib/groff/src/preproc/html/pushback.h
new file mode 100644
index 0000000..93cb3f1
--- /dev/null
+++ b/contrib/groff/src/preproc/html/pushback.h
@@ -0,0 +1,54 @@
+// -*- C -*-
+/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Written by Gaius Mulley (gaius@glam.ac.uk).
+
+This file is part of groff.
+
+groff is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+groff is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+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. */
+
+
+#define eof (char)-1
+
+
+/*
+ * defines the class and methods implemented within pushbackbuffer.cc
+ */
+
+class pushBackBuffer
+{
+ private:
+ char *charStack;
+ int stackPtr; /* index to push back stack */
+ int debug;
+ int verbose;
+ int eofFound;
+ char *fileName;
+ int lineNo;
+ 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 (char *string);
+};
+
+
diff --git a/contrib/groff/src/preproc/pic/Makefile.sub b/contrib/groff/src/preproc/pic/Makefile.sub
index f1e2927..05c47a1 100644
--- a/contrib/groff/src/preproc/pic/Makefile.sub
+++ b/contrib/groff/src/preproc/pic/Makefile.sub
@@ -1,16 +1,16 @@
-PROG=pic
+PROG=pic$(EXEEXT)
MAN1=pic.n
XLIBS=$(LIBGROFF)
MLIB=$(LIBM)
OBJS=\
- pic.o \
- lex.o \
- main.o \
- object.o \
- common.o \
- troff.o \
- tex.o
- # fig.o
+ pic.$(OBJEXT) \
+ lex.$(OBJEXT) \
+ main.$(OBJEXT) \
+ object.$(OBJEXT) \
+ common.$(OBJEXT) \
+ troff.$(OBJEXT) \
+ tex.$(OBJEXT)
+ # fig.$(OBJEXT)
CCSRCS=\
$(srcdir)/lex.cc \
$(srcdir)/main.cc \
@@ -26,6 +26,6 @@ HDRS=\
$(srcdir)/position.h \
$(srcdir)/text.h
GRAM=$(srcdir)/pic.y
-YTABC=$(srcdir)/pic.cc
-YTABH=$(srcdir)/pic_tab.h
+YTABC=pic.cc
+YTABH=pic_tab.h
NAMEPREFIX=$(g)
diff --git a/contrib/groff/src/preproc/pic/common.cc b/contrib/groff/src/preproc/pic/common.cc
index e83ef31..5075e93 100644
--- a/contrib/groff/src/preproc/pic/common.cc
+++ b/contrib/groff/src/preproc/pic/common.cc
@@ -437,7 +437,6 @@ void common_output::dot_line(const position &start, const position &end,
}
}
-
void common_output::solid_rounded_box(const position &cent,
const distance &dim, double rad,
const line_type &lt)
diff --git a/contrib/groff/src/preproc/pic/common.h b/contrib/groff/src/preproc/pic/common.h
index 25a6e10..90b65fa 100644
--- a/contrib/groff/src/preproc/pic/common.h
+++ b/contrib/groff/src/preproc/pic/common.h
@@ -63,6 +63,10 @@ public:
const line_type &, double) = 0;
void rounded_box(const position &, const distance &, double,
const line_type &, double);
+ void set_color(char *, char *) = 0;
+ void reset_color() = 0;
+ char *get_last_filled() = 0;
+ char *get_outline_color() = 0;
};
int compute_arc_center(const position &start, const position &cent,
diff --git a/contrib/groff/src/preproc/pic/lex.cc b/contrib/groff/src/preproc/pic/lex.cc
index 5b6d439..14a4cc3 100644
--- a/contrib/groff/src/preproc/pic/lex.cc
+++ b/contrib/groff/src/preproc/pic/lex.cc
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -83,8 +84,8 @@ int file_input::read_line()
int c = getc(fp);
if (c == EOF)
break;
- else if (illegal_input_char(c))
- lex_error("illegal input character code %1", c);
+ else if (invalid_input_char(c))
+ lex_error("invalid input character code %1", c);
else {
line += char(c);
if (c == '\n')
@@ -153,7 +154,7 @@ int macro_input::peek()
return (unsigned char)*p;
}
-// Character representing $1. Must be illegal input character.
+// Character representing $1. Must be invalid input character.
#define ARG1 14
char *process_body(const char *body)
@@ -446,6 +447,10 @@ int lookup_keyword(const char *str, int len)
{ "center", CENTER },
{ "chop", CHOP },
{ "circle", CIRCLE },
+ { "color", COLORED },
+ { "colored", COLORED },
+ { "colour", COLORED },
+ { "coloured", COLORED },
{ "command", COMMAND },
{ "copy", COPY },
{ "cos", COS },
@@ -457,6 +462,7 @@ int lookup_keyword(const char *str, int len)
{ "do", DO },
{ "dotted", DOTTED },
{ "down", DOWN },
+ { "east", EAST },
{ "ellipse", ELLIPSE },
{ "else", ELSE },
{ "end", END },
@@ -480,7 +486,10 @@ int lookup_keyword(const char *str, int len)
{ "max", K_MAX },
{ "min", K_MIN },
{ "move", MOVE },
+ { "north", NORTH },
{ "of", OF },
+ { "outline", OUTLINED },
+ { "outlined", OUTLINED },
{ "plot", PLOT },
{ "print", PRINT },
{ "rad", RADIUS },
@@ -491,8 +500,10 @@ int lookup_keyword(const char *str, int len)
{ "rjust", RJUST },
{ "same", SAME },
{ "sh", SH },
+ { "shaded", SHADED },
{ "sin", SIN },
{ "solid", SOLID },
+ { "south", SOUTH },
{ "spline", SPLINE },
{ "sprintf", SPRINTF },
{ "sqrt", SQRT },
@@ -510,6 +521,7 @@ int lookup_keyword(const char *str, int len)
{ "up", UP },
{ "upper", UPPER },
{ "way", WAY },
+ { "west", WEST },
{ "wid", WIDTH },
{ "width", WIDTH },
{ "with", WITH },
@@ -953,7 +965,7 @@ int get_token(int lookup_flag)
double factor = 1.0;
for (;;) {
c = input_stack::peek_char();
- if (!c == EOF || !csdigit(c))
+ if (c == EOF || !csdigit(c))
break;
input_stack::get_char();
context_buffer += char(c);
@@ -1618,8 +1630,8 @@ simple_file_input::~simple_file_input()
int simple_file_input::get()
{
int c = getc(fp);
- while (illegal_input_char(c)) {
- error("illegal input character code %1", c);
+ while (invalid_input_char(c)) {
+ error("invalid input character code %1", c);
c = getc(fp);
}
if (c == '\n')
@@ -1630,8 +1642,8 @@ int simple_file_input::get()
int simple_file_input::peek()
{
int c = getc(fp);
- while (illegal_input_char(c)) {
- error("illegal input character code %1", c);
+ while (invalid_input_char(c)) {
+ error("invalid input character code %1", c);
c = getc(fp);
}
if (c != EOF)
@@ -1816,6 +1828,46 @@ int yylex()
}
else
return t;
+ case NORTH:
+ // recognise NORTH only before OF
+ old_context_buffer = context_buffer;
+ lookahead_token = get_token(1);
+ if (lookahead_token != OF) {
+ yylval.str = strsave("north");
+ return VARIABLE;
+ }
+ else
+ return t;
+ case SOUTH:
+ // recognise SOUTH only before OF
+ old_context_buffer = context_buffer;
+ lookahead_token = get_token(1);
+ if (lookahead_token != OF) {
+ yylval.str = strsave("south");
+ return VARIABLE;
+ }
+ else
+ return t;
+ case EAST:
+ // recognise EAST only before OF
+ old_context_buffer = context_buffer;
+ lookahead_token = get_token(1);
+ if (lookahead_token != OF) {
+ yylval.str = strsave("east");
+ return VARIABLE;
+ }
+ else
+ return t;
+ case WEST:
+ // recognise WEST only before OF
+ old_context_buffer = context_buffer;
+ lookahead_token = get_token(1);
+ if (lookahead_token != OF) {
+ yylval.str = strsave("west");
+ return VARIABLE;
+ }
+ else
+ return t;
case TOP:
// recognise TOP only before OF
old_context_buffer = context_buffer;
diff --git a/contrib/groff/src/preproc/pic/main.cc b/contrib/groff/src/preproc/pic/main.cc
index b795d48..124cbd5 100644
--- a/contrib/groff/src/preproc/pic/main.cc
+++ b/contrib/groff/src/preproc/pic/main.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1989-1992, 2000, 2001, 2002 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -80,8 +80,8 @@ int top_input::get()
return c;
}
int c = getc(fp);
- while (illegal_input_char(c)) {
- error("illegal input character code %1", int(c));
+ while (invalid_input_char(c)) {
+ error("invalid input character code %1", int(c));
c = getc(fp);
bol = 0;
}
@@ -152,8 +152,8 @@ int top_input::peek()
if (push_back[0] != EOF)
return push_back[0];
int c = getc(fp);
- while (illegal_input_char(c)) {
- error("illegal input character code %1", int(c));
+ while (invalid_input_char(c)) {
+ error("invalid input character code %1", int(c));
c = getc(fp);
bol = 0;
}
@@ -476,7 +476,7 @@ void usage(FILE *stream)
#endif
}
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(__EMX__)
static char *fix_program_name(char *arg, char *dflt)
{
if (!arg)
@@ -499,13 +499,13 @@ static char *fix_program_name(char *arg, char *dflt)
*p = 'a' + (*p - 'A');
return prog;
}
-#endif /* __MSDOS__ */
+#endif /* __MSDOS__ || __EMX__ */
int main(int argc, char **argv)
{
-#ifdef __MSDOS__
+#if defined(__MSDOS__) || defined(__EMX__)
argv[0] = fix_program_name(argv[0], "pic");
-#endif /* __MSDOS__ */
+#endif /* __MSDOS__ || __EMX__ */
program_name = argv[0];
static char stderr_buf[BUFSIZ];
setbuf(stderr, stderr_buf);
diff --git a/contrib/groff/src/preproc/pic/object.cc b/contrib/groff/src/preproc/pic/object.cc
index 6b34633..fd25371 100644
--- a/contrib/groff/src/preproc/pic/object.cc
+++ b/contrib/groff/src/preproc/pic/object.cc
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -53,14 +54,6 @@ void output::set_args(const char *s)
args = strsave(s);
}
-void output::command(const char *, const char *, int)
-{
-}
-
-void output::set_location(const char *, int)
-{
-}
-
int output::supports_filled_polygons()
{
return 0;
@@ -219,7 +212,8 @@ struct arrow_head_type {
};
void draw_arrow(const position &pos, const distance &dir,
- const arrow_head_type &aht, const line_type &lt)
+ const arrow_head_type &aht, const line_type &lt,
+ char *outline_color_for_fill)
{
double hyp = hypot(dir);
if (hyp == 0.0) {
@@ -237,8 +231,9 @@ void draw_arrow(const position &pos, const distance &dir,
v[0] = pos;
v[1] = pos + base + n;
v[2] = pos + base - n;
- // A value > 1 means fill with the current color.
- out->polygon(v, 3, slt, 2.0);
+ // fill with outline color
+ out->set_color(outline_color_for_fill, outline_color_for_fill);
+ out->polygon(v, 3, slt, 1);
}
else {
position v[2];
@@ -549,6 +544,8 @@ class graphic_object : public object {
int aligned;
protected:
line_type lt;
+ char *outline_color;
+ char *color_fill;
public:
graphic_object();
~graphic_object();
@@ -559,10 +556,14 @@ public:
void set_dashed(double);
void set_thickness(double);
void set_invisible();
+ void set_outline_color(char *);
+ char *get_outline_color();
virtual void set_fill(double);
+ virtual void set_fill_color(char *);
};
-graphic_object::graphic_object() : ntext(0), text(0), aligned(0)
+graphic_object::graphic_object()
+: ntext(0), text(0), aligned(0), outline_color(0), color_fill(0)
{
}
@@ -587,6 +588,21 @@ void graphic_object::set_fill(double)
{
}
+void graphic_object::set_fill_color(char *c)
+{
+ color_fill = c;
+}
+
+void graphic_object::set_outline_color(char *c)
+{
+ outline_color = c;
+}
+
+char *graphic_object::get_outline_color()
+{
+ return outline_color;
+}
+
void graphic_object::set_invisible()
{
lt.type = line_type::invisible;
@@ -622,8 +638,11 @@ void graphic_object::print_text()
if (d.x != 0.0 || d.y != 0.0)
angle = atan2(d.y, d.x);
}
- if (text != 0)
+ if (text != 0) {
+ out->set_color(color_fill, get_outline_color());
out->text(center(), text, ntext, angle);
+ out->reset_color();
+ }
}
graphic_object::~graphic_object()
@@ -676,12 +695,14 @@ public:
closed_object(const position &);
object_type type() = 0;
void set_fill(double);
+ void set_fill_color(char *fill);
protected:
double fill; // < 0 if not filled
+ char *color_fill; // = 0 if not colored
};
closed_object::closed_object(const position &pos)
-: rectangle_object(pos), fill(-1.0)
+: rectangle_object(pos), fill(-1.0), color_fill(0)
{
}
@@ -691,6 +712,10 @@ void closed_object::set_fill(double f)
fill = f;
}
+void closed_object::set_fill_color(char *fill)
+{
+ color_fill = fill;
+}
class box_object : public closed_object {
double xrad;
@@ -738,8 +763,9 @@ position box_object::south_west()
void box_object::print()
{
- if (lt.type == line_type::invisible && fill < 0.0)
+ if (lt.type == line_type::invisible && fill < 0.0 && color_fill == 0)
return;
+ out->set_color(color_fill, graphic_object::get_outline_color());
if (xrad == 0.0) {
distance dim2 = dim/2.0;
position vec[4];
@@ -753,6 +779,7 @@ void box_object::print()
distance abs_dim(fabs(dim.x), fabs(dim.y));
out->rounded_box(cent, abs_dim, fabs(xrad), lt, fill);
}
+ out->reset_color();
}
graphic_object *object_spec::make_box(position *curpos, direction *dirp)
@@ -990,9 +1017,11 @@ ellipse_object::ellipse_object(const position &d)
void ellipse_object::print()
{
- if (lt.type == line_type::invisible && fill < 0.0)
+ if (lt.type == line_type::invisible && fill < 0.0 && color_fill == 0)
return;
+ out->set_color(color_fill, graphic_object::get_outline_color());
out->ellipse(cent, dim, lt, fill);
+ out->reset_color();
}
graphic_object *object_spec::make_ellipse(position *curpos, direction *dirp)
@@ -1037,9 +1066,11 @@ circle_object::circle_object(double diam)
void circle_object::print()
{
- if (lt.type == line_type::invisible && fill < 0.0)
+ if (lt.type == line_type::invisible && fill < 0.0 && color_fill == 0)
return;
+ out->set_color(color_fill, graphic_object::get_outline_color());
out->circle(cent, dim.x/2.0, lt, fill);
+ out->reset_color();
}
graphic_object *object_spec::make_circle(position *curpos, direction *dirp)
@@ -1098,7 +1129,7 @@ graphic_object *object_spec::make_move(position *curpos, direction *dirp)
// No need to look at at since `at' attribute sets `from' attribute.
position startpos = (flags & HAS_FROM) ? from : *curpos;
if (!(flags & HAS_SEGMENT)) {
- if ((flags && IS_SAME) && have_last_move)
+ if ((flags & IS_SAME) && have_last_move)
segment_pos = last_move;
else {
switch (dir) {
@@ -1222,11 +1253,14 @@ 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);
+ 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);
+ draw_arrow(en, v[n-1] - (n > 1 ? v[n - 2] : strt), aht, lt,
+ graphic_object::get_outline_color());
+ out->reset_color();
}
void line_object::update_bounding_box(bounding_box *p)
@@ -1289,11 +1323,14 @@ 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);
+ 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);
+ draw_arrow(en, v[n-1] - (n > 1 ? v[n - 2] : strt), aht, lt,
+ graphic_object::get_outline_color());
+ out->reset_color();
}
line_object::~line_object()
@@ -1500,6 +1537,7 @@ 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
@@ -1508,14 +1546,15 @@ void arc_object::print()
position c = cent - strt;
draw_arrow(strt,
(clockwise ? position(c.y, -c.x) : position(-c.y, c.x)),
- aht, lt);
+ aht, lt, graphic_object::get_outline_color());
}
if (arrow_at_end) {
position e = en - cent;
draw_arrow(en,
(clockwise ? position(e.y, -e.x) : position(-e.y, e.x)),
- aht, lt);
+ aht, lt, graphic_object::get_outline_color());
}
+ out->reset_color();
}
inline double max(double a, double b)
@@ -1708,13 +1747,19 @@ object *object_spec::make_object(position *curpos, direction *dirp)
else
lookup_variable("linethick", &th);
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)
- lookup_variable("fillval", &fill);
- if (fill < 0.0)
- error("bad fill value %1", fill);
- else
- obj->set_fill(fill);
+ if (flags & IS_SHADED)
+ obj->set_fill_color(shaded);
+ else {
+ if (flags & IS_DEFAULT_FILLED)
+ lookup_variable("fillval", &fill);
+ if (fill < 0.0)
+ error("bad fill value %1", fill);
+ else
+ obj->set_fill(fill);
+ }
}
}
return obj;
@@ -1737,18 +1782,28 @@ string_list::~string_list()
a_delete str;
}
-/* A path is used to hold the argument to the with attribute. For example,
-`.nw' or `.A.s' or `.A'. The major operation on a path is to take a
-place and follow the path through the place to place within the place.
-Note that `.A.B.C.sw' will work. */
+/* A path is used to hold the argument to the `with' attribute. For
+ example, `.nw' or `.A.s' or `.A'. The major operation on a path is to
+ take a place and follow the path through the place to place within the
+ place. Note that `.A.B.C.sw' will work.
+
+ For compatibility with DWB pic, `with' accepts positions also (this
+ is incorrectly documented in CSTR 116). */
path::path(corner c)
-: crn(c), label_list(0), ypath(0)
+: crn(c), label_list(0), ypath(0), is_position(0)
{
}
+path::path(position p)
+: crn(0), label_list(0), ypath(0), is_position(1)
+{
+ pos.x = p.x;
+ pos.y = p.y;
+}
+
path::path(char *l, corner c)
-: crn(c), ypath(0)
+: crn(c), ypath(0), is_position(0)
{
label_list = new string_list(l);
}
@@ -1786,6 +1841,12 @@ void path::set_ypath(path *p)
int path::follow(const place &pl, place *result) const
{
+ if (is_position) {
+ result->x = pos.x;
+ result->y = pos.y;
+ result->obj = 0;
+ return 1;
+ }
const place *p = &pl;
for (string_list *lb = label_list; lb; lb = lb->next)
if (p->obj == 0 || (p = p->obj->find_label(lb->str)) == 0) {
@@ -1795,9 +1856,9 @@ int path::follow(const place &pl, place *result) const
if (crn == 0 || p->obj == 0)
*result = *p;
else {
- position pos = ((p->obj)->*(crn))();
- result->x = pos.x;
- result->y = pos.y;
+ position ps = ((p->obj)->*(crn))();
+ result->x = ps.x;
+ result->y = ps.y;
result->obj = 0;
}
if (ypath) {
diff --git a/contrib/groff/src/preproc/pic/object.h b/contrib/groff/src/preproc/pic/object.h
index 2748e81..98937f93 100644
--- a/contrib/groff/src/preproc/pic/object.h
+++ b/contrib/groff/src/preproc/pic/object.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -76,11 +76,14 @@ struct place {
struct string_list;
class path {
+ position pos;
corner crn;
string_list *label_list;
path *ypath;
+ int is_position;
public:
path(corner = 0);
+ path(position);
path(char *, corner = 0);
~path();
void append(corner);
@@ -150,6 +153,8 @@ const unsigned long HAS_THICKNESS = 01000000;
const unsigned long IS_FILLED = 02000000;
const unsigned long IS_DEFAULT_FILLED = 04000000;
const unsigned long IS_ALIGNED = 010000000;
+const unsigned long IS_SHADED = 020000000;
+const unsigned long IS_OUTLINED = 040000000;
struct segment {
int is_absolute;
@@ -183,6 +188,8 @@ struct object_spec {
double end_chop;
double thickness;
double fill;
+ char *shaded;
+ char *outlined;
direction dir;
segment *segment_list;
position segment_pos;
diff --git a/contrib/groff/src/preproc/pic/output.h b/contrib/groff/src/preproc/pic/output.h
index ac490db..a0a8331 100644
--- a/contrib/groff/src/preproc/pic/output.h
+++ b/contrib/groff/src/preproc/pic/output.h
@@ -55,8 +55,12 @@ public:
const line_type &, double) = 0;
virtual void rounded_box(const position &, const distance &, double,
const line_type &, double) = 0;
- virtual void command(const char *, const char *, int);
- virtual void set_location(const char *, int);
+ virtual void command(const char *, const char *, int) = 0;
+ virtual void set_location(const char *, int) {}
+ virtual void set_color(char *, char *) = 0;
+ virtual void reset_color() = 0;
+ virtual char *get_last_filled() = 0;
+ virtual char *get_outline_color() = 0;
virtual int supports_filled_polygons();
virtual void begin_block(const position &ll, const position &ur);
virtual void end_block();
diff --git a/contrib/groff/src/preproc/pic/pic.h b/contrib/groff/src/preproc/pic/pic.h
index 36c36d1..0a092fe 100644
--- a/contrib/groff/src/preproc/pic/pic.h
+++ b/contrib/groff/src/preproc/pic/pic.h
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -18,8 +19,8 @@ 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. */
-#include <stdio.h>
-#include <string.h>
+#include "lib.h"
+
#include <math.h>
#include <stdlib.h>
#include <errno.h>
@@ -32,7 +33,6 @@ extern "C" {
#include "assert.h"
#include "cset.h"
-#include "lib.h"
#include "stringclass.h"
#include "errarg.h"
#include "error.h"
diff --git a/contrib/groff/src/preproc/pic/pic.man b/contrib/groff/src/preproc/pic/pic.man
index ea53074..406246f 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 Free Software Foundation, Inc.
+Copyright (C) 1989-2000, 2001, 2002 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,30 +16,43 @@ versions, except that this permission notice may be included in
translations approved by the Free Software Foundation instead of in
the original English.
..
+.
+.
.\" 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 t .ds tx T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
-.el .ds tx TeX
+.el .ds tx TeX
+.
.ie \n(.g .ds ic \/
-.el .ds ic \^
+.el .ds ic \^
+.
.\" The BSD man macros can't handle " in arguments to font change macros,
.\" so use \(ts instead of ".
.tr \(ts"
+.
+.
.TH @G@PIC @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
+.
+.
.SH NAME
+.
@g@pic \- compile pictures for troff or TeX
+.
+.
.SH SYNOPSIS
+.
.B @g@pic
[
.B \-nvCSU
]
[
.I filename
-\&.\|.\|.
+\&.\|.\|.\&
]
.br
.B @g@pic
@@ -49,9 +62,12 @@ the original English.
]
[
.I filename
-\&.\|.\|.
+\&.\|.\|.\&
]
+.
+.
.SH DESCRIPTION
+.
This manual page describes the GNU version of
.BR pic ,
which is part of the groff document formatting system.
@@ -80,7 +96,10 @@ When the macro package being used does not supply such definitions
appropriate definitions can be obtained with
.BR \-mpic :
these will center each picture.
+.
+.
.SH OPTIONS
+.
Options that do not take arguments may be grouped behind a single
.BR \- .
The special option
@@ -89,6 +108,7 @@ can be used to mark the end of the options.
A filename of
.B \-
refers to the standard input.
+.
.TP
.B \-C
Recognize
@@ -96,6 +116,7 @@ Recognize
and
.B .PE
even when followed by a character other than space or newline.
+.
.TP
.B \-S
Safer mode; do not execute
@@ -103,10 +124,12 @@ Safer mode; do not execute
commands.
This can be useful when operating on untrustworthy input.
(enabled by default)
+.
.TP
.B \-U
Unsafe mode; revert the default option
.BR \-S .
+.
.TP
.B \-n
Don't use the groff extensions to the troff drawing commands.
@@ -119,9 +142,11 @@ The
option also causes
.B pic
not to use zero-length lines to draw dots in troff mode.
+.
.TP
.B \-t
\*(tx mode.
+.
.TP
.B \-c
Be more compatible with
@@ -151,21 +176,26 @@ specified by use of the
attribute or by setting the
.B linethick
variable.
+.
.TP
.B \-v
Print the version number.
+.
.TP
.B \-z
In \*(tx mode draw dots using zero-length lines.
+.
.LP
The following options supported by other versions of
.B pic
are ignored:
+.
.TP
.B \-D
Draw all lines using the \eD escape sequence.
.B pic
always does this.
+.
.TP
.BI \-T \ dev
Generate output for the
@@ -177,15 +207,24 @@ This is unnecessary because the
output generated by
.B pic
is device-independent.
+.
+.
.SH USAGE
+.
This section describes only the differences between GNU
.B pic
and the original version of
.BR pic .
Many of these differences also apply to newer versions of Unix
.BR pic .
-.SS \*(tx mode
+A complete documentation is available in the file
.LP
+.RS
+.B @DOCDIR@/pic.ms
+.RE
+.
+.SS \*(tx mode
+.
\*(tx mode is enabled by the
.B \-t
option.
@@ -225,7 +264,9 @@ change the value of
.BR \ebaselineskip .
Anything else may well produce undesirable results; use at your own risk.
Lines beginning with a period are not given any special treatment.
+.
.SS Commands
+.
.TP
\fBfor\fR \fIvariable\fR \fB=\fR \fIexpr1\fR \fBto\fR \fIexpr2\fR \
[\fBby\fR [\fB*\fR]\fIexpr3\fR] \fBdo\fR \fIX\fR \fIbody\fR \fIX\fR
@@ -259,6 +300,7 @@ will instead be multiplied by
.I X
can be any character not occurring in
.IR body .
+.
.TP
\fBif\fR \fIexpr\fR \fBthen\fR \fIX\fR \fIif-true\fR \fIX\fR \
[\fBelse\fR \fIY\fR \fIif-false\fR \fIY\fR]
@@ -274,6 +316,7 @@ can be any character not occurring in
.I Y
can be any character not occurring in
.IR if-false .
+.
.TP
\fBprint\fR \fIarg\fR\|.\|.\|.
Concatenate the arguments and print as a line on stderr.
@@ -281,18 +324,20 @@ Each
.I arg
must be an expression, a position, or text.
This is useful for debugging.
+.
.TP
\fBcommand\fR \fIarg\fR\|.\|.\|.
Concatenate the arguments
-and pass them through as a line to troff or\*(tx.
+and pass them through as a line to troff or \*(tx.
Each
.I arg
must be an expression, a position, or text.
This has a similar effect to a line beginning with
-.B .
+.B .\&
or
.BR \e ,
but allows the values of variables to be passed through.
+.
.TP
\fBsh\fR \fIX\fR \fIcommand\fR \fIX\fR
Pass
@@ -301,11 +346,13 @@ to a shell.
.I X
can be any character not occurring in
.IR command .
+.
.TP
\fBcopy\fR \fB"\fIfilename\fB"\fR
Include
.I filename
at this point in the file.
+.
.TP
\fBcopy\fR [\fB"\fIfilename\fB"\fR] \fBthru\fR \fIX\fR \fIbody\fR \fIX\fR \
[\fBuntil\fR \fB"\fIword\*(ic\fB"\fR]
@@ -377,12 +424,13 @@ The commands to be performed for each line can also be taken
from a macro defined earlier by giving the name of the macro
as the argument to
.BR thru .
+.
.LP
.B reset
.br
.ns
.TP
-\fBreset\fI variable1\fB,\fI variable2 .\^.\^.
+\fBreset\fI variable1\fR[\fB,\fR]\fI variable2 .\^.\^.
Reset pre-defined variables
.IR variable1 ,
.I variable2
@@ -393,6 +441,7 @@ Note that assigning a value to
.B scale
also causes all pre-defined variables that control dimensions
to be reset to their default values times the new value of scale.
+.
.TP
\fBplot\fR \fIexpr\fR [\fB"\fItext\*(ic\fB"\fR]
This is a text object which is constructed by using
@@ -412,24 +461,48 @@ Be very careful that you specify an appropriate format string;
does only very limited checking of the string.
This is deprecated in favour of
.BR sprintf .
+.
.TP
-.IB variable := expr
+.IB variable\ := \ expr
This is similar to
.B =
except
.I variable
must already be defined,
-and the value of
+and
+.I expr
+will be assigned to
.I variable
-will be changed only in the innermost block in which it is defined.
+without creating a variable local to the current block.
(By contrast,
.B =
defines the variable in the current block if it is not already defined there,
-and then changes the value in the current block.)
+and then changes the value in the current block only.)
+For example, the following:
+.RS
+.IP
+.ft B
+.nf
+\&.PS
+x = 3
+y = 3
+[
+ x := 5
+ y = 5
+]
+print x " " y
+\&.PE
+.ft
+.fi
+.RE
+.IP
+prints
+.BR 5\ 3 .
+.
.LP
Arguments of the form
.IP
-.IR X\ anything\ X
+.I X anything X
.LP
are also allowed to be of the form
.IP
@@ -447,8 +520,11 @@ or imbalanced occurrences of
.B {
and
.BR } .
+.
.SS Expressions
+.
The syntax for expressions has been significantly extended:
+.
.LP
.IB x\ ^\ y
(exponentiation)
@@ -463,7 +539,9 @@ The syntax for expressions has been significantly extended:
(base 10)
.br
.BI exp( x )
-(base 10, ie 10\v'-.4m'\fIx\*(ic\fR\v'.4m')
+(base 10, ie
+.ie t 10\v'-.4m'\fIx\*(ic\fR\v'.4m')
+.el 10^\fIx\fR)
.br
.BI sqrt( x )
.br
@@ -506,11 +584,13 @@ deprecated)
.br
\fB"\fIstr1\*(ic\fB" != "\fIstr2\*(ic\fB"\fR
.br
+.
.LP
String comparison expressions must be parenthesised in some contexts
to avoid ambiguity.
+.
.SS Other Changes
-.LP
+.
A bare expression,
.IR expr ,
is acceptable as an attribute;
@@ -523,13 +603,19 @@ For example
.IP
.B line 2i
.LP
-means draw a line 2 inches long in the current direction.
+means draw a line 2\ inches long in the current direction.
+The `i' (or `I') character is ignored; to use another measurement unit,
+set the
+.I scale
+variable to an appropriate value.
+.
.LP
The maximum width and height of the picture are taken from the variables
.B maxpswid
and
.BR maxpsht .
Initially these have values 8.5 and 11.
+.
.LP
Scientific notation is allowed for numbers.
For example
@@ -537,6 +623,7 @@ For example
.B
x = 5e\-2
.RE
+.
.LP
Text attributes can be compounded.
For example,
@@ -545,6 +632,7 @@ For example,
"foo" above ljust
.RE
is legal.
+.
.LP
There is no limit to the depth to which blocks can be examined.
For example,
@@ -556,12 +644,15 @@ For example,
circle at last [\^].A.B.C
.RE
is acceptable.
+.
.LP
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.
+.
.LP
Boxes can have rounded corners.
The
@@ -576,8 +667,9 @@ attribute is given, a radius of
is used.
Initially,
.B boxrad
-has a value of 0.
+has a value of\ 0.
A box with rounded corners can be dotted or dashed.
+.
.LP
The
.B .PS
@@ -587,13 +679,15 @@ If the width of zero is specified the width will be ignored in computing
the scaling factor for the picture.
Note that GNU
.B pic
-will always scale a picture by the same amount vertically as horizontally.
+will always scale a picture by the same amount vertically as well as
+horizontally.
This is different from the
.SM DWB
2.0
.B pic
which may scale a picture by a different amount vertically than
horizontally if a height is specified.
+.
.LP
Each text object has an invisible box associated with it.
The compass points of a text object are determined by this box.
@@ -611,8 +705,9 @@ Initially
and
.B textht
have a value of 0.
+.
.LP
-In places where a quoted text string can be used,
+In (almost all) places where a quoted text string can be used,
an expression of the form
.IP
.BI sprintf(\(ts format \(ts,\ arg ,\fR.\|.\|.\fB)
@@ -622,14 +717,8 @@ this will produce the arguments formatted according to
.IR format ,
which should be a string as described in
.BR printf (3)
-appropriate for the number of arguments supplied,
-using only the
-.BR e ,
-.BR f ,
-.B g
-or
-.B %
-format characters.
+appropriate for the number of arguments supplied.
+.
.LP
The thickness of the lines used to draw objects is controlled by the
.B linethick
@@ -663,9 +752,10 @@ value of the
variable, nor by the width or height given in the
.B .PS
line.
+.
.LP
Boxes (including boxes with rounded corners),
-circles and ellipses can be filled by giving then an attribute of
+circles and ellipses can be filled by giving them an attribute of
.BR fill [ ed ].
This takes an optional argument of an expression with a value between
0 and 1; 0 will fill it with white, 1 with black, values in between
@@ -683,16 +773,48 @@ The invisible attribute does not affect the filling of objects.
Any text associated with a filled object will be added after the
object has been filled, so that the text will not be obscured
by the filling.
+.
+.LP
+Three additional modifiers are available to specify colored objects:
+.BR outline [ d ]
+sets the color of the outline,
+.B shaded
+the fill color, and
+.BR colo [ u ] r [ ed ]
+sets both.
+All three keywords expect a suffix specifying the color, for example
+.RS
+.LP
+.B circle shaded """green""" outline """black"""
+.RE
+.LP
+Currently, color support isn't available in \*(tx mode.
+Predefined color names for
+.B groff
+are in the device macro files, for example
+.BR ps.tmac ;
+additional colors can be defined with the
+.B .defcolor
+request (see the manual page of
+.BR @g@troff (@MAN1EXT@)
+for more details).
+.LP
+.B pic
+assumes that at the beginning of a picture both glyph and fill color are
+set to the default value.
+.
.LP
Arrow heads will be drawn as solid triangles if the variable
.B arrowhead
-is non-zero and either \*(tx mode is enabled or
-the
-.B \-x
-option has been given.
+is non-zero and either \*(tx mode is enabled or the
+.B \-n
+option has not been given.
Initially
.B arrowhead
-has a value of 1.
+has a value of\ 1.
+Note that solid arrow heads are always filled with the current outline
+color.
+.
.LP
The troff output of
.B pic
@@ -702,11 +824,12 @@ The
option is therefore redundant.
All numbers are taken to be in inches; numbers are never interpreted
to be in troff machine units.
+.
.LP
Objects can have an
.B aligned
attribute.
-This will only work when the postprocessor is
+This will only work if the postprocessor is
.BR grops .
Any text associated with an object having the
.B aligned
@@ -715,6 +838,7 @@ so that it is aligned in the direction from the start point
to the end point of the object.
Note that this attribute will have no effect for objects whose start and
end points are coincident.
+.
.LP
In places where
.IB n th
@@ -729,13 +853,17 @@ and the
.BR th .
For example,
.IP
-.B
+.ft B
.nf
for i = 1 to 4 do {
line from `i'th box.nw to `i+1'th box.se
}
+.ft
.fi
+.
+.
.SH CONVERSION
+.
To obtain a stand-alone picture from a
.B pic
file, enclose your
@@ -749,6 +877,7 @@ requests;
configuration commands may be added at the beginning of the file, but no
.B roff
text.
+.
.LP
It is necessary to feed this file into
.B groff
@@ -774,6 +903,7 @@ Alternatively, you can define your own requests, e.g. to do nothing:
.ft
.fi
.RE
+.
.LP
.B groff
itself does not provide direct conversion into other graphics file
@@ -806,6 +936,7 @@ Call
.RE
.LP
for a list of the available devices.
+.
.LP
As the Encapsulated PostScript File Format
.B EPS
@@ -827,7 +958,10 @@ file can be then converted to virtually any graphics format using the tools
of the
.B netpbm
package .
+.
+.
.SH FILES
+.
.Tp \w'\fB@MACRODIR@/pic.tmac'u+3n
.B
@MACRODIR@/pic.tmac
@@ -836,7 +970,10 @@ Example definitions of the
and
.B PE
macros.
+.
+.
.SH "SEE ALSO"
+.
.BR @g@troff (@MAN1EXT@),
.BR groff_out (@MAN5EXT@),
.BR tex (1),
@@ -851,7 +988,7 @@ Tpic: Pic for \*(tx
Brian W. Kernighan,
PIC \(em A Graphics Language for Typesetting (User Manual).
AT&T Bell Laboratories, Computing Science Technical Report No.\ 116
-<URL:http://cm.bell-labs.com/cm/cs/cstr/116.ps.gz>
+<http://cm.bell-labs.com/cm/cs/cstr/116.ps.gz>
(revised May, 1991).
.LP
.B ps2eps
@@ -866,14 +1003,16 @@ W. Richard Stevens - Turning PIC Into HTML
W. Richard Stevens - Examples of picMacros
.br
<http://www.kohala.com/start/troff/pic.examples.ps>
+.
+.
.SH BUGS
-.LP
-Input characters that are illegal for
+.
+Input characters that are invalid for
.B groff
(ie those with
.SM ASCII
-code 0 or between 013 and 037 octal or between 0200 and 0237 octal)
-are rejected even in \*(tx mode.
+code 0, or 013 octal, or between 015 and 037 octal, or between 0200 and 0237
+octal) are rejected even in \*(tx mode.
.LP
The interpretation of
.B fillval
diff --git a/contrib/groff/src/preproc/pic/pic.y b/contrib/groff/src/preproc/pic/pic.y
index c0a7315..15b6b3f 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
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -202,6 +202,10 @@ char *do_sprintf(const char *form, const double *v, int nv);
%token GREATEREQUAL
%token LEFT_CORNER
%token RIGHT_CORNER
+%token NORTH
+%token SOUTH
+%token EAST
+%token WEST
%token CENTER
%token END
%token START
@@ -210,6 +214,9 @@ char *do_sprintf(const char *form, const double *v, int nv);
%token PLOT
%token THICKNESS
%token FILL
+%token COLORED
+%token OUTLINED
+%token SHADED
%token ALIGNED
%token SPRINTF
%token COMMAND
@@ -217,6 +224,8 @@ char *do_sprintf(const char *form, const double *v, int nv);
%token DEFINE
%token UNDEF
+%left '.'
+
/* this ensures that plot 17 "%g" parses as (plot 17 "%g") */
%left PLOT
%left TEXT SPRINTF
@@ -231,12 +240,14 @@ box "foo" above ljust == box ("foo" above ljust)
/* Give attributes that take an optional expression a higher
precedence than left and right, so that eg `line chop left'
parses properly. */
-%left CHOP SOLID DASHED DOTTED UP DOWN FILL
+%left CHOP SOLID DASHED DOTTED UP DOWN FILL COLORED OUTLINED
%left LABEL
%left VARIABLE NUMBER '(' SIN COS ATAN2 LOG EXP SQRT K_MAX K_MIN INT RAND SRAND LAST
%left ORDINAL HERE '`'
+%left BOX CIRCLE ELLIPSE ARC LINE ARROW SPLINE '['
+
/* these need to be lower than '-' */
%left HEIGHT RADIUS WIDTH DIAMETER FROM TO AT THICKNESS
@@ -244,7 +255,7 @@ parses properly. */
works */
%left DOT_N DOT_E DOT_W DOT_S DOT_NE DOT_SE DOT_NW DOT_SW DOT_C
%left DOT_START DOT_END TOP BOTTOM LEFT_CORNER RIGHT_CORNER
-%left UPPER LOWER CENTER START END
+%left UPPER LOWER NORTH SOUTH EAST WEST CENTER START END
%left ','
%left OROR
@@ -350,7 +361,7 @@ placeless_element:
{
fprintf(stderr, "%s\n", $2.str);
a_delete $2.str;
- fflush(stderr);
+ fflush(stderr);
}
| SH
{ delim_flag = 1; }
@@ -433,11 +444,20 @@ placeless_element:
reset_variables:
RESET VARIABLE
- { reset($2); a_delete $2; }
+ {
+ reset($2);
+ a_delete $2;
+ }
| reset_variables VARIABLE
- { reset($2); a_delete $2; }
+ {
+ reset($2);
+ a_delete $2;
+ }
| reset_variables ',' VARIABLE
- { reset($3); a_delete $3; }
+ {
+ reset($3);
+ a_delete $3;
+ }
;
print_args:
@@ -462,7 +482,7 @@ print_args:
;
print_arg:
- expr %prec ','
+ expr %prec ','
{
$$.str = new char[GDIGITS + 1];
sprintf($$.str, "%g", $1);
@@ -471,19 +491,24 @@ print_arg:
}
| text
{ $$ = $1; }
- | position %prec ','
+ | position %prec ','
{
$$.str = new char[GDIGITS + 2 + GDIGITS + 1];
sprintf($$.str, "%g, %g", $1.x, $1.y);
$$.filename = 0;
$$.lineno = 0;
}
+ ;
simple_if:
IF any_expr THEN
{ delim_flag = 1; }
DELIMITED
- { delim_flag = 0; $$.x = $2; $$.body = $5; }
+ {
+ delim_flag = 0;
+ $$.x = $2;
+ $$.body = $5;
+ }
;
until:
@@ -532,11 +557,20 @@ text_expr:
optional_by:
/* empty */
- { $$.val = 1.0; $$.is_multiplicative = 0; }
+ {
+ $$.val = 1.0;
+ $$.is_multiplicative = 0;
+ }
| BY expr
- { $$.val = $2; $$.is_multiplicative = 0; }
+ {
+ $$.val = $2;
+ $$.is_multiplicative = 0;
+ }
| BY '*' expr
- { $$.val = $3; $$.is_multiplicative = 1; }
+ {
+ $$.val = $3;
+ $$.is_multiplicative = 1;
+ }
;
element:
@@ -555,7 +589,11 @@ element:
}
}
| LABEL ':' optional_separator element
- { $$ = $4; define_label($1, & $$); a_delete $1; }
+ {
+ $$ = $4;
+ define_label($1, & $$);
+ a_delete $1;
+ }
| LABEL ':' optional_separator position_not_place
{
$$.obj = 0;
@@ -603,17 +641,11 @@ optional_element:
object_spec:
BOX
- {
- $$ = new object_spec(BOX_OBJECT);
- }
+ { $$ = new object_spec(BOX_OBJECT); }
| CIRCLE
- {
- $$ = new object_spec(CIRCLE_OBJECT);
- }
+ { $$ = new object_spec(CIRCLE_OBJECT); }
| ELLIPSE
- {
- $$ = new object_spec(ELLIPSE_OBJECT);
- }
+ { $$ = new object_spec(ELLIPSE_OBJECT); }
| ARC
{
$$ = new object_spec(ARC_OBJECT);
@@ -647,7 +679,7 @@ object_spec:
lookup_variable("linewid", & $$->segment_width);
$$->dir = current_direction;
}
- | text %prec TEXT
+ | text %prec TEXT
{
$$ = new object_spec(TEXT_OBJECT);
$$->text = new text_item($1.str, $1.filename, $1.lineno);
@@ -715,7 +747,7 @@ object_spec:
$$->radius = $3/2.0;
$$->flags |= HAS_RADIUS;
}
- | object_spec expr %prec HEIGHT
+ | object_spec expr %prec HEIGHT
{
$$ = $1;
$$->flags |= HAS_SEGMENT;
@@ -830,6 +862,15 @@ object_spec:
$$->flags |= HAS_WITH;
$$->with = $3;
}
+ | object_spec WITH position %prec ','
+ {
+ $$ = $1;
+ $$->flags |= HAS_WITH;
+ position pos;
+ pos.x = $3.x;
+ pos.y = $3.y;
+ $$->with = new path(pos);
+ }
| object_spec BY expr_pair
{
$$ = $1;
@@ -888,6 +929,29 @@ object_spec:
$$->flags |= IS_FILLED;
$$->fill = $3;
}
+ | object_spec SHADED text
+ {
+ $$ = $1;
+ $$->flags |= (IS_SHADED | IS_FILLED);
+ $$->shaded = new char[strlen($3.str)+1];
+ strcpy($$->shaded, $3.str);
+ }
+ | object_spec COLORED text
+ {
+ $$ = $1;
+ $$->flags |= (IS_SHADED | IS_OUTLINED | IS_FILLED);
+ $$->shaded = new char[strlen($3.str)+1];
+ strcpy($$->shaded, $3.str);
+ $$->outlined = new char[strlen($3.str)+1];
+ strcpy($$->outlined, $3.str);
+ }
+ | object_spec OUTLINED text
+ {
+ $$ = $1;
+ $$->flags |= IS_OUTLINED;
+ $$->outlined = new char[strlen($3.str)+1];
+ strcpy($$->outlined, $3.str);
+ }
| object_spec CHOP
{
$$ = $1;
@@ -956,7 +1020,7 @@ object_spec:
$$ = $1;
$$->flags &= ~IS_CLOCKWISE;
}
- | object_spec text %prec TEXT
+ | object_spec text %prec TEXT
{
$$ = $1;
text_item **p;
@@ -1019,9 +1083,7 @@ object_spec:
text:
TEXT
- {
- $$ = $1;
- }
+ { $$ = $1; }
| SPRINTF '(' TEXT sprintf_args ')'
{
$$.filename = $3.filename;
@@ -1108,13 +1170,17 @@ between:
expr_pair:
expr ',' expr
- { $$.x = $1; $$.y = $3; }
+ {
+ $$.x = $1;
+ $$.y = $3;
+ }
| '(' expr_pair ')'
{ $$ = $2; }
;
place:
- label %prec CHOP /* line at A left == line (at A) left */
+ /* line at A left == line (at A) left */
+ label %prec CHOP
{ $$ = $1; }
| label corner
{
@@ -1154,9 +1220,7 @@ label:
a_delete $1;
}
| nth_primitive
- {
- $$.obj = $1;
- }
+ { $$.obj = $1; }
| label '.' LABEL
{
path pth($3);
@@ -1176,7 +1240,7 @@ ordinal:
;
optional_ordinal_last:
- LAST
+ LAST
{ $$ = 1; }
| ordinal LAST
{ $$ = $1; }
@@ -1238,9 +1302,7 @@ object_type:
label_path:
'.' LABEL
- {
- $$ = new path($2);
- }
+ { $$ = new path($2); }
| label_path '.' LABEL
{
$$ = $1;
@@ -1249,17 +1311,12 @@ label_path:
;
relative_path:
- corner
- {
- $$ = new path($1);
- }
+ corner %prec CHOP
+ { $$ = new path($1); }
/* give this a lower precedence than LEFT and RIGHT so that
[A: box] with .A left == [A: box] with (.A left) */
-
- | label_path %prec TEXT
- {
- $$ = $1;
- }
+ | label_path %prec TEXT
+ { $$ = $1; }
| label_path corner
{
$$ = $1;
@@ -1269,9 +1326,7 @@ relative_path:
path:
relative_path
- {
- $$ = $1;
- }
+ { $$ = $1; }
| '(' relative_path ',' relative_path ')'
{
$$ = $2;
@@ -1355,6 +1410,14 @@ corner:
{ $$ = &object::north_east; }
| LOWER RIGHT_CORNER
{ $$ = &object::south_east; }
+ | NORTH
+ { $$ = &object::north; }
+ | SOUTH
+ { $$ = &object::south; }
+ | EAST
+ { $$ = &object::east; }
+ | WEST
+ { $$ = &object::west; }
| CENTER
{ $$ = &object::center; }
| START
@@ -1444,7 +1507,7 @@ expr:
YYABORT;
}
}
- | '-' expr %prec '!'
+ | '-' expr %prec '!'
{ $$ = -$2; }
| '(' any_expr ')'
{ $$ = $2; }
@@ -1521,7 +1584,10 @@ expr:
$$ = (rand() & 0x7fff) / double(0x8000);
}
| SRAND '(' any_expr ')'
- { $$ = 0; srand((unsigned int)$3); }
+ {
+ $$ = 0;
+ srand((unsigned int)$3);
+ }
| expr '<' expr
{ $$ = ($1 < $3); }
| expr LESSEQUAL expr
@@ -1754,23 +1820,7 @@ char *format_number(const char *form, double n)
{
if (form == 0)
form = "%g";
- else {
- // this is a fairly feeble attempt at validation of the format
- int nspecs = 0;
- for (const char *p = form; *p != '\0'; p++)
- if (*p == '%') {
- if (p[1] == '%')
- p++;
- else
- nspecs++;
- }
- if (nspecs > 1) {
- lex_error("bad format `%1'", form);
- return strsave(form);
- }
- }
- sprintf(sprintf_buf, form, n);
- return strsave(sprintf_buf);
+ return do_sprintf(form, &n, 1);
}
char *do_sprintf(const char *form, const double *v, int nv)
@@ -1792,18 +1842,20 @@ char *do_sprintf(const char *form, const double *v, int nv)
if (*form == '%') {
one_format += *form++;
one_format += '\0';
- sprintf(sprintf_buf, one_format.contents());
+ snprintf(sprintf_buf, sizeof(sprintf_buf),
+ "%s", one_format.contents());
}
else {
if (i >= nv) {
- lex_error("too few arguments to sprintf");
+ lex_error("too few arguments to snprintf");
result += one_format;
result += form;
break;
}
one_format += *form++;
one_format += '\0';
- sprintf(sprintf_buf, one_format.contents(), v[i++]);
+ snprintf(sprintf_buf, sizeof(sprintf_buf),
+ one_format.contents(), v[i++]);
}
one_format.clear();
result += sprintf_buf;
diff --git a/contrib/groff/src/preproc/pic/tex.cc b/contrib/groff/src/preproc/pic/tex.cc
index 2a91b62..a9192ac 100644
--- a/contrib/groff/src/preproc/pic/tex.cc
+++ b/contrib/groff/src/preproc/pic/tex.cc
@@ -42,6 +42,10 @@ public:
void circle(const position &, double rad, const line_type &, double);
void ellipse(const position &, const distance &, const line_type &, double);
void command(const char *, const char *, int);
+ void set_color(char *, char *);
+ void reset_color();
+ char *get_last_filled();
+ char *get_outline_color();
int supports_filled_polygons();
private:
position upper_left;
@@ -350,6 +354,28 @@ void tex_output::dot(const position &pos, const line_type &lt)
}
}
+void tex_output::set_color(char *, char *)
+{
+ /* not implemented yet */
+}
+
+void tex_output::reset_color()
+{
+ /* not implemented yet */
+}
+
+char *tex_output::get_last_filled()
+{
+ /* not implemented yet */
+ return NULL;
+}
+
+char *tex_output::get_outline_color()
+{
+ /* not implemented yet */
+ return NULL;
+}
+
class tpic_output : public tex_output {
public:
tpic_output();
diff --git a/contrib/groff/src/preproc/pic/troff.cc b/contrib/groff/src/preproc/pic/troff.cc
index 62fe540..7ee7293 100644
--- a/contrib/groff/src/preproc/pic/troff.cc
+++ b/contrib/groff/src/preproc/pic/troff.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -21,7 +21,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "pic.h"
#include "common.h"
-#include "htmlindicate.h"
const double RELATIVE_THICKNESS = -1.0;
@@ -37,6 +36,9 @@ class simple_output : public common_output {
virtual void simple_polygon(int, const position *, int) = 0;
virtual void line_thickness(double) = 0;
virtual void set_fill(double) = 0;
+ virtual void set_color(char *, char *) = 0;
+ virtual void reset_color() = 0;
+ virtual char *get_last_filled() = 0;
void dot(const position &, const line_type &) = 0;
public:
void start_picture(double sc, const position &ll, const position &ur) = 0;
@@ -140,11 +142,10 @@ void simple_output::spline(const position &start, const position *v, int n,
void simple_output::polygon(const position *v, int n,
const line_type &lt, double fill)
{
- if (driver_extension_flag) {
- if (fill >= 0.0) {
+ if (driver_extension_flag && ((fill >= 0.0) || (get_last_filled() != 0))) {
+ if (get_last_filled() == 0)
set_fill(fill);
- simple_polygon(1, v, n);
- }
+ simple_polygon(1, v, n);
}
if (lt.type == line_type::solid && driver_extension_flag) {
line_thickness(lt.thickness);
@@ -159,8 +160,9 @@ void simple_output::polygon(const position *v, int n,
void simple_output::circle(const position &cent, double rad,
const line_type &lt, double fill)
{
- if (driver_extension_flag && fill >= 0.0) {
- set_fill(fill);
+ if (driver_extension_flag && ((fill >= 0.0) || (get_last_filled() != 0))) {
+ if (get_last_filled() == 0)
+ set_fill(fill);
simple_circle(1, cent, rad);
}
line_thickness(lt.thickness);
@@ -184,8 +186,9 @@ void simple_output::circle(const position &cent, double rad,
void simple_output::ellipse(const position &cent, const distance &dim,
const line_type &lt, double fill)
{
- if (driver_extension_flag && fill >= 0.0) {
- set_fill(fill);
+ if (driver_extension_flag && ((fill >= 0.0) || (get_last_filled() != 0))) {
+ if (get_last_filled() == 0)
+ set_fill(fill);
simple_ellipse(1, cent, dim);
}
if (lt.type != line_type::invisible)
@@ -212,6 +215,8 @@ class troff_output : public simple_output {
double scale;
double last_line_thickness;
double last_fill;
+ char *last_filled; // color
+ char *last_outlined; // color
public:
troff_output();
~troff_output();
@@ -229,6 +234,10 @@ public:
void simple_polygon(int, const position *, int);
void line_thickness(double p);
void set_fill(double);
+ void set_color(char *, char *);
+ void reset_color();
+ char *get_last_filled();
+ char *get_outline_color();
position transform(const position &);
};
@@ -238,7 +247,8 @@ output *make_troff_output()
}
troff_output::troff_output()
-: last_filename(0), last_line_thickness(BAD_THICKNESS), last_fill(-1.0)
+: last_filename(0), last_line_thickness(BAD_THICKNESS),
+ last_fill(-1.0), last_filled(0), last_outlined(0)
{
}
@@ -269,7 +279,6 @@ void troff_output::start_picture(double sc,
scale = compute_scale(sc, ll, ur);
height = (ur.y - ll.y)/scale;
double width = (ur.x - ll.x)/scale;
- graphic_start(0);
printf(".PS %.3fi %.3fi", height, width);
if (args)
printf(" %s\n", args);
@@ -288,6 +297,7 @@ void troff_output::finish_picture()
{
line_thickness(BAD_THICKNESS);
last_fill = -1.0; // force it to be reset for each picture
+ reset_color();
if (!flyback_flag)
printf(".sp %.3fi+1\n", height);
printf(".if \\n(" FILL_REG " .fi\n");
@@ -296,7 +306,6 @@ void troff_output::finish_picture()
// this is a little gross
set_location(current_filename, current_lineno);
fputs(flyback_flag ? ".PF\n" : ".PE\n", stdout);
- graphic_end();
}
void troff_output::command(const char *s,
@@ -472,6 +481,54 @@ void troff_output::set_fill(double f)
printf("\\D'f %du'\\h'%du'\n.sp -1\n", int(f*FILL_MAX), -int(f*FILL_MAX));
last_fill = f;
}
+ if (last_filled) {
+ free(last_filled);
+ last_filled = 0;
+ printf("\\M[]\n.sp -1\n");
+ }
+}
+
+void troff_output::set_color(char *color_fill, char *color_outlined)
+{
+ if (driver_extension_flag) {
+ if (last_filled || last_outlined) {
+ reset_color();
+ }
+ if (color_fill) {
+ printf("\\M[%s]\n.sp -1\n", color_fill);
+ last_filled = strdup(color_fill);
+ }
+ if (color_outlined) {
+ printf("\\m[%s]\n.sp -1\n", color_outlined);
+ last_outlined = strdup(color_outlined);
+ }
+ }
+}
+
+void troff_output::reset_color()
+{
+ if (driver_extension_flag) {
+ if (last_filled) {
+ printf("\\M[]\n.sp -1\n");
+ free(last_filled);
+ last_filled = 0;
+ }
+ if (last_outlined) {
+ printf("\\m[]\n.sp -1\n");
+ free(last_outlined);
+ last_outlined = 0;
+ }
+ }
+}
+
+char *troff_output::get_last_filled()
+{
+ return last_filled;
+}
+
+char *troff_output::get_outline_color()
+{
+ return last_outlined;
}
const double DOT_AXIS = .044;
diff --git a/contrib/groff/src/preproc/refer/Makefile.sub b/contrib/groff/src/preproc/refer/Makefile.sub
index 1631b5e..9f4a53b 100644
--- a/contrib/groff/src/preproc/refer/Makefile.sub
+++ b/contrib/groff/src/preproc/refer/Makefile.sub
@@ -1,13 +1,13 @@
-PROG=refer
+PROG=refer$(EXEEXT)
MAN1=refer.n
XLIBS=$(LIBBIB) $(LIBGROFF)
MLIB=$(LIBM)
OBJS=\
- command.o \
- label.o \
- ref.o \
- refer.o \
- token.o
+ command.$(OBJEXT) \
+ label.$(OBJEXT) \
+ ref.$(OBJEXT) \
+ refer.$(OBJEXT) \
+ token.$(OBJEXT)
CCSRCS=\
$(srcdir)/command.cc \
$(srcdir)/ref.cc \
@@ -19,5 +19,5 @@ HDRS=\
$(srcdir)/command.h \
$(srcdir)/ref.h
GRAM=$(srcdir)/label.y
-YTABC=$(srcdir)/label.cc
+YTABC=label.cc
NAMEPREFIX=$(g)
diff --git a/contrib/groff/src/preproc/refer/command.cc b/contrib/groff/src/preproc/refer/command.cc
index bf88c89d..a7c6bfb 100644
--- a/contrib/groff/src/preproc/refer/command.cc
+++ b/contrib/groff/src/preproc/refer/command.cc
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -193,9 +194,9 @@ void input_stack::push_file(const char *fn)
}
if (c == EOF)
break;
- if (illegal_input_char(c))
+ if (invalid_input_char(c))
error_with_file_and_line(fn, lineno,
- "illegal input character code %1", int(c));
+ "invalid input character code %1", int(c));
else {
buf += c;
if (c == '\n') {
diff --git a/contrib/groff/src/preproc/refer/refer.cc b/contrib/groff/src/preproc/refer/refer.cc
index c39def7..33df35c 100644
--- a/contrib/groff/src/preproc/refer/refer.cc
+++ b/contrib/groff/src/preproc/refer/refer.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1989-1992, 2000, 2001, 2002 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -445,8 +445,8 @@ static void do_file(const char *filename)
line += '\n';
break;
}
- if (illegal_input_char(c))
- error("illegal input character code %1", c);
+ if (invalid_input_char(c))
+ error("invalid input character code %1", c);
else {
line += c;
if (c == '\n')
@@ -476,8 +476,8 @@ static void do_file(const char *filename)
int d = getc(fp);
if (d == ']') {
while ((d = getc(fp)) != '\n' && d != EOF) {
- if (illegal_input_char(d))
- error("illegal input character code %1", d);
+ if (invalid_input_char(d))
+ error("invalid input character code %1", d);
else
post += d;
}
@@ -486,8 +486,8 @@ static void do_file(const char *filename)
if (d != EOF)
ungetc(d, fp);
}
- if (illegal_input_char(c))
- error("illegal input character code %1", c);
+ if (invalid_input_char(c))
+ error("invalid input character code %1", c);
else
str += c;
start_of_line = (c == '\n');
@@ -580,8 +580,8 @@ static void do_file(const char *filename)
"missing `.R2' line");
break;
}
- if (illegal_input_char(c))
- error("illegal input character code %1", int(c));
+ if (invalid_input_char(c))
+ error("invalid input character code %1", int(c));
else {
line += c;
start_of_line = c == '\n';
@@ -1113,8 +1113,8 @@ void do_bib(const char *filename)
int c = getc(fp);
if (c == EOF)
break;
- if (illegal_input_char(c)) {
- error("illegal input character code %1", c);
+ if (invalid_input_char(c)) {
+ error("invalid input character code %1", c);
continue;
}
switch (state) {
diff --git a/contrib/groff/src/preproc/refer/refer.h b/contrib/groff/src/preproc/refer/refer.h
index f0ab3cd..e1e0c6d 100644
--- a/contrib/groff/src/preproc/refer/refer.h
+++ b/contrib/groff/src/preproc/refer/refer.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.
@@ -18,15 +18,14 @@ 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. */
-#include <stdio.h>
+#include "lib.h"
+
#include <stdlib.h>
#include <assert.h>
-#include <string.h>
#include <errno.h>
#include "errarg.h"
#include "error.h"
-#include "lib.h"
#include "stringclass.h"
#include "cset.h"
#include "cmap.h"
diff --git a/contrib/groff/src/preproc/soelim/Makefile.sub b/contrib/groff/src/preproc/soelim/Makefile.sub
index 77007e2..4b59ab6 100644
--- a/contrib/groff/src/preproc/soelim/Makefile.sub
+++ b/contrib/groff/src/preproc/soelim/Makefile.sub
@@ -1,6 +1,6 @@
-PROG=soelim
+PROG=soelim$(EXEEXT)
MAN1=soelim.n
XLIBS=$(LIBGROFF)
-OBJS=soelim.o
+OBJS=soelim.$(OBJEXT)
CCSRCS=$(srcdir)/soelim.cc
NAMEPREFIX=$(g)
diff --git a/contrib/groff/src/preproc/soelim/soelim.cc b/contrib/groff/src/preproc/soelim/soelim.cc
index a604004..006b04a 100644
--- a/contrib/groff/src/preproc/soelim/soelim.cc
+++ b/contrib/groff/src/preproc/soelim/soelim.cc
@@ -18,13 +18,12 @@ 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. */
-#include <stdio.h>
+#include "lib.h"
+
#include <ctype.h>
-#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
-#include "lib.h"
#include "errarg.h"
#include "error.h"
#include "stringclass.h"
diff --git a/contrib/groff/src/preproc/tbl/Makefile.sub b/contrib/groff/src/preproc/tbl/Makefile.sub
index 224baff..fb14818 100644
--- a/contrib/groff/src/preproc/tbl/Makefile.sub
+++ b/contrib/groff/src/preproc/tbl/Makefile.sub
@@ -1,9 +1,9 @@
-PROG=tbl
+PROG=tbl$(EXEEXT)
MAN1=tbl.n
XLIBS=$(LIBGROFF)
OBJS=\
- main.o \
- table.o
+ main.$(OBJEXT) \
+ table.$(OBJEXT)
CCSRCS=\
$(srcdir)/main.cc \
$(srcdir)/table.cc
diff --git a/contrib/groff/src/preproc/tbl/main.cc b/contrib/groff/src/preproc/tbl/main.cc
index b1b14a7..dc0bdce 100644
--- a/contrib/groff/src/preproc/tbl/main.cc
+++ b/contrib/groff/src/preproc/tbl/main.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -20,7 +20,6 @@ with groff; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "table.h"
-#include "htmlindicate.h"
#define MAX_POINT_SIZE 99
#define MAX_VERTICAL_SPACING 72
@@ -110,7 +109,7 @@ int table_input::get()
else {
state = MIDDLE;
if (c == '\0') {
- error("illegal input character code 0");
+ error("invalid input character code 0");
break;
}
}
@@ -139,7 +138,7 @@ int table_input::get()
current_lineno++;
}
else if (c == '\0') {
- error("illegal input character code 0");
+ error("invalid input character code 0");
break;
}
return c;
@@ -221,8 +220,6 @@ void process_input_file(FILE *fp)
break;
case HAD_TS:
if (c == ' ' || c == '\n' || compatible_flag) {
- printf(".if '\\*(.T'html' \\X(table-start(\n");
- html_begin_suppress(0);
putchar('.');
putchar('T');
putchar('S');
@@ -244,16 +241,12 @@ void process_input_file(FILE *fp)
fputs(".TE", stdout);
while ((c = getc(fp)) != '\n') {
if (c == EOF) {
- printf(".if '\\*(.T'html' \\X(table-end(\n");
- html_end_suppress(0);
putchar('\n');
return;
}
putchar(c);
}
putchar('\n');
- printf(".if '\\*(.T'html' \\X(table-end(\n");
- html_end_suppress(0);
current_lineno++;
}
}
@@ -453,34 +446,39 @@ options *process_options(table_input &in)
}
else if (strieq(p, "center") || strieq(p, "centre")) {
if (arg)
- error("`center' option does not take a argument");
+ error("`center' option does not take an argument");
opt->flags |= table::CENTER;
}
else if (strieq(p, "expand")) {
if (arg)
- error("`expand' option does not take a argument");
+ error("`expand' option does not take an argument");
opt->flags |= table::EXPAND;
}
else if (strieq(p, "box") || strieq(p, "frame")) {
if (arg)
- error("`box' option does not take a argument");
+ error("`box' option does not take an argument");
opt->flags |= table::BOX;
}
else if (strieq(p, "doublebox") || strieq(p, "doubleframe")) {
if (arg)
- error("`doublebox' option does not take a argument");
+ error("`doublebox' option does not take an argument");
opt->flags |= table::DOUBLEBOX;
}
else if (strieq(p, "allbox")) {
if (arg)
- error("`allbox' option does not take a argument");
+ error("`allbox' option does not take an argument");
opt->flags |= table::ALLBOX;
}
else if (strieq(p, "nokeep")) {
if (arg)
- error("`nokeep' option does not take a argument");
+ error("`nokeep' option does not take an argument");
opt->flags |= table::NOKEEP;
}
+ else if (strieq(p, "nospaces")) {
+ if (arg)
+ error("`nospaces' option does not take an argument");
+ opt->flags |= table::NOSPACES;
+ }
else if (strieq(p, "decimalpoint")) {
if (!arg)
error("`decimalpoint' option requires argument in parentheses");
@@ -1214,6 +1212,8 @@ table *process_data(table_input &in, format *f, options *opt)
int ln = current_lineno;
if (c == '\n')
--ln;
+ if ((opt->flags & table::NOSPACES))
+ input_entry.remove_spaces();
while (col < ncolumns
&& line_format[col].type == FORMAT_SPAN) {
tbl->add_entry(current_row, col, "", &line_format[col],
@@ -1385,7 +1385,7 @@ table *process_data(table_input &in, format *f, options *opt)
f = newf;
}
if (line.length() >= 3
- && line[0] == '.' && line[1] == 'f' && line[2] == 'f') {
+ && line[0] == '.' && line[1] == 'l' && line[2] == 'f') {
line += '\0';
interpret_lf_args(line.contents() + 3);
}
diff --git a/contrib/groff/src/preproc/tbl/table.h b/contrib/groff/src/preproc/tbl/table.h
index ca55b80..69959b8 100644
--- a/contrib/groff/src/preproc/tbl/table.h
+++ b/contrib/groff/src/preproc/tbl/table.h
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -18,7 +19,8 @@ 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. */
-#include <stdio.h>
+#include "lib.h"
+
#include <stdlib.h>
#include <assert.h>
#include <ctype.h>
@@ -29,7 +31,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "stringclass.h"
#include "errarg.h"
#include "error.h"
-#include "lib.h"
struct inc_number {
short inc;
@@ -127,7 +128,8 @@ public:
BOX = 04,
ALLBOX = 010,
DOUBLEBOX = 020,
- NOKEEP = 040
+ NOKEEP = 040,
+ NOSPACES = 0100
};
table(int nc, unsigned flags, int linesize, char decimal_point_char);
~table();
diff --git a/contrib/groff/src/preproc/tbl/tbl.man b/contrib/groff/src/preproc/tbl/tbl.man
index 42dac25..f661fde 100644
--- a/contrib/groff/src/preproc/tbl/tbl.man
+++ b/contrib/groff/src/preproc/tbl/tbl.man
@@ -1,5 +1,5 @@
.ig
-Copyright (C) 1989-1995, 2001 Free Software Foundation, Inc.
+Copyright (C) 1989-1995, 2001, 2002 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -19,14 +19,18 @@ the original English.
.TH @G@TBL @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
.SH NAME
@g@tbl \- format tables for troff
+.
+.
.SH SYNOPSIS
.B @g@tbl
[
.B \-Cv
]
[
-.IR files \|.\|.\|.
+.IR files \|.\|.\|.\&
]
+.
+.
.SH DESCRIPTION
This manual page describes the GNU version of
.BR tbl ,
@@ -53,6 +57,8 @@ will be read.
A filename of
.B \-
will cause the standard input to be read.
+.
+.
.SH OPTIONS
.TP
.B \-C
@@ -64,47 +70,297 @@ even when followed by a character other than space or newline.
.TP
.B \-v
Print the version number.
+.
+.
.SH USAGE
-Only the differences between GNU
.B tbl
-and Unix
-.B tbl
-are described here.
-.LP
+expects to find table descriptions wrapped in the
+.B .TS
+(table start) and
+.B .TE
+(table end) macros.
+The line immediately following the
+.B .TS
+macro may contain any of the following global options (ignoring the case
+of characters -- Unix tbl only accepts options with all characters lowercase
+or all characters uppercase):
+.
+.TP
+.B center
+Centers the table (default is left-justified).
+The alternative keyword name
+.B centre
+is also recognized (this is a GNU tbl extension).
+.
+.TP
+.BI delim( xy )
+Use
+.I x
+and
+.I y
+as start and end delimiters for
+.BR @g@eqn (@MAN1EXT@).
+.
+.TP
+.B expand
+Makes the table as wide as the current line length.
+.
+.TP
+.B box
+Encloses the table in a box.
+.
+.TP
+.B doublebox
+Encloses the table in a double box.
+.
+.TP
+.B allbox
+Encloses each item of the table in a box.
+.
+.TP
+.B frame
+Same as box (GNU tbl only).
+.
+.TP
+.B doubleframe
+Same as doublebox (GNU tbl only).
+.
+.TP
+.BI tab( x )
+Uses the character
+.I x
+instead of a tab to separate items in a line of input data.
+.
+.TP
+.BI linesize( n )
+Sets lines or rules (e.g. from
+.BR box )
+in
+.IR n -point
+type.
+.
+.TP
+.B nokeep
+Don't use diversions to prevent page breaks (GNU tbl only).
Normally
.B tbl
attempts to prevent undesirable breaks in the table by using diversions.
-This can sometimes interact badly with macro packages' own use of diversions,
-when footnotes, for example, are used.
-The
-.B nokeep
-option tells
-.B tbl
-not to try and prevent breaks in this way.
+This can sometimes interact badly with macro packages' own use of
+diversions, when footnotes, for example, are used.
+.
+.TP
+.BI decimalpoint( c )
+Set the character to be recognized as the decimal point in numeric
+columns (GNU tbl only).
+.
+.TP
+.B nospaces
+Ignore leading and trailing spaces in data items (GNU tbl only).
+.
.LP
-The
-.B decimalpoint
-option specifies the character to be recognized as the decimal
-point character in place of the default period.
-It takes an argument in parentheses, which must be a single
-character, as for the
+The global options must end with a semicolon.
+There might be whitespace after an option and its argument in parentheses.
+.LP
+After global options come lines describing the format of each line of
+the table.
+Each such format line describes one line of the table itself, except that
+the last format line (which you must end with a period) describes all
+remaining lines of the table.
+A single key character describes each column of each line of the table.
+You may run format specs for multiple lines together on the same line by
+separating them with commas.
+.LP
+You may follow each key character with specifiers that determine the font
+and point size of the corresponding item, that determine column width,
+inter-column spacing, etc.
+.LP
+The longest format line defines the number of columns in the table; missing
+format descriptors at the end of format lines are assumed to be `L'.
+Extra columns in the data (which have no corresponding format entry) are
+ignored.
+.LP
+The available key characters are:
+.
+.TP
+c,C
+Centers item within the column.
+.
+.TP
+r,R
+Right-justifies item within the column.
+.
+.TP
+l,L
+Left-justifies item within the column.
+.
+.TP
+n,N
+Numerically justifies item in the column: Units positions of numbers are
+aligned vertically.
+.
+.TP
+s,S
+Spans previous item on the left into this column.
+.
+.TP
+a,A
+Centers longest line in this column and then left-justifies all other lines
+in this column with respect to that centered line.
+.
+.TP
+^
+Spans down entry from previous row in this column.
+.
+.TP
+_,-
+Replaces this entry with a horizontal line.
+.
+.TP
+=
+.
+Replaces this entry with a double horizontal line.
+.
+.TP
+|
+The corresponding column becomes a vertical rule (if two of these are
+adjacent, a double vertical rule).
+.
+.LP
+A vertical bar to the left of the first key-letter or to the right of the
+last one produces a line at the edge of the table.
+.LP
+Here are the specifiers that can appear in suffixes to column key letters:
+.
+.TP
+b,B
+Short form of fB (make affected entries bold).
+.
+.TP
+i,I
+Short form of fI (make affected entries italic).
+.
+.TP
+t,T
+Start an item vertically spanning rows at the top of its range rather than
+vertically centering it.
+.
+.TP
+d,D
+Start an item vertically spanning rows at the bottom of its range rather
+than vertically centering it (GNU tbl only).
+.
+.TP
+v,V
+Followed by a number, this indicates the vertical line spacing to be used in
+a multi-line table entry.
+If signed, the current vertical line spacing is incremented or decremented
+(using a signed number instead of a signed digit is a GNU tbl extension).
+A vertical line spacing specifier followed by a column separation number
+must be separated by one or more blanks.
+No effect if the corresponding table entry isn't a text block.
+.
+.TP
+f,F
+Either of these specifiers may be followed by a font name (either one or two
+characters long), font number (a single digit), or long name in parentheses
+(the last form is a GNU tbl extension).
+A one-letter font name must be separated by one or more blanks from whatever
+follows.
+.
+.TP
+p,P
+Followed by a number, this does a point size change for the affected fields.
+If signed, the current point size is incremented or decremented (using a
+signed number instead of a signed digit is a GNU tbl extension).
+A point size specifier followed by a column separation number must be
+separated by one or more blanks.
+.
+.TP
+w,W
+Minimal column width value.
+Must be followed either by a
+.BR @g@troff (@MAN1EXT@)
+width expression in parentheses or a unitless integer.
+If no unit is given, en units are used.
+Also used as the default line length for included text blocks.
+If used multiple times, the last entry takes effect.
+.
+.TP
+e,E
+Make equally-spaced columns.
+.
+.TP
+u,U
+Move the corresponding column up one half-line.
+.
+.TP
+z,Z
+Ignore the corresponding column for width-calculation purposes.
+.
+.LP
+A number suffix on a key character is interpreted as a column
+separation in ens (multiplied in proportion if the
+.B expand
+option is on).
+Default separation is 3n.
+.LP
+The format lines are followed by lines containing the actual data for the
+table, followed finally by
+.BR .TE .
+Within such data lines, items are normally separated by tab characters (or
+the character specified with the
.B tab
-option.
+option).
+Long input lines can be broken across multiple lines if the last character
+on the line is `\e' (which vanishes after concatenation).
.LP
-The
-.B f
-format modifier can be followed by an arbitrary length
-font name in parentheses.
-.LP
-There is a
-.B d
-format modifier which means that a vertically spanning entry
-should be aligned at the bottom of its range.
-.LP
-There is no limit on the number of columns in a table, nor any limit
-on the number of text blocks.
-All the lines of a table are considered in deciding column
-widths, not just the first 200.
+A dot starting a line, followed by anything but a digit is handled as a
+troff command, passed through without changes.
+The table position is unchanged in this case.
+.LP
+If a data line consists of only `_' or `=', a single or double line,
+respectively, is drawn across the table at that point; if a single item in a
+data line consists of only `_' or `=', then that item is replaced by a
+single or double line, joining its neighbours.
+If a data item consists only of `\e_' or `\e=', a single or double line,
+respectively, is drawn across the field at that point which does not join
+its neighbours.
+.LP
+A data item consisting only of `\eRx' (`x' any character) is replaced by
+repetitions of character `x' as wide as the column (not joining its
+neighbours).
+.LP
+A data item consisting only of `\e^' indicates that the field immediately
+above spans downward over this row.
+.LP
+A text block can be used to enter data as a single entry which would be
+too long as a simple string between tabs.
+It is started with `T{' and closed with `T}'.
+The latter must start a line, probably followed by other data columns
+(separated with tabs).
+.LP
+To change the data format within a table, use the
+.B .T&
+command (at the start of a line).
+It is followed by format and data lines (but no global options) similar to
+the
+.B .TS
+request.
+.
+.
+.SH "INTERACTION WITH @G@EQN"
+.BR @g@tbl (@MAN1EXT@)
+should always be called before
+.BR @g@eqn (@MAN1EXT@)
+.RB ( groff (@MAN1EXT@)
+automatically takes care of the correct order of preprocessors).
+.
+.
+.SH "GNU TBL ENHANCEMENTS"
+There is no limit on the number of columns in a table, nor any limit on the
+number of text blocks.
+All the lines of a table are considered in deciding column widths, not just
+the first 200.
Table continuation
.RB ( .T& )
lines are not restricted to the first 200 lines.
@@ -113,13 +369,15 @@ Numeric and alphabetic items may appear in the same column.
.LP
Numeric and alphabetic items may span horizontally.
.LP
-.B tbl
-uses register, string, macro and diversion names beginning with
+.B @g@tbl
+uses register, string, macro and diversion names beginning with the digit\~\c
.BR 3 .
When using
-.B tbl
-you should avoid using any names beginning with a
+.B @g@tbl
+you should avoid using any names beginning with a\~\c
.BR 3 .
+.
+.
.SH BUGS
You should use
.BR .TS\ H / .TH
@@ -157,7 +415,7 @@ instead of
.BR bp .
.LP
Using \ea directly in a table to get leaders will not work.
-This is correct behaviour: \ea is a
+This is correct behaviour: \ea is an
.B uninterpreted
leader.
To get leaders use a real leader, either by using a control A or like
@@ -173,6 +431,14 @@ A\e*a;B
\&.TE
.ft
.fi
+.
+.
+.SH REFERENCE
+Lesk, M.E.: "TBL -- A Program to Format Tables".
+For copyright reasons it cannot be included in the groff distribution,
+but copies can be found with a title search on the World Wide Web.
+.
+.
.SH "SEE ALSO"
.BR groff (@MAN1EXT@),
.BR @g@troff (@MAN1EXT@)
OpenPOWER on IntegriCloud