aboutsummaryrefslogtreecommitdiff
path: root/contrib/groff/src/preproc
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2017-06-07 23:00:34 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2017-06-07 23:00:34 +0000
commit738919c0391b99947b758d85f6a8636be1886fbb (patch)
tree6dcdfc8513007dbfe8dd40dfb3d7dfffb49b6651 /contrib/groff/src/preproc
parente0e0323354c55335775e3a55b1af0f93967fb412 (diff)
downloadsrc-738919c0391b99947b758d85f6a8636be1886fbb.tar.gz
src-738919c0391b99947b758d85f6a8636be1886fbb.zip
Remove groff from base
All manpages in base are now compatible with mandoc(1), all roff documentation will be relocated in the doc tree. man(1) can now use groff from the ports tree if it needs. Also remove checknr(1) and colcrt(1) which are only useful with groff. Approved by: (no objections on the mailing lists)
Notes
Notes: svn path=/head/; revision=319664
Diffstat (limited to 'contrib/groff/src/preproc')
-rw-r--r--contrib/groff/src/preproc/eqn/Makefile.sub60
-rw-r--r--contrib/groff/src/preproc/eqn/TODO49
-rw-r--r--contrib/groff/src/preproc/eqn/box.cpp612
-rw-r--r--contrib/groff/src/preproc/eqn/box.h280
-rw-r--r--contrib/groff/src/preproc/eqn/delim.cpp401
-rw-r--r--contrib/groff/src/preproc/eqn/eqn.h50
-rw-r--r--contrib/groff/src/preproc/eqn/eqn.man1160
-rw-r--r--contrib/groff/src/preproc/eqn/eqn.y330
-rw-r--r--contrib/groff/src/preproc/eqn/lex.cpp1172
-rw-r--r--contrib/groff/src/preproc/eqn/limit.cpp195
-rw-r--r--contrib/groff/src/preproc/eqn/list.cpp237
-rw-r--r--contrib/groff/src/preproc/eqn/main.cpp395
-rw-r--r--contrib/groff/src/preproc/eqn/mark.cpp121
-rw-r--r--contrib/groff/src/preproc/eqn/neqn.man43
-rw-r--r--contrib/groff/src/preproc/eqn/neqn.sh25
-rw-r--r--contrib/groff/src/preproc/eqn/other.cpp601
-rw-r--r--contrib/groff/src/preproc/eqn/over.cpp197
-rw-r--r--contrib/groff/src/preproc/eqn/pbox.h141
-rw-r--r--contrib/groff/src/preproc/eqn/pile.cpp293
-rw-r--r--contrib/groff/src/preproc/eqn/script.cpp222
-rw-r--r--contrib/groff/src/preproc/eqn/special.cpp115
-rw-r--r--contrib/groff/src/preproc/eqn/sqrt.cpp180
-rw-r--r--contrib/groff/src/preproc/eqn/text.cpp528
-rw-r--r--contrib/groff/src/preproc/grn/Makefile.sub17
-rw-r--r--contrib/groff/src/preproc/grn/README68
-rw-r--r--contrib/groff/src/preproc/grn/gprint.h86
-rw-r--r--contrib/groff/src/preproc/grn/grn.man652
-rw-r--r--contrib/groff/src/preproc/grn/hdb.cpp346
-rw-r--r--contrib/groff/src/preproc/grn/hgraph.cpp1048
-rw-r--r--contrib/groff/src/preproc/grn/hpoint.cpp49
-rw-r--r--contrib/groff/src/preproc/grn/main.cpp907
-rw-r--r--contrib/groff/src/preproc/html/Makefile.sub7
-rw-r--r--contrib/groff/src/preproc/html/pre-html.cpp1779
-rw-r--r--contrib/groff/src/preproc/html/pre-html.h37
-rw-r--r--contrib/groff/src/preproc/html/pushback.cpp329
-rw-r--r--contrib/groff/src/preproc/html/pushback.h54
-rw-r--r--contrib/groff/src/preproc/pic/Makefile.sub31
-rw-r--r--contrib/groff/src/preproc/pic/TODO35
-rw-r--r--contrib/groff/src/preproc/pic/common.cpp647
-rw-r--r--contrib/groff/src/preproc/pic/common.h80
-rw-r--r--contrib/groff/src/preproc/pic/lex.cpp2001
-rw-r--r--contrib/groff/src/preproc/pic/main.cpp642
-rw-r--r--contrib/groff/src/preproc/pic/object.cpp2017
-rw-r--r--contrib/groff/src/preproc/pic/object.h225
-rw-r--r--contrib/groff/src/preproc/pic/output.h83
-rw-r--r--contrib/groff/src/preproc/pic/pic.h123
-rw-r--r--contrib/groff/src/preproc/pic/pic.man1109
-rw-r--r--contrib/groff/src/preproc/pic/pic.y1898
-rw-r--r--contrib/groff/src/preproc/pic/position.h47
-rw-r--r--contrib/groff/src/preproc/pic/tex.cpp459
-rw-r--r--contrib/groff/src/preproc/pic/text.h28
-rw-r--r--contrib/groff/src/preproc/pic/troff.cpp567
-rw-r--r--contrib/groff/src/preproc/refer/Makefile.sub23
-rw-r--r--contrib/groff/src/preproc/refer/TODO124
-rw-r--r--contrib/groff/src/preproc/refer/command.cpp809
-rw-r--r--contrib/groff/src/preproc/refer/command.h36
-rw-r--r--contrib/groff/src/preproc/refer/label.y1193
-rw-r--r--contrib/groff/src/preproc/refer/ref.cpp1160
-rw-r--r--contrib/groff/src/preproc/refer/ref.h128
-rw-r--r--contrib/groff/src/preproc/refer/refer.cpp1242
-rw-r--r--contrib/groff/src/preproc/refer/refer.h78
-rw-r--r--contrib/groff/src/preproc/refer/refer.man1492
-rw-r--r--contrib/groff/src/preproc/refer/token.cpp378
-rw-r--r--contrib/groff/src/preproc/refer/token.h88
-rw-r--r--contrib/groff/src/preproc/soelim/Makefile.sub7
-rw-r--r--contrib/groff/src/preproc/soelim/TODO1
-rw-r--r--contrib/groff/src/preproc/soelim/soelim.cpp308
-rw-r--r--contrib/groff/src/preproc/soelim/soelim.man216
-rw-r--r--contrib/groff/src/preproc/tbl/Makefile.sub13
-rw-r--r--contrib/groff/src/preproc/tbl/main.cpp1590
-rw-r--r--contrib/groff/src/preproc/tbl/table.cpp2778
-rw-r--r--contrib/groff/src/preproc/tbl/table.h165
-rw-r--r--contrib/groff/src/preproc/tbl/tbl.man493
73 files changed, 0 insertions, 35100 deletions
diff --git a/contrib/groff/src/preproc/eqn/Makefile.sub b/contrib/groff/src/preproc/eqn/Makefile.sub
deleted file mode 100644
index 9028f94c8895..000000000000
--- a/contrib/groff/src/preproc/eqn/Makefile.sub
+++ /dev/null
@@ -1,60 +0,0 @@
-PROG=eqn$(EXEEXT)
-MAN1=eqn.n neqn.n
-XLIBS=$(LIBGROFF)
-MLIB=$(LIBM)
-OBJS=\
- 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.cpp \
- $(srcdir)/lex.cpp \
- $(srcdir)/box.cpp \
- $(srcdir)/limit.cpp \
- $(srcdir)/list.cpp \
- $(srcdir)/over.cpp \
- $(srcdir)/text.cpp \
- $(srcdir)/script.cpp \
- $(srcdir)/mark.cpp \
- $(srcdir)/other.cpp \
- $(srcdir)/delim.cpp \
- $(srcdir)/sqrt.cpp \
- $(srcdir)/pile.cpp \
- $(srcdir)/special.cpp
-HDRS=\
- $(srcdir)/box.h \
- $(srcdir)/eqn.h \
- $(srcdir)/pbox.h
-GRAM=$(srcdir)/eqn.y
-YTABC=eqn.cpp
-YTABH=eqn_tab.h
-NAMEPREFIX=$(g)
-CLEANADD=neqn
-
-all: neqn
-
-neqn: neqn.sh $(SH_DEPS_SED_SCRIPT)
- -rm -f $@
- sed -e 's/@g@/$(g)/g' \
- -f $(SH_DEPS_SED_SCRIPT) \
- -e $(SH_SCRIPT_SED_CMD) $(srcdir)/neqn.sh >$@
- chmod +x $@
-
-install_data: neqn
- -rm -f $(bindir)/$(NAMEPREFIX)neqn
- $(INSTALL_SCRIPT) neqn $(bindir)/$(NAMEPREFIX)neqn
-
-uninstall_sub:
- -rm -f $(bindir)/$(NAMEPREFIX)neqn
diff --git a/contrib/groff/src/preproc/eqn/TODO b/contrib/groff/src/preproc/eqn/TODO
deleted file mode 100644
index 210d0ab06e4d..000000000000
--- a/contrib/groff/src/preproc/eqn/TODO
+++ /dev/null
@@ -1,49 +0,0 @@
-Use the same size increases for sum prod int as eqn does.
-
-Perhaps chartype should be renamed.
-
-TeX makes {sub,super}script on a single character with an accent
-into an accent onto the (character with the script). Should we do this?
-
-Implement mark and lineups within scripts, matrices and piles, and accents.
-(Why would this be useful?)
-
-Perhaps push hmotions down through lists to avoid upsetting spacing
-adjustments.
-
-Possibly generate .lf commands during compute_metrics phase.
-
-Consider whether there should be extra space at the side of piles.
-
-Provide scriptstyle displaystyle etc.
-
-Provide a nicer matrix syntax, eg
-matrix ccc {
-a then b then c above
-e then f then g above
-h then i then k
-}
-
-Perhaps generate syntax error messages using the style of gpic.
-
-Wide accents.
-
-More use of \Z.
-
-Extensible square roots.
-
-Vphantom
-
-Smash.
-
-Provide a variant of vec that extends over the length of the accentee.
-
-Support vertical arrow delimiters.
-
-Make the following work:
-.EQ
-delim @@
-.EN
-.EQ @<-@
-some equation
-.EN
diff --git a/contrib/groff/src/preproc/eqn/box.cpp b/contrib/groff/src/preproc/eqn/box.cpp
deleted file mode 100644
index 953218a68da0..000000000000
--- a/contrib/groff/src/preproc/eqn/box.cpp
+++ /dev/null
@@ -1,612 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-This file is part of groff.
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "pbox.h"
-
-const char *current_roman_font;
-
-char *gfont = 0;
-char *grfont = 0;
-char *gbfont = 0;
-int gsize = 0;
-
-int script_size_reduction = -1; // negative means reduce by a percentage
-
-int positive_space = -1;
-int negative_space = -1;
-
-int minimum_size = 5;
-
-int fat_offset = 4;
-int body_height = 85;
-int body_depth = 35;
-
-int over_hang = 0;
-int accent_width = 31;
-int delimiter_factor = 900;
-int delimiter_shortfall = 50;
-
-int null_delimiter_space = 12;
-int script_space = 5;
-int thin_space = 17;
-int medium_space = 22;
-int thick_space = 28;
-
-int num1 = 70;
-int num2 = 40;
-// we don't use num3, because we don't have \atop
-int denom1 = 70;
-int denom2 = 36;
-int axis_height = 26; // in 100ths of an em
-int sup1 = 42;
-int sup2 = 37;
-int sup3 = 28;
-int default_rule_thickness = 4;
-int sub1 = 20;
-int sub2 = 23;
-int sup_drop = 38;
-int sub_drop = 5;
-int x_height = 45;
-int big_op_spacing1 = 11;
-int big_op_spacing2 = 17;
-int big_op_spacing3 = 20;
-int big_op_spacing4 = 60;
-int big_op_spacing5 = 10;
-
-// These are for piles and matrices.
-
-int baseline_sep = 140; // = num1 + denom1
-int shift_down = 26; // = axis_height
-int column_sep = 100; // = em space
-int matrix_side_sep = 17; // = thin space
-
-int nroff = 0; // should we grok ndefine or tdefine?
-
-struct S {
- const char *name;
- int *ptr;
-} param_table[] = {
- { "fat_offset", &fat_offset },
- { "over_hang", &over_hang },
- { "accent_width", &accent_width },
- { "delimiter_factor", &delimiter_factor },
- { "delimiter_shortfall", &delimiter_shortfall },
- { "null_delimiter_space", &null_delimiter_space },
- { "script_space", &script_space },
- { "thin_space", &thin_space },
- { "medium_space", &medium_space },
- { "thick_space", &thick_space },
- { "num1", &num1 },
- { "num2", &num2 },
- { "denom1", &denom1 },
- { "denom2", &denom2 },
- { "axis_height", &axis_height },
- { "sup1", &sup1 },
- { "sup2", &sup2 },
- { "sup3", &sup3 },
- { "default_rule_thickness", &default_rule_thickness },
- { "sub1", &sub1 },
- { "sub2", &sub2 },
- { "sup_drop", &sup_drop },
- { "sub_drop", &sub_drop },
- { "x_height", &x_height },
- { "big_op_spacing1", &big_op_spacing1 },
- { "big_op_spacing2", &big_op_spacing2 },
- { "big_op_spacing3", &big_op_spacing3 },
- { "big_op_spacing4", &big_op_spacing4 },
- { "big_op_spacing5", &big_op_spacing5 },
- { "minimum_size", &minimum_size },
- { "baseline_sep", &baseline_sep },
- { "shift_down", &shift_down },
- { "column_sep", &column_sep },
- { "matrix_side_sep", &matrix_side_sep },
- { "draw_lines", &draw_flag },
- { "body_height", &body_height },
- { "body_depth", &body_depth },
- { "nroff", &nroff },
- { 0, 0 }
-};
-
-void set_param(const char *name, int value)
-{
- for (int i = 0; param_table[i].name != 0; i++)
- if (strcmp(param_table[i].name, name) == 0) {
- *param_table[i].ptr = value;
- return;
- }
- error("unrecognised parameter `%1'", name);
-}
-
-int script_style(int style)
-{
- return style > SCRIPT_STYLE ? style - 2 : style;
-}
-
-int cramped_style(int style)
-{
- return (style & 1) ? style - 1 : style;
-}
-
-void set_space(int n)
-{
- if (n < 0)
- negative_space = -n;
- else
- positive_space = n;
-}
-
-// Return 0 if the specified size is bad.
-// The caller is responsible for giving the error message.
-
-int set_gsize(const char *s)
-{
- const char *p = (*s == '+' || *s == '-') ? s + 1 : s;
- char *end;
- long n = strtol(p, &end, 10);
- if (n <= 0 || *end != '\0' || n > INT_MAX)
- return 0;
- if (p > s) {
- if (!gsize)
- gsize = 10;
- if (*s == '+') {
- if (gsize > INT_MAX - n)
- return 0;
- gsize += int(n);
- }
- else {
- if (gsize - n <= 0)
- return 0;
- gsize -= int(n);
- }
- }
- else
- gsize = int(n);
- return 1;
-}
-
-void set_script_reduction(int n)
-{
- script_size_reduction = n;
-}
-
-const char *get_gfont()
-{
- return gfont ? gfont : "I";
-}
-
-const char *get_grfont()
-{
- return grfont ? grfont : "R";
-}
-
-const char *get_gbfont()
-{
- return gbfont ? gbfont : "B";
-}
-
-void set_gfont(const char *s)
-{
- a_delete gfont;
- gfont = strsave(s);
-}
-
-void set_grfont(const char *s)
-{
- a_delete grfont;
- grfont = strsave(s);
-}
-
-void set_gbfont(const char *s)
-{
- a_delete gbfont;
- gbfont = strsave(s);
-}
-
-// this must be precisely 2 characters in length
-#define COMPATIBLE_REG "0C"
-
-void start_string()
-{
- printf(".nr " COMPATIBLE_REG " \\n(.C\n");
- printf(".cp 0\n");
- printf(".ds " LINE_STRING "\n");
-}
-
-void output_string()
-{
- printf("\\*(" LINE_STRING "\n");
-}
-
-void restore_compatibility()
-{
- printf(".cp \\n(" COMPATIBLE_REG "\n");
-}
-
-void do_text(const char *s)
-{
- printf(".eo\n");
- printf(".as " LINE_STRING " \"%s\n", s);
- printf(".ec\n");
-}
-
-void set_minimum_size(int n)
-{
- minimum_size = n;
-}
-
-void set_script_size()
-{
- if (minimum_size < 0)
- minimum_size = 0;
- if (script_size_reduction >= 0)
- printf(".ps \\n[.s]-%d>?%d\n", script_size_reduction, minimum_size);
- else
- printf(".ps (u;\\n[.ps]*7+5/10>?%d)\n", minimum_size);
-}
-
-int box::next_uid = 0;
-
-box::box() : spacing_type(ORDINARY_TYPE), uid(next_uid++)
-{
-}
-
-box::~box()
-{
-}
-
-void box::top_level()
-{
- // debug_print();
- // putc('\n', stderr);
- box *b = this;
- printf(".nr " SAVED_FONT_REG " \\n[.f]\n");
- printf(".ft\n");
- printf(".nr " SAVED_PREV_FONT_REG " \\n[.f]\n");
- printf(".ft %s\n", get_gfont());
- printf(".nr " SAVED_SIZE_REG " \\n[.ps]\n");
- if (gsize > 0) {
- char buf[INT_DIGITS + 1];
- sprintf(buf, "%d", gsize);
- b = new size_box(strsave(buf), b);
- }
- current_roman_font = get_grfont();
- // This catches tabs used within \Z (which aren't allowed).
- b->check_tabs(0);
- int r = b->compute_metrics(DISPLAY_STYLE);
- printf(".ft \\n[" SAVED_PREV_FONT_REG "]\n");
- printf(".ft \\n[" SAVED_FONT_REG "]\n");
- printf(".nr " MARK_OR_LINEUP_FLAG_REG " %d\n", r);
- if (r == FOUND_MARK) {
- printf(".nr " SAVED_MARK_REG " \\n[" MARK_REG "]\n");
- printf(".nr " MARK_WIDTH_REG " 0\\n[" WIDTH_FORMAT "]\n", b->uid);
- }
- else if (r == FOUND_LINEUP)
- 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);
- // The problem here is that the argument to \f is read in copy mode,
- // so we cannot use \E there; so we hide it in a string instead.
- // Another problem is that if we use \R directly, then the space will
- // prevent it working in a macro argument.
- printf(".ds " SAVE_FONT_STRING " "
- "\\R'" SAVED_INLINE_FONT_REG " \\\\n[.f]'"
- "\\fP"
- "\\R'" SAVED_INLINE_PREV_FONT_REG " \\\\n[.f]'"
- "\\R'" SAVED_INLINE_SIZE_REG " \\\\n[.ps]'"
- "\\s0"
- "\\R'" SAVED_INLINE_PREV_SIZE_REG " \\\\n[.ps]'"
- "\n"
- ".ds " RESTORE_FONT_STRING " "
- "\\f[\\\\n[" SAVED_INLINE_PREV_FONT_REG "]]"
- "\\f[\\\\n[" SAVED_INLINE_FONT_REG "]]"
- "\\s'\\\\n[" SAVED_INLINE_PREV_SIZE_REG "]u'"
- "\\s'\\\\n[" SAVED_INLINE_SIZE_REG "]u'"
- "\n");
- 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 " .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);
- b->extra_space();
- if (!inline_flag)
- printf(".ne \\n[" HEIGHT_FORMAT "]u-%dM>?0+(\\n["
- DEPTH_FORMAT "]u-%dM>?0)\n",
- b->uid, body_height, b->uid, body_depth);
- delete b;
- next_uid = 0;
-}
-
-// gpic defines this register so as to make geqn not produce `\x's
-#define EQN_NO_EXTRA_SPACE_REG "0x"
-
-void box::extra_space()
-{
- printf(".if !r" EQN_NO_EXTRA_SPACE_REG " "
- ".nr " EQN_NO_EXTRA_SPACE_REG " 0\n");
- if (positive_space >= 0 || negative_space >= 0) {
- if (positive_space > 0)
- printf(".if !\\n[" EQN_NO_EXTRA_SPACE_REG "] "
- ".as1 " LINE_STRING " \\x'-%dM'\n", positive_space);
- if (negative_space > 0)
- printf(".if !\\n[" EQN_NO_EXTRA_SPACE_REG "] "
- ".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 .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 .as1 " LINE_STRING
- " \\x'\\n[" DEPTH_FORMAT
- "]u-%dM'\n",
- uid, body_depth, uid, body_depth);
- }
-}
-
-int box::compute_metrics(int)
-{
- printf(".nr " WIDTH_FORMAT " 0\n", uid);
- printf(".nr " HEIGHT_FORMAT " 0\n", uid);
- printf(".nr " DEPTH_FORMAT " 0\n", uid);
- return FOUND_NOTHING;
-}
-
-void box::compute_subscript_kern()
-{
- printf(".nr " SUB_KERN_FORMAT " 0\n", uid);
-}
-
-void box::compute_skew()
-{
- printf(".nr " SKEW_FORMAT " 0\n", uid);
-}
-
-void box::output()
-{
-}
-
-void box::check_tabs(int)
-{
-}
-
-int box::is_char()
-{
- return 0;
-}
-
-int box::left_is_italic()
-{
- return 0;
-}
-
-int box::right_is_italic()
-{
- return 0;
-}
-
-void box::hint(unsigned)
-{
-}
-
-void box::handle_char_type(int, int)
-{
-}
-
-
-box_list::box_list(box *pp)
-{
- p = new box*[10];
- for (int i = 0; i < 10; i++)
- p[i] = 0;
- maxlen = 10;
- len = 1;
- p[0] = pp;
-}
-
-void box_list::append(box *pp)
-{
- if (len + 1 > maxlen) {
- box **oldp = p;
- maxlen *= 2;
- p = new box*[maxlen];
- memcpy(p, oldp, sizeof(box*)*len);
- a_delete oldp;
- }
- p[len++] = pp;
-}
-
-box_list::~box_list()
-{
- for (int i = 0; i < len; i++)
- delete p[i];
- a_delete p;
-}
-
-void box_list::list_check_tabs(int level)
-{
- for (int i = 0; i < len; i++)
- p[i]->check_tabs(level);
-}
-
-
-pointer_box::pointer_box(box *pp) : p(pp)
-{
- spacing_type = p->spacing_type;
-}
-
-pointer_box::~pointer_box()
-{
- delete p;
-}
-
-int pointer_box::compute_metrics(int style)
-{
- int r = p->compute_metrics(style);
- 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);
- return r;
-}
-
-void pointer_box::compute_subscript_kern()
-{
- p->compute_subscript_kern();
- printf(".nr " SUB_KERN_FORMAT " \\n[" SUB_KERN_FORMAT "]\n", uid, p->uid);
-}
-
-void pointer_box::compute_skew()
-{
- p->compute_skew();
- printf(".nr " SKEW_FORMAT " 0\\n[" SKEW_FORMAT "]\n",
- uid, p->uid);
-}
-
-void pointer_box::check_tabs(int level)
-{
- p->check_tabs(level);
-}
-
-int simple_box::compute_metrics(int)
-{
- printf(".nr " WIDTH_FORMAT " 0\\w" DELIMITER_CHAR, uid);
- output();
- printf(DELIMITER_CHAR "\n");
- printf(".nr " HEIGHT_FORMAT " 0>?\\n[rst]\n", uid);
- printf(".nr " DEPTH_FORMAT " 0-\\n[rsb]>?0\n", uid);
- printf(".nr " SUB_KERN_FORMAT " 0-\\n[ssc]>?0\n", uid);
- printf(".nr " SKEW_FORMAT " 0\\n[skw]\n", uid);
- return FOUND_NOTHING;
-}
-
-void simple_box::compute_subscript_kern()
-{
- // do nothing, we already computed it in do_metrics
-}
-
-void simple_box::compute_skew()
-{
- // do nothing, we already computed it in do_metrics
-}
-
-int box::is_simple()
-{
- return 0;
-}
-
-int simple_box::is_simple()
-{
- return 1;
-}
-
-quoted_text_box::quoted_text_box(char *s) : text(s)
-{
-}
-
-quoted_text_box::~quoted_text_box()
-{
- a_delete text;
-}
-
-void quoted_text_box::output()
-{
- if (text)
- fputs(text, stdout);
-}
-
-tab_box::tab_box() : disabled(0)
-{
-}
-
-// We treat a tab_box as having width 0 for width computations.
-
-void tab_box::output()
-{
- if (!disabled)
- printf("\\t");
-}
-
-void tab_box::check_tabs(int level)
-{
- if (level > 0) {
- error("tabs allowed only at outermost level");
- disabled = 1;
- }
-}
-
-space_box::space_box()
-{
- spacing_type = SUPPRESS_TYPE;
-}
-
-void space_box::output()
-{
- printf("\\h'%dM'", thick_space);
-}
-
-half_space_box::half_space_box()
-{
- spacing_type = SUPPRESS_TYPE;
-}
-
-void half_space_box::output()
-{
- printf("\\h'%dM'", thin_space);
-}
-
-void box_list::list_debug_print(const char *sep)
-{
- p[0]->debug_print();
- for (int i = 1; i < len; i++) {
- fprintf(stderr, "%s", sep);
- p[i]->debug_print();
- }
-}
-
-void quoted_text_box::debug_print()
-{
- fprintf(stderr, "\"%s\"", (text ? text : ""));
-}
-
-void half_space_box::debug_print()
-{
- fprintf(stderr, "^");
-}
-
-void space_box::debug_print()
-{
- fprintf(stderr, "~");
-}
-
-void tab_box::debug_print()
-{
- fprintf(stderr, "<tab>");
-}
diff --git a/contrib/groff/src/preproc/eqn/box.h b/contrib/groff/src/preproc/eqn/box.h
deleted file mode 100644
index 94842077039a..000000000000
--- a/contrib/groff/src/preproc/eqn/box.h
+++ /dev/null
@@ -1,280 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2004, 2005
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-This file is part of groff.
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-class list_box;
-
-class box {
-private:
- static int next_uid;
-public:
- int spacing_type;
- const int uid;
- box();
- virtual void debug_print() = 0;
- virtual ~box();
- void top_level();
- virtual int compute_metrics(int);
- virtual void compute_subscript_kern();
- virtual void compute_skew();
- virtual void output();
- void extra_space();
- virtual list_box *to_list_box();
- virtual int is_simple();
- virtual int is_char();
- virtual int left_is_italic();
- virtual int right_is_italic();
- virtual void handle_char_type(int, int);
- enum { FOUND_NOTHING = 0, FOUND_MARK = 1, FOUND_LINEUP = 2 };
- void set_spacing_type(char *type);
- virtual void hint(unsigned);
- virtual void check_tabs(int);
-};
-
-class box_list {
-private:
- int maxlen;
-public:
- box **p;
- int len;
-
- box_list(box *);
- ~box_list();
- void append(box *);
- void list_check_tabs(int);
- void list_debug_print(const char *sep);
- friend class list_box;
-};
-
-// declarations to avoid friend name injection problems
-box *make_script_box(box *, box *, box *);
-box *make_mark_box(box *);
-box *make_lineup_box(box *);
-
-class list_box : public box {
- int is_script;
- box_list list;
- int sty;
-public:
- list_box(box *);
- void debug_print();
- int compute_metrics(int);
- void compute_subscript_kern();
- void output();
- void check_tabs(int);
- void append(box *);
- list_box *to_list_box();
- void handle_char_type(int, int);
- void compute_sublist_width(int n);
- friend box *make_script_box(box *, box *, box *);
- friend box *make_mark_box(box *);
- friend box *make_lineup_box(box *);
-};
-
-enum alignment { LEFT_ALIGN, RIGHT_ALIGN, CENTER_ALIGN };
-
-class column : public box_list {
- alignment align;
- int space;
-public:
- column(box *);
- void set_alignment(alignment);
- void set_space(int);
- void debug_print(const char *);
-
- friend class matrix_box;
- friend class pile_box;
-};
-
-class pile_box : public box {
- column col;
-public:
- pile_box(box *);
- int compute_metrics(int);
- void output();
- void debug_print();
- void check_tabs(int);
- void set_alignment(alignment a) { col.set_alignment(a); }
- void set_space(int n) { col.set_space(n); }
- void append(box *p) { col.append(p); }
-};
-
-class matrix_box : public box {
-private:
- int len;
- int maxlen;
- column **p;
-public:
- matrix_box(column *);
- ~matrix_box();
- void append(column *);
- int compute_metrics(int);
- void output();
- void check_tabs(int);
- void debug_print();
-};
-
-class pointer_box : public box {
-protected:
- box *p;
-public:
- pointer_box(box *);
- ~pointer_box();
- int compute_metrics(int);
- void compute_subscript_kern();
- void compute_skew();
- void debug_print() = 0;
- void check_tabs(int);
-};
-
-class vcenter_box : public pointer_box {
-public:
- vcenter_box(box *);
- int compute_metrics(int);
- void output();
- void debug_print();
-};
-
-class simple_box : public box {
-public:
- int compute_metrics(int);
- void compute_subscript_kern();
- void compute_skew();
- void output() = 0;
- void debug_print() = 0;
- int is_simple();
-};
-
-class quoted_text_box : public simple_box {
- char *text;
-public:
- quoted_text_box(char *);
- ~quoted_text_box();
- void debug_print();
- void output();
-};
-
-class half_space_box : public simple_box {
-public:
- half_space_box();
- void output();
- void debug_print();
-};
-
-class space_box : public simple_box {
-public:
- space_box();
- void output();
- void debug_print();
-};
-
-class tab_box : public box {
- int disabled;
-public:
- tab_box();
- void output();
- void debug_print();
- void check_tabs(int);
-};
-
-class size_box : public pointer_box {
-private:
- char *size;
-public:
- size_box(char *, box *);
- ~size_box();
- int compute_metrics(int);
- void output();
- void debug_print();
-};
-
-class font_box : public pointer_box {
-private:
- char *f;
-public:
- font_box(char *, box *);
- ~font_box();
- int compute_metrics(int);
- void output();
- void debug_print();
-};
-
-class fat_box : public pointer_box {
-public:
- fat_box(box *);
- int compute_metrics(int);
- void output();
- void debug_print();
-};
-
-class vmotion_box : public pointer_box {
-private:
- int n; // up is >= 0
-public:
- vmotion_box(int, box *);
- int compute_metrics(int);
- void output();
- void debug_print();
-};
-
-class hmotion_box : public pointer_box {
- int n;
-public:
- hmotion_box(int, box *);
- int compute_metrics(int);
- void output();
- void debug_print();
-};
-
-box *split_text(char *);
-box *make_delim_box(char *, box *, char *);
-box *make_sqrt_box(box *);
-box *make_prime_box(box *);
-box *make_over_box(box *, box *);
-box *make_small_over_box(box *, box *);
-box *make_limit_box(box *, box *, box *);
-box *make_accent_box(box *, box *);
-box *make_uaccent_box(box *, box *);
-box *make_overline_box(box *);
-box *make_underline_box(box *);
-box *make_special_box(char *, box *);
-
-void set_space(int);
-int set_gsize(const char *);
-void set_gfont(const char *);
-void set_grfont(const char *);
-void set_gbfont(const char *);
-const char *get_gfont();
-const char *get_grfont();
-const char *get_gbfont();
-void start_string();
-void output_string();
-void do_text(const char *);
-void restore_compatibility();
-void set_script_reduction(int n);
-void set_minimum_size(int n);
-void set_param(const char *name, int value);
-
-void set_char_type(const char *type, char *ch);
-
-void init_char_table();
-void init_extensible();
-void define_extensible(const char *name, const char *ext, const char *top = 0,
- const char *mid = 0, const char *bot = 0);
diff --git a/contrib/groff/src/preproc/eqn/delim.cpp b/contrib/groff/src/preproc/eqn/delim.cpp
deleted file mode 100644
index 9bb7c9b982c4..000000000000
--- a/contrib/groff/src/preproc/eqn/delim.cpp
+++ /dev/null
@@ -1,401 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2003 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "pbox.h"
-
-enum left_or_right_t { LEFT_DELIM = 01, RIGHT_DELIM = 02 };
-
-// Small must be none-zero and must exist in each device.
-// Small will be put in the roman font, others are assumed to be
-// on the special font (so no font change will be necessary.)
-
-struct delimiter {
- const char *name;
- int flags;
- const char *small;
- const char *chain_format;
- const char *ext;
- const char *top;
- const char *mid;
- const char *bot;
-} delim_table[] = {
- {
- "(", LEFT_DELIM|RIGHT_DELIM, "(", "\\[parenleft%s]",
- "\\[parenleftex]",
- "\\[parenlefttp]",
- 0,
- "\\[parenleftbt]",
- },
- {
- ")", LEFT_DELIM|RIGHT_DELIM, ")", "\\[parenright%s]",
- "\\[parenrightex]",
- "\\[parenrighttp]",
- 0,
- "\\[parenrightbt]",
- },
- {
- "[", LEFT_DELIM|RIGHT_DELIM, "[", "\\[bracketleft%s]",
- "\\[bracketleftex]",
- "\\[bracketlefttp]",
- 0,
- "\\[bracketleftbt]",
- },
- {
- "]", LEFT_DELIM|RIGHT_DELIM, "]", "\\[bracketright%s]",
- "\\[bracketrightex]",
- "\\[bracketrighttp]",
- 0,
- "\\[bracketrightbt]",
- },
- {
- "{", LEFT_DELIM|RIGHT_DELIM, "{", "\\[braceleft%s]",
- "\\[braceleftex]",
- "\\[bracelefttp]",
- "\\[braceleftmid]",
- "\\[braceleftbt]",
- },
- {
- "}", LEFT_DELIM|RIGHT_DELIM, "}", "\\[braceright%s]",
- "\\[bracerightex]",
- "\\[bracerighttp]",
- "\\[bracerightmid]",
- "\\[bracerightbt]",
- },
- {
- "|", LEFT_DELIM|RIGHT_DELIM, "|", "\\[bar%s]",
- "\\[barex]",
- 0,
- 0,
- 0,
- },
- {
- "floor", LEFT_DELIM, "\\(lf", "\\[floorleft%s]",
- "\\[bracketleftex]",
- 0,
- 0,
- "\\[bracketleftbt]",
- },
- {
- "floor", RIGHT_DELIM, "\\(rf", "\\[floorright%s]",
- "\\[bracketrightex]",
- 0,
- 0,
- "\\[bracketrightbt]",
- },
- {
- "ceiling", LEFT_DELIM, "\\(lc", "\\[ceilingleft%s]",
- "\\[bracketleftex]",
- "\\[bracketlefttp]",
- 0,
- 0,
- },
- {
- "ceiling", RIGHT_DELIM, "\\(rc", "\\[ceilingright%s]",
- "\\[bracketrightex]",
- "\\[bracketrighttp]",
- 0,
- 0,
- },
- {
- "||", LEFT_DELIM|RIGHT_DELIM, "|", "\\[bar%s]",
- "\\[bardblex]",
- 0,
- 0,
- 0,
- },
- {
- "<", LEFT_DELIM|RIGHT_DELIM, "\\(la", "\\[angleleft%s]",
- 0,
- 0,
- 0,
- 0,
- },
- {
- ">", LEFT_DELIM|RIGHT_DELIM, "\\(ra", "\\[angleright%s]",
- 0,
- 0,
- 0,
- 0,
- },
- {
- "uparrow", LEFT_DELIM|RIGHT_DELIM, "\\(ua", "\\[arrowup%s]",
- "\\[arrowvertex]",
- "\\[arrowverttp]",
- 0,
- 0,
- },
- {
- "downarrow", LEFT_DELIM|RIGHT_DELIM, "\\(da", "\\[arrowdown%s]",
- "\\[arrowvertex]",
- 0,
- 0,
- "\\[arrowvertbt]",
- },
- {
- "updownarrow", LEFT_DELIM|RIGHT_DELIM, "\\(va", "\\[arrowupdown%s]",
- "\\[arrowvertex]",
- "\\[arrowverttp]",
- 0,
- "\\[arrowvertbt]",
- },
-};
-
-const int DELIM_TABLE_SIZE = int(sizeof(delim_table)/sizeof(delim_table[0]));
-
-class delim_box : public box {
-private:
- char *left;
- char *right;
- box *p;
-public:
- delim_box(char *, box *, char *);
- ~delim_box();
- int compute_metrics(int);
- void output();
- void check_tabs(int);
- void debug_print();
-};
-
-box *make_delim_box(char *l, box *pp, char *r)
-{
- if (l != 0 && *l == '\0') {
- a_delete l;
- l = 0;
- }
- if (r != 0 && *r == '\0') {
- a_delete r;
- r = 0;
- }
- return new delim_box(l, pp, r);
-}
-
-delim_box::delim_box(char *l, box *pp, char *r)
-: left(l), right(r), p(pp)
-{
-}
-
-delim_box::~delim_box()
-{
- a_delete left;
- a_delete right;
- delete p;
-}
-
-static void build_extensible(const char *ext, const char *top, const char *mid,
- const char *bot)
-{
- assert(ext != 0);
- printf(".nr " DELIM_WIDTH_REG " 0\\w" DELIMITER_CHAR "%s" DELIMITER_CHAR "\n",
- ext);
- printf(".nr " EXT_HEIGHT_REG " 0\\n[rst]\n");
- printf(".nr " EXT_DEPTH_REG " 0-\\n[rsb]\n");
- if (top) {
- printf(".nr " DELIM_WIDTH_REG " 0\\n[" DELIM_WIDTH_REG "]"
- ">?\\w" DELIMITER_CHAR "%s" DELIMITER_CHAR "\n",
- top);
- printf(".nr " TOP_HEIGHT_REG " 0\\n[rst]\n");
- printf(".nr " TOP_DEPTH_REG " 0-\\n[rsb]\n");
- }
- if (mid) {
- printf(".nr " DELIM_WIDTH_REG " 0\\n[" DELIM_WIDTH_REG "]"
- ">?\\w" DELIMITER_CHAR "%s" DELIMITER_CHAR "\n",
- mid);
- printf(".nr " MID_HEIGHT_REG " 0\\n[rst]\n");
- printf(".nr " MID_DEPTH_REG " 0-\\n[rsb]\n");
- }
- if (bot) {
- printf(".nr " DELIM_WIDTH_REG " 0\\n[" DELIM_WIDTH_REG "]"
- ">?\\w" DELIMITER_CHAR "%s" DELIMITER_CHAR "\n",
- bot);
- printf(".nr " BOT_HEIGHT_REG " 0\\n[rst]\n");
- printf(".nr " BOT_DEPTH_REG " 0-\\n[rsb]\n");
- }
- printf(".nr " TOTAL_HEIGHT_REG " 0");
- if (top)
- printf("+\\n[" TOP_HEIGHT_REG "]+\\n[" TOP_DEPTH_REG "]");
- if (bot)
- printf("+\\n[" BOT_HEIGHT_REG "]+\\n[" BOT_DEPTH_REG "]");
- if (mid)
- printf("+\\n[" MID_HEIGHT_REG "]+\\n[" MID_DEPTH_REG "]");
- printf("\n");
- // determine how many extensible characters we need
- printf(".nr " TEMP_REG " \\n[" DELTA_REG "]-\\n[" TOTAL_HEIGHT_REG "]");
- if (mid)
- printf("/2");
- printf(">?0+\\n[" EXT_HEIGHT_REG "]+\\n[" EXT_DEPTH_REG "]-1/(\\n["
- EXT_HEIGHT_REG "]+\\n[" EXT_DEPTH_REG "])\n");
-
- printf(".nr " TOTAL_HEIGHT_REG " +(\\n[" EXT_HEIGHT_REG "]+\\n["
- EXT_DEPTH_REG "]*\\n[" TEMP_REG "]");
- if (mid)
- printf("*2");
- printf(")\n");
- printf(".ds " DELIM_STRING " \\Z" DELIMITER_CHAR
- "\\v'-%dM-(\\n[" TOTAL_HEIGHT_REG "]u/2u)'\n",
- axis_height);
- if (top)
- printf(".as " DELIM_STRING " \\v'\\n[" TOP_HEIGHT_REG "]u'"
- "\\Z" DELIMITER_CHAR "%s" DELIMITER_CHAR
- "\\v'\\n[" TOP_DEPTH_REG "]u'\n",
- top);
-
- // this macro appends $2 copies of $3 to string $1
- printf(".de " REPEAT_APPEND_STRING_MACRO "\n"
- ".if \\\\$2 \\{.as \\\\$1 \"\\\\$3\n"
- "." REPEAT_APPEND_STRING_MACRO " \\\\$1 \\\\$2-1 \"\\\\$3\"\n"
- ".\\}\n"
- "..\n");
-
- printf("." REPEAT_APPEND_STRING_MACRO " " DELIM_STRING " \\n[" TEMP_REG "] "
- "\\v'\\n[" EXT_HEIGHT_REG "]u'"
- "\\Z" DELIMITER_CHAR "%s" DELIMITER_CHAR
- "\\v'\\n[" EXT_DEPTH_REG "]u'\n",
- ext);
-
- if (mid) {
- printf(".as " DELIM_STRING " \\v'\\n[" MID_HEIGHT_REG "]u'"
- "\\Z" DELIMITER_CHAR "%s" DELIMITER_CHAR
- "\\v'\\n[" MID_DEPTH_REG "]u'\n",
- mid);
- printf("." REPEAT_APPEND_STRING_MACRO " " DELIM_STRING
- " \\n[" TEMP_REG "] "
- "\\v'\\n[" EXT_HEIGHT_REG "]u'"
- "\\Z" DELIMITER_CHAR "%s" DELIMITER_CHAR
- "\\v'\\n[" EXT_DEPTH_REG "]u'\n",
- ext);
- }
- if (bot)
- printf(".as " DELIM_STRING " \\v'\\n[" BOT_HEIGHT_REG "]u'"
- "\\Z" DELIMITER_CHAR "%s" DELIMITER_CHAR
- "\\v'\\n[" BOT_DEPTH_REG "]u'\n",
- bot);
- printf(".as " DELIM_STRING " " DELIMITER_CHAR "\n");
-}
-
-static void define_extensible_string(char *delim, int uid,
- left_or_right_t left_or_right)
-{
- printf(".ds " DELIM_STRING "\n");
- delimiter *d = delim_table;
- int delim_len = strlen(delim);
- int i;
- for (i = 0; i < DELIM_TABLE_SIZE; i++, d++)
- if (strncmp(delim, d->name, delim_len) == 0
- && (left_or_right & d->flags) != 0)
- break;
- if (i >= DELIM_TABLE_SIZE) {
- error("there is no `%1' delimiter", delim);
- printf(".nr " DELIM_WIDTH_REG " 0\n");
- return;
- }
-
- printf(".nr " DELIM_WIDTH_REG " 0\\w" DELIMITER_CHAR "\\f[%s]%s\\fP" DELIMITER_CHAR "\n"
- ".ds " DELIM_STRING " \\Z" DELIMITER_CHAR
- "\\v'\\n[rsb]u+\\n[rst]u/2u-%dM'\\f[%s]%s\\fP" DELIMITER_CHAR "\n"
- ".nr " TOTAL_HEIGHT_REG " \\n[rst]-\\n[rsb]\n"
- ".if \\n[" TOTAL_HEIGHT_REG "]<\\n[" DELTA_REG "] "
- "\\{",
- current_roman_font, d->small, axis_height,
- current_roman_font, d->small);
-
- char buf[256];
- sprintf(buf, d->chain_format, "\\\\n[" INDEX_REG "]");
- printf(".nr " INDEX_REG " 0\n"
- ".de " TEMP_MACRO "\n"
- ".ie c%s \\{\\\n"
- ".nr " DELIM_WIDTH_REG " 0\\w" DELIMITER_CHAR "%s" DELIMITER_CHAR "\n"
- ".ds " DELIM_STRING " \\Z" DELIMITER_CHAR
- "\\v'\\\\n[rsb]u+\\\\n[rst]u/2u-%dM'%s" DELIMITER_CHAR "\n"
- ".nr " TOTAL_HEIGHT_REG " \\\\n[rst]-\\\\n[rsb]\n"
- ".if \\\\n[" TOTAL_HEIGHT_REG "]<\\n[" DELTA_REG "] "
- "\\{.nr " INDEX_REG " +1\n"
- "." TEMP_MACRO "\n"
- ".\\}\\}\n"
- ".el .nr " INDEX_REG " 0-1\n"
- "..\n"
- "." TEMP_MACRO "\n",
- buf, buf, axis_height, buf);
- if (d->ext) {
- printf(".if \\n[" INDEX_REG "]<0 \\{.if c%s \\{\\\n", d->ext);
- build_extensible(d->ext, d->top, d->mid, d->bot);
- printf(".\\}\\}\n");
- }
- printf(".\\}\n");
- printf(".as " DELIM_STRING " \\h'\\n[" DELIM_WIDTH_REG "]u'\n");
- printf(".nr " WIDTH_FORMAT " +\\n[" DELIM_WIDTH_REG "]\n", uid);
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]"
- ">?(\\n[" TOTAL_HEIGHT_REG "]/2+%dM)\n",
- uid, uid, axis_height);
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]"
- ">?(\\n[" TOTAL_HEIGHT_REG "]/2-%dM)\n",
- uid, uid, axis_height);
-}
-
-int delim_box::compute_metrics(int style)
-{
- int r = p->compute_metrics(style);
- 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);
- printf(".nr " DELTA_REG " \\n[" HEIGHT_FORMAT "]-%dM"
- ">?(\\n[" DEPTH_FORMAT "]+%dM)\n",
- p->uid, axis_height, p->uid, axis_height);
- printf(".nr " DELTA_REG " 0\\n[" DELTA_REG "]*%d/500"
- ">?(\\n[" DELTA_REG "]*2-%dM)\n",
- delimiter_factor, delimiter_shortfall);
- if (left) {
- define_extensible_string(left, uid, LEFT_DELIM);
- printf(".rn " DELIM_STRING " " LEFT_DELIM_STRING_FORMAT "\n",
- uid);
- if (r)
- printf(".nr " MARK_REG " +\\n[" DELIM_WIDTH_REG "]\n");
- }
- if (right) {
- define_extensible_string(right, uid, RIGHT_DELIM);
- printf(".rn " DELIM_STRING " " RIGHT_DELIM_STRING_FORMAT "\n",
- uid);
- }
- return r;
-}
-
-void delim_box::output()
-{
- if (left)
- printf("\\*[" LEFT_DELIM_STRING_FORMAT "]", uid);
- p->output();
- if (right)
- printf("\\*[" RIGHT_DELIM_STRING_FORMAT "]", uid);
-}
-
-void delim_box::check_tabs(int level)
-{
- p->check_tabs(level);
-}
-
-void delim_box::debug_print()
-{
- fprintf(stderr, "left \"%s\" { ", left ? left : "");
- p->debug_print();
- fprintf(stderr, " }");
- if (right)
- fprintf(stderr, " right \"%s\"", right);
-}
-
diff --git a/contrib/groff/src/preproc/eqn/eqn.h b/contrib/groff/src/preproc/eqn/eqn.h
deleted file mode 100644
index fca3e9793a38..000000000000
--- a/contrib/groff/src/preproc/eqn/eqn.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2001 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "lib.h"
-
-#include <assert.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "cset.h"
-#include "errarg.h"
-#include "error.h"
-
-#include "box.h"
-
-extern char start_delim;
-extern char end_delim;
-extern int non_empty_flag;
-extern int inline_flag;
-extern int draw_flag;
-extern int one_size_reduction_flag;
-extern int compatible_flag;
-extern int nroff;
-
-void init_lex(const char *str, const char *filename, int lineno);
-void lex_error(const char *message,
- const errarg &arg1 = empty_errarg,
- const errarg &arg2 = empty_errarg,
- const errarg &arg3 = empty_errarg);
-
-void init_table(const char *device);
-
-// prefix for all registers, strings, macros
-#define PREFIX "0"
diff --git a/contrib/groff/src/preproc/eqn/eqn.man b/contrib/groff/src/preproc/eqn/eqn.man
deleted file mode 100644
index 0f47771c2392..000000000000
--- a/contrib/groff/src/preproc/eqn/eqn.man
+++ /dev/null
@@ -1,1160 +0,0 @@
-.ig
-Copyright (C) 1989-2000, 2001, 2004, 2005 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-versions, except that this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
-..
-.
-.
-.ie \n(.V<\n(.v \
-. ds tx T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
-.el \
-. ds tx TeX
-.
-.
-.\" 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"
-..
-.
-.
-.de TQ
-. br
-. ns
-. TP \\$1
-..
-.
-.
-.\" The BSD man macros can't handle " in arguments to font change macros,
-.\" so use \(ts instead of ".
-.tr \(ts"
-.
-.
-.TH @G@EQN @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
-.
-.
-.SH NAME
-@g@eqn \- format equations for troff
-.
-.
-.SH SYNOPSIS
-.nr a \n(.j
-.ad l
-.nr i \n(.i
-.in +\w'\fB@g@eqn 'u
-.ti \niu
-.B @g@eqn
-.de OP
-. ie \\n(.$-1 .RI "[\ \fB\\$1\fP" "\\$2" "\ ]"
-. el .RB "[\ " "\\$1" "\ ]"
-..
-.OP \-rvCNR
-.OP \-d xy
-.OP \-T name
-.OP \-M dir
-.OP \-f F
-.OP \-s n
-.OP \-p n
-.OP \-m n
-.RI "[\ " files\|.\|.\|. "\ ]"
-.br
-.ad \na
-.
-.LP
-It is possible to have whitespace between a command line option and its
-parameter.
-.
-.
-.SH DESCRIPTION
-This manual page describes the GNU version of
-.BR eqn ,
-which is part of the groff document formatting system.
-.B eqn
-compiles descriptions of equations embedded within
-.B troff
-input files into commands that are understood by
-.BR troff .
-Normally, it should be invoked using the
-.B \-e
-option of
-.BR groff .
-The syntax is quite compatible with Unix eqn.
-The output of GNU
-.B eqn
-cannot be processed with Unix troff;
-it must be processed with GNU troff.
-If no files are given on the command line, the standard input
-will be read.
-A filename of
-.B \-
-will cause the standard input to be read.
-.
-.LP
-.B eqn
-searches for the file
-.B eqnrc
-in the directories given with the
-.B \-M
-option first, then in
-.BR @SYSTEMMACRODIR@ ,
-.BR @LOCALMACRODIR@ ,
-and finally in the standard macro directory
-.BR @MACRODIR@ .
-If it exists,
-.B eqn
-will process it before the other input files.
-The
-.B \-R
-option prevents this.
-.
-.LP
-GNU
-.B eqn
-does not provide the functionality of neqn:
-it does not support low-resolution, typewriter-like devices
-(although it may work adequately for very simple input).
-.
-.
-.SH OPTIONS
-.TP
-.BI \-d xy
-Specify delimiters
-.I x
-and\~\c
-.I y
-for the left and right end, respectively, of in-line equations.
-Any
-.B delim
-statements in the source file overrides this.
-.
-.TP
-.B \-C
-Recognize
-.B .EQ
-and
-.B .EN
-even when followed by a character other than space or newline.
-.TP
-.B \-N
-Don't allow newlines within delimiters.
-This option allows
-.B eqn
-to recover better from missing closing delimiters.
-.
-.TP
-.B \-v
-Print the version number.
-.
-.TP
-.B \-r
-Only one size reduction.
-.
-.TP
-.BI \-m n
-The minimum point-size is\~\c
-.IR n .
-.B eqn
-will not reduce the size of subscripts or superscripts to
-a smaller size than\~\c
-.IR n .
-.
-.TP
-.BI \-T name
-The output is for device
-.IR name .
-The only effect of this is to define a macro
-.I name
-with a value of\~\c
-.BR 1 .
-Typically
-.B eqnrc
-will use this to provide definitions appropriate for the output device.
-The default output device is
-.BR @DEVICE@ .
-.
-.TP
-.BI \-M dir
-Search
-.I dir
-for
-.B eqnrc
-before the default directories.
-.
-.TP
-.B \-R
-Don't load
-.BR eqnrc .
-.
-.TP
-.BI \-f F
-This is equivalent to a
-.BI gfont\ F
-command.
-.
-.TP
-.BI \-s n
-This is equivalent to a
-.BI gsize\ n
-command.
-This option is deprecated.
-.B eqn
-will normally set equations at whatever the current point size
-is when the equation is encountered.
-.
-.TP
-.BI \-p n
-This says that subscripts and superscripts should be
-.I n\~\c
-points smaller than the surrounding text.
-This option is deprecated.
-Normally
-.B eqn
-makes sets subscripts and superscripts at 70%
-of the size of the surrounding text.
-.
-.
-.SH USAGE
-Only the differences between GNU
-.B eqn
-and Unix eqn are described here.
-.
-.LP
-Most of the new features of GNU
-.B eqn
-are based on \*(tx.
-There are some references to the differences between \*(tx and GNU
-.B eqn
-below;
-these may safely be ignored if you do not know \*(tx.
-.
-.SS Automatic spacing
-.B eqn
-gives each component of an equation a type, and adjusts the spacing
-between components using that type.
-Possible types are:
-.
-.RS
-.TP \w'punctuation'u+2n
-ordinary
-an ordinary character such as `1' or `\c
-.IR x ';
-.
-.TP
-operator
-a large operator such as
-.ds Su `\s+5\(*S\s0'
-.if \n(.g .if !c\(*S .ds Su the summation operator
-\*(Su;
-.
-.TP
-binary
-a binary operator such as `\(pl';
-.
-.TP
-relation
-a relation such as `=';
-.
-.TP
-opening
-a opening bracket such as `(';
-.
-.TP
-closing
-a closing bracket such as `)';
-.
-.TP
-punctuation
-a punctuation character such as `,';
-.
-.TP
-inner
-a subformula contained within brackets;
-.TP
-suppress
-spacing that suppresses automatic spacing adjustment.
-.RE
-.
-.LP
-Components of an equation get a type in one of two ways.
-.
-.TP
-.BI type\ t\ e
-This yields an equation component that contains\~\c
-.I e
-but that has type\~\c
-.IR t ,
-where
-.I t
-is one of the types mentioned above.
-For example,
-.B times
-is defined as
-.
-.RS
-.IP
-.B
-type "binary" \e(mu
-.RE
-.
-.IP
-The name of the type doesn't have to be quoted, but quoting protects
-from macro expansion.
-.
-.TP
-.BI chartype\ t\ text
-Unquoted groups of characters are split up into individual characters,
-and the type of each character is looked up;
-this changes the type that is stored for each character;
-it says that the characters in
-.I text
-from now on have type\~\c
-.IR t .
-For example,
-.
-.RS
-.IP
-.B
-chartype "punctuation" .,;:
-.RE
-.
-.IP
-would make the characters `.,;:' have type punctuation
-whenever they subsequently appeared in an equation.
-The type\~\c
-.I t
-can also be
-.B letter
-or
-.BR digit ;
-in these cases
-.B chartype
-changes the font type of the characters.
-See the
-.B Fonts
-subsection.
-.
-.SS New primitives
-.TP
-.IB e1\ smallover\ e2
-This is similar to
-.BR over ;
-.B smallover
-reduces the size of
-.I e1
-and
-.IR e2 ;
-it also puts less vertical space between
-.I e1
-or
-.I e2
-and the fraction bar.
-The
-.B over
-primitive corresponds to the \*(tx
-.B \eover
-primitive in display styles;
-.B smallover
-corresponds to
-.B \eover
-in non-display styles.
-.
-.TP
-.BI vcenter\ e
-This vertically centers
-.I e
-about the math axis.
-The math axis is the vertical position about which characters
-such as `\(pl' and `\(mi' are centered; also it is the vertical position
-used for the bar of fractions.
-For example,
-.B sum
-is defined as
-.
-.RS
-.IP
-.B
-{ type "operator" vcenter size +5 \e(*S }
-.RE
-.
-.TP
-.IB e1\ accent\ e2
-This sets
-.I e2
-as an accent over
-.IR e1 .
-.I e2
-is assumed to be at the correct height for a lowercase letter;
-.I e2
-will be moved down according if
-.I e1
-is taller or shorter than a lowercase letter.
-For example,
-.B hat
-is defined as
-.
-.RS
-.IP
-.B
-accent { "^" }
-.RE
-.
-.IP
-.BR dotdot ,
-.BR dot ,
-.BR tilde ,
-.BR vec ,
-and
-.B dyad
-are also defined using the
-.B accent
-primitive.
-.
-.TP
-.IB e1\ uaccent\ e2
-This sets
-.I e2
-as an accent under
-.IR e1 .
-.I e2
-is assumed to be at the correct height for a character without a descender;
-.I e2
-will be moved down if
-.I e1
-has a descender.
-.B utilde
-is pre-defined using
-.B uaccent
-as a tilde accent below the baseline.
-.
-.TP
-.BI split\ \(ts text \(ts
-This has the same effect as simply
-.
-.RS
-.IP
-.I text
-.RE
-.
-.IP
-but
-.I text
-is not subject to macro expansion because it is quoted;
-.I text
-will be split up and the spacing between individual characters
-will be adjusted.
-.
-.TP
-.BI nosplit\ text
-This has the same effect as
-.
-.RS
-.IP
-.BI \(ts text \(ts
-.RE
-.
-.IP
-but because
-.I text
-is not quoted it will be subject to macro expansion;
-.I text
-will not be split up
-and the spacing between individual characters will not be adjusted.
-.
-.TP
-.IB e\ opprime
-This is a variant of
-.B prime
-that acts as an operator on\~\c
-.IR e .
-It produces a different result from
-.B prime
-in a case such as
-.BR A\ opprime\ sub\ 1 :
-with
-.B opprime
-the\~\c
-.B 1
-will be tucked under the prime as a subscript to the\~\c
-.B A
-(as is conventional in mathematical typesetting),
-whereas with
-.B prime
-the\~\c
-.B 1
-will be a subscript to the prime character.
-The precedence of
-.B opprime
-is the same as that of
-.B bar
-and
-.BR under ,
-which is higher than that of everything except
-.B accent
-and
-.BR uaccent .
-In unquoted text a\~\c
-.B '
-that is not the first character will be treated like
-.BR opprime .
-.
-.TP
-.BI special\ text\ e
-This constructs a new object from\~\c
-.I e
-using a
-.BR @g@troff (@MAN1EXT@)
-macro named
-.IR text .
-When the macro is called,
-the string
-.B 0s
-will contain the output for\~\c
-.IR e ,
-and the number registers
-.BR 0w ,
-.BR 0h ,
-.BR 0d ,
-.BR 0skern ,
-and
-.BR 0skew
-will contain the width, height, depth, subscript kern, and skew of\~\c
-.IR e .
-(The
-.I "subscript kern"
-of an object says how much a subscript on that object should be tucked in;
-the
-.I skew
-of an object says how far to the right of the center of the object an
-accent over the object should be placed.)
-The macro must modify
-.B 0s
-so that it will output the desired result with its origin at the current
-point, and increase the current horizontal position by the width
-of the object.
-The number registers must also be modified so that they correspond to the
-result.
-.
-.IP
-For example, suppose you wanted a construct that `cancels' an expression
-by drawing a diagonal line through it.
-.
-.RS
-.IP
-.ft B
-.if t .ne 6+\n(.Vu
-.br
-\&.EQ
-.br
-define cancel 'special Ca'
-.br
-\&.EN
-.br
-\&.de Ca
-.br
-\&.\ \ ds 0s \e
-.br
-\eZ'\e\e*(0s'\e
-.br
-\ev'\e\en(0du'\e
-.br
-\eD'l \e\en(0wu -\e\en(0hu-\e\en(0du'\e
-.br
-\ev'\e\en(0hu'
-.br
-\&..
-.ft
-.RE
-.
-.IP
-Then you could cancel an expression\~\c
-.I e
-with
-.BI \%cancel\ {\ e\ }
-.
-.IP
-Here's a more complicated construct that draws a box round an expression:
-.
-.RS
-.IP
-.ft B
-.if t .ne 11+\n(.Vu
-\&.EQ
-.br
-define box 'special Bx'
-.br
-\&.EN
-.br
-\&.de Bx
-.br
-\&.\ \ ds 0s \e
-.br
-\eZ'\eh'1n'\e\e*(0s'\e
-.br
-\eZ'\e
-.br
-\ev'\e\en(0du+1n'\e
-.br
-\eD'l \e\en(0wu+2n 0'\e
-.br
-\eD'l 0 -\e\en(0hu-\e\en(0du-2n'\e
-.br
-\eD'l -\e\en(0wu-2n 0'\e
-.br
-\eD'l 0 \e\en(0hu+\e\en(0du+2n'\e
-.br
-\&'\e
-.br
-\eh'\e\en(0wu+2n'
-.br
-\&.\ \ nr 0w +2n
-.br
-\&.\ \ nr 0d +1n
-.br
-\&.\ \ nr 0h +1n
-.br
-\&..
-.ft
-.RE
-.
-.TP
-.BI space\ n
-A positive value of the integer\~\c
-.I n
-(in hundredths of an em) sets the vertical spacing before the equation,
-a negative value sets the spacing after the equation, replacing the
-default values.
-This primitive provides an interface to
-.BR groff 's
-.B \ex
-escape (but with opposite sign).
-.
-.IP
-This keyword has no effect if the equation is part of a
-.B pic
-picture.
-.
-.SS Extended primitives
-.TP
-.BI col\ n\ {\ .\|.\|.\ }
-.TQ
-.BI ccol\ n\ {\ .\|.\|.\ }
-.TQ
-.BI lcol\ n\ {\ .\|.\|.\ }
-.TQ
-.BI rcol\ n\ {\ .\|.\|.\ }
-.TQ
-.BI pile\ n\ {\ .\|.\|.\ }
-.TQ
-.BI cpile\ n\ {\ .\|.\|.\ }
-.TQ
-.BI lpile\ n\ {\ .\|.\|.\ }
-.TQ
-.BI rpile\ n\ {\ .\|.\|.\ }
-The integer value\~\c
-.I n
-(in hundredths of an em) increases the vertical spacing between rows,
-using
-.BR groff 's
-.B \ex
-escape.
-Negative values are possible but have no effect.
-If there is more than a single value given in a matrix, the biggest one
-is used.
-.
-.SS Customization
-The appearance of equations is controlled by a large number of parameters.
-These can be set using
-the
-.B set
-command.
-.
-.TP
-.BI set\ p\ n
-This sets parameter\~\c
-.I p
-to value\~\c
-.IR n ;
-.I n\~\c
-is an integer.
-For example,
-.
-.RS
-.IP
-.B
-set x_height 45
-.RE
-.
-.IP
-says that
-.B eqn
-should assume an x\~height of 0.45\~ems.
-.
-.RS
-.LP
-Possible parameters are as follows.
-Values are in units of hundredths of an em unless otherwise stated.
-These descriptions are intended to be expository rather than
-definitive.
-.
-.ie t \
-. TP \w'\fBdefault_rule_thickness'u+2n
-.el \
-. TP
-.B minimum_size
-.B eqn
-will not set anything at a smaller point-size than this.
-The value is in points.
-.
-.TP
-.B fat_offset
-The
-.B fat
-primitive emboldens an equation
-by overprinting two copies of the equation
-horizontally offset by this amount.
-.
-.TP
-.B over_hang
-A fraction bar will be longer by twice this amount than
-the maximum of the widths of the numerator and denominator;
-in other words, it will overhang the numerator and
-denominator by at least this amount.
-.
-.TP
-.B accent_width
-When
-.B bar
-or
-.B under
-is applied to a single character,
-the line will be this long.
-Normally,
-.B bar
-or
-.B under
-produces a line whose length is the width of the object to which it applies;
-in the case of a single character,
-this tends to produce a line that looks too long.
-.
-.TP
-.B delimiter_factor
-Extensible delimiters produced with the
-.B left
-and
-.B right
-primitives will have a combined height and depth of at least this many
-thousandths of twice the maximum amount by which the sub-equation that
-the delimiters enclose extends away from the axis.
-.
-.TP
-.B delimiter_shortfall
-Extensible delimiters produced with the
-.B left
-and
-.B right
-primitives will have a combined height and depth
-not less than the difference of
-twice the maximum amount by which the sub-equation that
-the delimiters enclose extends away from the axis
-and this amount.
-.
-.TP
-.B null_delimiter_space
-This much horizontal space is inserted
-on each side of a fraction.
-.
-.TP
-.B script_space
-The width of subscripts and superscripts is increased by this amount.
-.
-.TP
-.B thin_space
-This amount of space is automatically inserted after punctuation
-characters.
-.
-.TP
-.B medium_space
-This amount of space is automatically inserted on either side
-of binary operators.
-.
-.TP
-.B thick_space
-This amount of space is automatically inserted on either side of
-relations.
-.
-.TP
-.B x_height
-The height of lowercase letters without ascenders such as `x'.
-.
-.TP
-.B axis_height
-The height above the baseline of the center of characters
-such as `\(pl' and `\(mi'.
-It is important that this value is correct for the font
-you are using.
-.
-.TP
-.B default_rule_thickness
-This should set to the thickness of the
-.B \e(ru
-character, or the thickness of horizontal lines produced with the
-.B \eD
-escape sequence.
-.
-.TP
-.B num1
-The
-.B over
-command will shift up the numerator by at least this amount.
-.
-.TP
-.B num2
-The
-.B smallover
-command will shift up the numerator by at least this amount.
-.
-.TP
-.B denom1
-The
-.B over
-command will shift down the denominator by at least this amount.
-.
-.TP
-.B denom2
-The
-.B smallover
-command will shift down the denominator by at least this amount.
-.
-.TP
-.B sup1
-Normally superscripts will be shifted up by at least this amount.
-.
-.TP
-.B sup2
-Superscripts within superscripts or upper limits
-or numerators of
-.B smallover
-fractions
-will be shifted up by at least this amount.
-This is usually less than sup1.
-.
-.TP
-.B sup3
-Superscripts within denominators or square roots
-or subscripts or lower limits will be shifted up by at least
-this amount.
-This is usually less than sup2.
-.
-.TP
-.B sub1
-Subscripts will normally be shifted down by at least this amount.
-.
-.TP
-.B sub2
-When there is both a subscript and a superscript, the subscript
-will be shifted down by at least this amount.
-.
-.TP
-.B sup_drop
-The baseline of a superscript will be no more
-than this much amount below the top of the object on
-which the superscript is set.
-.
-.TP
-.B sub_drop
-The baseline of a subscript will be at least this much below
-the bottom of the object on which the subscript is set.
-.
-.TP
-.B big_op_spacing1
-The baseline of an upper limit will be at least this
-much above the top of the object on which the limit is set.
-.
-.TP
-.B big_op_spacing2
-The baseline of a lower limit will be at least this
-much below the bottom of the object on which the limit is set.
-.
-.TP
-.B big_op_spacing3
-The bottom of an upper limit will be at least this much above the
-top of the object on which the limit is set.
-.
-.TP
-.B big_op_spacing4
-The top of a lower limit will be at least this much below
-the bottom of the object on which the limit is set.
-.
-.TP
-.B big_op_spacing5
-This much vertical space will be added above and below limits.
-.
-.TP
-.B baseline_sep
-The baselines of the rows in a pile or matrix will normally be
-this far apart.
-In most cases this should be equal to the sum of
-.B num1
-and
-.BR denom1 .
-.
-.TP
-.B shift_down
-The midpoint between the top baseline and the bottom baseline
-in a matrix or pile will be shifted down by this much from the axis.
-In most cases this should be equal to
-.BR axis_height .
-.
-.TP
-.B column_sep
-This much space will be added between columns in a matrix.
-.
-.TP
-.B matrix_side_sep
-This much space will be added at each side of a matrix.
-.
-.TP
-.B draw_lines
-If this is non-zero, lines will be drawn using the
-.B \eD
-escape sequence, rather than with the
-.B \el
-escape sequence and the
-.B \e(ru
-character.
-.
-.TP
-.B body_height
-The amount by which the height of the equation exceeds this
-will be added as extra space before the line containing the equation
-(using
-.BR \ex ).
-The default value is 85.
-.
-.TP
-.B body_depth
-The amount by which the depth of the equation exceeds this
-will be added as extra space after the line containing the equation
-(using
-.BR \ex ).
-The default value is 35.
-.
-.TP
-.B nroff
-If this is non-zero,
-then
-.B ndefine
-will behave like
-.B define
-and
-.B tdefine
-will be ignored,
-otherwise
-.B tdefine
-will behave like
-.B define
-and
-.B ndefine
-will be ignored.
-The default value is\~0
-(This is typically changed to\~1 by the
-.B eqnrc
-file for the
-.BR ascii ,
-.BR latin1 ,
-.BR utf8 ,
-and
-.B cp1047
-devices.)
-.
-.LP
-A more precise description of the role of many of these
-parameters can be found in Appendix\~H of
-.IR "The \*(txbook" .
-.RE
-.
-.SS Macros
-Macros can take arguments.
-In a macro body,
-.BI $ n
-where
-.I n
-is between 1 and\~9,
-will be replaced by the
-.IR n-th
-argument if the macro is called with arguments;
-if there are fewer than
-.I n\~\c
-arguments, it will be replaced by nothing.
-A word containing a left parenthesis where the part of the word
-before the left parenthesis has been defined using the
-.B define
-command
-will be recognized as a macro call with arguments;
-characters following the left parenthesis
-up to a matching right parenthesis will be treated as comma-separated
-arguments;
-commas inside nested parentheses do not terminate an argument.
-.
-.TP
-.BI sdefine\ name\ X\ anything\ X
-This is like the
-.B define
-command, but
-.I name
-will not be recognized if called with arguments.
-.
-.TP
-.BI include\ \(ts file \(ts
-.TQ
-.BI copy\ \(ts file \(ts
-Include the contents of
-.I file
-.RB ( include
-and
-.B copy
-are synonyms).
-Lines of
-.I file
-beginning with
-.B .EQ
-or
-.B .EN
-will be ignored.
-.
-.TP
-.BI ifdef\ name\ X\ anything\ X
-If
-.I name
-has been defined by
-.B define
-(or has been automatically defined because
-.I name
-is the output device)
-process
-.IR anything ;
-otherwise ignore
-.IR anything .
-.I X
-can be any character not appearing in
-.IR anything .
-.
-.TP
-.BI undef\ name
-Remove definition of
-.IR name ,
-making it undefined.
-.
-.LP
-Besides the macros mentioned above, the following definitions are available:
-.BR Alpha ,
-.BR Beta ,
-\&.\|.\|.,
-.B Omega
-(this is the same as
-.BR ALPHA ,
-.BR BETA ,
-\&.\|.\|.,
-.BR OMEGA ),
-.B ldots
-(three dots on the base line),
-and
-.BR dollar .
-.
-.SS Fonts
-.B eqn
-normally uses at least two fonts to set an equation:
-an italic font for letters,
-and a roman font for everything else.
-The existing
-.B gfont
-command
-changes the font that is used as the italic font.
-By default this is\~\c
-.BR I .
-The font that is used as the roman font can be changed
-using the new
-.B grfont
-command.
-.
-.TP
-.BI grfont\ f
-Set the roman font to\~\c
-.IR f .
-.
-.LP
-The
-.B italic
-primitive uses the current italic font set by
-.BR gfont ;
-the
-.B roman
-primitive uses the current roman font set by
-.BR grfont .
-There is also a new
-.B gbfont
-command, which changes the font used by the
-.B bold
-primitive.
-If you only use the
-.BR roman ,
-.B italic
-and
-.B bold
-primitives to changes fonts within an equation,
-you can change all the fonts used by your equations
-just by using
-.BR gfont ,
-.B grfont
-and
-.B gbfont
-commands.
-.
-.LP
-You can control which characters are treated as letters
-(and therefore set in italics) by using the
-.B chartype
-command described above.
-A type of
-.B letter
-will cause a character to be set in italic type.
-A type of
-.B digit
-will cause a character to be set in roman type.
-.
-.
-.SH FILES
-.Tp \w'\fB@MACRODIR@/eqnrc'u+2n
-.B @MACRODIR@/eqnrc
-Initialization file.
-.
-.
-.SH BUGS
-Inline equations will be set at the point size that is current at the
-beginning of the input line.
-.
-.
-.SH "SEE ALSO"
-.BR groff (@MAN1EXT@),
-.BR @g@troff (@MAN1EXT@),
-.BR @g@pic (@MAN1EXT@),
-.BR groff_font (@MAN5EXT@),
-.I The\ \*(txbook
-.
-.\" Local Variables:
-.\" mode: nroff
-.\" End:
diff --git a/contrib/groff/src/preproc/eqn/eqn.y b/contrib/groff/src/preproc/eqn/eqn.y
deleted file mode 100644
index 85157d6fce4b..000000000000
--- a/contrib/groff/src/preproc/eqn/eqn.y
+++ /dev/null
@@ -1,330 +0,0 @@
-/* Copyright (C) 1989, 1990, 1991, 1992, 2004 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-%{
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "lib.h"
-#include "box.h"
-extern int non_empty_flag;
-int yylex();
-void yyerror(const char *);
-%}
-
-%union {
- char *str;
- box *b;
- pile_box *pb;
- matrix_box *mb;
- int n;
- column *col;
-}
-
-%token OVER
-%token SMALLOVER
-%token SQRT
-%token SUB
-%token SUP
-%token LPILE
-%token RPILE
-%token CPILE
-%token PILE
-%token LEFT
-%token RIGHT
-%token TO
-%token FROM
-%token SIZE
-%token FONT
-%token ROMAN
-%token BOLD
-%token ITALIC
-%token FAT
-%token ACCENT
-%token BAR
-%token UNDER
-%token ABOVE
-%token <str> TEXT
-%token <str> QUOTED_TEXT
-%token FWD
-%token BACK
-%token DOWN
-%token UP
-%token MATRIX
-%token COL
-%token LCOL
-%token RCOL
-%token CCOL
-%token MARK
-%token LINEUP
-%token TYPE
-%token VCENTER
-%token PRIME
-%token SPLIT
-%token NOSPLIT
-%token UACCENT
-%token SPECIAL
-
-/* these are handled in the lexer */
-%token SPACE
-%token GFONT
-%token GSIZE
-%token DEFINE
-%token NDEFINE
-%token TDEFINE
-%token SDEFINE
-%token UNDEF
-%token IFDEF
-%token INCLUDE
-%token DELIM
-%token CHARTYPE
-%token SET
-%token GRFONT
-%token GBFONT
-
-/* The original eqn manual says that `left' is right associative. It's lying.
-Consider `left ( ~ left ( ~ right ) right )'. */
-
-%right LEFT
-%left RIGHT
-%right LPILE RPILE CPILE PILE TEXT QUOTED_TEXT MATRIX MARK LINEUP '^' '~' '\t' '{' SPLIT NOSPLIT
-%right FROM TO
-%left SQRT OVER SMALLOVER
-%right SUB SUP
-%right ROMAN BOLD ITALIC FAT FONT SIZE FWD BACK DOWN UP TYPE VCENTER SPECIAL
-%right BAR UNDER PRIME
-%left ACCENT UACCENT
-
-%type <b> mark from_to sqrt_over script simple equation nonsup
-%type <n> number
-%type <str> text delim
-%type <pb> pile_element_list pile_arg
-%type <mb> column_list
-%type <col> column column_arg column_element_list
-
-%%
-top:
- /* empty */
- | equation
- { $1->top_level(); non_empty_flag = 1; }
- ;
-
-equation:
- mark
- { $$ = $1; }
- | equation mark
- {
- list_box *lb = $1->to_list_box();
- if (!lb)
- lb = new list_box($1);
- lb->append($2);
- $$ = lb;
- }
- ;
-
-mark:
- from_to
- { $$ = $1; }
- | MARK mark
- { $$ = make_mark_box($2); }
- | LINEUP mark
- { $$ = make_lineup_box($2); }
- ;
-
-from_to:
- sqrt_over %prec FROM
- { $$ = $1; }
- | sqrt_over TO from_to
- { $$ = make_limit_box($1, 0, $3); }
- | sqrt_over FROM sqrt_over
- { $$ = make_limit_box($1, $3, 0); }
- | sqrt_over FROM sqrt_over TO from_to
- { $$ = make_limit_box($1, $3, $5); }
- | sqrt_over FROM sqrt_over FROM from_to
- { $$ = make_limit_box($1, make_limit_box($3, $5, 0), 0); }
- ;
-
-sqrt_over:
- script
- { $$ = $1; }
- | SQRT sqrt_over
- { $$ = make_sqrt_box($2); }
- | sqrt_over OVER sqrt_over
- { $$ = make_over_box($1, $3); }
- | sqrt_over SMALLOVER sqrt_over
- { $$ = make_small_over_box($1, $3); }
- ;
-
-script:
- nonsup
- { $$ = $1; }
- | simple SUP script
- { $$ = make_script_box($1, 0, $3); }
- ;
-
-nonsup:
- simple %prec SUP
- { $$ = $1; }
- | simple SUB nonsup
- { $$ = make_script_box($1, $3, 0); }
- | simple SUB simple SUP script
- { $$ = make_script_box($1, $3, $5); }
- ;
-
-simple:
- TEXT
- { $$ = split_text($1); }
- | QUOTED_TEXT
- { $$ = new quoted_text_box($1); }
- | SPLIT QUOTED_TEXT
- { $$ = split_text($2); }
- | NOSPLIT TEXT
- { $$ = new quoted_text_box($2); }
- | '^'
- { $$ = new half_space_box; }
- | '~'
- { $$ = new space_box; }
- | '\t'
- { $$ = new tab_box; }
- | '{' equation '}'
- { $$ = $2; }
- | PILE pile_arg
- { $2->set_alignment(CENTER_ALIGN); $$ = $2; }
- | LPILE pile_arg
- { $2->set_alignment(LEFT_ALIGN); $$ = $2; }
- | RPILE pile_arg
- { $2->set_alignment(RIGHT_ALIGN); $$ = $2; }
- | CPILE pile_arg
- { $2->set_alignment(CENTER_ALIGN); $$ = $2; }
- | MATRIX '{' column_list '}'
- { $$ = $3; }
- | LEFT delim equation RIGHT delim
- { $$ = make_delim_box($2, $3, $5); }
- | LEFT delim equation
- { $$ = make_delim_box($2, $3, 0); }
- | simple BAR
- { $$ = make_overline_box($1); }
- | simple UNDER
- { $$ = make_underline_box($1); }
- | simple PRIME
- { $$ = make_prime_box($1); }
- | simple ACCENT simple
- { $$ = make_accent_box($1, $3); }
- | simple UACCENT simple
- { $$ = make_uaccent_box($1, $3); }
- | ROMAN simple
- { $$ = new font_box(strsave(get_grfont()), $2); }
- | BOLD simple
- { $$ = new font_box(strsave(get_gbfont()), $2); }
- | ITALIC simple
- { $$ = new font_box(strsave(get_gfont()), $2); }
- | FAT simple
- { $$ = new fat_box($2); }
- | FONT text simple
- { $$ = new font_box($2, $3); }
- | SIZE text simple
- { $$ = new size_box($2, $3); }
- | FWD number simple
- { $$ = new hmotion_box($2, $3); }
- | BACK number simple
- { $$ = new hmotion_box(-$2, $3); }
- | UP number simple
- { $$ = new vmotion_box($2, $3); }
- | DOWN number simple
- { $$ = new vmotion_box(-$2, $3); }
- | TYPE text simple
- { $3->set_spacing_type($2); $$ = $3; }
- | VCENTER simple
- { $$ = new vcenter_box($2); }
- | SPECIAL text simple
- { $$ = make_special_box($2, $3); }
- ;
-
-number:
- text
- {
- int n;
- if (sscanf($1, "%d", &n) == 1)
- $$ = n;
- a_delete $1;
- }
- ;
-
-pile_element_list:
- equation
- { $$ = new pile_box($1); }
- | pile_element_list ABOVE equation
- { $1->append($3); $$ = $1; }
- ;
-
-pile_arg:
- '{' pile_element_list '}'
- { $$ = $2; }
- | number '{' pile_element_list '}'
- { $3->set_space($1); $$ = $3; }
- ;
-
-column_list:
- column
- { $$ = new matrix_box($1); }
- | column_list column
- { $1->append($2); $$ = $1; }
- ;
-
-column_element_list:
- equation
- { $$ = new column($1); }
- | column_element_list ABOVE equation
- { $1->append($3); $$ = $1; }
- ;
-
-column_arg:
- '{' column_element_list '}'
- { $$ = $2; }
- | number '{' column_element_list '}'
- { $3->set_space($1); $$ = $3; }
- ;
-
-column:
- COL column_arg
- { $2->set_alignment(CENTER_ALIGN); $$ = $2; }
- | LCOL column_arg
- { $2->set_alignment(LEFT_ALIGN); $$ = $2; }
- | RCOL column_arg
- { $2->set_alignment(RIGHT_ALIGN); $$ = $2; }
- | CCOL column_arg
- { $2->set_alignment(CENTER_ALIGN); $$ = $2; }
- ;
-
-text: TEXT
- { $$ = $1; }
- | QUOTED_TEXT
- { $$ = $1; }
- ;
-
-delim:
- text
- { $$ = $1; }
- | '{'
- { $$ = strsave("{"); }
- | '}'
- { $$ = strsave("}"); }
- ;
-
-%%
diff --git a/contrib/groff/src/preproc/eqn/lex.cpp b/contrib/groff/src/preproc/eqn/lex.cpp
deleted file mode 100644
index 6aa494dbf0d8..000000000000
--- a/contrib/groff/src/preproc/eqn/lex.cpp
+++ /dev/null
@@ -1,1172 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2005
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "eqn_tab.h"
-#include "stringclass.h"
-#include "ptable.h"
-
-
-// declarations to avoid friend name injection problems
-int get_char();
-int peek_char();
-int get_location(char **, int *);
-
-struct definition {
- char is_macro;
- char is_simple;
- union {
- int tok;
- char *contents;
- };
- definition();
- ~definition();
-};
-
-definition::definition() : is_macro(1), is_simple(0)
-{
- contents = 0;
-}
-
-definition::~definition()
-{
- if (is_macro)
- a_delete contents;
-}
-
-declare_ptable(definition)
-implement_ptable(definition)
-
-PTABLE(definition) macro_table;
-
-static struct {
- const char *name;
- int token;
-} token_table[] = {
- { "over", OVER },
- { "smallover", SMALLOVER },
- { "sqrt", SQRT },
- { "sub", SUB },
- { "sup", SUP },
- { "lpile", LPILE },
- { "rpile", RPILE },
- { "cpile", CPILE },
- { "pile", PILE },
- { "left", LEFT },
- { "right", RIGHT },
- { "to", TO },
- { "from", FROM },
- { "size", SIZE },
- { "font", FONT },
- { "roman", ROMAN },
- { "bold", BOLD },
- { "italic", ITALIC },
- { "fat", FAT },
- { "bar", BAR },
- { "under", UNDER },
- { "accent", ACCENT },
- { "uaccent", UACCENT },
- { "above", ABOVE },
- { "fwd", FWD },
- { "back", BACK },
- { "down", DOWN },
- { "up", UP },
- { "matrix", MATRIX },
- { "col", COL },
- { "lcol", LCOL },
- { "rcol", RCOL },
- { "ccol", CCOL },
- { "mark", MARK },
- { "lineup", LINEUP },
- { "space", SPACE },
- { "gfont", GFONT },
- { "gsize", GSIZE },
- { "define", DEFINE },
- { "sdefine", SDEFINE },
- { "ndefine", NDEFINE },
- { "tdefine", TDEFINE },
- { "undef", UNDEF },
- { "ifdef", IFDEF },
- { "include", INCLUDE },
- { "copy", INCLUDE },
- { "delim", DELIM },
- { "chartype", CHARTYPE },
- { "type", TYPE },
- { "vcenter", VCENTER },
- { "set", SET },
- { "opprime", PRIME },
- { "grfont", GRFONT },
- { "gbfont", GBFONT },
- { "split", SPLIT },
- { "nosplit", NOSPLIT },
- { "special", SPECIAL },
-};
-
-static struct {
- const char *name;
- const char *def;
-} def_table[] = {
- { "ALPHA", "\\(*A" },
- { "BETA", "\\(*B" },
- { "CHI", "\\(*X" },
- { "DELTA", "\\(*D" },
- { "EPSILON", "\\(*E" },
- { "ETA", "\\(*Y" },
- { "GAMMA", "\\(*G" },
- { "IOTA", "\\(*I" },
- { "KAPPA", "\\(*K" },
- { "LAMBDA", "\\(*L" },
- { "MU", "\\(*M" },
- { "NU", "\\(*N" },
- { "OMEGA", "\\(*W" },
- { "OMICRON", "\\(*O" },
- { "PHI", "\\(*F" },
- { "PI", "\\(*P" },
- { "PSI", "\\(*Q" },
- { "RHO", "\\(*R" },
- { "SIGMA", "\\(*S" },
- { "TAU", "\\(*T" },
- { "THETA", "\\(*H" },
- { "UPSILON", "\\(*U" },
- { "XI", "\\(*C" },
- { "ZETA", "\\(*Z" },
- { "Alpha", "\\(*A" },
- { "Beta", "\\(*B" },
- { "Chi", "\\(*X" },
- { "Delta", "\\(*D" },
- { "Epsilon", "\\(*E" },
- { "Eta", "\\(*Y" },
- { "Gamma", "\\(*G" },
- { "Iota", "\\(*I" },
- { "Kappa", "\\(*K" },
- { "Lambda", "\\(*L" },
- { "Mu", "\\(*M" },
- { "Nu", "\\(*N" },
- { "Omega", "\\(*W" },
- { "Omicron", "\\(*O" },
- { "Phi", "\\(*F" },
- { "Pi", "\\(*P" },
- { "Psi", "\\(*Q" },
- { "Rho", "\\(*R" },
- { "Sigma", "\\(*S" },
- { "Tau", "\\(*T" },
- { "Theta", "\\(*H" },
- { "Upsilon", "\\(*U" },
- { "Xi", "\\(*C" },
- { "Zeta", "\\(*Z" },
- { "alpha", "\\(*a" },
- { "beta", "\\(*b" },
- { "chi", "\\(*x" },
- { "delta", "\\(*d" },
- { "epsilon", "\\(*e" },
- { "eta", "\\(*y" },
- { "gamma", "\\(*g" },
- { "iota", "\\(*i" },
- { "kappa", "\\(*k" },
- { "lambda", "\\(*l" },
- { "mu", "\\(*m" },
- { "nu", "\\(*n" },
- { "omega", "\\(*w" },
- { "omicron", "\\(*o" },
- { "phi", "\\(*f" },
- { "pi", "\\(*p" },
- { "psi", "\\(*q" },
- { "rho", "\\(*r" },
- { "sigma", "\\(*s" },
- { "tau", "\\(*t" },
- { "theta", "\\(*h" },
- { "upsilon", "\\(*u" },
- { "xi", "\\(*c" },
- { "zeta", "\\(*z" },
- { "max", "{type \"operator\" roman \"max\"}" },
- { "min", "{type \"operator\" roman \"min\"}" },
- { "lim", "{type \"operator\" roman \"lim\"}" },
- { "sin", "{type \"operator\" roman \"sin\"}" },
- { "cos", "{type \"operator\" roman \"cos\"}" },
- { "tan", "{type \"operator\" roman \"tan\"}" },
- { "sinh", "{type \"operator\" roman \"sinh\"}" },
- { "cosh", "{type \"operator\" roman \"cosh\"}" },
- { "tanh", "{type \"operator\" roman \"tanh\"}" },
- { "arc", "{type \"operator\" roman \"arc\"}" },
- { "log", "{type \"operator\" roman \"log\"}" },
- { "ln", "{type \"operator\" roman \"ln\"}" },
- { "exp", "{type \"operator\" roman \"exp\"}" },
- { "Re", "{type \"operator\" roman \"Re\"}" },
- { "Im", "{type \"operator\" roman \"Im\"}" },
- { "det", "{type \"operator\" roman \"det\"}" },
- { "and", "{roman \"and\"}" },
- { "if", "{roman \"if\"}" },
- { "for", "{roman \"for\"}" },
- { "sum", "{type \"operator\" vcenter size +5 \\(*S}" },
- { "prod", "{type \"operator\" vcenter size +5 \\(*P}" },
- { "int", "{type \"operator\" vcenter size +8 \\(is}" },
- { "union", "{type \"operator\" vcenter size +5 \\(cu}" },
- { "inter", "{type \"operator\" vcenter size +5 \\(ca}" },
- { "times", "type \"binary\" \\(mu" },
- { "ldots", "type \"inner\" { . . . }" },
- { "inf", "\\(if" },
- { "partial", "\\(pd" },
- { "nothing", "\"\"" },
- { "half", "{1 smallover 2}" },
- { "hat_def", "roman \"^\"" },
- { "hat", "accent { hat_def }" },
- { "dot_def", "back 15 \"\\v'-52M'.\\v'52M'\"" },
- { "dot", "accent { dot_def }" },
- { "dotdot_def", "back 25 \"\\v'-52M'..\\v'52M'\"" },
- { "dotdot", "accent { dotdot_def }" },
- { "tilde_def", "\"~\"" },
- { "tilde", "accent { tilde_def }" },
- { "utilde_def", "\"\\v'75M'~\\v'-75M'\"" },
- { "utilde", "uaccent { utilde_def }" },
- { "vec_def", "up 52 size -5 \\(->" },
- { "vec", "accent { vec_def }" },
- { "dyad_def", "up 52 size -5 {\\(<- back 60 \\(->}" },
- { "dyad", "accent { dyad_def }" },
- { "==", "type \"relation\" \\(==" },
- { "!=", "type \"relation\" \\(!=" },
- { "+-", "type \"binary\" \\(+-" },
- { "->", "type \"relation\" \\(->" },
- { "<-", "type \"relation\" \\(<-" },
- { "<<", "{ < back 20 < }" },
- { ">>", "{ > back 20 > }" },
- { "...", "type \"inner\" vcenter { . . . }" },
- { "prime", "'" },
- { "approx", "type \"relation\" \"\\(~=\"" },
- { "grad", "\\(gr" },
- { "del", "\\(gr" },
- { "cdot", "type \"binary\" vcenter ." },
- { "dollar", "$" },
-};
-
-void init_table(const char *device)
-{
- unsigned int i;
- for (i = 0; i < sizeof(token_table)/sizeof(token_table[0]); i++) {
- definition *def = new definition[1];
- def->is_macro = 0;
- def->tok = token_table[i].token;
- macro_table.define(token_table[i].name, def);
- }
- for (i = 0; i < sizeof(def_table)/sizeof(def_table[0]); i++) {
- definition *def = new definition[1];
- def->is_macro = 1;
- def->contents = strsave(def_table[i].def);
- def->is_simple = 1;
- macro_table.define(def_table[i].name, def);
- }
- definition *def = new definition[1];
- def->is_macro = 1;
- def->contents = strsave("1");
- macro_table.define(device, def);
-}
-
-class input {
- input *next;
-public:
- input(input *p);
- virtual ~input();
- virtual int get() = 0;
- virtual int peek() = 0;
- virtual int get_location(char **, int *);
-
- friend int get_char();
- friend int peek_char();
- friend int get_location(char **, int *);
- friend void init_lex(const char *str, const char *filename, int lineno);
-};
-
-class file_input : public input {
- FILE *fp;
- char *filename;
- int lineno;
- string line;
- const char *ptr;
- int read_line();
-public:
- file_input(FILE *, const char *, input *);
- ~file_input();
- int get();
- int peek();
- int get_location(char **, int *);
-};
-
-
-class macro_input : public input {
- char *s;
- char *p;
-public:
- macro_input(const char *, input *);
- ~macro_input();
- int get();
- int peek();
-};
-
-class top_input : public macro_input {
- char *filename;
- int lineno;
- public:
- top_input(const char *, const char *, int, input *);
- ~top_input();
- int get();
- int get_location(char **, int *);
-};
-
-class argument_macro_input: public input {
- char *s;
- char *p;
- char *ap;
- int argc;
- char *argv[9];
-public:
- argument_macro_input(const char *, int, char **, input *);
- ~argument_macro_input();
- int get();
- int peek();
-};
-
-input::input(input *x) : next(x)
-{
-}
-
-input::~input()
-{
-}
-
-int input::get_location(char **, int *)
-{
- return 0;
-}
-
-file_input::file_input(FILE *f, const char *fn, input *p)
-: input(p), lineno(0), ptr("")
-{
- fp = f;
- filename = strsave(fn);
-}
-
-file_input::~file_input()
-{
- a_delete filename;
- fclose(fp);
-}
-
-int file_input::read_line()
-{
- for (;;) {
- line.clear();
- lineno++;
- for (;;) {
- int c = getc(fp);
- if (c == EOF)
- break;
- else if (invalid_input_char(c))
- lex_error("invalid input character code %1", c);
- else {
- line += char(c);
- if (c == '\n')
- break;
- }
- }
- if (line.length() == 0)
- return 0;
- if (!(line.length() >= 3 && line[0] == '.' && line[1] == 'E'
- && (line[2] == 'Q' || line[2] == 'N')
- && (line.length() == 3 || line[3] == ' ' || line[3] == '\n'
- || compatible_flag))) {
- line += '\0';
- ptr = line.contents();
- return 1;
- }
- }
-}
-
-int file_input::get()
-{
- if (*ptr != '\0' || read_line())
- return *ptr++ & 0377;
- else
- return EOF;
-}
-
-int file_input::peek()
-{
- if (*ptr != '\0' || read_line())
- return *ptr;
- else
- return EOF;
-}
-
-int file_input::get_location(char **fnp, int *lnp)
-{
- *fnp = filename;
- *lnp = lineno;
- return 1;
-}
-
-macro_input::macro_input(const char *str, input *x) : input(x)
-{
- p = s = strsave(str);
-}
-
-macro_input::~macro_input()
-{
- a_delete s;
-}
-
-int macro_input::get()
-{
- if (p == 0 || *p == '\0')
- return EOF;
- else
- return *p++ & 0377;
-}
-
-int macro_input::peek()
-{
- if (p == 0 || *p == '\0')
- return EOF;
- else
- return *p & 0377;
-}
-
-top_input::top_input(const char *str, const char *fn, int ln, input *x)
-: macro_input(str, x), lineno(ln)
-{
- filename = strsave(fn);
-}
-
-top_input::~top_input()
-{
- a_delete filename;
-}
-
-int top_input::get()
-{
- int c = macro_input::get();
- if (c == '\n')
- lineno++;
- return c;
-}
-
-int top_input::get_location(char **fnp, int *lnp)
-{
- *fnp = filename;
- *lnp = lineno;
- return 1;
-}
-
-// Character representing $1. Must be invalid input character.
-#define ARG1 14
-
-argument_macro_input::argument_macro_input(const char *body, int ac,
- char **av, input *x)
-: input(x), ap(0), argc(ac)
-{
- int i;
- for (i = 0; i < argc; i++)
- argv[i] = av[i];
- p = s = strsave(body);
- int j = 0;
- for (i = 0; s[i] != '\0'; i++)
- if (s[i] == '$' && s[i+1] >= '0' && s[i+1] <= '9') {
- if (s[i+1] != '0')
- s[j++] = ARG1 + s[++i] - '1';
- }
- else
- s[j++] = s[i];
- s[j] = '\0';
-}
-
-
-argument_macro_input::~argument_macro_input()
-{
- for (int i = 0; i < argc; i++)
- a_delete argv[i];
- a_delete s;
-}
-
-int argument_macro_input::get()
-{
- if (ap) {
- if (*ap != '\0')
- return *ap++ & 0377;
- ap = 0;
- }
- if (p == 0)
- return EOF;
- while (*p >= ARG1 && *p <= ARG1 + 8) {
- int i = *p++ - ARG1;
- if (i < argc && argv[i] != 0 && argv[i][0] != '\0') {
- ap = argv[i];
- return *ap++ & 0377;
- }
- }
- if (*p == '\0')
- return EOF;
- return *p++ & 0377;
-}
-
-int argument_macro_input::peek()
-{
- if (ap) {
- if (*ap != '\0')
- return *ap & 0377;
- ap = 0;
- }
- if (p == 0)
- return EOF;
- while (*p >= ARG1 && *p <= ARG1 + 8) {
- int i = *p++ - ARG1;
- if (i < argc && argv[i] != 0 && argv[i][0] != '\0') {
- ap = argv[i];
- return *ap & 0377;
- }
- }
- if (*p == '\0')
- return EOF;
- return *p & 0377;
-}
-
-static input *current_input = 0;
-
-/* we insert a newline between input from different levels */
-
-int get_char()
-{
- if (current_input == 0)
- return EOF;
- else {
- int c = current_input->get();
- if (c != EOF)
- return c;
- else {
- input *tem = current_input;
- current_input = current_input->next;
- delete tem;
- return '\n';
- }
- }
-}
-
-int peek_char()
-{
- if (current_input == 0)
- return EOF;
- else {
- int c = current_input->peek();
- if (c != EOF)
- return c;
- else
- return '\n';
- }
-}
-
-int get_location(char **fnp, int *lnp)
-{
- for (input *p = current_input; p; p = p->next)
- if (p->get_location(fnp, lnp))
- return 1;
- return 0;
-}
-
-string token_buffer;
-const int NCONTEXT = 4;
-string context_ring[NCONTEXT];
-int context_index = 0;
-
-void flush_context()
-{
- for (int i = 0; i < NCONTEXT; i++)
- context_ring[i] = "";
- context_index = 0;
-}
-
-void show_context()
-{
- int i = context_index;
- fputs(" context is\n\t", stderr);
- for (;;) {
- int j = (i + 1) % NCONTEXT;
- if (j == context_index) {
- fputs(">>> ", stderr);
- put_string(context_ring[i], stderr);
- fputs(" <<<", stderr);
- break;
- }
- else if (context_ring[i].length() > 0) {
- put_string(context_ring[i], stderr);
- putc(' ', stderr);
- }
- i = j;
- }
- putc('\n', stderr);
-}
-
-void add_context(const string &s)
-{
- context_ring[context_index] = s;
- context_index = (context_index + 1) % NCONTEXT;
-}
-
-void add_context(char c)
-{
- context_ring[context_index] = c;
- context_index = (context_index + 1) % NCONTEXT;
-}
-
-void add_quoted_context(const string &s)
-{
- string &r = context_ring[context_index];
- r = '"';
- for (int i = 0; i < s.length(); i++)
- if (s[i] == '"')
- r += "\\\"";
- else
- r += s[i];
- r += '"';
- context_index = (context_index + 1) % NCONTEXT;
-}
-
-void init_lex(const char *str, const char *filename, int lineno)
-{
- while (current_input != 0) {
- input *tem = current_input;
- current_input = current_input->next;
- delete tem;
- }
- current_input = new top_input(str, filename, lineno, 0);
- flush_context();
-}
-
-
-void get_delimited_text()
-{
- char *filename;
- int lineno;
- int got_location = get_location(&filename, &lineno);
- int start = get_char();
- while (start == ' ' || start == '\t' || start == '\n')
- start = get_char();
- token_buffer.clear();
- if (start == EOF) {
- if (got_location)
- error_with_file_and_line(filename, lineno,
- "end of input while defining macro");
- else
- error("end of input while defining macro");
- return;
- }
- for (;;) {
- int c = get_char();
- if (c == EOF) {
- if (got_location)
- error_with_file_and_line(filename, lineno,
- "end of input while defining macro");
- else
- error("end of input while defining macro");
- add_context(start + token_buffer);
- return;
- }
- if (c == start)
- break;
- token_buffer += char(c);
- }
- add_context(start + token_buffer + start);
-}
-
-void interpolate_macro_with_args(const char *body)
-{
- char *argv[9];
- int argc = 0;
- int i;
- for (i = 0; i < 9; i++)
- argv[i] = 0;
- int level = 0;
- int c;
- do {
- token_buffer.clear();
- for (;;) {
- c = get_char();
- if (c == EOF) {
- lex_error("end of input while scanning macro arguments");
- break;
- }
- if (level == 0 && (c == ',' || c == ')')) {
- if (token_buffer.length() > 0) {
- token_buffer += '\0';
- argv[argc] = strsave(token_buffer.contents());
- }
- // for `foo()', argc = 0
- if (argc > 0 || c != ')' || i > 0)
- argc++;
- break;
- }
- token_buffer += char(c);
- if (c == '(')
- level++;
- else if (c == ')')
- level--;
- }
- } while (c != ')' && c != EOF);
- current_input = new argument_macro_input(body, argc, argv, current_input);
-}
-
-/* If lookup flag is non-zero the token will be looked up to see
-if it is macro. If it's 1, it will looked up to see if it's a token.
-*/
-
-int get_token(int lookup_flag = 0)
-{
- for (;;) {
- int c = get_char();
- while (c == ' ' || c == '\n')
- c = get_char();
- switch (c) {
- case EOF:
- {
- add_context("end of input");
- }
- return 0;
- case '"':
- {
- int quoted = 0;
- token_buffer.clear();
- for (;;) {
- c = get_char();
- if (c == EOF) {
- lex_error("missing \"");
- break;
- }
- else if (c == '\n') {
- lex_error("newline before end of quoted text");
- break;
- }
- else if (c == '"') {
- if (!quoted)
- break;
- token_buffer[token_buffer.length() - 1] = '"';
- quoted = 0;
- }
- else {
- token_buffer += c;
- quoted = quoted ? 0 : c == '\\';
- }
- }
- }
- add_quoted_context(token_buffer);
- return QUOTED_TEXT;
- case '{':
- case '}':
- case '^':
- case '~':
- case '\t':
- add_context(c);
- return c;
- default:
- {
- int break_flag = 0;
- int quoted = 0;
- token_buffer.clear();
- if (c == '\\')
- quoted = 1;
- else
- token_buffer += c;
- int done = 0;
- while (!done) {
- c = peek_char();
- if (!quoted && lookup_flag != 0 && c == '(') {
- token_buffer += '\0';
- definition *def = macro_table.lookup(token_buffer.contents());
- if (def && def->is_macro && !def->is_simple) {
- (void)get_char(); // skip initial '('
- interpolate_macro_with_args(def->contents);
- break_flag = 1;
- break;
- }
- token_buffer.set_length(token_buffer.length() - 1);
- }
- if (quoted) {
- quoted = 0;
- switch (c) {
- case EOF:
- lex_error("`\\' ignored at end of equation");
- done = 1;
- break;
- case '\n':
- lex_error("`\\' ignored because followed by newline");
- done = 1;
- break;
- case '\t':
- lex_error("`\\' ignored because followed by tab");
- done = 1;
- break;
- case '"':
- (void)get_char();
- token_buffer += '"';
- break;
- default:
- (void)get_char();
- token_buffer += '\\';
- token_buffer += c;
- break;
- }
- }
- else {
- switch (c) {
- case EOF:
- case '{':
- case '}':
- case '^':
- case '~':
- case '"':
- case ' ':
- case '\t':
- case '\n':
- done = 1;
- break;
- case '\\':
- (void)get_char();
- quoted = 1;
- break;
- default:
- (void)get_char();
- token_buffer += char(c);
- break;
- }
- }
- }
- if (break_flag || token_buffer.length() == 0)
- break;
- if (lookup_flag != 0) {
- token_buffer += '\0';
- definition *def = macro_table.lookup(token_buffer.contents());
- token_buffer.set_length(token_buffer.length() - 1);
- if (def) {
- if (def->is_macro) {
- current_input = new macro_input(def->contents, current_input);
- break;
- }
- else if (lookup_flag == 1) {
- add_context(token_buffer);
- return def->tok;
- }
- }
- }
- add_context(token_buffer);
- return TEXT;
- }
- }
- }
-}
-
-void do_include()
-{
- int t = get_token(2);
- if (t != TEXT && t != QUOTED_TEXT) {
- lex_error("bad filename for include");
- return;
- }
- token_buffer += '\0';
- const char *filename = token_buffer.contents();
- errno = 0;
- FILE *fp = fopen(filename, "r");
- if (fp == 0) {
- lex_error("can't open included file `%1'", filename);
- return;
- }
- current_input = new file_input(fp, filename, current_input);
-}
-
-void ignore_definition()
-{
- int t = get_token();
- if (t != TEXT) {
- lex_error("bad definition");
- return;
- }
- get_delimited_text();
-}
-
-void do_definition(int is_simple)
-{
- int t = get_token();
- if (t != TEXT) {
- lex_error("bad definition");
- return;
- }
- token_buffer += '\0';
- const char *name = token_buffer.contents();
- definition *def = macro_table.lookup(name);
- if (def == 0) {
- def = new definition[1];
- macro_table.define(name, def);
- }
- else if (def->is_macro) {
- a_delete def->contents;
- }
- get_delimited_text();
- token_buffer += '\0';
- def->is_macro = 1;
- def->contents = strsave(token_buffer.contents());
- def->is_simple = is_simple;
-}
-
-void do_undef()
-{
- int t = get_token();
- if (t != TEXT) {
- lex_error("bad undef command");
- return;
- }
- token_buffer += '\0';
- macro_table.define(token_buffer.contents(), 0);
-}
-
-void do_gsize()
-{
- int t = get_token(2);
- if (t != TEXT && t != QUOTED_TEXT) {
- lex_error("bad argument to gsize command");
- return;
- }
- token_buffer += '\0';
- if (!set_gsize(token_buffer.contents()))
- lex_error("invalid size `%1'", token_buffer.contents());
-}
-
-void do_gfont()
-{
- int t = get_token(2);
- if (t != TEXT && t != QUOTED_TEXT) {
- lex_error("bad argument to gfont command");
- return;
- }
- token_buffer += '\0';
- set_gfont(token_buffer.contents());
-}
-
-void do_grfont()
-{
- int t = get_token(2);
- if (t != TEXT && t != QUOTED_TEXT) {
- lex_error("bad argument to grfont command");
- return;
- }
- token_buffer += '\0';
- set_grfont(token_buffer.contents());
-}
-
-void do_gbfont()
-{
- int t = get_token(2);
- if (t != TEXT && t != QUOTED_TEXT) {
- lex_error("bad argument to gbfont command");
- return;
- }
- token_buffer += '\0';
- set_gbfont(token_buffer.contents());
-}
-
-void do_space()
-{
- int t = get_token(2);
- if (t != TEXT && t != QUOTED_TEXT) {
- lex_error("bad argument to space command");
- return;
- }
- token_buffer += '\0';
- char *ptr;
- long n = strtol(token_buffer.contents(), &ptr, 10);
- if (n == 0 && ptr == token_buffer.contents())
- lex_error("bad argument `%1' to space command", token_buffer.contents());
- else
- set_space(int(n));
-}
-
-void do_ifdef()
-{
- int t = get_token();
- if (t != TEXT) {
- lex_error("bad ifdef");
- return;
- }
- token_buffer += '\0';
- definition *def = macro_table.lookup(token_buffer.contents());
- int result = def && def->is_macro && !def->is_simple;
- get_delimited_text();
- if (result) {
- token_buffer += '\0';
- current_input = new macro_input(token_buffer.contents(), current_input);
- }
-}
-
-void do_delim()
-{
- int c = get_char();
- while (c == ' ' || c == '\n')
- c = get_char();
- int d;
- if (c == EOF || (d = get_char()) == EOF)
- lex_error("end of file while reading argument to `delim'");
- else {
- if (c == 'o' && d == 'f' && peek_char() == 'f') {
- (void)get_char();
- start_delim = end_delim = '\0';
- }
- else {
- start_delim = c;
- end_delim = d;
- }
- }
-}
-
-void do_chartype()
-{
- int t = get_token(2);
- if (t != TEXT && t != QUOTED_TEXT) {
- lex_error("bad chartype");
- return;
- }
- token_buffer += '\0';
- string type = token_buffer;
- t = get_token();
- if (t != TEXT && t != QUOTED_TEXT) {
- lex_error("bad chartype");
- return;
- }
- token_buffer += '\0';
- set_char_type(type.contents(), strsave(token_buffer.contents()));
-}
-
-void do_set()
-{
- int t = get_token(2);
- if (t != TEXT && t != QUOTED_TEXT) {
- lex_error("bad set");
- return;
- }
- token_buffer += '\0';
- string param = token_buffer;
- t = get_token();
- if (t != TEXT && t != QUOTED_TEXT) {
- lex_error("bad set");
- return;
- }
- token_buffer += '\0';
- int n;
- if (sscanf(&token_buffer[0], "%d", &n) != 1) {
- lex_error("bad number `%1'", token_buffer.contents());
- return;
- }
- set_param(param.contents(), n);
-}
-
-int yylex()
-{
- for (;;) {
- int tk = get_token(1);
- switch(tk) {
- case UNDEF:
- do_undef();
- break;
- case SDEFINE:
- do_definition(1);
- break;
- case DEFINE:
- do_definition(0);
- break;
- case TDEFINE:
- if (!nroff)
- do_definition(0);
- else
- ignore_definition();
- break;
- case NDEFINE:
- if (nroff)
- do_definition(0);
- else
- ignore_definition();
- break;
- case GSIZE:
- do_gsize();
- break;
- case GFONT:
- do_gfont();
- break;
- case GRFONT:
- do_grfont();
- break;
- case GBFONT:
- do_gbfont();
- break;
- case SPACE:
- do_space();
- break;
- case INCLUDE:
- do_include();
- break;
- case IFDEF:
- do_ifdef();
- break;
- case DELIM:
- do_delim();
- break;
- case CHARTYPE:
- do_chartype();
- break;
- case SET:
- do_set();
- break;
- case QUOTED_TEXT:
- case TEXT:
- token_buffer += '\0';
- yylval.str = strsave(token_buffer.contents());
- // fall through
- default:
- return tk;
- }
- }
-}
-
-void lex_error(const char *message,
- const errarg &arg1,
- const errarg &arg2,
- const errarg &arg3)
-{
- char *filename;
- int lineno;
- if (!get_location(&filename, &lineno))
- error(message, arg1, arg2, arg3);
- else
- error_with_file_and_line(filename, lineno, message, arg1, arg2, arg3);
-}
-
-void yyerror(const char *s)
-{
- char *filename;
- int lineno;
- if (!get_location(&filename, &lineno))
- error(s);
- else
- error_with_file_and_line(filename, lineno, s);
- show_context();
-}
-
diff --git a/contrib/groff/src/preproc/eqn/limit.cpp b/contrib/groff/src/preproc/eqn/limit.cpp
deleted file mode 100644
index b9f35f97efc5..000000000000
--- a/contrib/groff/src/preproc/eqn/limit.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "pbox.h"
-
-class limit_box : public box {
-private:
- box *p;
- box *from;
- box *to;
-public:
- limit_box(box *, box *, box *);
- ~limit_box();
- int compute_metrics(int);
- void output();
- void debug_print();
- void check_tabs(int);
-};
-
-box *make_limit_box(box *pp, box *qq, box *rr)
-{
- return new limit_box(pp, qq, rr);
-}
-
-limit_box::limit_box(box *pp, box *qq, box *rr)
-: p(pp), from(qq), to(rr)
-{
- spacing_type = p->spacing_type;
-}
-
-limit_box::~limit_box()
-{
- delete p;
- delete from;
- delete to;
-}
-
-int limit_box::compute_metrics(int style)
-{
- 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[.ps]\n", uid);
- int res = 0;
- int mark_uid = -1;
- if (from != 0) {
- res = from->compute_metrics(cramped_style(script_style(style)));
- if (res)
- mark_uid = from->uid;
- }
- if (to != 0) {
- int r = to->compute_metrics(script_style(style));
- if (res && r)
- error("multiple marks and lineups");
- else {
- mark_uid = to->uid;
- res = r;
- }
- }
- printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
- int r = p->compute_metrics(style);
- p->compute_subscript_kern();
- if (res && r)
- error("multiple marks and lineups");
- else {
- mark_uid = p->uid;
- res = r;
- }
- printf(".nr " LEFT_WIDTH_FORMAT " "
- "0\\n[" WIDTH_FORMAT "]",
- uid, p->uid);
- if (from != 0)
- printf(">?(\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
- p->uid, from->uid);
- if (to != 0)
- printf(">?(-\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
- p->uid, to->uid);
- printf("/2\n");
- printf(".nr " WIDTH_FORMAT " "
- "0\\n[" WIDTH_FORMAT "]",
- uid, p->uid);
- if (from != 0)
- printf(">?(-\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
- p->uid, from->uid);
- if (to != 0)
- printf(">?(\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
- p->uid, to->uid);
- printf("/2+\\n[" LEFT_WIDTH_FORMAT "]\n", uid);
- printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]", uid, p->uid);
- if (to != 0)
- printf(">?\\n[" WIDTH_FORMAT "]", to->uid);
- if (from != 0)
- printf(">?\\n[" WIDTH_FORMAT "]", from->uid);
- printf("\n");
- if (res)
- printf(".nr " MARK_REG " +(\\n[" LEFT_WIDTH_FORMAT "]"
- "-(\\n[" WIDTH_FORMAT "]/2))\n",
- uid, mark_uid);
- if (to != 0) {
- printf(".nr " SUP_RAISE_FORMAT " %dM+\\n[" DEPTH_FORMAT
- "]>?%dM+\\n[" HEIGHT_FORMAT "]\n",
- uid, big_op_spacing1, to->uid, big_op_spacing3, p->uid);
- printf(".nr " HEIGHT_FORMAT " \\n[" SUP_RAISE_FORMAT "]+\\n["
- HEIGHT_FORMAT "]+%dM\n",
- uid, uid, to->uid, big_op_spacing5);
- }
- else
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
- if (from != 0) {
- printf(".nr " SUB_LOWER_FORMAT " %dM+\\n[" HEIGHT_FORMAT
- "]>?%dM+\\n[" DEPTH_FORMAT "]\n",
- uid, big_op_spacing2, from->uid, big_op_spacing4, p->uid);
- printf(".nr " DEPTH_FORMAT " \\n[" SUB_LOWER_FORMAT "]+\\n["
- DEPTH_FORMAT "]+%dM\n",
- uid, uid, from->uid, big_op_spacing5);
- }
- else
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
- return res;
-}
-
-void limit_box::output()
-{
- printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", uid);
- if (to != 0) {
- printf("\\Z" DELIMITER_CHAR);
- printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
- printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u"
- "+(-\\n[" WIDTH_FORMAT "]u+\\n[" SUB_KERN_FORMAT "]u/2u)'",
- uid, to->uid, p->uid);
- to->output();
- printf(DELIMITER_CHAR);
- }
- if (from != 0) {
- printf("\\Z" DELIMITER_CHAR);
- printf("\\v'\\n[" SUB_LOWER_FORMAT "]u'", uid);
- printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u"
- "+(-\\n[" SUB_KERN_FORMAT "]u-\\n[" WIDTH_FORMAT "]u/2u)'",
- uid, p->uid, from->uid);
- from->output();
- printf(DELIMITER_CHAR);
- }
- printf("\\s[\\n[" SIZE_FORMAT "]u]", uid);
- printf("\\Z" DELIMITER_CHAR);
- printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u"
- "-(\\n[" WIDTH_FORMAT "]u/2u)'",
- uid, p->uid);
- p->output();
- printf(DELIMITER_CHAR);
- printf("\\h'\\n[" WIDTH_FORMAT "]u'", uid);
-}
-
-void limit_box::debug_print()
-{
- fprintf(stderr, "{ ");
- p->debug_print();
- fprintf(stderr, " }");
- if (from) {
- fprintf(stderr, " from { ");
- from->debug_print();
- fprintf(stderr, " }");
- }
- if (to) {
- fprintf(stderr, " to { ");
- to->debug_print();
- fprintf(stderr, " }");
- }
-}
-
-void limit_box::check_tabs(int level)
-{
- if (to)
- to->check_tabs(level + 1);
- if (from)
- from->check_tabs(level + 1);
- p->check_tabs(level + 1);
-}
diff --git a/contrib/groff/src/preproc/eqn/list.cpp b/contrib/groff/src/preproc/eqn/list.cpp
deleted file mode 100644
index 003562afa501..000000000000
--- a/contrib/groff/src/preproc/eqn/list.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "pbox.h"
-
-list_box *box::to_list_box()
-{
- return 0;
-}
-
-list_box *list_box::to_list_box()
-{
- return this;
-}
-
-void list_box::append(box *pp)
-{
- list_box *q = pp->to_list_box();
- if (q == 0)
- list.append(pp);
- else {
- for (int i = 0; i < q->list.len; i++) {
- list.append(q->list.p[i]);
- q->list.p[i] = 0;
- }
- q->list.len = 0;
- delete q;
- }
-}
-
-list_box::list_box(box *pp) : list(pp), sty(-1)
-{
- list_box *q = pp->to_list_box();
- if (q != 0) {
- // flatten it
- list.p[0] = q->list.p[0];
- for (int i = 1; i < q->list.len; i++) {
- list.append(q->list.p[i]);
- q->list.p[i] = 0;
- }
- q->list.len = 0;
- delete q;
- }
-}
-
-static int compute_spacing(int is_script, int left, int right)
-{
- if (left == SUPPRESS_TYPE || right == SUPPRESS_TYPE)
- return 0;
- if (left == PUNCTUATION_TYPE)
- return is_script ? 0 : thin_space;
- if (left == OPENING_TYPE || right == CLOSING_TYPE)
- return 0;
- if (right == BINARY_TYPE || left == BINARY_TYPE)
- return is_script ? 0 : medium_space;
- if (right == RELATION_TYPE) {
- if (left == RELATION_TYPE)
- return 0;
- else
- return is_script ? 0 : thick_space;
- }
- if (left == RELATION_TYPE)
- return is_script ? 0 : thick_space;
- if (right == OPERATOR_TYPE)
- return thin_space;
- if (left == INNER_TYPE || right == INNER_TYPE)
- return is_script ? 0 : thin_space;
- if (left == OPERATOR_TYPE && right == ORDINARY_TYPE)
- return thin_space;
- return 0;
-}
-
-int list_box::compute_metrics(int style)
-{
- sty = style;
- int i;
- for (i = 0; i < list.len; i++) {
- int t = list.p[i]->spacing_type;
- // 5
- if (t == BINARY_TYPE) {
- int prevt;
- if (i == 0
- || (prevt = list.p[i-1]->spacing_type) == BINARY_TYPE
- || prevt == OPERATOR_TYPE
- || prevt == RELATION_TYPE
- || prevt == OPENING_TYPE
- || prevt == PUNCTUATION_TYPE)
- list.p[i]->spacing_type = ORDINARY_TYPE;
- }
- // 7
- else if ((t == RELATION_TYPE || t == CLOSING_TYPE
- || t == PUNCTUATION_TYPE)
- && i > 0 && list.p[i-1]->spacing_type == BINARY_TYPE)
- list.p[i-1]->spacing_type = ORDINARY_TYPE;
- }
- for (i = 0; i < list.len; i++) {
- unsigned flags = 0;
- if (i - 1 >= 0 && list.p[i - 1]->right_is_italic())
- flags |= HINT_PREV_IS_ITALIC;
- if (i + 1 < list.len && list.p[i + 1]->left_is_italic())
- flags |= HINT_NEXT_IS_ITALIC;
- if (flags)
- list.p[i]->hint(flags);
- }
- is_script = (style <= SCRIPT_STYLE);
- int total_spacing = 0;
- for (i = 1; i < list.len; i++)
- total_spacing += compute_spacing(is_script, list.p[i-1]->spacing_type,
- list.p[i]->spacing_type);
- int res = 0;
- for (i = 0; i < list.len; i++)
- if (!list.p[i]->is_simple()) {
- int r = list.p[i]->compute_metrics(style);
- if (r) {
- if (res)
- error("multiple marks and lineups");
- else {
- compute_sublist_width(i);
- printf(".nr " MARK_REG " +\\n[" TEMP_REG"]\n");
- res = r;
- }
- }
- }
- printf(".nr " WIDTH_FORMAT " %dM", uid, total_spacing);
- for (i = 0; i < list.len; i++)
- if (!list.p[i]->is_simple())
- printf("+\\n[" WIDTH_FORMAT "]", list.p[i]->uid);
- printf("\n");
- printf(".nr " HEIGHT_FORMAT " 0", uid);
- for (i = 0; i < list.len; i++)
- if (!list.p[i]->is_simple())
- printf(">?\\n[" HEIGHT_FORMAT "]", list.p[i]->uid);
- printf("\n");
- printf(".nr " DEPTH_FORMAT " 0", uid);
- for (i = 0; i < list.len; i++)
- if (!list.p[i]->is_simple())
- printf(">?\\n[" DEPTH_FORMAT "]", list.p[i]->uid);
- printf("\n");
- int have_simple = 0;
- for (i = 0; i < list.len && !have_simple; i++)
- have_simple = list.p[i]->is_simple();
- if (have_simple) {
- printf(".nr " WIDTH_FORMAT " +\\w" DELIMITER_CHAR, uid);
- for (i = 0; i < list.len; i++)
- if (list.p[i]->is_simple())
- list.p[i]->output();
- printf(DELIMITER_CHAR "\n");
- printf(".nr " HEIGHT_FORMAT " \\n[rst]>?\\n[" HEIGHT_FORMAT "]\n",
- uid, uid);
- printf(".nr " DEPTH_FORMAT " 0-\\n[rsb]>?\\n[" DEPTH_FORMAT "]\n",
- uid, uid);
- }
- return res;
-}
-
-void list_box::compute_sublist_width(int n)
-{
- int total_spacing = 0;
- int i;
- for (i = 1; i < n + 1 && i < list.len; i++)
- total_spacing += compute_spacing(is_script, list.p[i-1]->spacing_type,
- list.p[i]->spacing_type);
- printf(".nr " TEMP_REG " %dM", total_spacing);
- for (i = 0; i < n; i++)
- if (!list.p[i]->is_simple())
- printf("+\\n[" WIDTH_FORMAT "]", list.p[i]->uid);
- int have_simple = 0;
- for (i = 0; i < n && !have_simple; i++)
- have_simple = list.p[i]->is_simple();
- if (have_simple) {
- printf("+\\w" DELIMITER_CHAR);
- for (i = 0; i < n; i++)
- if (list.p[i]->is_simple())
- list.p[i]->output();
- printf(DELIMITER_CHAR);
- }
- printf("\n");
-}
-
-void list_box::compute_subscript_kern()
-{
- // We can only call compute_subscript_kern if we have called
- // compute_metrics first.
- if (list.p[list.len-1]->is_simple())
- list.p[list.len-1]->compute_metrics(sty);
- list.p[list.len-1]->compute_subscript_kern();
- printf(".nr " SUB_KERN_FORMAT " \\n[" SUB_KERN_FORMAT "]\n",
- uid, list.p[list.len-1]->uid);
-}
-
-void list_box::output()
-{
- for (int i = 0; i < list.len; i++) {
- if (i > 0) {
- int n = compute_spacing(is_script,
- list.p[i-1]->spacing_type,
- list.p[i]->spacing_type);
- if (n > 0)
- printf("\\h'%dM'", n);
- }
- list.p[i]->output();
- }
-}
-
-void list_box::handle_char_type(int st, int ft)
-{
- for (int i = 0; i < list.len; i++)
- list.p[i]->handle_char_type(st, ft);
-}
-
-void list_box::debug_print()
-{
- list.list_debug_print(" ");
-}
-
-void list_box::check_tabs(int level)
-{
- list.list_check_tabs(level);
-}
diff --git a/contrib/groff/src/preproc/eqn/main.cpp b/contrib/groff/src/preproc/eqn/main.cpp
deleted file mode 100644
index 7971e2c2dc3c..000000000000
--- a/contrib/groff/src/preproc/eqn/main.cpp
+++ /dev/null
@@ -1,395 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "stringclass.h"
-#include "device.h"
-#include "searchpath.h"
-#include "macropath.h"
-#include "htmlhint.h"
-#include "pbox.h"
-#include "ctype.h"
-
-#define STARTUP_FILE "eqnrc"
-
-extern int yyparse();
-extern "C" const char *Version_string;
-
-static char *delim_search (char *, int);
-static int inline_equation (FILE *, string &, string &);
-
-char start_delim = '\0';
-char end_delim = '\0';
-int non_empty_flag;
-int inline_flag;
-int draw_flag = 0;
-int one_size_reduction_flag = 0;
-int compatible_flag = 0;
-int no_newline_in_delim_flag = 0;
-int html = 0;
-
-
-int read_line(FILE *fp, string *p)
-{
- p->clear();
- int c = -1;
- while ((c = getc(fp)) != EOF) {
- if (!invalid_input_char(c))
- *p += char(c);
- else
- error("invalid input character code `%1'", c);
- if (c == '\n')
- break;
- }
- current_lineno++;
- return p->length() > 0;
-}
-
-void do_file(FILE *fp, const char *filename)
-{
- string linebuf;
- string str;
- printf(".lf 1 %s\n", filename);
- current_filename = filename;
- current_lineno = 0;
- while (read_line(fp, &linebuf)) {
- if (linebuf.length() >= 4
- && linebuf[0] == '.' && linebuf[1] == 'l' && linebuf[2] == 'f'
- && (linebuf[3] == ' ' || linebuf[3] == '\n' || compatible_flag)) {
- put_string(linebuf, stdout);
- linebuf += '\0';
- if (interpret_lf_args(linebuf.contents() + 3))
- current_lineno--;
- }
- else if (linebuf.length() >= 4
- && linebuf[0] == '.'
- && linebuf[1] == 'E'
- && linebuf[2] == 'Q'
- && (linebuf[3] == ' ' || linebuf[3] == '\n'
- || compatible_flag)) {
- put_string(linebuf, stdout);
- int start_lineno = current_lineno + 1;
- str.clear();
- for (;;) {
- if (!read_line(fp, &linebuf))
- fatal("end of file before .EN");
- if (linebuf.length() >= 3 && linebuf[0] == '.' && linebuf[1] == 'E') {
- if (linebuf[2] == 'N'
- && (linebuf.length() == 3 || linebuf[3] == ' '
- || linebuf[3] == '\n' || compatible_flag))
- break;
- else if (linebuf[2] == 'Q' && linebuf.length() > 3
- && (linebuf[3] == ' ' || linebuf[3] == '\n'
- || compatible_flag))
- fatal("nested .EQ");
- }
- str += linebuf;
- }
- str += '\0';
- start_string();
- init_lex(str.contents(), current_filename, start_lineno);
- non_empty_flag = 0;
- inline_flag = 0;
- yyparse();
- restore_compatibility();
- if (non_empty_flag) {
- printf(".lf %d\n", current_lineno - 1);
- output_string();
- }
- printf(".lf %d\n", current_lineno);
- put_string(linebuf, stdout);
- }
- else if (start_delim != '\0' && linebuf.search(start_delim) >= 0
- && inline_equation(fp, linebuf, str))
- ;
- else
- put_string(linebuf, stdout);
- }
- current_filename = 0;
- current_lineno = 0;
-}
-
-// Handle an inline equation. Return 1 if it was an inline equation,
-// otherwise.
-static int inline_equation(FILE *fp, string &linebuf, string &str)
-{
- linebuf += '\0';
- char *ptr = &linebuf[0];
- char *start = delim_search(ptr, start_delim);
- if (!start) {
- // It wasn't a delimiter after all.
- linebuf.set_length(linebuf.length() - 1); // strip the '\0'
- return 0;
- }
- start_string();
- inline_flag = 1;
- for (;;) {
- if (no_newline_in_delim_flag && strchr(start + 1, end_delim) == 0) {
- error("missing `%1'", end_delim);
- char *nl = strchr(start + 1, '\n');
- if (nl != 0)
- *nl = '\0';
- do_text(ptr);
- break;
- }
- int start_lineno = current_lineno;
- *start = '\0';
- do_text(ptr);
- ptr = start + 1;
- str.clear();
- for (;;) {
- char *end = strchr(ptr, end_delim);
- if (end != 0) {
- *end = '\0';
- str += ptr;
- ptr = end + 1;
- break;
- }
- str += ptr;
- if (!read_line(fp, &linebuf))
- fatal("unterminated `%1' at line %2, looking for `%3'",
- start_delim, start_lineno, end_delim);
- linebuf += '\0';
- ptr = &linebuf[0];
- }
- str += '\0';
- if (html) {
- printf(".as1 %s ", LINE_STRING);
- html_begin_suppress();
- printf("\n");
- }
- init_lex(str.contents(), current_filename, start_lineno);
- yyparse();
- if (html) {
- printf(".as1 %s ", LINE_STRING);
- html_end_suppress();
- printf("\n");
- }
- start = delim_search(ptr, start_delim);
- if (start == 0) {
- char *nl = strchr(ptr, '\n');
- if (nl != 0)
- *nl = '\0';
- do_text(ptr);
- break;
- }
- }
- restore_compatibility();
- printf(".lf %d\n", current_lineno);
- output_string();
- printf(".lf %d\n", current_lineno + 1);
- return 1;
-}
-
-/* Search for delim. Skip over number register and string names etc. */
-
-static char *delim_search(char *ptr, int delim)
-{
- while (*ptr) {
- if (*ptr == delim)
- return ptr;
- if (*ptr++ == '\\') {
- switch (*ptr) {
- case 'n':
- case '*':
- case 'f':
- case 'g':
- case 'k':
- switch (*++ptr) {
- case '\0':
- case '\\':
- break;
- case '(':
- if (*++ptr != '\\' && *ptr != '\0'
- && *++ptr != '\\' && *ptr != '\0')
- ptr++;
- break;
- case '[':
- while (*++ptr != '\0')
- if (*ptr == ']') {
- ptr++;
- break;
- }
- break;
- default:
- ptr++;
- break;
- }
- break;
- case '\\':
- case '\0':
- break;
- default:
- ptr++;
- break;
- }
- }
- }
- return 0;
-}
-
-void usage(FILE *stream)
-{
- fprintf(stream,
- "usage: %s [ -rvDCNR ] -dxx -fn -sn -pn -mn -Mdir -Ts [ files ... ]\n",
- program_name);
-}
-
-int main(int argc, char **argv)
-{
- program_name = argv[0];
- static char stderr_buf[BUFSIZ];
- setbuf(stderr, stderr_buf);
- int opt;
- int load_startup_file = 1;
- static const struct option long_options[] = {
- { "help", no_argument, 0, CHAR_MAX + 1 },
- { "version", no_argument, 0, 'v' },
- { NULL, 0, 0, 0 }
- };
- while ((opt = getopt_long(argc, argv, "DCRvd:f:p:s:m:T:M:rN", long_options,
- NULL))
- != EOF)
- switch (opt) {
- case 'C':
- compatible_flag = 1;
- break;
- case 'R': // don't load eqnrc
- load_startup_file = 0;
- break;
- case 'M':
- config_macro_path.command_line_dir(optarg);
- break;
- case 'v':
- {
- printf("GNU eqn (groff) version %s\n", Version_string);
- exit(0);
- break;
- }
- case 'd':
- if (optarg[0] == '\0' || optarg[1] == '\0')
- error("-d requires two character argument");
- else if (invalid_input_char(optarg[0]))
- error("bad delimiter `%1'", optarg[0]);
- else if (invalid_input_char(optarg[1]))
- error("bad delimiter `%1'", optarg[1]);
- else {
- start_delim = optarg[0];
- end_delim = optarg[1];
- }
- break;
- case 'f':
- set_gfont(optarg);
- break;
- case 'T':
- device = optarg;
- if (strcmp(device, "ps:html") == 0) {
- device = "ps";
- html = 1;
- }
- break;
- case 's':
- if (!set_gsize(optarg))
- error("invalid size `%1'", optarg);
- break;
- case 'p':
- {
- int n;
- if (sscanf(optarg, "%d", &n) == 1)
- set_script_reduction(n);
- else
- error("bad size `%1'", optarg);
- }
- break;
- case 'm':
- {
- int n;
- if (sscanf(optarg, "%d", &n) == 1)
- set_minimum_size(n);
- else
- error("bad size `%1'", optarg);
- }
- break;
- case 'r':
- one_size_reduction_flag = 1;
- break;
- case 'D':
- warning("-D option is obsolete: use `set draw_lines 1' instead");
- draw_flag = 1;
- break;
- case 'N':
- no_newline_in_delim_flag = 1;
- break;
- case CHAR_MAX + 1: // --help
- usage(stdout);
- exit(0);
- break;
- case '?':
- usage(stderr);
- exit(1);
- break;
- default:
- assert(0);
- }
- init_table(device);
- init_char_table();
- printf(".if !'\\*(.T'%s' "
- ".if !'\\*(.T'html' " // the html device uses `-Tps' to render
- // equations as images
- ".tm warning: %s should have been given a `-T\\*(.T' option\n",
- device, program_name);
- printf(".if '\\*(.T'html' "
- ".if !'%s'ps' "
- ".tm warning: %s should have been given a `-Tps' option\n",
- device, program_name);
- printf(".if '\\*(.T'html' "
- ".if !'%s'ps' "
- ".tm warning: (it is advisable to invoke groff via: groff -Thtml -e)\n",
- device);
- if (load_startup_file) {
- char *path;
- FILE *fp = config_macro_path.open_file(STARTUP_FILE, &path);
- if (fp) {
- do_file(fp, path);
- fclose(fp);
- a_delete path;
- }
- }
- if (optind >= argc)
- do_file(stdin, "-");
- else
- for (int i = optind; i < argc; i++)
- if (strcmp(argv[i], "-") == 0)
- do_file(stdin, "-");
- else {
- errno = 0;
- FILE *fp = fopen(argv[i], "r");
- if (!fp)
- fatal("can't open `%1': %2", argv[i], strerror(errno));
- else {
- do_file(fp, argv[i]);
- fclose(fp);
- }
- }
- if (ferror(stdout) || fflush(stdout) < 0)
- fatal("output error");
- return 0;
-}
diff --git a/contrib/groff/src/preproc/eqn/mark.cpp b/contrib/groff/src/preproc/eqn/mark.cpp
deleted file mode 100644
index 9fa65790c6f1..000000000000
--- a/contrib/groff/src/preproc/eqn/mark.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "pbox.h"
-
-class mark_box : public pointer_box {
-public:
- mark_box(box *);
- int compute_metrics(int);
- void output();
- void debug_print();
-};
-
-// we push down marks so that they don't interfere with spacing
-
-box *make_mark_box(box *p)
-{
- list_box *b = p->to_list_box();
- if (b != 0) {
- b->list.p[0] = make_mark_box(b->list.p[0]);
- return b;
- }
- else
- return new mark_box(p);
-}
-
-mark_box::mark_box(box *pp) : pointer_box(pp)
-{
-}
-
-void mark_box::output()
-{
- p->output();
-}
-
-int mark_box::compute_metrics(int style)
-{
- int res = p->compute_metrics(style);
- if (res)
- error("multiple marks and lineups");
- 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);
- printf(".nr " MARK_REG " 0\n");
- return FOUND_MARK;
-}
-
-void mark_box::debug_print()
-{
- fprintf(stderr, "mark { ");
- p->debug_print();
- fprintf(stderr, " }");
-}
-
-
-class lineup_box : public pointer_box {
-public:
- lineup_box(box *);
- void output();
- int compute_metrics(int style);
- void debug_print();
-};
-
-// we push down lineups so that they don't interfere with spacing
-
-box *make_lineup_box(box *p)
-{
- list_box *b = p->to_list_box();
- if (b != 0) {
- b->list.p[0] = make_lineup_box(b->list.p[0]);
- return b;
- }
- else
- return new lineup_box(p);
-}
-
-lineup_box::lineup_box(box *pp) : pointer_box(pp)
-{
-}
-
-void lineup_box::output()
-{
- p->output();
-}
-
-int lineup_box::compute_metrics(int style)
-{
- int res = p->compute_metrics(style);
- if (res)
- error("multiple marks and lineups");
- 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);
- printf(".nr " MARK_REG " 0\n");
- return FOUND_LINEUP;
-}
-
-void lineup_box::debug_print()
-{
- fprintf(stderr, "lineup { ");
- p->debug_print();
- fprintf(stderr, " }");
-}
diff --git a/contrib/groff/src/preproc/eqn/neqn.man b/contrib/groff/src/preproc/eqn/neqn.man
deleted file mode 100644
index 27261c419ccd..000000000000
--- a/contrib/groff/src/preproc/eqn/neqn.man
+++ /dev/null
@@ -1,43 +0,0 @@
-.ig
-Copyright (C) 2001 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-versions, except that this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
-..
-.TH @G@NEQN @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
-.SH NAME
-@g@neqn \- format equations for ascii output
-.SH SYNOPSIS
-.B @g@neqn
-[@g@eqn options]
-.SH DESCRIPTION
-The
-.B @g@neqn
-program is actually just a shell script which invokes the
-.BR @g@eqn (@MAN1EXT@)
-command with the
-.B ascii
-output device.
-.LP
-Note that
-.B @g@eqn
-does not support low-resolution, typewriter-like devices (although it may
-work adequately for very simple input).
-.SH "SEE ALSO"
-.BR @g@eqn (@MAN1EXT@)
-.
-.\" Local Variables:
-.\" mode: nroff
-.\" End:
diff --git a/contrib/groff/src/preproc/eqn/neqn.sh b/contrib/groff/src/preproc/eqn/neqn.sh
deleted file mode 100644
index 5390bba6c9ad..000000000000
--- a/contrib/groff/src/preproc/eqn/neqn.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#! /bin/sh
-# Provision of this shell script should not be taken to imply that use of
-# GNU eqn with groff -Tascii|-Tlatin1|-Tkoi8-r|-Tutf8|-Tcp1047 is supported.
-# $FreeBSD$
-
-# Default device.
-case "${LC_ALL-${LC_CTYPE-${LANG}}}" in
- *.UTF-8)
- T=utf8 ;;
- iso_8859_1 | *.ISO*8859-1 | *.ISO*8859-15)
- T=latin1 ;;
- *.IBM-1047)
- T=cp1047 ;;
- *.KOI8-R)
- T=koi8-r ;;
- *)
- T=ascii ;;
-esac
-
-@GROFF_BIN_PATH_SETUP@
-PATH="$GROFF_RUNTIME$PATH"
-export PATH
-exec @g@eqn -T${T} ${1+"$@"}
-
-# eof
diff --git a/contrib/groff/src/preproc/eqn/other.cpp b/contrib/groff/src/preproc/eqn/other.cpp
deleted file mode 100644
index 9f360df67912..000000000000
--- a/contrib/groff/src/preproc/eqn/other.cpp
+++ /dev/null
@@ -1,601 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "pbox.h"
-
-class accent_box : public pointer_box {
-private:
- box *ab;
-public:
- accent_box(box *, box *);
- ~accent_box();
- int compute_metrics(int);
- void output();
- void debug_print();
- void check_tabs(int);
-};
-
-box *make_accent_box(box *p, box *q)
-{
- return new accent_box(p, q);
-}
-
-accent_box::accent_box(box *pp, box *qq) : pointer_box(pp), ab(qq)
-{
-}
-
-accent_box::~accent_box()
-{
- delete ab;
-}
-
-#if 0
-int accent_box::compute_metrics(int style)
-{
- int r = p->compute_metrics(style);
- p->compute_skew();
- ab->compute_metrics(style);
- printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
- printf(".nr " SUP_RAISE_FORMAT " \\n[" HEIGHT_FORMAT "]-%dM>?0\n",
- uid, p->uid, x_height);
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]+\\n["
- SUP_RAISE_FORMAT "]\n",
- uid, ab->uid, uid);
- return r;
-}
-
-void accent_box::output()
-{
- printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u/2u+\\n["
- SKEW_FORMAT "]u'",
- p->uid, ab->uid, p->uid);
- printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
- ab->output();
- printf("\\h'-\\n[" WIDTH_FORMAT "]u'", ab->uid);
- printf("\\v'\\n[" SUP_RAISE_FORMAT "]u'", uid);
- printf("\\h'-(\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u/2u+\\n["
- SKEW_FORMAT "]u)'",
- p->uid, ab->uid, p->uid);
- p->output();
-}
-#endif
-
-/* This version copes with the possibility of an accent's being wider
-than its accentee. LEFT_WIDTH_FORMAT gives the distance from the
-left edge of the resulting box to the middle of the accentee's box.*/
-
-int accent_box::compute_metrics(int style)
-{
- int r = p->compute_metrics(style);
- p->compute_skew();
- ab->compute_metrics(style);
- printf(".nr " LEFT_WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]/2"
- ">?(\\n[" WIDTH_FORMAT "]/2-\\n[" SKEW_FORMAT "])\n",
- uid, p->uid, ab->uid, p->uid);
- printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]/2"
- ">?(\\n[" WIDTH_FORMAT "]/2+\\n[" SKEW_FORMAT "])"
- "+\\n[" LEFT_WIDTH_FORMAT "]\n",
- uid, p->uid, ab->uid, p->uid, uid);
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
- printf(".nr " SUP_RAISE_FORMAT " \\n[" HEIGHT_FORMAT "]-%dM>?0\n",
- uid, p->uid, x_height);
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]+\\n["
- SUP_RAISE_FORMAT "]\n",
- uid, ab->uid, uid);
- if (r)
- printf(".nr " MARK_REG " +\\n[" LEFT_WIDTH_FORMAT "]"
- "-(\\n[" WIDTH_FORMAT "]/2)'\n",
- uid, p->uid);
- return r;
-}
-
-void accent_box::output()
-{
- printf("\\Z" DELIMITER_CHAR);
- printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u+\\n[" SKEW_FORMAT "]u"
- "-(\\n[" WIDTH_FORMAT "]u/2u)'",
- uid, p->uid, ab->uid);
- printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
- ab->output();
- printf(DELIMITER_CHAR);
- printf("\\Z" DELIMITER_CHAR);
- printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u-(\\n[" WIDTH_FORMAT "]u/2u)'",
- uid, p->uid);
- p->output();
- printf(DELIMITER_CHAR);
- printf("\\h'\\n[" WIDTH_FORMAT "]u'", uid);
-}
-
-void accent_box::check_tabs(int level)
-{
- ab->check_tabs(level + 1);
- p->check_tabs(level + 1);
-}
-
-void accent_box::debug_print()
-{
- fprintf(stderr, "{ ");
- p->debug_print();
- fprintf(stderr, " } accent { ");
- ab->debug_print();
- fprintf(stderr, " }");
-}
-
-class overline_char_box : public simple_box {
-public:
- overline_char_box();
- void output();
- void debug_print();
-};
-
-overline_char_box::overline_char_box()
-{
-}
-
-void overline_char_box::output()
-{
- printf("\\v'-%dM/2u-%dM'", 7*default_rule_thickness, x_height);
- printf((draw_flag ? "\\D'l%dM 0'" : "\\l'%dM\\&\\(ru'"),
- accent_width);
- printf("\\v'%dM/2u+%dM'", 7*default_rule_thickness, x_height);
-}
-
-void overline_char_box::debug_print()
-{
- fprintf(stderr, "<overline char>");
-}
-
-class overline_box : public pointer_box {
-public:
- overline_box(box *);
- int compute_metrics(int);
- void output();
- void debug_print();
-};
-
-box *make_overline_box(box *p)
-{
- if (p->is_char())
- return new accent_box(p, new overline_char_box);
- else
- return new overline_box(p);
-}
-
-overline_box::overline_box(box *pp) : pointer_box(pp)
-{
-}
-
-int overline_box::compute_metrics(int style)
-{
- int r = p->compute_metrics(cramped_style(style));
- // 9
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]+%dM\n",
- uid, p->uid, default_rule_thickness*5);
- printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
- return r;
-}
-
-void overline_box::output()
-{
- // 9
- printf("\\Z" DELIMITER_CHAR);
- printf("\\v'-\\n[" HEIGHT_FORMAT "]u-(%dM/2u)'",
- p->uid, 7*default_rule_thickness);
- if (draw_flag)
- printf("\\D'l\\n[" WIDTH_FORMAT "]u 0'", p->uid);
- else
- printf("\\l'\\n[" WIDTH_FORMAT "]u\\&\\(ru'", p->uid);
- printf(DELIMITER_CHAR);
- p->output();
-}
-
-void overline_box::debug_print()
-{
- fprintf(stderr, "{ ");
- p->debug_print();
- fprintf(stderr, " } bar");
-}
-
-class uaccent_box : public pointer_box {
- box *ab;
-public:
- uaccent_box(box *, box *);
- ~uaccent_box();
- int compute_metrics(int);
- void output();
- void compute_subscript_kern();
- void check_tabs(int);
- void debug_print();
-};
-
-box *make_uaccent_box(box *p, box *q)
-{
- return new uaccent_box(p, q);
-}
-
-uaccent_box::uaccent_box(box *pp, box *qq)
-: pointer_box(pp), ab(qq)
-{
-}
-
-uaccent_box::~uaccent_box()
-{
- delete ab;
-}
-
-int uaccent_box::compute_metrics(int style)
-{
- int r = p->compute_metrics(style);
- ab->compute_metrics(style);
- printf(".nr " LEFT_WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]/2"
- ">?(\\n[" WIDTH_FORMAT "]/2)\n",
- uid, p->uid, ab->uid);
- printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]/2"
- ">?(\\n[" WIDTH_FORMAT "]/2)"
- "+\\n[" LEFT_WIDTH_FORMAT "]\n",
- uid, p->uid, ab->uid, uid);
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]"
- "+\\n[" DEPTH_FORMAT "]\n",
- uid, p->uid, ab->uid);
- if (r)
- printf(".nr " MARK_REG " +\\n[" LEFT_WIDTH_FORMAT "]"
- "-(\\n[" WIDTH_FORMAT "]/2)'\n",
- uid, p->uid);
- return r;
-}
-
-void uaccent_box::output()
-{
- printf("\\Z" DELIMITER_CHAR);
- printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u-(\\n[" WIDTH_FORMAT "]u/2u)'",
- uid, ab->uid);
- printf("\\v'\\n[" DEPTH_FORMAT "]u'", p->uid);
- ab->output();
- printf(DELIMITER_CHAR);
- printf("\\Z" DELIMITER_CHAR);
- printf("\\h'\\n[" LEFT_WIDTH_FORMAT "]u-(\\n[" WIDTH_FORMAT "]u/2u)'",
- uid, p->uid);
- p->output();
- printf(DELIMITER_CHAR);
- printf("\\h'\\n[" WIDTH_FORMAT "]u'", uid);
-}
-
-void uaccent_box::check_tabs(int level)
-{
- ab->check_tabs(level + 1);
- p->check_tabs(level + 1);
-}
-
-void uaccent_box::compute_subscript_kern()
-{
- box::compute_subscript_kern(); // want 0 subscript kern
-}
-
-void uaccent_box::debug_print()
-{
- fprintf(stderr, "{ ");
- p->debug_print();
- fprintf(stderr, " } uaccent { ");
- ab->debug_print();
- fprintf(stderr, " }");
-}
-
-class underline_char_box : public simple_box {
-public:
- underline_char_box();
- void output();
- void debug_print();
-};
-
-underline_char_box::underline_char_box()
-{
-}
-
-void underline_char_box::output()
-{
- printf("\\v'%dM/2u'", 7*default_rule_thickness);
- printf((draw_flag ? "\\D'l%dM 0'" : "\\l'%dM\\&\\(ru'"),
- accent_width);
- printf("\\v'-%dM/2u'", 7*default_rule_thickness);
-}
-
-void underline_char_box::debug_print()
-{
- fprintf(stderr, "<underline char>");
-}
-
-
-class underline_box : public pointer_box {
-public:
- underline_box(box *);
- int compute_metrics(int);
- void output();
- void compute_subscript_kern();
- void debug_print();
-};
-
-box *make_underline_box(box *p)
-{
- if (p->is_char())
- return new uaccent_box(p, new underline_char_box);
- else
- return new underline_box(p);
-}
-
-underline_box::underline_box(box *pp) : pointer_box(pp)
-{
-}
-
-int underline_box::compute_metrics(int style)
-{
- int r = p->compute_metrics(style);
- // 10
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]+%dM\n",
- uid, p->uid, default_rule_thickness*5);
- printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
- return r;
-}
-
-void underline_box::output()
-{
- // 10
- printf("\\Z" DELIMITER_CHAR);
- printf("\\v'\\n[" DEPTH_FORMAT "]u+(%dM/2u)'",
- p->uid, 7*default_rule_thickness);
- if (draw_flag)
- printf("\\D'l\\n[" WIDTH_FORMAT "]u 0'", p->uid);
- else
- printf("\\l'\\n[" WIDTH_FORMAT "]u\\&\\(ru'", p->uid);
- printf(DELIMITER_CHAR);
- p->output();
-}
-
-// we want an underline box to have 0 subscript kern
-
-void underline_box::compute_subscript_kern()
-{
- box::compute_subscript_kern();
-}
-
-void underline_box::debug_print()
-{
- fprintf(stderr, "{ ");
- p->debug_print();
- fprintf(stderr, " } under");
-}
-
-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[.ps]\n", uid);
- printf(".ps %s\n", size);
- printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
- int r = p->compute_metrics(style);
- 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);
- return r;
-}
-
-void size_box::output()
-{
- printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", uid);
- p->output();
- printf("\\s[\\n[" SIZE_FORMAT "]u]", uid);
-}
-
-size_box::~size_box()
-{
- a_delete size;
-}
-
-void size_box::debug_print()
-{
- fprintf(stderr, "size %s { ", size);
- p->debug_print();
- fprintf(stderr, " }");
-}
-
-
-font_box::font_box(char *s, box *pp) : pointer_box(pp), f(s)
-{
-}
-
-font_box::~font_box()
-{
- a_delete f;
-}
-
-int font_box::compute_metrics(int style)
-{
- const char *old_roman_font = current_roman_font;
- current_roman_font = f;
- printf(".nr " FONT_FORMAT " \\n[.f]\n", uid);
- printf(".ft %s\n", f);
- int r = p->compute_metrics(style);
- current_roman_font = old_roman_font;
- printf(".ft \\n[" FONT_FORMAT "]\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);
- return r;
-}
-
-void font_box::output()
-{
- printf("\\f[%s]", f);
- const char *old_roman_font = current_roman_font;
- current_roman_font = f;
- p->output();
- current_roman_font = old_roman_font;
- printf("\\f[\\n[" FONT_FORMAT "]]", uid);
-}
-
-void font_box::debug_print()
-{
- fprintf(stderr, "font %s { ", f);
- p->debug_print();
- fprintf(stderr, " }");
-}
-
-fat_box::fat_box(box *pp) : pointer_box(pp)
-{
-}
-
-int fat_box::compute_metrics(int style)
-{
- int r = p->compute_metrics(style);
- printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]+%dM\n",
- uid, p->uid, fat_offset);
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
- return r;
-}
-
-void fat_box::output()
-{
- p->output();
- printf("\\h'-\\n[" WIDTH_FORMAT "]u'", p->uid);
- printf("\\h'%dM'", fat_offset);
- p->output();
-}
-
-
-void fat_box::debug_print()
-{
- fprintf(stderr, "fat { ");
- p->debug_print();
- fprintf(stderr, " }");
-}
-
-
-vmotion_box::vmotion_box(int i, box *pp) : pointer_box(pp), n(i)
-{
-}
-
-int vmotion_box::compute_metrics(int style)
-{
- int r = p->compute_metrics(style);
- printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
- if (n > 0) {
- printf(".nr " HEIGHT_FORMAT " %dM+\\n[" HEIGHT_FORMAT "]\n",
- uid, n, p->uid);
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
- }
- else {
- printf(".nr " DEPTH_FORMAT " %dM+\\n[" DEPTH_FORMAT "]>?0\n",
- uid, -n, p->uid);
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n",
- uid, p->uid);
- }
- return r;
-}
-
-void vmotion_box::output()
-{
- printf("\\v'%dM'", -n);
- p->output();
- printf("\\v'%dM'", n);
-}
-
-void vmotion_box::debug_print()
-{
- if (n >= 0)
- fprintf(stderr, "up %d { ", n);
- else
- fprintf(stderr, "down %d { ", -n);
- p->debug_print();
- fprintf(stderr, " }");
-}
-
-hmotion_box::hmotion_box(int i, box *pp) : pointer_box(pp), n(i)
-{
-}
-
-int hmotion_box::compute_metrics(int style)
-{
- int r = p->compute_metrics(style);
- printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]+%dM\n",
- uid, p->uid, n);
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
- if (r)
- printf(".nr " MARK_REG " +%dM\n", n);
- return r;
-}
-
-void hmotion_box::output()
-{
- printf("\\h'%dM'", n);
- p->output();
-}
-
-void hmotion_box::debug_print()
-{
- if (n >= 0)
- fprintf(stderr, "fwd %d { ", n);
- else
- fprintf(stderr, "back %d { ", -n);
- p->debug_print();
- fprintf(stderr, " }");
-}
-
-vcenter_box::vcenter_box(box *pp) : pointer_box(pp)
-{
-}
-
-int vcenter_box::compute_metrics(int style)
-{
- int r = p->compute_metrics(style);
- printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
- printf(".nr " SUP_RAISE_FORMAT " \\n[" DEPTH_FORMAT "]-\\n["
- HEIGHT_FORMAT "]/2+%dM\n",
- uid, p->uid, p->uid, axis_height);
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]+\\n["
- SUP_RAISE_FORMAT "]>?0\n", uid, p->uid, uid);
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]-\\n["
- SUP_RAISE_FORMAT "]>?0\n", uid, p->uid, uid);
-
- return r;
-}
-
-void vcenter_box::output()
-{
- printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
- p->output();
- printf("\\v'\\n[" SUP_RAISE_FORMAT "]u'", uid);
-}
-
-void vcenter_box::debug_print()
-{
- fprintf(stderr, "vcenter { ");
- p->debug_print();
- fprintf(stderr, " }");
-}
-
diff --git a/contrib/groff/src/preproc/eqn/over.cpp b/contrib/groff/src/preproc/eqn/over.cpp
deleted file mode 100644
index 302c5b5d50c0..000000000000
--- a/contrib/groff/src/preproc/eqn/over.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-// -*- C++ -*-
-/* 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.
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "pbox.h"
-
-class over_box : public box {
-private:
- int reduce_size;
- box *num;
- box *den;
-public:
- over_box(int small, box *, box *);
- ~over_box();
- void debug_print();
- int compute_metrics(int);
- void output();
- void check_tabs(int);
-};
-
-box *make_over_box(box *pp, box *qq)
-{
- return new over_box(0, pp, qq);
-}
-
-box *make_small_over_box(box *pp, box *qq)
-{
- return new over_box(1, pp, qq);
-}
-
-over_box::over_box(int is_small, box *pp, box *qq)
-: reduce_size(is_small), num(pp), den(qq)
-{
- spacing_type = INNER_TYPE;
-}
-
-over_box::~over_box()
-{
- delete num;
- delete den;
-}
-
-int over_box::compute_metrics(int style)
-{
- if (reduce_size) {
- style = script_style(style);
- printf(".nr " SIZE_FORMAT " \\n[.ps]\n", uid);
- set_script_size();
- printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
- }
- int mark_uid = 0;
- int res = num->compute_metrics(style);
- if (res)
- mark_uid = num->uid;
- int r = den->compute_metrics(cramped_style(style));
- if (r && res)
- error("multiple marks and lineups");
- else {
- mark_uid = den->uid;
- res = r;
- }
- if (reduce_size)
- 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
- if (!draw_flag)
- fputs(">?\\w" DELIMITER_CHAR "\\(ru" DELIMITER_CHAR, stdout);
- printf(")+%dM\n", null_delimiter_space*2 + over_hang*2);
- // 15b
- printf(".nr " SUP_RAISE_FORMAT " %dM\n",
- uid, (reduce_size ? num2 : num1));
- printf(".nr " SUB_LOWER_FORMAT " %dM\n",
- uid, (reduce_size ? denom2 : denom1));
-
- // 15d
- printf(".nr " SUP_RAISE_FORMAT " +(\\n[" DEPTH_FORMAT
- "]-\\n[" SUP_RAISE_FORMAT "]+%dM+(%dM/2)+%dM)>?0\n",
- uid, num->uid, uid, axis_height, default_rule_thickness,
- default_rule_thickness*(reduce_size ? 1 : 3));
- printf(".nr " SUB_LOWER_FORMAT " +(\\n[" HEIGHT_FORMAT
- "]-\\n[" SUB_LOWER_FORMAT "]-%dM+(%dM/2)+%dM)>?0\n",
- uid, den->uid, uid, axis_height, default_rule_thickness,
- default_rule_thickness*(reduce_size ? 1 : 3));
-
-
- printf(".nr " HEIGHT_FORMAT " \\n[" SUP_RAISE_FORMAT "]+\\n["
- HEIGHT_FORMAT "]\n",
- uid, uid, num->uid);
- printf(".nr " DEPTH_FORMAT " \\n[" SUB_LOWER_FORMAT "]+\\n["
- DEPTH_FORMAT "]\n",
- uid, uid, den->uid);
- if (res)
- printf(".nr " MARK_REG " +(\\n[" WIDTH_FORMAT "]-\\n["
- WIDTH_FORMAT "]/2)\n", uid, mark_uid);
- return res;
-}
-
-#define USE_Z
-
-void over_box::output()
-{
- if (reduce_size)
- printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", uid);
-#ifdef USE_Z
- printf("\\Z" DELIMITER_CHAR);
-#endif
- // move up to the numerator baseline
- printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
- // move across so that it's centered
- printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u/2u'",
- uid, num->uid);
-
- // print the numerator
- num->output();
-
-#ifdef USE_Z
- printf(DELIMITER_CHAR);
-#else
- // back again
- printf("\\h'-\\n[" WIDTH_FORMAT "]u'", num->uid);
- printf("\\h'-(\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u/2u)'",
- uid, num->uid);
- // down again
- printf("\\v'\\n[" SUP_RAISE_FORMAT "]u'", uid);
-#endif
-#ifdef USE_Z
- printf("\\Z" DELIMITER_CHAR);
-#endif
- // move down to the denominator baseline
- printf("\\v'\\n[" SUB_LOWER_FORMAT "]u'", uid);
-
- // move across so that it's centered
- printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u/2u'",
- uid, den->uid);
-
- // print the the denominator
- den->output();
-
-#ifdef USE_Z
- printf(DELIMITER_CHAR);
-#else
- // back again
- printf("\\h'-\\n[" WIDTH_FORMAT "]u'", den->uid);
- printf("\\h'-(\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u/2u)'",
- uid, den->uid);
- // up again
- printf("\\v'-\\n[" SUB_LOWER_FORMAT "]u'", uid);
-#endif
- if (reduce_size)
- printf("\\s[\\n[" SIZE_FORMAT "]u]", uid);
- // draw the line
- printf("\\h'%dM'", null_delimiter_space);
- printf("\\v'-%dM'", axis_height);
- fputs(draw_flag ? "\\D'l" : "\\l'", stdout);
- printf("\\n[" WIDTH_FORMAT "]u-%dM",
- uid, 2*null_delimiter_space);
- fputs(draw_flag ? " 0'" : "\\&\\(ru'", stdout);
- printf("\\v'%dM'", axis_height);
- printf("\\h'%dM'", null_delimiter_space);
-}
-
-void over_box::debug_print()
-{
- fprintf(stderr, "{ ");
- num->debug_print();
- if (reduce_size)
- fprintf(stderr, " } smallover { ");
- else
- fprintf(stderr, " } over { ");
- den->debug_print();
- fprintf(stderr, " }");
-}
-
-void over_box::check_tabs(int level)
-{
- num->check_tabs(level + 1);
- den->check_tabs(level + 1);
-}
diff --git a/contrib/groff/src/preproc/eqn/pbox.h b/contrib/groff/src/preproc/eqn/pbox.h
deleted file mode 100644
index f100f2165662..000000000000
--- a/contrib/groff/src/preproc/eqn/pbox.h
+++ /dev/null
@@ -1,141 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-extern int fat_offset;
-
-extern int over_hang;
-extern int accent_width;
-
-extern int delimiter_factor;
-extern int delimiter_shortfall;
-
-extern int null_delimiter_space;
-extern int script_space;
-extern int thin_space;
-extern int medium_space;
-extern int thick_space;
-
-extern int num1;
-extern int num2;
-// we don't use num3, because we don't have \atop
-extern int denom1;
-extern int denom2;
-extern int axis_height;
-extern int sup1;
-extern int sup2;
-extern int sup3;
-extern int default_rule_thickness;
-extern int sub1;
-extern int sub2;
-extern int sup_drop;
-extern int sub_drop;
-extern int x_height;
-extern int big_op_spacing1;
-extern int big_op_spacing2;
-extern int big_op_spacing3;
-extern int big_op_spacing4;
-extern int big_op_spacing5;
-
-extern int baseline_sep;
-extern int shift_down;
-extern int column_sep;
-extern int matrix_side_sep;
-
-// ms.eqn relies on this!
-
-#define LINE_STRING "10"
-#define MARK_OR_LINEUP_FLAG_REG "MK"
-
-#define WIDTH_FORMAT PREFIX "w%d"
-#define HEIGHT_FORMAT PREFIX "h%d"
-#define DEPTH_FORMAT PREFIX "d%d"
-#define TOTAL_FORMAT PREFIX "t%d"
-#define SIZE_FORMAT PREFIX "z%d"
-#define SMALL_SIZE_FORMAT PREFIX "Z%d"
-#define SUP_RAISE_FORMAT PREFIX "p%d"
-#define SUB_LOWER_FORMAT PREFIX "b%d"
-#define SUB_KERN_FORMAT PREFIX "k%d"
-#define FONT_FORMAT PREFIX "f%d"
-#define SKEW_FORMAT PREFIX "s%d"
-#define LEFT_WIDTH_FORMAT PREFIX "lw%d"
-#define LEFT_DELIM_STRING_FORMAT PREFIX "l%d"
-#define RIGHT_DELIM_STRING_FORMAT PREFIX "r%d"
-#define SQRT_STRING_FORMAT PREFIX "sqr%d"
-#define SQRT_WIDTH_FORMAT PREFIX "sq%d"
-#define BASELINE_SEP_FORMAT PREFIX "bs%d"
-// this needs two parameters, the uid and the column index
-#define COLUMN_WIDTH_FORMAT PREFIX "cw%d,%d"
-
-#define BAR_STRING PREFIX "sqb"
-#define TEMP_REG PREFIX "temp"
-#define MARK_REG PREFIX "mark"
-#define MARK_WIDTH_REG PREFIX "mwidth"
-#define SAVED_MARK_REG PREFIX "smark"
-#define MAX_SIZE_REG PREFIX "mxsz"
-#define REPEAT_APPEND_STRING_MACRO PREFIX "ras"
-#define TOP_HEIGHT_REG PREFIX "th"
-#define TOP_DEPTH_REG PREFIX "td"
-#define MID_HEIGHT_REG PREFIX "mh"
-#define MID_DEPTH_REG PREFIX "md"
-#define BOT_HEIGHT_REG PREFIX "bh"
-#define BOT_DEPTH_REG PREFIX "bd"
-#define EXT_HEIGHT_REG PREFIX "eh"
-#define EXT_DEPTH_REG PREFIX "ed"
-#define TOTAL_HEIGHT_REG PREFIX "tot"
-#define DELTA_REG PREFIX "delta"
-#define DELIM_STRING PREFIX "delim"
-#define DELIM_WIDTH_REG PREFIX "dwidth"
-#define SAVED_FONT_REG PREFIX "sfont"
-#define SAVED_PREV_FONT_REG PREFIX "spfont"
-#define SAVED_INLINE_FONT_REG PREFIX "sifont"
-#define SAVED_INLINE_PREV_FONT_REG PREFIX "sipfont"
-#define SAVED_SIZE_REG PREFIX "ssize"
-#define SAVED_INLINE_SIZE_REG PREFIX "sisize"
-#define SAVED_INLINE_PREV_SIZE_REG PREFIX "sipsize"
-#define SAVE_FONT_STRING PREFIX "sfont"
-#define RESTORE_FONT_STRING PREFIX "rfont"
-#define INDEX_REG PREFIX "i"
-#define TEMP_MACRO PREFIX "tempmac"
-
-#define DELIMITER_CHAR "\\(EQ"
-
-const int CRAMPED_SCRIPT_STYLE = 0;
-const int SCRIPT_STYLE = 1;
-const int CRAMPED_DISPLAY_STYLE = 2;
-const int DISPLAY_STYLE = 3;
-
-extern int script_style(int);
-extern int cramped_style(int);
-
-const int ORDINARY_TYPE = 0;
-const int OPERATOR_TYPE = 1;
-const int BINARY_TYPE = 2;
-const int RELATION_TYPE = 3;
-const int OPENING_TYPE = 4;
-const int CLOSING_TYPE = 5;
-const int PUNCTUATION_TYPE = 6;
-const int INNER_TYPE = 7;
-const int SUPPRESS_TYPE = 8;
-
-void set_script_size();
-
-enum { HINT_PREV_IS_ITALIC = 01, HINT_NEXT_IS_ITALIC = 02 };
-
-extern const char *current_roman_font;
diff --git a/contrib/groff/src/preproc/eqn/pile.cpp b/contrib/groff/src/preproc/eqn/pile.cpp
deleted file mode 100644
index 10d1708809af..000000000000
--- a/contrib/groff/src/preproc/eqn/pile.cpp
+++ /dev/null
@@ -1,293 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2004 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-// piles and matrices
-
-#include "eqn.h"
-#include "pbox.h"
-
-// SUP_RAISE_FORMAT gives the first baseline
-// BASELINE_SEP_FORMAT gives the separation between baselines
-
-int pile_box::compute_metrics(int style)
-{
- int i;
- for (i = 0; i < col.len; i++)
- col.p[i]->compute_metrics(style);
- printf(".nr " WIDTH_FORMAT " 0", uid);
- for (i = 0; i < col.len; i++)
- printf(">?\\n[" WIDTH_FORMAT "]", col.p[i]->uid);
- printf("\n");
- printf(".nr " BASELINE_SEP_FORMAT " %dM",
- uid, baseline_sep+col.space);
- for (i = 1; i < col.len; i++)
- printf(">?(\\n[" DEPTH_FORMAT "]+\\n[" HEIGHT_FORMAT "]+%dM)",
- col.p[i-1]->uid, col.p[i]->uid, default_rule_thickness*5);
- // round it so that it's a multiple of the vertical resolution
- printf("/\\n(.V+(\\n(.V/2)*\\n(.V\n");
-
- printf(".nr " SUP_RAISE_FORMAT " \\n[" BASELINE_SEP_FORMAT "]*%d/2"
- "+%dM\n",
- uid, uid, col.len-1, axis_height - shift_down);
- printf(".nr " HEIGHT_FORMAT " \\n[" SUP_RAISE_FORMAT "]+\\n["
- HEIGHT_FORMAT "]\n",
- uid, uid, col.p[0]->uid);
- printf(".nr " DEPTH_FORMAT " \\n[" BASELINE_SEP_FORMAT "]*%d+\\n["
- DEPTH_FORMAT "]-\\n[" SUP_RAISE_FORMAT "]\n",
- uid, uid, col.len-1, col.p[col.len-1]->uid, uid);
- return FOUND_NOTHING;
-}
-
-void pile_box::output()
-{
- int i;
- printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
- for (i = 0; i < col.len; i++) {
- switch (col.align) {
- case LEFT_ALIGN:
- break;
- case CENTER_ALIGN:
- printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u/2u'",
- uid, col.p[i]->uid);
- break;
- case RIGHT_ALIGN:
- printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u'",
- uid, col.p[i]->uid);
- break;
- default:
- assert(0);
- }
- col.p[i]->output();
- printf("\\h'-\\n[" WIDTH_FORMAT "]u'", col.p[i]->uid);
- switch (col.align) {
- case LEFT_ALIGN:
- break;
- case CENTER_ALIGN:
- printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u/2u'",
- col.p[i]->uid, uid);
- break;
- case RIGHT_ALIGN:
- printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u'",
- col.p[i]->uid, uid);
- break;
- default:
- assert(0);
- }
- if (i != col.len - 1)
- printf("\\v'\\n[" BASELINE_SEP_FORMAT "]u'", uid);
- }
- printf("\\v'\\n[" SUP_RAISE_FORMAT "]u'", uid);
- printf("\\v'-(%du*\\n[" BASELINE_SEP_FORMAT "]u)'", col.len - 1, uid);
- printf("\\h'\\n[" WIDTH_FORMAT "]u'", uid);
-}
-
-pile_box::pile_box(box *pp) : col(pp)
-{
-}
-
-void pile_box::check_tabs(int level)
-{
- col.list_check_tabs(level);
-}
-
-void pile_box::debug_print()
-{
- col.debug_print("pile");
-}
-
-int matrix_box::compute_metrics(int style)
-{
- int i, j;
- int max_len = 0;
- int space = 0;
- for (i = 0; i < len; i++) {
- for (j = 0; j < p[i]->len; j++)
- p[i]->p[j]->compute_metrics(style);
- if (p[i]->len > max_len)
- max_len = p[i]->len;
- if (p[i]->space > space)
- space = p[i]->space;
- }
- for (i = 0; i < len; i++) {
- printf(".nr " COLUMN_WIDTH_FORMAT " 0", uid, i);
- for (j = 0; j < p[i]->len; j++)
- printf(">?\\n[" WIDTH_FORMAT "]", p[i]->p[j]->uid);
- printf("\n");
- }
- printf(".nr " WIDTH_FORMAT " %dM",
- uid, column_sep*(len-1)+2*matrix_side_sep);
- for (i = 0; i < len; i++)
- printf("+\\n[" COLUMN_WIDTH_FORMAT "]", uid, i);
- printf("\n");
- printf(".nr " BASELINE_SEP_FORMAT " %dM",
- uid, baseline_sep+space);
- for (i = 0; i < len; i++)
- for (j = 1; j < p[i]->len; j++)
- printf(">?(\\n[" DEPTH_FORMAT "]+\\n[" HEIGHT_FORMAT "]+%dM)",
- p[i]->p[j-1]->uid, p[i]->p[j]->uid, default_rule_thickness*5);
- // round it so that it's a multiple of the vertical resolution
- printf("/\\n(.V+(\\n(.V/2)*\\n(.V\n");
- printf(".nr " SUP_RAISE_FORMAT " \\n[" BASELINE_SEP_FORMAT "]*%d/2"
- "+%dM\n",
- uid, uid, max_len-1, axis_height - shift_down);
- printf(".nr " HEIGHT_FORMAT " 0\\n[" SUP_RAISE_FORMAT "]+(0",
- uid, uid);
- for (i = 0; i < len; i++)
- printf(">?\\n[" HEIGHT_FORMAT "]", p[i]->p[0]->uid);
- printf(")>?0\n");
- printf(".nr " DEPTH_FORMAT " \\n[" BASELINE_SEP_FORMAT "]*%d-\\n["
- SUP_RAISE_FORMAT "]+(0",
- uid, uid, max_len-1, uid);
- for (i = 0; i < len; i++)
- if (p[i]->len == max_len)
- printf(">?\\n[" DEPTH_FORMAT "]", p[i]->p[max_len-1]->uid);
- printf(")>?0\n");
- return FOUND_NOTHING;
-}
-
-void matrix_box::output()
-{
- printf("\\h'%dM'", matrix_side_sep);
- for (int i = 0; i < len; i++) {
- int j;
- printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
- for (j = 0; j < p[i]->len; j++) {
- switch (p[i]->align) {
- case LEFT_ALIGN:
- break;
- case CENTER_ALIGN:
- printf("\\h'\\n[" COLUMN_WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u/2u'",
- uid, i, p[i]->p[j]->uid);
- break;
- case RIGHT_ALIGN:
- printf("\\h'\\n[" COLUMN_WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u'",
- uid, i, p[i]->p[j]->uid);
- break;
- default:
- assert(0);
- }
- p[i]->p[j]->output();
- printf("\\h'-\\n[" WIDTH_FORMAT "]u'", p[i]->p[j]->uid);
- switch (p[i]->align) {
- case LEFT_ALIGN:
- break;
- case CENTER_ALIGN:
- printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" COLUMN_WIDTH_FORMAT "]u/2u'",
- p[i]->p[j]->uid, uid, i);
- break;
- case RIGHT_ALIGN:
- printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" COLUMN_WIDTH_FORMAT "]u'",
- p[i]->p[j]->uid, uid, i);
- break;
- default:
- assert(0);
- }
- if (j != p[i]->len - 1)
- printf("\\v'\\n[" BASELINE_SEP_FORMAT "]u'", uid);
- }
- printf("\\v'\\n[" SUP_RAISE_FORMAT "]u'", uid);
- printf("\\v'-(%du*\\n[" BASELINE_SEP_FORMAT "]u)'", p[i]->len - 1, uid);
- printf("\\h'\\n[" COLUMN_WIDTH_FORMAT "]u'", uid, i);
- if (i != len - 1)
- printf("\\h'%dM'", column_sep);
- }
- printf("\\h'%dM'", matrix_side_sep);
-}
-
-matrix_box::matrix_box(column *pp)
-{
- p = new column*[10];
- for (int i = 0; i < 10; i++)
- p[i] = 0;
- maxlen = 10;
- len = 1;
- p[0] = pp;
-}
-
-matrix_box::~matrix_box()
-{
- for (int i = 0; i < len; i++)
- delete p[i];
- a_delete p;
-}
-
-void matrix_box::append(column *pp)
-{
- if (len + 1 > maxlen) {
- column **oldp = p;
- maxlen *= 2;
- p = new column*[maxlen];
- memcpy(p, oldp, sizeof(column*)*len);
- a_delete oldp;
- }
- p[len++] = pp;
-}
-
-void matrix_box::check_tabs(int level)
-{
- for (int i = 0; i < len; i++)
- p[i]->list_check_tabs(level);
-}
-
-void matrix_box::debug_print()
-{
- fprintf(stderr, "matrix { ");
- p[0]->debug_print("col");
- for (int i = 1; i < len; i++) {
- fprintf(stderr, " ");
- p[i]->debug_print("col");
- }
- fprintf(stderr, " }");
-}
-
-column::column(box *pp) : box_list(pp), align(CENTER_ALIGN), space(0)
-{
-}
-
-void column::set_alignment(alignment a)
-{
- align = a;
-}
-
-void column::set_space(int n)
-{
- space = n;
-}
-
-void column::debug_print(const char *s)
-{
- char c = '\0'; // shut up -Wall
- switch (align) {
- case LEFT_ALIGN:
- c = 'l';
- break;
- case RIGHT_ALIGN:
- c = 'r';
- break;
- case CENTER_ALIGN:
- c = 'c';
- break;
- default:
- assert(0);
- }
- fprintf(stderr, "%c%s %d { ", c, s, space);
- list_debug_print(" above ");
- fprintf(stderr, " }");
-}
-
diff --git a/contrib/groff/src/preproc/eqn/script.cpp b/contrib/groff/src/preproc/eqn/script.cpp
deleted file mode 100644
index a9de7428718b..000000000000
--- a/contrib/groff/src/preproc/eqn/script.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-This file is part of groff.
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "pbox.h"
-
-class script_box : public pointer_box {
-private:
- box *sub;
- box *sup;
-public:
- script_box(box *, box *, box *);
- ~script_box();
- int compute_metrics(int);
- void output();
- void debug_print();
- int left_is_italic();
- void hint(unsigned);
- void check_tabs(int);
-};
-
-/* The idea is that the script should attach to the rightmost box
-of a list. For example, given `2x sup 3', the superscript should
-attach to `x' rather than `2x'. */
-
-box *make_script_box(box *nuc, box *sub, box *sup)
-{
- list_box *b = nuc->to_list_box();
- if (b != 0) {
- b->list.p[b->list.len-1] = make_script_box(b->list.p[b->list.len - 1],
- sub,
- sup);
- return b;
- }
- else
- return new script_box(nuc, sub, sup);
-}
-
-script_box::script_box(box *pp, box *qq, box *rr)
-: pointer_box(pp), sub(qq), sup(rr)
-{
-}
-
-script_box::~script_box()
-{
- delete sub;
- delete sup;
-}
-
-int script_box::left_is_italic()
-{
- return p->left_is_italic();
-}
-
-int script_box::compute_metrics(int style)
-{
- int res = p->compute_metrics(style);
- p->compute_subscript_kern();
- 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[.ps]\n", uid);
- if (sub != 0)
- sub->compute_metrics(cramped_style(script_style(style)));
- if (sup != 0)
- sup->compute_metrics(script_style(style));
- // 18a
- if (p->is_char()) {
- printf(".nr " SUP_RAISE_FORMAT " 0\n", uid);
- printf(".nr " SUB_LOWER_FORMAT " 0\n", uid);
- }
- else {
- printf(".nr " SUP_RAISE_FORMAT " \\n[" HEIGHT_FORMAT "]-%dM>?0\n",
- uid, p->uid, sup_drop);
- printf(".nr " SUB_LOWER_FORMAT " \\n[" DEPTH_FORMAT "]+%dM\n",
- uid, p->uid, sub_drop);
- }
- printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
- if (sup == 0) {
- assert(sub != 0);
- // 18b
- printf(".nr " SUB_LOWER_FORMAT " \\n[" SUB_LOWER_FORMAT "]>?%dM>?(\\n["
- HEIGHT_FORMAT "]-(%dM*4/5))\n",
- uid, uid, sub1, sub->uid, x_height);
- }
- else {
- // sup != 0
- // 18c
- int pos;
- if (style == DISPLAY_STYLE)
- pos = sup1;
- else if (style & 1) // not cramped
- pos = sup2;
- else
- pos = sup3;
- printf(".nr " SUP_RAISE_FORMAT " \\n[" SUP_RAISE_FORMAT
- "]>?%dM>?(\\n[" DEPTH_FORMAT "]+(%dM/4))\n",
- uid, uid, pos, sup->uid, x_height);
- // 18d
- if (sub != 0) {
- printf(".nr " SUB_LOWER_FORMAT " \\n[" SUB_LOWER_FORMAT "]>?%dM\n",
- uid, uid, sub2);
- // 18e
- printf(".nr " TEMP_REG " \\n[" DEPTH_FORMAT "]-\\n["
- SUP_RAISE_FORMAT "]+\\n[" HEIGHT_FORMAT "]-\\n["
- SUB_LOWER_FORMAT "]+(4*%dM)\n",
- sup->uid, uid, sub->uid, uid, default_rule_thickness);
- printf(".if \\n[" TEMP_REG "] \\{");
- printf(".nr " SUB_LOWER_FORMAT " +\\n[" TEMP_REG "]\n", uid);
- printf(".nr " TEMP_REG " (%dM*4/5)-\\n[" SUP_RAISE_FORMAT
- "]+\\n[" DEPTH_FORMAT "]>?0\n",
- x_height, uid, sup->uid);
- printf(".nr " SUP_RAISE_FORMAT " +\\n[" TEMP_REG "]\n", uid);
- printf(".nr " SUB_LOWER_FORMAT " -\\n[" TEMP_REG "]\n", uid);
- printf(".\\}\n");
- }
- }
- printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]", uid, p->uid);
- if (sub != 0 && sup != 0)
- printf("+((\\n[" WIDTH_FORMAT "]-\\n[" SUB_KERN_FORMAT "]>?\\n["
- WIDTH_FORMAT "])+%dM)>?0\n",
- sub->uid, p->uid, sup->uid, script_space);
- else if (sub != 0)
- printf("+(\\n[" WIDTH_FORMAT "]-\\n[" SUB_KERN_FORMAT "]+%dM)>?0\n",
- sub->uid, p->uid, script_space);
- else if (sup != 0)
- printf("+(\\n[" WIDTH_FORMAT "]+%dM)>?0\n", sup->uid, script_space);
- else
- printf("\n");
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]",
- uid, p->uid);
- if (sup != 0)
- printf(">?(\\n[" SUP_RAISE_FORMAT "]+\\n[" HEIGHT_FORMAT "])",
- uid, sup->uid);
- if (sub != 0)
- printf(">?(-\\n[" SUB_LOWER_FORMAT "]+\\n[" HEIGHT_FORMAT "])",
- uid, sub->uid);
- printf("\n");
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]",
- uid, p->uid);
- if (sub != 0)
- printf(">?(\\n[" SUB_LOWER_FORMAT "]+\\n[" DEPTH_FORMAT "])",
- uid, sub->uid);
- if (sup != 0)
- printf(">?(-\\n[" SUP_RAISE_FORMAT "]+\\n[" DEPTH_FORMAT "])",
- uid, sup->uid);
- printf("\n");
- return res;
-}
-
-void script_box::output()
-{
- p->output();
- if (sup != 0) {
- printf("\\Z" DELIMITER_CHAR);
- printf("\\v'-\\n[" SUP_RAISE_FORMAT "]u'", uid);
- printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", uid);
- sup->output();
- 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 "]u]", uid);
- printf("\\h'-\\n[" SUB_KERN_FORMAT "]u'", p->uid);
- sub->output();
- printf("\\s[\\n[" SIZE_FORMAT "]u]", uid);
- printf(DELIMITER_CHAR);
- }
- printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u'",
- uid, p->uid);
-}
-
-void script_box::hint(unsigned flags)
-{
- p->hint(flags & ~HINT_NEXT_IS_ITALIC);
-}
-
-void script_box::debug_print()
-{
- fprintf(stderr, "{ ");
- p->debug_print();
- fprintf(stderr, " }");
- if (sub) {
- fprintf(stderr, " sub { ");
- sub->debug_print();
- fprintf(stderr, " }");
- }
- if (sup) {
- fprintf(stderr, " sup { ");
- sup->debug_print();
- fprintf(stderr, " }");
- }
-}
-
-void script_box::check_tabs(int level)
-{
- if (sup)
- sup->check_tabs(level + 1);
- if (sub)
- sub->check_tabs(level + 1);
- p->check_tabs(level);
-}
diff --git a/contrib/groff/src/preproc/eqn/special.cpp b/contrib/groff/src/preproc/eqn/special.cpp
deleted file mode 100644
index 172686a505b5..000000000000
--- a/contrib/groff/src/preproc/eqn/special.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "pbox.h"
-
-#define STRING_FORMAT PREFIX "str%d"
-
-#define SPECIAL_STRING "0s"
-#define SPECIAL_WIDTH_REG "0w"
-#define SPECIAL_HEIGHT_REG "0h"
-#define SPECIAL_DEPTH_REG "0d"
-#define SPECIAL_SUB_KERN_REG "0skern"
-#define SPECIAL_SKEW_REG "0skew"
-
-/*
-For example:
-
-.de Cl
-.ds 0s \Z'\\*[0s]'\v'\\n(0du'\D'l \\n(0wu -\\n(0hu-\\n(0du'\v'\\n(0hu'
-..
-.EQ
-define cancel 'special Cl'
-.EN
-*/
-
-
-class special_box : public pointer_box {
- char *macro_name;
-public:
- special_box(char *, box *);
- ~special_box();
- int compute_metrics(int);
- void compute_subscript_kern();
- void compute_skew();
- void output();
- void debug_print();
-};
-
-box *make_special_box(char *s, box *p)
-{
- return new special_box(s, p);
-}
-
-special_box::special_box(char *s, box *pp) : pointer_box(pp), macro_name(s)
-{
-}
-
-special_box::~special_box()
-{
- a_delete macro_name;
-}
-
-int special_box::compute_metrics(int style)
-{
- int r = p->compute_metrics(style);
- p->compute_subscript_kern();
- p->compute_skew();
- printf(".ds " SPECIAL_STRING " \"");
- p->output();
- printf("\n");
- printf(".nr " SPECIAL_WIDTH_REG " 0\\n[" WIDTH_FORMAT "]\n", p->uid);
- printf(".nr " SPECIAL_HEIGHT_REG " \\n[" HEIGHT_FORMAT "]\n", p->uid);
- printf(".nr " SPECIAL_DEPTH_REG " \\n[" DEPTH_FORMAT "]\n", p->uid);
- printf(".nr " SPECIAL_SUB_KERN_REG " \\n[" SUB_KERN_FORMAT "]\n", p->uid);
- printf(".nr " SPECIAL_SKEW_REG " 0\\n[" SKEW_FORMAT "]\n", p->uid);
- printf(".%s\n", macro_name);
- printf(".rn " SPECIAL_STRING " " STRING_FORMAT "\n", uid);
- printf(".nr " WIDTH_FORMAT " 0\\n[" SPECIAL_WIDTH_REG "]\n", uid);
- printf(".nr " HEIGHT_FORMAT " 0>?\\n[" SPECIAL_HEIGHT_REG "]\n", uid);
- printf(".nr " DEPTH_FORMAT " 0>?\\n[" SPECIAL_DEPTH_REG "]\n", uid);
- printf(".nr " SUB_KERN_FORMAT " 0>?\\n[" SPECIAL_SUB_KERN_REG "]\n", uid);
- printf(".nr " SKEW_FORMAT " 0\\n[" SPECIAL_SKEW_REG "]\n", uid);
- // User will have to change MARK_REG if appropriate.
- return r;
-}
-
-void special_box::compute_subscript_kern()
-{
- // Already computed in compute_metrics(), so do nothing.
-}
-
-void special_box::compute_skew()
-{
- // Already computed in compute_metrics(), so do nothing.
-}
-
-void special_box::output()
-{
- printf("\\*[" STRING_FORMAT "]", uid);
-}
-
-void special_box::debug_print()
-{
- fprintf(stderr, "special %s { ", macro_name);
- p->debug_print();
- fprintf(stderr, " }");
-}
diff --git a/contrib/groff/src/preproc/eqn/sqrt.cpp b/contrib/groff/src/preproc/eqn/sqrt.cpp
deleted file mode 100644
index 8f3373ff9cad..000000000000
--- a/contrib/groff/src/preproc/eqn/sqrt.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2003
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "pbox.h"
-
-
-class sqrt_box : public pointer_box {
-public:
- sqrt_box(box *);
- int compute_metrics(int style);
- void output();
- void debug_print();
- void check_tabs(int);
-};
-
-box *make_sqrt_box(box *pp)
-{
- return new sqrt_box(pp);
-}
-
-sqrt_box::sqrt_box(box *pp) : pointer_box(pp)
-{
-}
-
-#define SQRT_CHAR "\\[sqrt]"
-#define RADICAL_EXTENSION_CHAR "\\[sqrtex]"
-
-#define SQRT_CHAIN "\\[sqrt\\\\n[" INDEX_REG "]]"
-#define BAR_CHAIN "\\[sqrtex\\\\n[" INDEX_REG "]]"
-
-int sqrt_box::compute_metrics(int style)
-{
- // 11
- int r = p->compute_metrics(cramped_style(style));
- printf(".nr " TEMP_REG " \\n[" HEIGHT_FORMAT "]+\\n[" DEPTH_FORMAT
- "]+%dM+(%dM/4)\n",
- p->uid, p->uid, default_rule_thickness,
- (style > SCRIPT_STYLE ? x_height : default_rule_thickness));
- 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
- " 0\\w" DELIMITER_CHAR SQRT_CHAR DELIMITER_CHAR "\n",
- uid);
- printf(".if \\n[rst]-\\n[rsb]-%dM<\\n[" TEMP_REG "] \\{",
- default_rule_thickness);
-
- printf(".nr " INDEX_REG " 0\n"
- ".de " TEMP_MACRO "\n"
- ".ie c" SQRT_CHAIN " \\{"
- ".ds " SQRT_STRING_FORMAT " " SQRT_CHAIN "\n"
- ".ie c" BAR_CHAIN " .ds " BAR_STRING " " BAR_CHAIN "\n"
- ".el .ds " BAR_STRING " " RADICAL_EXTENSION_CHAR "\n"
- ".nr " SQRT_WIDTH_FORMAT
- " 0\\w" DELIMITER_CHAR SQRT_CHAIN DELIMITER_CHAR "\n"
- ".if \\\\n[rst]-\\\\n[rsb]-%dM<\\n[" TEMP_REG "] \\{"
- ".nr " INDEX_REG " +1\n"
- "." TEMP_MACRO "\n"
- ".\\}\\}\n"
- ".el .nr " INDEX_REG " 0-1\n"
- "..\n"
- "." TEMP_MACRO "\n",
- uid, uid, default_rule_thickness);
-
- printf(".if \\n[" INDEX_REG "]<0 \\{");
-
- // Determine the maximum point size
- printf(".ps 1000\n");
- 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.
- printf(".de " TEMP_MACRO "\n"
- ".nr " SQRT_WIDTH_FORMAT
- " 0\\w" DELIMITER_CHAR "\\*[" SQRT_STRING_FORMAT "]" DELIMITER_CHAR "\n"
- ".if \\\\n[rst]-\\\\n[rsb]-%dM<\\n[" TEMP_REG "]"
- "&(\\\\n[.ps]<\\n[" MAX_SIZE_REG "]) \\{"
- ".ps +1\n"
- "." TEMP_MACRO "\n"
- ".\\}\n"
- "..\n"
- "." TEMP_MACRO "\n",
- uid, uid, default_rule_thickness);
-
- printf(".\\}\\}\n");
-
- 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);
- // If TEMP_REG is negative, the bottom of the radical sign should
- // be -TEMP_REG above the bottom of p. If it's positive, the bottom
- // of the radical sign should be TEMP_REG/2 below the bottom of p.
- // This calculates the amount by which the baseline of the radical
- // should be raised.
- printf(".nr " SUP_RAISE_FORMAT " (-\\n[" TEMP_REG "]>?(-\\n[" TEMP_REG "]/2))"
- "-\\n[rsb]-\\n[" DEPTH_FORMAT "]\n", uid, p->uid);
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]"
- ">?(\\n[" SUP_RAISE_FORMAT "]+\\n[rst])\n",
- uid, p->uid, uid);
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]"
- ">?(-\\n[" SUP_RAISE_FORMAT "]-\\n[rsb])\n",
- uid, p->uid, uid);
- // Do this last, so we don't lose height and depth information on
- // the radical sign.
- // Remember that the width of the bar might be greater than the width of p.
-
- printf(".nr " TEMP_REG " "
- "\\n[" WIDTH_FORMAT "]"
- ">?\\w" DELIMITER_CHAR "\\*[" BAR_STRING "]" DELIMITER_CHAR "\n",
- p->uid);
- printf(".as " SQRT_STRING_FORMAT " "
- "\\l'\\n[" TEMP_REG "]u\\&\\*[" BAR_STRING "]'\n",
- uid);
- printf(".nr " WIDTH_FORMAT " \\n[" TEMP_REG "]"
- "+\\n[" SQRT_WIDTH_FORMAT "]\n",
- uid, uid);
-
- if (r)
- printf(".nr " MARK_REG " +\\n[" SQRT_WIDTH_FORMAT "]\n", uid);
- // the top of the bar might be higher than the top of the radical sign
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]"
- ">?(\\n[" SUP_RAISE_FORMAT "]+\\n[rst])\n",
- 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 "]u\n", uid);
- return r;
-}
-
-void sqrt_box::output()
-{
- printf("\\Z" DELIMITER_CHAR);
- 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 "]u]", uid);
- printf(DELIMITER_CHAR);
-
- printf("\\Z" DELIMITER_CHAR);
- printf("\\h'\\n[" WIDTH_FORMAT "]u-\\n[" WIDTH_FORMAT "]u"
- "+\\n[" SQRT_WIDTH_FORMAT "]u/2u'",
- uid, p->uid, uid);
- p->output();
- printf(DELIMITER_CHAR);
-
- printf("\\h'\\n[" WIDTH_FORMAT "]u'", uid);
-}
-
-void sqrt_box::debug_print()
-{
- fprintf(stderr, "sqrt { ");
- p->debug_print();
- fprintf(stderr, " }");
-}
-
-void sqrt_box::check_tabs(int level)
-{
- p->check_tabs(level + 1);
-}
diff --git a/contrib/groff/src/preproc/eqn/text.cpp b/contrib/groff/src/preproc/eqn/text.cpp
deleted file mode 100644
index e39221276b58..000000000000
--- a/contrib/groff/src/preproc/eqn/text.cpp
+++ /dev/null
@@ -1,528 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2003 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "eqn.h"
-#include "pbox.h"
-#include "ptable.h"
-
-class char_box : public simple_box {
- unsigned char c;
- char next_is_italic;
- char prev_is_italic;
-public:
- char_box(unsigned char);
- void debug_print();
- void output();
- int is_char();
- int left_is_italic();
- int right_is_italic();
- void hint(unsigned);
- void handle_char_type(int, int);
-};
-
-class special_char_box : public simple_box {
- char *s;
-public:
- special_char_box(const char *);
- ~special_char_box();
- void output();
- void debug_print();
- int is_char();
- void handle_char_type(int, int);
-};
-
-const char *spacing_type_table[] = {
- "ordinary",
- "operator",
- "binary",
- "relation",
- "opening",
- "closing",
- "punctuation",
- "inner",
- "suppress",
- 0,
-};
-
-const int DIGIT_TYPE = 0;
-const int LETTER_TYPE = 1;
-
-const char *font_type_table[] = {
- "digit",
- "letter",
- 0,
-};
-
-struct char_info {
- int spacing_type;
- int font_type;
- char_info();
-};
-
-char_info::char_info()
-: spacing_type(ORDINARY_TYPE), font_type(DIGIT_TYPE)
-{
-}
-
-static char_info char_table[256];
-
-declare_ptable(char_info)
-implement_ptable(char_info)
-
-PTABLE(char_info) special_char_table;
-
-static int get_special_char_spacing_type(const char *ch)
-{
- char_info *p = special_char_table.lookup(ch);
- return p ? p->spacing_type : ORDINARY_TYPE;
-}
-
-static int get_special_char_font_type(const char *ch)
-{
- char_info *p = special_char_table.lookup(ch);
- return p ? p->font_type : DIGIT_TYPE;
-}
-
-static void set_special_char_type(const char *ch, int st, int ft)
-{
- char_info *p = special_char_table.lookup(ch);
- if (!p) {
- p = new char_info[1];
- special_char_table.define(ch, p);
- }
- if (st >= 0)
- p->spacing_type = st;
- if (ft >= 0)
- p->font_type = ft;
-}
-
-void init_char_table()
-{
- set_special_char_type("pl", 2, -1); // binary
- set_special_char_type("mi", 2, -1);
- set_special_char_type("eq", 3, -1); // relation
- set_special_char_type("<=", 3, -1);
- set_special_char_type(">=", 3, -1);
- char_table['}'].spacing_type = 5; // closing
- char_table[')'].spacing_type = 5;
- char_table[']'].spacing_type = 5;
- char_table['{'].spacing_type = 4; // opening
- char_table['('].spacing_type = 4;
- char_table['['].spacing_type = 4;
- char_table[','].spacing_type = 6; // punctuation
- char_table[';'].spacing_type = 6;
- char_table[':'].spacing_type = 6;
- char_table['.'].spacing_type = 6;
- char_table['>'].spacing_type = 3;
- char_table['<'].spacing_type = 3;
- char_table['*'].spacing_type = 2; // binary
- for (int i = 0; i < 256; i++)
- if (csalpha(i))
- char_table[i].font_type = LETTER_TYPE;
-}
-
-static int lookup_spacing_type(const char *type)
-{
- for (int i = 0; spacing_type_table[i] != 0; i++)
- if (strcmp(spacing_type_table[i], type) == 0)
- return i;
- return -1;
-}
-
-static int lookup_font_type(const char *type)
-{
- for (int i = 0; font_type_table[i] != 0; i++)
- if (strcmp(font_type_table[i], type) == 0)
- return i;
- return -1;
-}
-
-void box::set_spacing_type(char *type)
-{
- int t = lookup_spacing_type(type);
- if (t < 0)
- error("unrecognised type `%1'", type);
- else
- spacing_type = t;
- a_delete type;
-}
-
-char_box::char_box(unsigned char cc)
-: c(cc), next_is_italic(0), prev_is_italic(0)
-{
- spacing_type = char_table[c].spacing_type;
-}
-
-void char_box::hint(unsigned flags)
-{
- if (flags & HINT_PREV_IS_ITALIC)
- prev_is_italic = 1;
- if (flags & HINT_NEXT_IS_ITALIC)
- next_is_italic = 1;
-}
-
-void char_box::output()
-{
- int font_type = char_table[c].font_type;
- if (font_type != LETTER_TYPE)
- printf("\\f[%s]", current_roman_font);
- if (!prev_is_italic)
- fputs("\\,", stdout);
- if (c == '\\')
- fputs("\\e", stdout);
- else
- putchar(c);
- if (!next_is_italic)
- fputs("\\/", stdout);
- else
- fputs("\\&", stdout); // suppress ligaturing and kerning
- if (font_type != LETTER_TYPE)
- fputs("\\fP", stdout);
-}
-
-int char_box::left_is_italic()
-{
- int font_type = char_table[c].font_type;
- return font_type == LETTER_TYPE;
-}
-
-int char_box::right_is_italic()
-{
- int font_type = char_table[c].font_type;
- return font_type == LETTER_TYPE;
-}
-
-int char_box::is_char()
-{
- return 1;
-}
-
-void char_box::debug_print()
-{
- if (c == '\\') {
- putc('\\', stderr);
- putc('\\', stderr);
- }
- else
- putc(c, stderr);
-}
-
-special_char_box::special_char_box(const char *t)
-{
- s = strsave(t);
- spacing_type = get_special_char_spacing_type(s);
-}
-
-special_char_box::~special_char_box()
-{
- a_delete s;
-}
-
-void special_char_box::output()
-{
- int font_type = get_special_char_font_type(s);
- if (font_type != LETTER_TYPE)
- printf("\\f[%s]", current_roman_font);
- printf("\\,\\[%s]\\/", s);
- if (font_type != LETTER_TYPE)
- printf("\\fP");
-}
-
-int special_char_box::is_char()
-{
- return 1;
-}
-
-void special_char_box::debug_print()
-{
- fprintf(stderr, "\\[%s]", s);
-}
-
-
-void char_box::handle_char_type(int st, int ft)
-{
- if (st >= 0)
- char_table[c].spacing_type = st;
- if (ft >= 0)
- char_table[c].font_type = ft;
-}
-
-void special_char_box::handle_char_type(int st, int ft)
-{
- set_special_char_type(s, st, ft);
-}
-
-void set_char_type(const char *type, char *ch)
-{
- assert(ch != 0);
- int st = lookup_spacing_type(type);
- int ft = lookup_font_type(type);
- if (st < 0 && ft < 0) {
- error("bad character type `%1'", type);
- a_delete ch;
- return;
- }
- box *b = split_text(ch);
- b->handle_char_type(st, ft);
- delete b;
-}
-
-/* We give primes special treatment so that in ``x' sub 2'', the ``2''
-will be tucked under the prime */
-
-class prime_box : public pointer_box {
- box *pb;
-public:
- prime_box(box *);
- ~prime_box();
- int compute_metrics(int style);
- void output();
- void compute_subscript_kern();
- void debug_print();
- void handle_char_type(int, int);
-};
-
-box *make_prime_box(box *pp)
-{
- return new prime_box(pp);
-}
-
-prime_box::prime_box(box *pp) : pointer_box(pp)
-{
- pb = new special_char_box("fm");
-}
-
-prime_box::~prime_box()
-{
- delete pb;
-}
-
-int prime_box::compute_metrics(int style)
-{
- int res = p->compute_metrics(style);
- pb->compute_metrics(style);
- printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]"
- "+\\n[" WIDTH_FORMAT "]\n",
- uid, p->uid, pb->uid);
- printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]"
- ">?\\n[" HEIGHT_FORMAT "]\n",
- uid, p->uid, pb->uid);
- printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]"
- ">?\\n[" DEPTH_FORMAT "]\n",
- uid, p->uid, pb->uid);
- return res;
-}
-
-void prime_box::compute_subscript_kern()
-{
- p->compute_subscript_kern();
- printf(".nr " SUB_KERN_FORMAT " 0\\n[" WIDTH_FORMAT "]"
- "+\\n[" SUB_KERN_FORMAT "]>?0\n",
- uid, pb->uid, p->uid);
-}
-
-void prime_box::output()
-{
- p->output();
- pb->output();
-}
-
-void prime_box::handle_char_type(int st, int ft)
-{
- p->handle_char_type(st, ft);
- pb->handle_char_type(st, ft);
-}
-
-void prime_box::debug_print()
-{
- p->debug_print();
- putc('\'', stderr);
-}
-
-box *split_text(char *text)
-{
- list_box *lb = 0;
- box *fb = 0;
- char *s = text;
- while (*s != '\0') {
- char c = *s++;
- box *b = 0;
- switch (c) {
- case '+':
- b = new special_char_box("pl");
- break;
- case '-':
- b = new special_char_box("mi");
- break;
- case '=':
- b = new special_char_box("eq");
- break;
- case '\'':
- b = new special_char_box("fm");
- break;
- case '<':
- if (*s == '=') {
- b = new special_char_box("<=");
- s++;
- break;
- }
- goto normal_char;
- case '>':
- if (*s == '=') {
- b = new special_char_box(">=");
- s++;
- break;
- }
- goto normal_char;
- case '\\':
- if (*s == '\0') {
- lex_error("bad escape");
- break;
- }
- c = *s++;
- switch (c) {
- case '(':
- {
- char buf[3];
- if (*s != '\0') {
- buf[0] = *s++;
- if (*s != '\0') {
- buf[1] = *s++;
- buf[2] = '\0';
- b = new special_char_box(buf);
- }
- else {
- lex_error("bad escape");
- }
- }
- else {
- lex_error("bad escape");
- }
- }
- break;
- case '[':
- {
- char *ch = s;
- while (*s != ']' && *s != '\0')
- s++;
- if (*s == '\0')
- lex_error("bad escape");
- else {
- *s++ = '\0';
- b = new special_char_box(ch);
- }
- }
- break;
- case 'f':
- case 'g':
- case 'k':
- case 'n':
- case '*':
- {
- char *escape_start = s - 2;
- switch (*s) {
- case '(':
- if (*++s != '\0')
- ++s;
- break;
- case '[':
- for (++s; *s != '\0' && *s != ']'; s++)
- ;
- break;
- }
- if (*s == '\0')
- lex_error("bad escape");
- else {
- ++s;
- char *buf = new char[s - escape_start + 1];
- memcpy(buf, escape_start, s - escape_start);
- buf[s - escape_start] = '\0';
- b = new quoted_text_box(buf);
- }
- }
- break;
- case '-':
- case '_':
- {
- char buf[2];
- buf[0] = c;
- buf[1] = '\0';
- b = new special_char_box(buf);
- }
- break;
- case '`':
- b = new special_char_box("ga");
- break;
- case '\'':
- b = new special_char_box("aa");
- break;
- case 'e':
- case '\\':
- b = new char_box('\\');
- break;
- case '^':
- case '|':
- case '0':
- {
- char buf[3];
- buf[0] = '\\';
- buf[1] = c;
- buf[2] = '\0';
- b = new quoted_text_box(strsave(buf));
- break;
- }
- default:
- lex_error("unquoted escape");
- b = new quoted_text_box(strsave(s - 2));
- s = strchr(s, '\0');
- break;
- }
- break;
- default:
- normal_char:
- b = new char_box(c);
- break;
- }
- while (*s == '\'') {
- if (b == 0)
- b = new quoted_text_box(0);
- b = new prime_box(b);
- s++;
- }
- if (b != 0) {
- if (lb != 0)
- lb->append(b);
- else if (fb != 0) {
- lb = new list_box(fb);
- lb->append(b);
- }
- else
- fb = b;
- }
- }
- a_delete text;
- if (lb != 0)
- return lb;
- else if (fb != 0)
- return fb;
- else
- return new quoted_text_box(0);
-}
-
diff --git a/contrib/groff/src/preproc/grn/Makefile.sub b/contrib/groff/src/preproc/grn/Makefile.sub
deleted file mode 100644
index c28db477ffa6..000000000000
--- a/contrib/groff/src/preproc/grn/Makefile.sub
+++ /dev/null
@@ -1,17 +0,0 @@
-PROG=grn$(EXEEXT)
-MAN1=grn.n
-MLIB=$(LIBM)
-XLIBS=$(LIBGROFF)
-OBJS=\
- hdb.$(OBJEXT) \
- hpoint.$(OBJEXT) \
- hgraph.$(OBJEXT) \
- main.$(OBJEXT)
-CCSRCS=\
- $(srcdir)/hdb.cpp \
- $(srcdir)/hpoint.cpp \
- $(srcdir)/hgraph.cpp \
- $(srcdir)/main.cpp
-HDRS=\
- $(srcdir)/gprint.h
-NAMEPREFIX=$(g)
diff --git a/contrib/groff/src/preproc/grn/README b/contrib/groff/src/preproc/grn/README
deleted file mode 100644
index 124103bacab8..000000000000
--- a/contrib/groff/src/preproc/grn/README
+++ /dev/null
@@ -1,68 +0,0 @@
-This is grn from the Berkeley ditroff distribution. It has no
-AT&T code and is therefore freely distributable.
-
-Tim Theisen <tim@cs.wisc.edu>
-
-=====================================================================
-
-This is the modified code for the groff. It uses the different
-devxxx format that is ascii rather than binary as in the
-Berkeley distribution. Since groff does not have the \Ds option
-for line drawing (dotted, dashed, etc.), this version includes
-the routines for drawing curves and arcs, so it does not use the
-\D~, \Da nor \Dc. Although also included in here is a routine
-for drawing the optional gremlin style curves, it is not used
-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)
-
-=====================================================================
-
-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)
-
-=====================================================================
-
-It has been further modified by Werner Lemberg <wl@gnu.org> to fit
-better into the groff package.
-
- . Replaced Makefile with Makefile.sub.
-
- . Removed dev.h since it is unused.
-
- . Renamed grn.1 to grn.man; this man page has been extensively
- revised.
-
- . Used error() and fatal() from libgroff for all source files.
-
- . Renamed *.c to *.cpp; updates as needed for C++ (prototypes, proper
- casts, standard header files etc). Heavy formatting.
-
- . main.cpp:
-
- Using groff's default values instead of DEVDIR, DEFAULTDEV, PRINTER,
- TYPESETTER, and GREMLIB.
-
- `res' is now an integer.
-
- Added `-C' command flag (for compatibility mode) as with other
- preprocessors.
-
- Added `-F' and `-v' option (similar to troff).
-
- Renamed `-L' option to `-M' for consistence.
-
- Removed `-P' option.
-
- Using font::load_desc() for scanning DESC files.
-
- Removed SYSV-specific code.
-
- Using macro_path.open_file() for getting gremlin graphic files.
-
- Added usage().
diff --git a/contrib/groff/src/preproc/grn/gprint.h b/contrib/groff/src/preproc/grn/gprint.h
deleted file mode 100644
index ad3be443015d..000000000000
--- a/contrib/groff/src/preproc/grn/gprint.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Last non-groff version: gprint.h 1.1 84/10/08
- *
- * This file contains standard definitions used by the gprint program.
- */
-
-#include <stdio.h>
-#include <math.h>
-
-
-#define xorn(x,y) (x)
- /* was 512 */
-#define yorn(x,y) (511 - (y)) /* switch direction for */
- /* y-coordinates */
-
-#define STYLES 6
-#define SIZES 4
-#define FONTS 4
-#define SOLID -1
-#define DOTTED 004 /* 014 */
-#define DASHED 020 /* 034 */
-#define DOTDASHED 024 /* 054 */
-#define LONGDASHED 074
-
-#define DEFTHICK -1 /* default thicknes */
-#define DEFSTYLE SOLID /* default line style */
-
-#define TRUE 1
-#define FALSE 0
-
-#define nullelt -1
-#define nullpt -1
-#define nullun NULL
-
-#define BOTLEFT 0
-#define BOTRIGHT 1
-#define CENTCENT 2
-#define VECTOR 3
-#define ARC 4
-#define CURVE 5
-#define POLYGON 6
-#define BSPLINE 7
-#define BEZIER 8
-#define TOPLEFT 10
-#define TOPCENT 11
-#define TOPRIGHT 12
-#define CENTLEFT 13
-#define CENTRIGHT 14
-#define BOTCENT 15
-#define TEXT(t) ( (t <= CENTCENT) || (t >= TOPLEFT) )
-
-/* WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
- * The above (TEXT) test is dependent on the relative values of the
- * constants and will have to change if these values change or if new
- * commands are added with value greater than BOTCENT
- */
-
-#define NUSER 4
-#define NFONTS 4
-#define NBRUSHES 6
-#define NSIZES 4
-#define NJUSTS 9
-#define NSTIPPLES 16
-
-#define ADD 1
-#define DELETE 2
-#define MOD 3
-
-typedef struct point {
- double x, y;
- struct point *nextpt;
-} POINT;
-
-typedef struct elmt {
- int type, brushf, size, textlength;
- char *textpt;
- POINT *ptlist;
- struct elmt *nextelt, *setnext;
-} ELT;
-
-#define DBNextElt(elt) (elt->nextelt)
-#define DBNextofSet(elt) (elt->setnext)
-#define DBNullelt(elt) (elt == NULL)
-#define Nullpoint(pt) ((pt) == (POINT *) NULL)
-#define PTNextPoint(pt) (pt->nextpt)
-
-/* EOF */
diff --git a/contrib/groff/src/preproc/grn/grn.man b/contrib/groff/src/preproc/grn/grn.man
deleted file mode 100644
index 575b4ee70c77..000000000000
--- a/contrib/groff/src/preproc/grn/grn.man
+++ /dev/null
@@ -1,652 +0,0 @@
-'\" t
-.ig
-Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-versions, except that this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
-..
-.
-.do nr grn_C \n[.C]
-.cp 0
-.
-.de TQ
-. br
-. ns
-. TP \\$1
-..
-.
-.\" 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"
-..
-.
-.
-.TH @G@GRN @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
-.SH NAME
-@g@grn \- groff preprocessor for gremlin files
-.SH SYNOPSIS
-.BR @g@grn
-[
-.B \-Cv
-]
-[
-.BI \-T dev
-]
-[
-.BI \-M dir
-]
-[
-.BI \-F dir
-]
-[
-.IR file\.\.\.\&
-]
-.PP
-It is possible to have whitespace between a command line option and its
-parameter.
-.SH DESCRIPTION
-.I @g@grn
-is a preprocessor for including
-.I gremlin
-pictures in
-.I groff
-input.
-.I @g@grn
-writes to standard output, processing only input lines between two that
-start with
-.B .GS
-and
-.BR .GE.
-Those lines must contain
-.I @g@grn
-commands (see below).
-These commands request a
-.I gremlin
-file, and the picture in that file is
-converted and placed in the
-.I @g@troff
-input stream.
-The
-.B .GS
-request may be followed by a C, L, or R to center, left, or right
-justify the whole
-.I gremlin
-picture (default justification is center).
-If no
-.I file
-is mentioned, the standard input is read.
-At the end of the picture, the position on the page is the bottom of the
-.I gremlin
-picture.
-If the
-.I @g@grn
-entry is ended with
-.B .GF
-instead of
-.BR .GE ,
-the position is left at the top of the picture.
-.PP
-Please note that currently only the \-me macro package has support for
-.BR .GS ,
-.BR .GE ,
-and
-.BR .GF .
-.PP
-The following command-line options are understood:
-.TP
-.BI \-T dev
-Prepare output for printer
-.IR dev .
-The default device is
-.BR @DEVICE@ .
-See
-.BR groff (@MAN1EXT@)
-for acceptable devices.
-.TP
-.BI \-M dir
-Prepend
-.I dir
-to the default search path for
-.I gremlin
-files.
-The default path is (in that order) the current directory, the home
-directory,
-.BR @SYSTEMMACRODIR@ ,
-.BR @LOCALMACRODIR@ ,
-and
-.BR @MACRODIR@ .
-.TP
-.BI \-F dir
-Search
-.I dir
-for subdirectories
-.BI dev name
-.RI ( name
-is the name of the device) for the
-.B DESC
-file before the default font directories
-.BR @LOCALFONTDIR@ ,
-.BR @FONTDIR@ ,
-and
-.BR @LEGACYFONTDIR@ .
-.TP
-.B \-C
-Recognize
-.B .GS
-and
-.B .GE
-(and
-.BR .GF )
-even when followed by a character other than space or newline.
-.\".TP
-.\".B \-s
-.\"This switch causes the picture to be traversed twice:
-.\"The first time, only the interiors of filled polygons (as borderless
-.\"polygons) are printed.
-.\"The second time, the outline is printed as a series of line segments.
-.\"This way, postprocessors that overwrite rather than merge picture elements
-.\"(such as Postscript) can still have text and graphics on a shaded
-.\"background.
-.TP
-.B \-v
-Print the version number.
-.SH GRN COMMANDS
-Each input line between
-.B .GS
-and
-.B .GE
-may have one
-.I @g@grn
-command.
-Commands consist of one or two strings separated by white space, the first
-string being the command and the second its operand.
-Commands may be upper or lower case and abbreviated down to one character.
-.PP
-Commands that affect a picture's environment (those listed before
-.BR default ,
-see below) are only in effect for the current picture:
-The environment is reinitialized to the defaults at the start of the next
-picture.
-The commands are as follows:
-.TP
-.BI 1\ N
-.TQ
-.BI 2\ N
-.TQ
-.BI 3\ N
-.TQ
-.BI 4\ N
-Set
-.IR gremlin 's
-text size number 1 (2, 3, or 4) to
-.I N
-points.
-The default is 12 (16, 24, and 36, respectively).
-.TP
-.BI roman\ f
-.TQ
-.BI italics\ f
-.TQ
-.BI bold\ f
-.TQ
-.BI special\ f
-Set the roman (italics, bold, or special) font to
-.IR @g@troff 's
-font
-.I f
-(either a name or number).
-The default is R (I, B, and S, respectively).
-.TP
-.BI l\ f
-.TQ
-.BI stipple\ f
-Set the stipple font to
-.IR @g@troff 's
-stipple font
-.I f
-(name or number).
-The command
-.B stipple
-may be abbreviated down as far as `st' (to avoid
-confusion with
-.BR special ).
-There is
-.I no
-default for stipples (unless one is set by the default command), and it is
-invalid to include a
-.I gremlin
-picture with polygons without specifying a
-stipple font.
-.TP
-.BI x\ N
-.TQ
-.BI scale\ N
-Magnify the picture (in addition to any default magnification) by
-.IR N ,
-a floating point number larger than zero.
-The command
-.B scale
-may be abbreviated down to `sc'.
-.TP
-.BI narrow\ N
-.TQ
-.BI medium\ N
-.TQ
-.BI thick\ N
-Set the thickness of
-.IR gremlin 's
-narrow (medium and thick, respectively) lines to
-.I N
-times 0.15pt (this value can be changed at compile time).
-The default is 1.0 (3.0 and 5.0, respectively), which corresponds to 0.15pt
-(0.45pt and 0.75pt, respectively).
-A thickness value of zero selects the smallest available line thickness.
-Negative values cause the line thickness to be proportional to the current
-point size.
-.TP
-.BI pointscale\ <off/on>
-Scale text to match the picture.
-Gremlin text is usually printed in the point size specified with the
-commands
-.BR 1 ,
-.BR 2 ,
-.BR 3 ,
-.RB or\~ 4 ,
-regardless of any scaling factors in the picture.
-Setting
-.B pointscale
-will cause the point sizes to scale with the picture (within
-.IR @g@troff 's
-limitations, of course).
-An operand of anything but
-.I off
-will turn text scaling on.
-.TP
-.B default
-Reset the picture environment defaults to the settings in the current
-picture.
-This is meant to be used as a global parameter setting mechanism at the
-beginning of the
-.I @g@troff
-input file, but can be used at any time to reset the
-default settings.
-.TP
-.BI width\ N
-Forces the picture to be
-.I N
-inches wide.
-This overrides any scaling factors present in the same picture.
-.RB ` width
-.IR 0 '
-is ignored.
-.TP
-.BI height\ N
-Forces picture to be
-.I N
-inches high, overriding other scaling factors.
-If both `width' and `height' are specified the tighter constraint will
-determine the scale of the picture.
-.B Height
-and
-.B width
-commands are not saved with a
-.B default
-command.
-They will, however, affect point size scaling if that option is set.
-.TP
-.BI file\ name
-Get picture from
-.I gremlin
-file
-.I name
-located the current directory (or in the library directory; see the
-.B \-M
-option above).
-If two
-.B file
-commands are given, the second one overrides the first.
-If
-.I name
-doesn't exist, an error message is reported and processing continues from
-the
-.B .GE
-line.
-.SH NOTES ABOUT GROFF
-Since
-.I @g@grn
-is a preprocessor, it doesn't know about current indents, point sizes,
-margins, number registers, etc.
-Consequently, no
-.I @g@troff
-input can be placed between the
-.B .GS
-and
-.B .GE
-requests.
-However,
-.I gremlin
-text is now processed by
-.IR @g@troff ,
-so anything legal in a single line of
-.I @g@troff
-input is legal in a line of
-.I gremlin
-text (barring `.' directives at the beginning of a line).
-Thus, it is possible to have equations within a
-.I gremlin
-figure by including in the
-.I gremlin
-file
-.I eqn
-expressions enclosed by previously defined delimiters (e.g.
-.IR $$ ).
-.PP
-When using
-.I @g@grn
-along with other preprocessors, it is best to run
-.I tbl
-before
-.IR @g@grn ,
-.IR pic ,
-and/or
-.I ideal
-to avoid overworking
-.IR tbl .
-.I Eqn
-should always be run last.
-.PP
-A picture is considered an entity, but that doesn't stop
-.I @g@troff
-from trying to break it up if it falls off the end of a page.
-Placing the picture between `keeps' in \-me macros will ensure proper
-placement.
-.PP
-.I @g@grn
-uses
-.IR @g@troff 's
-number registers
-.B g1
-through
-.B g9
-and sets registers
-.B g1
-and
-.B g2
-to the width and height of the
-.I gremlin
-figure (in device units) before entering the
-.B .GS
-request (this is for those who want to rewrite these macros).
-.SH GREMLIN FILE FORMAT
-There exist two distinct
-.I gremlin
-file formats, the original format from the
-.I AED
-graphic terminal version, and the
-.I SUN
-or
-.I X11
-version.
-An extension to the
-.IR SUN / X11
-version allowing reference points with negative coordinates is
-.B not
-compatible with the
-.I AED
-version.
-As long as a
-.I gremlin
-file does not contain negative coordinates, either format will be read
-correctly by either version of
-.I gremlin
-or
-.IR @g@grn .
-The other difference to the
-.IR SUN / X11
-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
-.TS
-center, tab(@);
-l lw(0.1i) l.
-sungremlinfile@@gremlinfile
-0 240.00 128.00@@0 240.00 128.00
-CENTCENT@@2
-240.00 128.00@@240.00 128.00
-185.00 120.00@@185.00 120.00
-240.00 120.00@@240.00 120.00
-296.00 120.00@@296.00 120.00
-*@@-1.00 -1.00
-2 3@@2 3
-10 A Triangle@@10 A Triangle
-POLYGON@@6
-224.00 416.00@@224.00 416.00
-96.00 160.00@@96.00 160.00
-384.00 160.00@@384.00 160.00
-*@@-1.00 -1.00
-5 1@@5 1
-0@@0
--1@@-1
-.T&
-css.
-.sp
-Table 1. File examples
-.TE
-.sp
-.IP \(bu
-The first line of each
-.I gremlin
-file contains either the string
-.B gremlinfile
-.RI ( AED
-version) or
-.B sungremlinfile
-.RI ( SUN / X11 )
-.IP \(bu
-The second line of the file contains an orientation, and
-.B x
-and
-.B y
-values for a positioning point, separated by spaces.
-The orientation, either
-.B 0
-or
-.BR 1 ,
-is ignored by the
-.IR SUN / X11
-version.
-.B 0
-means that
-.I gremlin
-will display things in horizontal format (drawing area wider than it is
-tall, with menu across top).
-.B 1
-means that
-.I gremlin
-will display things in vertical format (drawing area taller than it is wide,
-with menu on left side).
-.B x
-and
-.B y
-are floating point values giving a positioning point to be used when this
-file is read into another file.
-The stuff on this line really isn't all that important; a value of ``1 0.00
-0.00'' is suggested.
-.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
-type of the element
-.RI ( AED
-version) or its ASCII name
-.RI ( SUN / X11
-version).
-See Table 2.
-.sp
-.TS
-center, tab(@);
-css
-ccc
-nll.
-\fIgremlin\fP File Format \(mi Object Type Specification
-.sp
-\fIAED\fP Number@\fISUN\fP/\fIX11\fP Name@Description
-0@BOTLEFT@bottom-left-justified text
-1@BOTRIGHT@bottom-right-justified text
-2@CENTCENT@center-justified text
-3@VECTOR@vector
-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
-13@CENTLEFT@left-center-justified text
-14@CENTRIGHT@right-center-justified text
-15@BOTCENT@bottom-center-justified text
-.T&
-css.
-.sp
-Table 2.
-Type Specifications in \fIgremlin\fP Files
-.TE
-.sp
-.IP \(bu
-After the object type comes a variable number of lines, each specifying a
-point used to display the element.
-Each line contains an x-coordinate and a y-coordinate in floating point
-format, separated by spaces.
-The list of points is terminated by a line containing the string ``-1.0
--1.0''
-.RI ( AED
-version) or a single asterisk, ``*''
-.RI ( SUN / X11
-version).
-.IP \(bu
-After the points comes a line containing two decimal values, giving the
-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
-.TS
-center, tab(@);
-ncw(0.1i)l.
-1 \(mi@@thin dotted lines
-2 \(mi@@thin dot-dashed lines
-3 \(mi@@thick solid lines
-4 \(mi@@thin dashed lines
-5 \(mi@@thin solid lines
-6 \(mi@@medium solid lines
-.TE
-.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
-.TS
-center, tab(@);
-ncw(0.1i)l.
-1 \(mi@@roman (R font in groff)
-2 \(mi@@italics (I font in groff)
-3 \(mi@@bold (B font in groff)
-4 \(mi@@special (S font in groff)
-.TE
-.sp
-If you're using
-.I @g@grn
-to run your pictures through
-.IR groff ,
-the font is really just a starting font:
-The text string can contain formatting sequences like
-``\efI''
-or
-``\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.
-For polygons, this size field is interpreted as a stipple number to fill the
-polygon with.
-The number is used to index into a stipple font at print time.
-.IP \(bu
-The last line of each element contains a decimal number and a string of
-characters, separated by a single space.
-The number is a count of the number of characters in the string.
-This information is only used for text elements, and contains the text
-string.
-There can be spaces inside the text.
-For arcs, curves, and vectors, this line of the element contains the string
-``0''.
-.SH NOTES ON COORDINATES
-.I gremlin
-was designed for
-.IR AED s,
-and its coordinates reflect the
-.I AED
-coordinate space.
-For vertical pictures, x-values range 116 to 511, and y-values from 0 to
-483.
-For horizontal pictures, x-values range from 0 to 511 and y-values range
-from 0 to 367.
-Although you needn't absolutely stick to this range, you'll get best results
-if you at least stay in this vicinity.
-Also, point lists are terminated by a point of (-1, -1), so you shouldn't
-ever use negative coordinates.
-.I gremlin
-writes out coordinates using format ``%f1.2''; it's probably a good idea to
-use the same format if you want to modify the
-.I @g@grn
-code.
-.SH NOTES ON SUN/X11 COORDINATES
-There is no longer a restriction on the range of coordinates used to create
-objects in the
-.IR SUN / X11
-version of
-.IR gremlin .
-However, files with negative coordinates
-.B will
-cause problems if displayed on the
-.IR AED .
-.SH FILES
-.Tp \w'@FONTDIR@/devname/DESC'u+3n
-.BI @FONTDIR@/dev name /DESC
-Device description file for device
-.IR name .
-.SH SEE ALSO
-.BR gremlin (1),
-.BR groff (@MAN1EXT@),
-.BR @g@pic (@MAN1EXT@),
-.BR ideal (1)
-.SH HISTORY
-.PP
-David Slattengren and Barry Roitblat wrote the original Berkeley
-.IR @g@grn .
-.PP
-Daniel Senderowicz and Werner Lemberg modified it for
-.IR groff .
-.
-.cp \n[grn_C]
-.
-.\" Local Variables:
-.\" mode: nroff
-.\" End:
diff --git a/contrib/groff/src/preproc/grn/hdb.cpp b/contrib/groff/src/preproc/grn/hdb.cpp
deleted file mode 100644
index 5f54040dd5c5..000000000000
--- a/contrib/groff/src/preproc/grn/hdb.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
- /* Last non-groff version: hdb.c 1.8 (Berkeley) 84/10/20
- *
- * Copyright -C- 1982 Barry S. Roitblat
- *
- * This file contains database routines for the hard copy programs of the
- * gremlin picture editor.
- */
-
-#include "gprint.h"
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "errarg.h"
-#include "error.h"
-
-#define MAXSTRING 128
-#define MAXSTRING_S "127"
-
-/* imports from main.cpp */
-
-extern int linenum; /* current line number in input file */
-extern char gremlinfile[]; /* name of file currently reading */
-extern int SUNFILE; /* TRUE if SUN gremlin file */
-extern int compatibility_flag; /* TRUE if in compatibility mode */
-extern void savebounds(double x, double y);
-
-/* imports from hpoint.cpp */
-
-extern POINT *PTInit();
-extern POINT *PTMakePoint(double x, double y, POINT ** pplist);
-
-
-int DBGetType(register char *s);
-
-
-/*
- * This routine returns a pointer to an initialized database element which
- * would be the only element in an empty list.
- */
-ELT *
-DBInit()
-{
- return ((ELT *) NULL);
-} /* end DBInit */
-
-
-/*
- * This routine creates a new element with the specified attributes and
- * links it into database.
- */
-ELT *
-DBCreateElt(int type,
- POINT * pointlist,
- int brush,
- int size,
- char *text,
- ELT **db)
-{
- register ELT *temp;
-
- temp = (ELT *) malloc(sizeof(ELT));
- temp->nextelt = *db;
- temp->type = type;
- temp->ptlist = pointlist;
- temp->brushf = brush;
- temp->size = size;
- temp->textpt = text;
- *db = temp;
- return (temp);
-} /* end CreateElt */
-
-
-/*
- * This routine reads the specified file into a database and returns a
- * pointer to that database.
- */
-ELT *
-DBRead(register FILE *file)
-{
- register int i;
- register int done; /* flag for input exhausted */
- register double nx; /* x holder so x is not set before orienting */
- int type; /* element type */
- ELT *elist; /* pointer to the file's elements */
- POINT *plist; /* pointer for reading in points */
- char string[MAXSTRING], *txt;
- double x, y; /* x and y are read in point coords */
- int len, brush, size;
- int lastpoint;
-
- SUNFILE = FALSE;
- elist = DBInit();
- (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);
- return (elist);
- }
- SUNFILE = TRUE;
- }
-
- (void) fscanf(file, "%d%lf%lf\n", &size, &x, &y);
- /* ignore orientation and file positioning point */
-
- done = FALSE;
- while (!done) {
- /* 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%" MAXSTRING_S "[^\n]%*[^\n]\n", string) == EOF) {
- error("`%1', error in file format", gremlinfile);
- return (elist);
- }
-
- type = DBGetType(string); /* interpret element type */
- if (type < 0) { /* no more data */
- done = TRUE;
- } else {
-#ifdef UW_FASTSCAN
- (void) xscanf(file, &x, &y); /* always one point */
-#else
- (void) fscanf(file, "%lf%lf\n", &x, &y); /* always one point */
-#endif /* UW_FASTSCAN */
- plist = PTInit(); /* NULL point list */
-
- /*
- * Files created on the SUN have point lists terminated by a line
- * containing only an asterik ('*'). Files created on the AED have
- * point lists terminated by the coordinate pair (-1.00 -1.00).
- */
- if (TEXT(type)) { /* read only first point for TEXT elements */
- nx = xorn(x, y);
- y = yorn(x, y);
- (void) PTMakePoint(nx, y, &plist);
- savebounds(nx, y);
-
-#ifdef UW_FASTSCAN
- while (xscanf(file, &x, &y));
-#else
- lastpoint = FALSE;
- do {
- fgets(string, MAXSTRING, file);
- if (string[0] == '*') { /* SUN gremlin file */
- lastpoint = TRUE;
- } else {
- (void) sscanf(string, "%lf%lf", &x, &y);
- if ((x == -1.00 && y == -1.00) && (!SUNFILE))
- lastpoint = TRUE;
- else {
- if (compatibility_flag)
- savebounds(xorn(x, y), yorn(x, y));
- }
- }
- } while (!lastpoint);
-#endif /* UW_FASTSCAN */
- } else { /* not TEXT element */
-#ifdef UW_FASTSCAN
- do {
- nx = xorn(x, y);
- y = yorn(x, y);
- (void) PTMakePoint(nx, y, &plist);
- savebounds(nx, y);
- } while (xscanf(file, &x, &y));
-#else
- lastpoint = FALSE;
- while (!lastpoint) {
- nx = xorn(x, y);
- y = yorn(x, y);
- (void) PTMakePoint(nx, y, &plist);
- savebounds(nx, y);
-
- fgets(string, MAXSTRING, file);
- if (string[0] == '*') { /* SUN gremlin file */
- lastpoint = TRUE;
- } else {
- (void) sscanf(string, "%lf%lf", &x, &y);
- if ((x == -1.00 && y == -1.00) && (!SUNFILE))
- lastpoint = TRUE;
- }
- }
-#endif /* UW_FASTSCAN */
- }
- (void) fscanf(file, "%d%d\n", &brush, &size);
- (void) fscanf(file, "%d", &len); /* text length */
- (void) getc(file); /* eat blank */
- txt = (char *) malloc((unsigned) len + 1);
- for (i = 0; i < len; ++i) { /* read text */
- int c = getc(file);
- if (c == EOF)
- break;
- txt[i] = c;
- }
- txt[len] = '\0';
- (void) DBCreateElt(type, plist, brush, size, txt, &elist);
- } /* end else */
- } /* end while not done */ ;
- return (elist);
-} /* end DBRead */
-
-
-/*
- * Interpret element type in string s.
- * Old file format consisted of integer element types.
- * New file format has literal names for element types.
- */
-int
-DBGetType(register char *s)
-{
- if (isdigit(s[0]) || (s[0] == '-')) /* old element format or EOF */
- return (atoi(s));
-
- switch (s[0]) {
- case 'P':
- return (POLYGON);
- case 'V':
- return (VECTOR);
- case 'A':
- return (ARC);
- case 'C':
- 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);
- case 'C':
- return (CENTCENT);
- case 'R':
- return (CENTRIGHT);
- default:
- fatal("unknown element type");
- }
- case 'B':
- switch (s[3]) {
- case 'L':
- return (BOTLEFT);
- case 'C':
- return (BOTCENT);
- case 'R':
- return (BOTRIGHT);
- default:
- fatal("unknown element type");
- }
- case 'T':
- switch (s[3]) {
- case 'L':
- return (TOPLEFT);
- case 'C':
- return (TOPCENT);
- case 'R':
- return (TOPRIGHT);
- default:
- fatal("unknown element type");
- }
- default:
- fatal("unknown element type");
- }
-
- return 0; /* never reached */
-}
-
-#ifdef UW_FASTSCAN
-/*
- * Optimization hack added by solomon@crys.wisc.edu, 12/2/86.
- * A huge fraction of the time was spent reading floating point numbers from
- * the input file, but the numbers always have the format 'ddd.dd'. Thus
- * the following special-purpose version of fscanf.
- *
- * xscanf(f,xp,yp) does roughly what fscanf(f,"%f%f",xp,yp) does except:
- * -the next piece of input must be of the form
- * <space>* <digit>*'.'<digit>* <space>* <digit>*'.'<digit>*
- * -xscanf eats the character following the second number
- * -xscanf returns 0 for "end-of-data" indication, 1 otherwise, where
- * end-of-data is signalled by a '*' [in which case the rest of the
- * line is gobbled], or by '-1.00 -1.00' [but only if !SUNFILE].
- */
-int
-xscanf(FILE *f,
- double *xp,
- double *yp)
-{
- register int c, i, j, m, frac;
- int iscale = 1, jscale = 1; /* x = i/scale, y=j/jscale */
-
- while ((c = getc(f)) == ' ');
- if (c == '*') {
- while ((c = getc(f)) != '\n');
- return 0;
- }
- i = m = frac = 0;
- while (isdigit(c) || c == '.' || c == '-') {
- if (c == '-') {
- m++;
- c = getc(f);
- continue;
- }
- if (c == '.')
- frac = 1;
- else {
- if (frac)
- iscale *= 10;
- i = 10 * i + c - '0';
- }
- c = getc(f);
- }
- if (m)
- i = -i;
- *xp = (double) i / (double) iscale;
-
- while ((c = getc(f)) == ' ');
- j = m = frac = 0;
- while (isdigit(c) || c == '.' || c == '-') {
- if (c == '-') {
- m++;
- c = getc(f);
- continue;
- }
- if (c == '.')
- frac = 1;
- else {
- if (frac)
- jscale *= 10;
- j = 10 * j + c - '0';
- }
- c = getc(f);
- }
- if (m)
- j = -j;
- *yp = (double) j / (double) jscale;
- return (SUNFILE || i != -iscale || j != -jscale);
-}
-#endif /* UW_FASTSCAN */
-
-/* EOF */
diff --git a/contrib/groff/src/preproc/grn/hgraph.cpp b/contrib/groff/src/preproc/grn/hgraph.cpp
deleted file mode 100644
index 01208951f28f..000000000000
--- a/contrib/groff/src/preproc/grn/hgraph.cpp
+++ /dev/null
@@ -1,1048 +0,0 @@
-/* Last non-groff version: hgraph.c 1.14 (Berkeley) 84/11/27
- *
- * This file contains the graphics routines for converting gremlin pictures
- * to troff input.
- */
-
-#include "lib.h"
-
-#include "gprint.h"
-
-#define MAXVECT 40
-#define MAXPOINTS 200
-#define LINELENGTH 1
-#define PointsPerInterval 64
-#define pi 3.14159265358979324
-#define twopi (2.0 * pi)
-#define len(a, b) groff_hypot((double)(b.x-a.x), (double)(b.y-a.y))
-
-
-extern int dotshifter; /* for the length of dotted curves */
-
-extern int style[]; /* line and character styles */
-extern double thick[];
-extern char *tfont[];
-extern int tsize[];
-extern int stipple_index[]; /* stipple font index for stipples 0 - 16 */
-extern char *stipple; /* stipple type (cf or ug) */
-
-
-extern double troffscale; /* imports from main.c */
-extern double linethickness;
-extern int linmod;
-extern int lastx;
-extern int lasty;
-extern int lastyline;
-extern int ytop;
-extern int ybottom;
-extern int xleft;
-extern int xright;
-extern enum E {
- OUTLINE, FILL, BOTH
-} polyfill;
-
-extern double adj1;
-extern double adj2;
-extern double adj3;
-extern double adj4;
-extern int res;
-
-void HGSetFont(int font, int size);
-void HGPutText(int justify, POINT pnt, register char *string);
-void HGSetBrush(int mode);
-void tmove2(int px, int py);
-void doarc(POINT cp, POINT sp, int angle);
-void tmove(POINT * ptr);
-void cr();
-void drawwig(POINT * ptr, int type);
-void HGtline(int x1, int y1);
-void deltax(double x);
-void deltay(double y);
-void HGArc(register int cx, register int cy, int px, int py, int angle);
-void picurve(register int *x, register int *y, int npts);
-void HGCurve(int *x, int *y, int numpoints);
-void Paramaterize(int x[], int y[], double h[], int n);
-void PeriodicSpline(double h[], int z[],
- double dz[], double d2z[], double d3z[],
- int npoints);
-void NaturalEndSpline(double h[], int z[],
- double dz[], double d2z[], double d3z[],
- int npoints);
-
-
-
-/*----------------------------------------------------------------------------*
- | Routine: HGPrintElt (element_pointer, baseline)
- |
- | Results: Examines a picture element and calls the appropriate
- | routine(s) to print them according to their type. After the
- | picture is drawn, current position is (lastx, lasty).
- *----------------------------------------------------------------------------*/
-
-void
-HGPrintElt(ELT *element,
- int /* baseline */)
-{
- register POINT *p1;
- register POINT *p2;
- register int length;
- register int graylevel;
-
- if (!DBNullelt(element) && !Nullpoint((p1 = element->ptlist))) {
- /* p1 always has first point */
- if (TEXT(element->type)) {
- HGSetFont(element->brushf, element->size);
- switch (element->size) {
- case 1:
- p1->y += adj1;
- break;
- case 2:
- p1->y += adj2;
- break;
- case 3:
- p1->y += adj3;
- break;
- case 4:
- p1->y += adj4;
- break;
- default:
- break;
- }
- HGPutText(element->type, *p1, element->textpt);
- } else {
- if (element->brushf) /* if there is a brush, the */
- HGSetBrush(element->brushf); /* graphics need it set */
-
- switch (element->type) {
-
- case ARC:
- p2 = PTNextPoint(p1);
- tmove(p2);
- doarc(*p1, *p2, element->size);
- cr();
- break;
-
- case CURVE:
- 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;
-
- case VECTOR:
- length = 0; /* keep track of line length so */
- tmove(p1); /* single lines don't get long */
- while (!Nullpoint((p1 = PTNextPoint(p1)))) {
- HGtline((int) (p1->x * troffscale),
- (int) (p1->y * troffscale));
- if (length++ > LINELENGTH) {
- length = 0;
- printf("\\\n");
- }
- } /* end while */
- cr();
- break;
-
- case POLYGON:
- {
- /* brushf = style of outline; size = color of fill:
- * on first pass (polyfill=FILL), do the interior using 'P'
- * unless size=0
- * on second pass (polyfill=OUTLINE), do the outline using a series
- * of vectors. It might make more sense to use \D'p ...',
- * but there is no uniform way to specify a 'fill character'
- * that prints as 'no fill' on all output devices (and
- * stipple fonts).
- * If polyfill=BOTH, just use the \D'p ...' command.
- */
- double firstx = p1->x;
- double firsty = p1->y;
-
- length = 0; /* keep track of line length so */
- /* single lines don't get long */
-
- if (polyfill == FILL || polyfill == BOTH) {
- /* do the interior */
- char command = (polyfill == BOTH && element->brushf) ? 'p' : 'P';
-
- /* include outline, if there is one and */
- /* the -p flag was set */
-
- /* switch based on what gremlin gives */
- switch (element->size) {
- case 1:
- graylevel = 1;
- break;
- case 3:
- graylevel = 2;
- break;
- case 12:
- graylevel = 3;
- break;
- case 14:
- graylevel = 4;
- break;
- case 16:
- graylevel = 5;
- break;
- case 19:
- graylevel = 6;
- break;
- case 21:
- graylevel = 7;
- break;
- case 23:
- graylevel = 8;
- break;
- default: /* who's giving something else? */
- graylevel = NSTIPPLES;
- break;
- }
- /* int graylevel = element->size; */
-
- if (graylevel < 0)
- break;
- if (graylevel > NSTIPPLES)
- graylevel = NSTIPPLES;
- printf("\\D'Fg %.3f'",
- double(1000 - stipple_index[graylevel]) / 1000.0);
- cr();
- tmove(p1);
- printf("\\D'%c", command);
-
- while (!Nullpoint((PTNextPoint(p1)))) {
- p1 = PTNextPoint(p1);
- deltax((double) p1->x);
- deltay((double) p1->y);
- if (length++ > LINELENGTH) {
- length = 0;
- printf("\\\n");
- }
- } /* end while */
-
- /* close polygon if not done so by user */
- if ((firstx != p1->x) || (firsty != p1->y)) {
- deltax((double) firstx);
- deltay((double) firsty);
- }
- putchar('\'');
- cr();
- break;
- }
- /* else polyfill == OUTLINE; only draw the outline */
- if (!(element->brushf))
- break;
- length = 0; /* keep track of line length */
- tmove(p1);
-
- while (!Nullpoint((PTNextPoint(p1)))) {
- p1 = PTNextPoint(p1);
- HGtline((int) (p1->x * troffscale),
- (int) (p1->y * troffscale));
- if (length++ > LINELENGTH) {
- length = 0;
- printf("\\\n");
- }
- } /* end while */
-
- /* close polygon if not done so by user */
- if ((firstx != p1->x) || (firsty != p1->y)) {
- HGtline((int) (firstx * troffscale),
- (int) (firsty * troffscale));
- }
- cr();
- break;
- } /* end case POLYGON */
- } /* end switch */
- } /* end else Text */
- } /* end if */
-} /* end PrintElt */
-
-
-/*----------------------------------------------------------------------------*
- | Routine: HGPutText (justification, position_point, string)
- |
- | Results: Given the justification, a point to position with, and a
- | string to put, HGPutText first sends the string into a
- | diversion, moves to the positioning point, then outputs
- | local vertical and horizontal motions as needed to justify
- | the text. After all motions are done, the diversion is
- | printed out.
- *----------------------------------------------------------------------------*/
-
-void
-HGPutText(int justify,
- POINT pnt,
- register char *string)
-{
- int savelasty = lasty; /* vertical motion for text is to be */
- /* ignored. Save current y here */
-
- printf(".nr g8 \\n(.d\n"); /* save current vertical position. */
- printf(".ds g9 \""); /* define string containing the text. */
- while (*string) { /* put out the string */
- if (*string == '\\' &&
- *(string + 1) == '\\') { /* one character at a */
- printf("\\\\\\"); /* time replacing // */
- string++; /* by //// to prevent */
- } /* interpretation at */
- printf("%c", *(string++)); /* printout time */
- }
- printf("\n");
-
- tmove(&pnt); /* move to positioning point */
-
- switch (justify) {
- /* local vertical motions */
- /* (the numbers here are used to be somewhat compatible with gprint) */
- case CENTLEFT:
- case CENTCENT:
- case CENTRIGHT:
- printf("\\v'0.85n'"); /* down half */
- break;
-
- case TOPLEFT:
- case TOPCENT:
- case TOPRIGHT:
- printf("\\v'1.7n'"); /* down whole */
- }
-
- switch (justify) {
- /* local horizontal motions */
- case BOTCENT:
- case CENTCENT:
- case TOPCENT:
- printf("\\h'-\\w'\\*(g9'u/2u'"); /* back half */
- break;
-
- case BOTRIGHT:
- case CENTRIGHT:
- case TOPRIGHT:
- printf("\\h'-\\w'\\*(g9'u'"); /* back whole */
- }
-
- printf("\\&\\*(g9\n"); /* now print the text. */
- printf(".sp |\\n(g8u\n"); /* restore vertical position */
- lasty = savelasty; /* vertical position restored to where it */
- lastx = xleft; /* was before text, also horizontal is at */
- /* left */
-} /* end HGPutText */
-
-
-/*----------------------------------------------------------------------------*
- | Routine: doarc (center_point, start_point, angle)
- |
- | Results: Produces either drawarc command or a drawcircle command
- | depending on the angle needed to draw through.
- *----------------------------------------------------------------------------*/
-
-void
-doarc(POINT cp,
- POINT sp,
- int angle)
-{
- if (angle) /* arc with angle */
- HGArc((int) (cp.x * troffscale), (int) (cp.y * troffscale),
- (int) (sp.x * troffscale), (int) (sp.y * troffscale), angle);
- else /* a full circle (angle == 0) */
- HGArc((int) (cp.x * troffscale), (int) (cp.y * troffscale),
- (int) (sp.x * troffscale), (int) (sp.y * troffscale), 0);
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: HGSetFont (font_number, Point_size)
- |
- | Results: ALWAYS outputs a .ft and .ps directive to troff. This is
- | done because someone may change stuff inside a text string.
- | Changes thickness back to default thickness. Default
- | thickness depends on font and pointsize.
- *----------------------------------------------------------------------------*/
-
-void
-HGSetFont(int font,
- int size)
-{
- printf(".ft %s\n"
- ".ps %d\n", tfont[font - 1], tsize[size - 1]);
- linethickness = DEFTHICK;
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: HGSetBrush (line_mode)
- |
- | Results: Generates the troff commands to set up the line width and
- | style of subsequent lines. Does nothing if no change is
- | needed.
- |
- | Side Efct: Sets `linmode' and `linethicknes'.
- *----------------------------------------------------------------------------*/
-
-void
-HGSetBrush(int mode)
-{
- register int printed = 0;
-
- if (linmod != style[--mode]) {
- /* Groff doesn't understand \Ds, so we take it out */
- /* printf ("\\D's %du'", linmod = style[mode]); */
- linmod = style[mode];
- printed = 1;
- }
- if (linethickness != thick[mode]) {
- linethickness = thick[mode];
- printf("\\h'-%.2fp'\\D't %.2fp'", linethickness, linethickness);
- printed = 1;
- }
- if (printed)
- cr();
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: deltax (x_destination)
- |
- | Results: Scales and outputs a number for delta x (with a leading
- | space) given `lastx' and x_destination.
- |
- | Side Efct: Resets `lastx' to x_destination.
- *----------------------------------------------------------------------------*/
-
-void
-deltax(double x)
-{
- register int ix = (int) (x * troffscale);
-
- printf(" %du", ix - lastx);
- lastx = ix;
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: deltay (y_destination)
- |
- | Results: Scales and outputs a number for delta y (with a leading
- | space) given `lastyline' and y_destination.
- |
- | Side Efct: Resets `lastyline' to y_destination. Since `line' vertical
- | motions don't affect `page' ones, `lasty' isn't updated.
- *----------------------------------------------------------------------------*/
-
-void
-deltay(double y)
-{
- register int iy = (int) (y * troffscale);
-
- printf(" %du", iy - lastyline);
- lastyline = iy;
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: tmove2 (px, py)
- |
- | Results: Produces horizontal and vertical moves for troff given the
- | pair of points to move to and knowing the current position.
- | Also puts out a horizontal move to start the line. This is
- | a variation without the .sp command.
- *----------------------------------------------------------------------------*/
-
-void
-tmove2(int px,
- int py)
-{
- register int dx;
- register int dy;
-
- if ((dy = py - lasty)) {
- printf("\\v'%du'", dy);
- }
- lastyline = lasty = py; /* lasty is always set to current */
- if ((dx = px - lastx)) {
- printf("\\h'%du'", dx);
- lastx = px;
- }
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: tmove (point_pointer)
- |
- | Results: Produces horizontal and vertical moves for troff given the
- | pointer of a point to move to and knowing the current
- | position. Also puts out a horizontal move to start the
- | line.
- *----------------------------------------------------------------------------*/
-
-void
-tmove(POINT * ptr)
-{
- register int ix = (int) (ptr->x * troffscale);
- register int iy = (int) (ptr->y * troffscale);
- register int dx;
- register int dy;
-
- if ((dy = iy - lasty)) {
- printf(".sp %du\n", dy);
- }
- lastyline = lasty = iy; /* lasty is always set to current */
- if ((dx = ix - lastx)) {
- printf("\\h'%du'", dx);
- lastx = ix;
- }
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: cr ( )
- |
- | Results: Ends off an input line. `.sp -1' is also added to counteract
- | the vertical move done at the end of text lines.
- |
- | Side Efct: Sets `lastx' to `xleft' for troff's return to left margin.
- *----------------------------------------------------------------------------*/
-
-void
-cr()
-{
- printf("\n.sp -1\n");
- lastx = xleft;
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: line ( )
- |
- | Results: Draws a single solid line to (x,y).
- *----------------------------------------------------------------------------*/
-
-void
-line(int px,
- int py)
-{
- printf("\\D'l");
- printf(" %du", px - lastx);
- printf(" %du'", py - lastyline);
- lastx = px;
- lastyline = lasty = py;
-}
-
-
-/*----------------------------------------------------------------------------
- | 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 corresponding type parameter,
- | either picurve or HGCurve are called.
- *----------------------------------------------------------------------------*/
-
-void
-drawwig(POINT * ptr,
- int type)
-{
- register int npts; /* point list index */
- int x[MAXPOINTS], y[MAXPOINTS]; /* point list */
-
- for (npts = 1; !Nullpoint(ptr); ptr = PTNextPoint(ptr), npts++) {
- x[npts] = (int) (ptr->x * troffscale);
- y[npts] = (int) (ptr->y * troffscale);
- }
- if (--npts) {
- if (type == CURVE) /* Use the 2 different types of curves */
- HGCurve(&x[0], &y[0], npts);
- else
- picurve(&x[0], &y[0], npts);
- }
-}
-
-
-/*----------------------------------------------------------------------------
- | Routine: HGArc (xcenter, ycenter, xstart, ystart, angle)
- |
- | Results: This routine plots an arc centered about (cx, cy) counter
- | clockwise starting from the point (px, py) through `angle'
- | degrees. If angle is 0, a full circle is drawn. It does so
- | by creating a draw-path around the arc whose density of
- | points depends on the size of the arc.
- *----------------------------------------------------------------------------*/
-
-void
-HGArc(register int cx,
- register int cy,
- int px,
- int py,
- int angle)
-{
- double xs, ys, resolution, fullcircle;
- int m;
- register int mask;
- register int extent;
- register int nx;
- register int ny;
- register int length;
- register double epsilon;
-
- xs = px - cx;
- ys = py - cy;
-
- length = 0;
-
- resolution = (1.0 + groff_hypot(xs, ys) / res) * PointsPerInterval;
- /* mask = (1 << (int) log10(resolution + 1.0)) - 1; */
- (void) frexp(resolution, &m); /* A bit more elegant than log10 */
- for (mask = 1; mask < m; mask = mask << 1);
- mask -= 1;
-
- epsilon = 1.0 / resolution;
- fullcircle = (2.0 * pi) * resolution;
- if (angle == 0)
- extent = (int) fullcircle;
- else
- extent = (int) (angle * fullcircle / 360.0);
-
- HGtline(px, py);
- while (--extent >= 0) {
- xs += epsilon * ys;
- nx = cx + (int) (xs + 0.5);
- ys -= epsilon * xs;
- ny = cy + (int) (ys + 0.5);
- if (!(extent & mask)) {
- HGtline(nx, ny); /* put out a point on circle */
- if (length++ > LINELENGTH) {
- length = 0;
- printf("\\\n");
- }
- }
- } /* end for */
-} /* end HGArc */
-
-
-/*----------------------------------------------------------------------------
- | Routine: picurve (xpoints, ypoints, num_of_points)
- |
- | Results: Draws a curve delimited by (not through) the line segments
- | traced by (xpoints, ypoints) point list. This is the `Pic'
- | style curve.
- *----------------------------------------------------------------------------*/
-
-void
-picurve(register int *x,
- register int *y,
- int npts)
-{
- register int nseg; /* effective resolution for each curve */
- register int xp; /* current point (and temporary) */
- register int yp;
- int pxp, pyp; /* previous point (to make lines from) */
- int i; /* inner curve segment traverser */
- int length = 0;
- double w; /* position factor */
- double t1, t2, t3; /* calculation temps */
-
- if (x[1] == x[npts] && y[1] == y[npts]) {
- x[0] = x[npts - 1]; /* if the lines' ends meet, make */
- y[0] = y[npts - 1]; /* sure the curve meets */
- x[npts + 1] = x[2];
- y[npts + 1] = y[2];
- } else { /* otherwise, make the ends of the */
- x[0] = x[1]; /* curve touch the ending points of */
- y[0] = y[1]; /* the line segments */
- x[npts + 1] = x[npts];
- y[npts + 1] = y[npts];
- }
-
- pxp = (x[0] + x[1]) / 2; /* make the last point pointers */
- pyp = (y[0] + y[1]) / 2; /* point to the start of the 1st line */
- tmove2(pxp, pyp);
-
- for (; npts--; x++, y++) { /* traverse the line segments */
- xp = x[0] - x[1];
- yp = y[0] - y[1];
- nseg = (int) groff_hypot((double) xp, (double) yp);
- xp = x[1] - x[2];
- yp = y[1] - y[2];
- /* `nseg' is the number of line */
- /* segments that will be drawn for */
- /* each curve segment. */
- nseg = (int) ((double) (nseg + (int) groff_hypot((double) xp, (double) yp)) /
- res * PointsPerInterval);
-
- for (i = 1; i < nseg; i++) {
- w = (double) i / (double) nseg;
- t1 = w * w;
- t3 = t1 + 1.0 - (w + w);
- t2 = 2.0 - (t3 + t1);
- xp = (((int) (t1 * x[2] + t2 * x[1] + t3 * x[0])) + 1) / 2;
- yp = (((int) (t1 * y[2] + t2 * y[1] + t3 * y[0])) + 1) / 2;
-
- HGtline(xp, yp);
- if (length++ > LINELENGTH) {
- length = 0;
- printf("\\\n");
- }
- }
- }
-}
-
-
-/*----------------------------------------------------------------------------
- | Routine: HGCurve(xpoints, ypoints, num_points)
- |
- | Results: This routine generates a smooth curve through a set of
- | points. The method used is the parametric spline curve on
- | unit knot mesh described in `Spline Curve Techniques' by
- | Patrick Baudelaire, Robert Flegal, and Robert Sproull --
- | Xerox Parc.
- *----------------------------------------------------------------------------*/
-
-void
-HGCurve(int *x,
- int *y,
- int numpoints)
-{
- double h[MAXPOINTS], dx[MAXPOINTS], dy[MAXPOINTS];
- double d2x[MAXPOINTS], d2y[MAXPOINTS], d3x[MAXPOINTS], d3y[MAXPOINTS];
- double t, t2, t3;
- register int j;
- register int k;
- register int nx;
- register int ny;
- int lx, ly;
- int length = 0;
-
- lx = x[1];
- ly = y[1];
- tmove2(lx, ly);
-
- /*
- * Solve for derivatives of the curve at each point separately for x and y
- * (parametric).
- */
- Paramaterize(x, y, h, numpoints);
-
- /* closed curve */
- if ((x[1] == x[numpoints]) && (y[1] == y[numpoints])) {
- PeriodicSpline(h, x, dx, d2x, d3x, numpoints);
- PeriodicSpline(h, y, dy, d2y, d3y, numpoints);
- } else {
- NaturalEndSpline(h, x, dx, d2x, d3x, numpoints);
- NaturalEndSpline(h, y, dy, d2y, d3y, numpoints);
- }
-
- /*
- * generate the curve using the above information and PointsPerInterval
- * vectors between each specified knot.
- */
-
- for (j = 1; j < numpoints; ++j) {
- if ((x[j] == x[j + 1]) && (y[j] == y[j + 1]))
- continue;
- for (k = 0; k <= PointsPerInterval; ++k) {
- t = (double) k *h[j] / (double) PointsPerInterval;
- t2 = t * t;
- t3 = t * t * t;
- nx = x[j] + (int) (t * dx[j] + t2 * d2x[j] / 2 + t3 * d3x[j] / 6);
- ny = y[j] + (int) (t * dy[j] + t2 * d2y[j] / 2 + t3 * d3y[j] / 6);
- HGtline(nx, ny);
- if (length++ > LINELENGTH) {
- length = 0;
- printf("\\\n");
- }
- } /* end for k */
- } /* end for j */
-} /* end HGCurve */
-
-
-/*----------------------------------------------------------------------------
- | Routine: Paramaterize (xpoints, ypoints, hparams, num_points)
- |
- | Results: This routine calculates parameteric values for use in
- | calculating curves. The parametric values are returned
- | in the array h. The values are an approximation of
- | cumulative arc lengths of the curve (uses cord length).
- | For additional information, see paper cited below.
- *----------------------------------------------------------------------------*/
-
-void
-Paramaterize(int x[],
- int y[],
- double h[],
- int n)
-{
- register int dx;
- register int dy;
- register int i;
- register int j;
- double u[MAXPOINTS];
-
- for (i = 1; i <= n; ++i) {
- u[i] = 0;
- for (j = 1; j < i; j++) {
- dx = x[j + 1] - x[j];
- dy = y[j + 1] - y[j];
- /* Here was overflowing, so I changed it. */
- /* u[i] += sqrt ((double) (dx * dx + dy * dy)); */
- u[i] += groff_hypot((double) dx, (double) dy);
- }
- }
- for (i = 1; i < n; ++i)
- h[i] = u[i + 1] - u[i];
-} /* end Paramaterize */
-
-
-/*----------------------------------------------------------------------------
- | Routine: PeriodicSpline (h, z, dz, d2z, d3z, npoints)
- |
- | Results: This routine solves for the cubic polynomial to fit a spline
- | curve to the the points specified by the list of values.
- | The Curve generated is periodic. The algorithms for this
- | curve are from the `Spline Curve Techniques' paper cited
- | above.
- *----------------------------------------------------------------------------*/
-
-void
-PeriodicSpline(double h[], /* paramaterization */
- int z[], /* point list */
- double dz[], /* to return the 1st derivative */
- double d2z[], /* 2nd derivative */
- double d3z[], /* 3rd derivative */
- int npoints) /* number of valid points */
-{
- double d[MAXPOINTS];
- double deltaz[MAXPOINTS], a[MAXPOINTS], b[MAXPOINTS];
- double c[MAXPOINTS], r[MAXPOINTS], s[MAXPOINTS];
- int i;
-
- /* step 1 */
- for (i = 1; i < npoints; ++i) {
- deltaz[i] = h[i] ? ((double) (z[i + 1] - z[i])) / h[i] : 0;
- }
- h[0] = h[npoints - 1];
- deltaz[0] = deltaz[npoints - 1];
-
- /* step 2 */
- for (i = 1; i < npoints - 1; ++i) {
- d[i] = deltaz[i + 1] - deltaz[i];
- }
- d[0] = deltaz[1] - deltaz[0];
-
- /* step 3a */
- a[1] = 2 * (h[0] + h[1]);
- b[1] = d[0];
- c[1] = h[0];
- for (i = 2; i < npoints - 1; ++i) {
- a[i] = 2 * (h[i - 1] + h[i]) -
- pow((double) h[i - 1], (double) 2.0) / a[i - 1];
- b[i] = d[i - 1] - h[i - 1] * b[i - 1] / a[i - 1];
- c[i] = -h[i - 1] * c[i - 1] / a[i - 1];
- }
-
- /* step 3b */
- r[npoints - 1] = 1;
- s[npoints - 1] = 0;
- for (i = npoints - 2; i > 0; --i) {
- r[i] = -(h[i] * r[i + 1] + c[i]) / a[i];
- s[i] = (6 * b[i] - h[i] * s[i + 1]) / a[i];
- }
-
- /* step 4 */
- d2z[npoints - 1] = (6 * d[npoints - 2] - h[0] * s[1]
- - h[npoints - 1] * s[npoints - 2])
- / (h[0] * r[1] + h[npoints - 1] * r[npoints - 2]
- + 2 * (h[npoints - 2] + h[0]));
- for (i = 1; i < npoints - 1; ++i) {
- d2z[i] = r[i] * d2z[npoints - 1] + s[i];
- }
- d2z[npoints] = d2z[1];
-
- /* step 5 */
- for (i = 1; i < npoints; ++i) {
- dz[i] = deltaz[i] - h[i] * (2 * d2z[i] + d2z[i + 1]) / 6;
- d3z[i] = h[i] ? (d2z[i + 1] - d2z[i]) / h[i] : 0;
- }
-} /* end PeriodicSpline */
-
-
-/*----------------------------------------------------------------------------
- | Routine: NaturalEndSpline (h, z, dz, d2z, d3z, npoints)
- |
- | Results: This routine solves for the cubic polynomial to fit a spline
- | curve the the points specified by the list of values. The
- | alogrithms for this curve are from the `Spline Curve
- | Techniques' paper cited above.
- *----------------------------------------------------------------------------*/
-
-void
-NaturalEndSpline(double h[], /* parameterization */
- int z[], /* Point list */
- double dz[], /* to return the 1st derivative */
- double d2z[], /* 2nd derivative */
- double d3z[], /* 3rd derivative */
- int npoints) /* number of valid points */
-{
- double d[MAXPOINTS];
- double deltaz[MAXPOINTS], a[MAXPOINTS], b[MAXPOINTS];
- int i;
-
- /* step 1 */
- for (i = 1; i < npoints; ++i) {
- deltaz[i] = h[i] ? ((double) (z[i + 1] - z[i])) / h[i] : 0;
- }
- deltaz[0] = deltaz[npoints - 1];
-
- /* step 2 */
- for (i = 1; i < npoints - 1; ++i) {
- d[i] = deltaz[i + 1] - deltaz[i];
- }
- d[0] = deltaz[1] - deltaz[0];
-
- /* step 3 */
- a[0] = 2 * (h[2] + h[1]);
- b[0] = d[1];
- for (i = 1; i < npoints - 2; ++i) {
- a[i] = 2 * (h[i + 1] + h[i + 2]) -
- pow((double) h[i + 1], (double) 2.0) / a[i - 1];
- b[i] = d[i + 1] - h[i + 1] * b[i - 1] / a[i - 1];
- }
-
- /* step 4 */
- d2z[npoints] = d2z[1] = 0;
- for (i = npoints - 1; i > 1; --i) {
- d2z[i] = (6 * b[i - 2] - h[i] * d2z[i + 1]) / a[i - 2];
- }
-
- /* step 5 */
- for (i = 1; i < npoints; ++i) {
- dz[i] = deltaz[i] - h[i] * (2 * d2z[i] + d2z[i + 1]) / 6;
- d3z[i] = h[i] ? (d2z[i + 1] - d2z[i]) / h[i] : 0;
- }
-} /* end NaturalEndSpline */
-
-
-/*----------------------------------------------------------------------------*
- | Routine: change (x_position, y_position, visible_flag)
- |
- | Results: As HGtline passes from the invisible to visible (or vice
- | versa) portion of a line, change is called to either draw
- | the line, or initialize the beginning of the next one.
- | Change calls line to draw segments if visible_flag is set
- | (which means we're leaving a visible area).
- *----------------------------------------------------------------------------*/
-
-void
-change(register int x,
- register int y,
- register int vis)
-{
- static int length = 0;
-
- if (vis) { /* leaving a visible area, draw it. */
- line(x, y);
- if (length++ > LINELENGTH) {
- length = 0;
- printf("\\\n");
- }
- } else { /* otherwise, we're entering one, remember */
- /* beginning */
- tmove2(x, y);
- }
-}
-
-
-/*----------------------------------------------------------------------------
- | Routine: HGtline (xstart, ystart, xend, yend)
- |
- | Results: Draws a line from current position to (x1,y1) using line(x1,
- | y1) to place individual segments of dotted or dashed lines.
- *----------------------------------------------------------------------------*/
-
-void
-HGtline(int x_1,
- int y_1)
-{
- register int x_0 = lastx;
- register int y_0 = lasty;
- register int dx;
- register int dy;
- register int oldcoord;
- register int res1;
- register int visible;
- register int res2;
- register int xinc;
- register int yinc;
- register int dotcounter;
-
- if (linmod == SOLID) {
- line(x_1, y_1);
- return;
- }
-
- /* for handling different resolutions */
- dotcounter = linmod << dotshifter;
-
- xinc = 1;
- yinc = 1;
- if ((dx = x_1 - x_0) < 0) {
- xinc = -xinc;
- dx = -dx;
- }
- if ((dy = y_1 - y_0) < 0) {
- yinc = -yinc;
- dy = -dy;
- }
- res1 = 0;
- res2 = 0;
- visible = 0;
- if (dx >= dy) {
- oldcoord = y_0;
- while (x_0 != x_1) {
- if ((x_0 & dotcounter) && !visible) {
- change(x_0, y_0, 0);
- visible = 1;
- } else if (visible && !(x_0 & dotcounter)) {
- change(x_0 - xinc, oldcoord, 1);
- visible = 0;
- }
- if (res1 > res2) {
- oldcoord = y_0;
- res2 += dx - res1;
- res1 = 0;
- y_0 += yinc;
- }
- res1 += dy;
- x_0 += xinc;
- }
- } else {
- oldcoord = x_0;
- while (y_0 != y_1) {
- if ((y_0 & dotcounter) && !visible) {
- change(x_0, y_0, 0);
- visible = 1;
- } else if (visible && !(y_0 & dotcounter)) {
- change(oldcoord, y_0 - yinc, 1);
- visible = 0;
- }
- if (res1 > res2) {
- oldcoord = x_0;
- res2 += dy - res1;
- res1 = 0;
- x_0 += xinc;
- }
- res1 += dx;
- y_0 += yinc;
- }
- }
- if (visible)
- change(x_1, y_1, 1);
- else
- change(x_1, y_1, 0);
-}
-
-/* EOF */
diff --git a/contrib/groff/src/preproc/grn/hpoint.cpp b/contrib/groff/src/preproc/grn/hpoint.cpp
deleted file mode 100644
index fa24dca7fd47..000000000000
--- a/contrib/groff/src/preproc/grn/hpoint.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Last non-groff version: hpoint.c 1.1 84/10/08 */
-
-/*
- * This file contains routines for manipulating the point data structures
- * for the gremlin picture editor.
- */
-
-#include <stdlib.h>
-#include "gprint.h"
-
-
-/*
- * Return pointer to empty point list.
- */
-POINT *
-PTInit()
-{
- return ((POINT *) NULL);
-}
-
-
-/*
- * This routine creates a new point with coordinates x and y and links it
- * into the pointlist.
- */
-POINT *
-PTMakePoint(double x,
- double y,
- POINT **pplist)
-{
- register POINT *pt;
-
- if (Nullpoint(pt = *pplist)) { /* empty list */
- *pplist = (POINT *) malloc(sizeof(POINT));
- pt = *pplist;
- } else {
- while (!Nullpoint(pt->nextpt))
- pt = pt->nextpt;
- pt->nextpt = (POINT *) malloc(sizeof(POINT));
- pt = pt->nextpt;
- }
-
- pt->x = x;
- pt->y = y;
- pt->nextpt = PTInit();
- return (pt);
-} /* end PTMakePoint */
-
-/* EOF */
diff --git a/contrib/groff/src/preproc/grn/main.cpp b/contrib/groff/src/preproc/grn/main.cpp
deleted file mode 100644
index c939647f2c9b..000000000000
--- a/contrib/groff/src/preproc/grn/main.cpp
+++ /dev/null
@@ -1,907 +0,0 @@
-/* Last non-groff version: main.c 1.23 (Berkeley) 85/08/05
- *
- * Adapted to GNU troff by Daniel Senderowicz 99/12/29.
- *
- * Further refinements by Werner Lemberg 00/02/20.
- *
- *
- * This file contains the main and file system dependent routines for
- * processing gremlin files into troff input. The program watches input go
- * by to standard output, only interpreting things between .GS and .GE
- * lines. Default values (font, size, scale, thickness) may be overridden
- * with a `default' command and are further overridden by commands in the
- * input.
- *
- * Inside the GS and GE, commands are accepted to reconfigure the picture.
- * At most one command may reside on each line, and each command is followed
- * by a parameter separated by white space. The commands are as follows,
- * and may be abbreviated down to one character (with exception of `scale'
- * and `stipple' down to "sc" and "st") and may be upper or lower case.
- *
- * default - Make all settings in the current
- * .GS/.GE the global defaults. Height,
- * width and file are NOT saved.
- * 1, 2, 3, 4 - Set size 1, 2, 3, or 4 (followed by an
- * integer point size).
- * roman, italics, bold, special - Set gremlin's fonts to any other troff
- * font (one or two characters).
- * stipple, l - Use a stipple font for polygons. Arg
- * is troff font name. No Default. Can
- * use only one stipple font per picture.
- * (See below for stipple font index.)
- * scale, x - Scale is IN ADDITION to the global
- * scale factor from the default.
- * pointscale - Turn on scaling point sizes to match
- * `scale' commands. (Optional operand
- * `off' to turn it off.)
- * narrow, medium, thick - Set widths of lines.
- * file - Set the file name to read the gremlin
- * picture from. If the file isn't in
- * the current directory, the gremlin
- * library is tried.
- * width, height - These two commands override any
- * scaling factor that is in effect, and
- * forces the picture to fit into either
- * the height or width specified,
- * whichever makes the picture smaller.
- * The operand for these two commands is
- * a floating-point number in units of
- * inches.
- * l<nn> (integer <nn>) - Set association between stipple <nn>
- * and a stipple `character'. <nn> must
- * be in the range 0 to NSTIPPLES (16)
- * inclusive. The integer operand is an
- * index in the stipple font selected.
- * Valid cf (cifplot) indices are 1-32
- * (although 24 is not defined), valid ug
- * (unigrafix) indices are 1-14, and
- * valid gs (gray scale) indices are
- * 0-16. Nonetheless, any number between
- * 0 and 255 is accepted since new
- * stipple fonts may be added. An
- * integer operand is required.
- *
- * Troff number registers used: g1 through g9. g1 is the width of the
- * picture, and g2 is the height. g3, and g4, save information, g8 and g9
- * are used for text processing and g5-g7 are reserved.
- */
-
-
-#include "lib.h"
-
-#include <ctype.h>
-#include <stdlib.h>
-#include "gprint.h"
-
-#include "device.h"
-#include "font.h"
-#include "searchpath.h"
-#include "macropath.h"
-
-#include "errarg.h"
-#include "error.h"
-#include "defs.h"
-
-extern "C" const char *Version_string;
-
-/* database imports */
-
-extern void HGPrintElt(ELT *element, int baseline);
-extern ELT *DBInit();
-extern ELT *DBRead(register FILE *file);
-extern POINT *PTInit();
-extern POINT *PTMakePoint(double x, double y, POINT **pplist);
-
-
-#define SUN_SCALEFACTOR 0.70
-
-/* #define DEFSTIPPLE "gs" */
-#define DEFSTIPPLE "cf"
-
-#define MAXINLINE 100 /* input line length */
-
-#define SCREENtoINCH 0.02 /* scaling factor, screen to inches */
-
-#define BIG 999999999999.0 /* unweildly large floating number */
-
-
-static char sccsid[] = "@(#) (Berkeley) 8/5/85, 12/28/99";
-
-int res; /* the printer's resolution goes here */
-
-int dotshifter; /* for the length of dotted curves */
-
-double linethickness; /* brush styles */
-int linmod;
-int lastx; /* point registers for printing elements */
-int lasty;
-int lastyline; /* A line's vertical position is NOT the */
- /* same after that line is over, so for a */
- /* line of drawing commands, vertical */
- /* spacing is kept in lastyline */
-
-/* These are the default fonts, sizes, line styles, */
-/* and thicknesses. They can be modified from a */
-/* `default' command and are reset each time the */
-/* start of a picture (.GS) is found. */
-
-const char *deffont[] =
-{"R", "I", "B", "S"};
-int defsize[] =
-{10, 16, 24, 36};
-/* #define BASE_THICKNESS 1.0 */
-#define BASE_THICKNESS 0.15
-double defthick[STYLES] =
-{1 * BASE_THICKNESS,
- 1 * BASE_THICKNESS,
- 5 * BASE_THICKNESS,
- 1 * BASE_THICKNESS,
- 1 * BASE_THICKNESS,
- 3 * BASE_THICKNESS};
-
-/* int cf_stipple_index[NSTIPPLES + 1] = */
-/* {0, 1, 3, 12, 14, 16, 19, 21, 23}; */
-/* a logarithmic scale looks better than a linear one for the gray shades */
-/* */
-/* int other_stipple_index[NSTIPPLES + 1] = */
-/* {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; */
-
-int cf_stipple_index[NSTIPPLES + 1] =
-{0, 18, 32, 56, 100, 178, 316, 562, 1000}; /* only 1-8 used */
-int other_stipple_index[NSTIPPLES + 1] =
-{0, 62, 125, 187, 250, 312, 375, 437, 500,
- 562, 625, 687, 750, 812, 875, 937, 1000};
-
-/* int *defstipple_index = other_stipple_index; */
-int *defstipple_index = cf_stipple_index;
-
-int style[STYLES] =
-{DOTTED, DOTDASHED, SOLID, DASHED, SOLID, SOLID};
-double scale = 1.0; /* no scaling, default */
-int defpoint = 0; /* flag for pointsize scaling */
-char *defstipple = (char *) 0;
-enum E {
- OUTLINE, FILL, BOTH
-} polyfill;
-
-/* flag to controll filling of polygons */
-
-double adj1 = 0.0;
-double adj2 = 0.0;
-double adj3 = 0.0;
-double adj4 = 0.0;
-
-double thick[STYLES]; /* thicknesses set by defaults, then by */
- /* commands */
-char *tfont[FONTS]; /* fonts originally set to deffont values, */
- /* then */
-int tsize[SIZES]; /* optionally changed by commands inside */
- /* grn */
-int stipple_index[NSTIPPLES + 1]; /* stipple font file indices */
-char *stipple;
-
-double xscale; /* scaling factor from individual pictures */
-double troffscale; /* scaling factor at output time */
-
-double width; /* user-request maximum width for picture */
- /* (in inches) */
-double height; /* user-request height */
-int pointscale; /* flag for pointsize scaling */
-int setdefault; /* flag for a .GS/.GE to remember all */
- /* settings */
-int sflag; /* -s flag: sort order (do polyfill first) */
-
-double toppoint; /* remember the picture */
-double bottompoint; /* bounds in these variables */
-double leftpoint;
-double rightpoint;
-
-int ytop; /* these are integer versions of the above */
-int ybottom; /* so not to convert each time they're used */
-int xleft;
-int xright;
-
-int linenum = 0; /* line number of input file */
-char inputline[MAXINLINE]; /* spot to filter through the file */
-char *c1 = inputline; /* c1, c2, and c3 will be used to */
-char *c2 = inputline + 1; /* hunt for lines that begin with */
-char *c3 = inputline + 2; /* ".GS" by looking individually */
-char *c4 = inputline + 3; /* needed for compatibility mode */
-char GScommand[MAXINLINE]; /* put user's ".GS" command line here */
-char gremlinfile[MAXINLINE]; /* filename to use for a picture */
-int SUNFILE = FALSE; /* TRUE if SUN gremlin file */
-int compatibility_flag = FALSE; /* TRUE if in compatibility mode */
-
-
-void getres();
-int doinput(FILE *fp);
-void conv(register FILE *fp, int baseline);
-void savestate();
-int has_polygon(register ELT *elist);
-void interpret(char *line);
-
-
-void
-usage(FILE *stream)
-{
- fprintf(stream,
- "usage: %s [ -vCs ] [ -M dir ] [ -F dir ] [ -T dev ] [ file ]\n",
- program_name);
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: main (argument_count, argument_pointer)
- |
- | Results: Parses the command line, accumulating input file names, then
- | reads the inputs, passing it directly to output until a `.GS'
- | line is read. Main then passes control to `conv' to do the
- | gremlin file conversions.
- *----------------------------------------------------------------------------*/
-
-int
-main(int argc,
- char **argv)
-{
- setlocale(LC_NUMERIC, "C");
- program_name = argv[0];
- register FILE *fp;
- register int k;
- register char c;
- register int gfil = 0;
- char *file[50];
- char *operand(int *argcp, char ***argvp);
-
- while (--argc) {
- if (**++argv != '-')
- file[gfil++] = *argv;
- else
- switch (c = (*argv)[1]) {
-
- case 0:
- file[gfil++] = NULL;
- break;
-
- case 'C': /* compatibility mode */
- compatibility_flag = TRUE;
- break;
-
- case 'F': /* font path to find DESC */
- font::command_line_font_dir(operand(&argc, &argv));
- break;
-
- case 'T': /* final output typesetter name */
- device = operand(&argc, &argv);
- break;
-
- case 'M': /* set library directory */
- macro_path.command_line_dir(operand(&argc, &argv));
- break;
-
- case 's': /* preserve order of elements */
- sflag = 1;
- break;
-
- case '-':
- if (strcmp(*argv,"--version")==0) {
- case 'v':
- printf("GNU grn (groff) version %s\n", Version_string);
- exit(0);
- break;
- }
- if (strcmp(*argv,"--help")==0) {
- case '?':
- usage(stdout);
- exit(0);
- break;
- }
- // fallthrough
- default:
- error("unknown switch: %1", c);
- usage(stderr);
- exit(1);
- }
- }
-
- getres(); /* set the resolution for an output device */
-
- if (gfil == 0) { /* no filename, use standard input */
- file[0] = NULL;
- gfil++;
- }
-
- for (k = 0; k < gfil; k++) {
- if (file[k] != NULL) {
- if ((fp = fopen(file[k], "r")) == NULL)
- fatal("can't open %1", file[k]);
- } else
- fp = stdin;
-
- while (doinput(fp)) {
- if (*c1 == '.' && *c2 == 'G' && *c3 == 'S') {
- if (compatibility_flag ||
- *c4 == '\n' || *c4 == ' ' || *c4 == '\0')
- conv(fp, linenum);
- else
- fputs(inputline, stdout);
- } else
- fputs(inputline, stdout);
- }
- }
-
- return 0;
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: char * operand (& argc, & argv)
- |
- | Results: Returns address of the operand given with a command-line
- | option. It uses either `-Xoperand' or `-X operand', whichever
- | is present. The program is terminated if no option is
- | present.
- |
- | Side Efct: argc and argv are updated as necessary.
- *----------------------------------------------------------------------------*/
-
-char *
-operand(int *argcp,
- char ***argvp)
-{
- if ((**argvp)[2])
- return (**argvp + 2); /* operand immediately follows */
- if ((--*argcp) <= 0) { /* no operand */
- error("command-line option operand missing.");
- exit(8);
- }
- return (*(++(*argvp))); /* operand is next word */
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: getres ()
- |
- | Results: Sets `res' to the resolution of the output device.
- *----------------------------------------------------------------------------*/
-
-void
-getres()
-{
- int linepiece;
-
- if (!font::load_desc())
- fatal("sorry, I can't continue");
-
- res = font::res;
-
- /* Correct the brush thicknesses based on res */
- /* if (res >= 256) {
- defthick[0] = res >> 8;
- defthick[1] = res >> 8;
- defthick[2] = res >> 4;
- defthick[3] = res >> 8;
- defthick[4] = res >> 8;
- defthick[5] = res >> 6;
- } */
-
- linepiece = res >> 9;
- for (dotshifter = 0; linepiece; dotshifter++)
- linepiece = linepiece >> 1;
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: int doinput (file_pointer)
- |
- | Results: A line of input is read into `inputline'.
- |
- | Side Efct: "linenum" is incremented.
- |
- | Bugs: Lines longer than MAXINLINE are NOT checked, except for
- | updating `linenum'.
- *----------------------------------------------------------------------------*/
-
-int
-doinput(FILE *fp)
-{
- if (fgets(inputline, MAXINLINE, fp) == NULL)
- return 0;
- if (strchr(inputline, '\n')) /* ++ only if it's a complete line */
- linenum++;
- return 1;
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: initpic ( )
- |
- | Results: Sets all parameters to the normal defaults, possibly
- | overridden by a setdefault command. Initialize the picture
- | variables, and output the startup commands to troff to begin
- | the picture.
- *----------------------------------------------------------------------------*/
-
-void
-initpic()
-{
- register int i;
-
- for (i = 0; i < STYLES; i++) { /* line thickness defaults */
- thick[i] = defthick[i];
- }
- for (i = 0; i < FONTS; i++) { /* font name defaults */
- tfont[i] = (char *)deffont[i];
- }
- for (i = 0; i < SIZES; i++) { /* font size defaults */
- tsize[i] = defsize[i];
- }
- for (i = 0; i <= NSTIPPLES; i++) { /* stipple font file default indices */
- stipple_index[i] = defstipple_index[i];
- }
- stipple = defstipple;
-
- gremlinfile[0] = 0; /* filename is `null' */
- setdefault = 0; /* this is not the default settings (yet) */
-
- toppoint = BIG; /* set the picture bounds out */
- bottompoint = -BIG; /* of range so they'll be set */
- leftpoint = BIG; /* by `savebounds' on input */
- rightpoint = -BIG;
-
- pointscale = defpoint; /* flag for scaling point sizes default */
- xscale = scale; /* default scale of individual pictures */
- width = 0.0; /* size specifications input by user */
- height = 0.0;
-
- linethickness = DEFTHICK; /* brush styles */
- linmod = DEFSTYLE;
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: conv (file_pointer, starting_line)
- |
- | Results: At this point, we just passed a `.GS' line in the input
- | file. conv reads the input and calls `interpret' to process
- | commands, gathering up information until a `.GE' line is
- | found. It then calls `HGPrint' to do the translation of the
- | gremlin file to troff commands.
- *----------------------------------------------------------------------------*/
-
-void
-conv(register FILE *fp,
- int baseline)
-{
- register FILE *gfp = NULL; /* input file pointer */
- register int done = 0; /* flag to remember if finished */
- register ELT *e; /* current element pointer */
- ELT *PICTURE; /* whole picture data base pointer */
- double temp; /* temporary calculating area */
- /* POINT ptr; */ /* coordinates of a point to pass to `mov' */
- /* routine */
- int flyback; /* flag `want to end up at the top of the */
- /* picture?' */
- int compat; /* test character after .GE or .GF */
-
-
- initpic(); /* set defaults, ranges, etc. */
- strcpy(GScommand, inputline); /* save `.GS' line for later */
-
- do {
- done = !doinput(fp); /* test for EOF */
- flyback = (*c3 == 'F'); /* and .GE or .GF */
- compat = (compatibility_flag ||
- *c4 == '\n' || *c4 == ' ' || *c4 == '\0');
- done |= (*c1 == '.' && *c2 == 'G' && (*c3 == 'E' || flyback) &&
- compat);
-
- if (done) {
- if (setdefault)
- savestate();
-
- if (!gremlinfile[0]) {
- if (!setdefault)
- error("at line %1: no picture filename.\n", baseline);
- return;
- }
- char *path;
- gfp = macro_path.open_file(gremlinfile, &path);
- if (!gfp)
- return;
- PICTURE = DBRead(gfp); /* read picture file */
- fclose(gfp);
- a_delete path;
- if (DBNullelt(PICTURE))
- return; /* If a request is made to make the */
- /* picture fit into a specific area, */
- /* set the scale to do that. */
-
- if (stipple == (char *) NULL) /* if user forgot stipple */
- if (has_polygon(PICTURE)) /* and picture has a polygon */
- stipple = (char *)DEFSTIPPLE; /* then set the default */
-
- if ((temp = bottompoint - toppoint) < 0.1)
- temp = 0.1;
- temp = (height != 0.0) ? height / (temp * SCREENtoINCH) : BIG;
- if ((troffscale = rightpoint - leftpoint) < 0.1)
- troffscale = 0.1;
- troffscale = (width != 0.0) ?
- width / (troffscale * SCREENtoINCH) : BIG;
- if (temp == BIG && troffscale == BIG)
- troffscale = xscale;
- else {
- if (temp < troffscale)
- troffscale = temp;
- } /* here, troffscale is the */
- /* picture's scaling factor */
- if (pointscale) {
- register int i; /* do pointscaling here, when */
- /* scale is known, before output */
- for (i = 0; i < SIZES; i++)
- tsize[i] = (int) (troffscale * (double) tsize[i] + 0.5);
- }
-
- /* change to device units */
- troffscale *= SCREENtoINCH * res; /* from screen units */
-
- ytop = (int) (toppoint * troffscale); /* calculate integer */
- ybottom = (int) (bottompoint * troffscale); /* versions of the */
- xleft = (int) (leftpoint * troffscale); /* picture limits */
- xright = (int) (rightpoint * troffscale);
-
- /* save stuff in number registers, */
- /* register g1 = picture width and */
- /* register g2 = picture height, */
- /* set vertical spacing, no fill, */
- /* and break (to make sure picture */
- /* starts on left), and put out the */
- /* user's `.GS' line. */
- printf(".br\n"
- ".nr g1 %du\n"
- ".nr g2 %du\n"
- "%s"
- ".nr g3 \\n(.f\n"
- ".nr g4 \\n(.s\n"
- "\\0\n"
- ".sp -1\n",
- xright - xleft, ybottom - ytop, GScommand);
-
- if (stipple) /* stipple requested for this picture */
- printf(".st %s\n", stipple);
- lastx = xleft; /* note where we are (upper left */
- lastyline = lasty = ytop; /* corner of the picture) */
-
- /* Just dump everything in the order it appears.
- *
- * If -s command-line option, traverse picture twice: First time,
- * print only the interiors of filled polygons (as borderless
- * polygons). Second time, print the outline as series of line
- * segments. This way, postprocessors that overwrite rather than
- * merge picture elements (such as Postscript) can still have text and
- * graphics on a shaded background.
- */
- /* if (sflag) */
- if (!sflag) { /* changing the default for filled polygons */
- e = PICTURE;
- polyfill = FILL;
- while (!DBNullelt(e)) {
- printf(".mk\n");
- if (e->type == POLYGON)
- HGPrintElt(e, baseline);
- printf(".rt\n");
- lastx = xleft;
- lastyline = lasty = ytop;
- e = DBNextElt(e);
- }
- }
- e = PICTURE;
-
- /* polyfill = !sflag ? BOTH : OUTLINE; */
- polyfill = sflag ? BOTH : OUTLINE; /* changing the default */
- while (!DBNullelt(e)) {
- printf(".mk\n");
- HGPrintElt(e, baseline);
- printf(".rt\n");
- lastx = xleft;
- lastyline = lasty = ytop;
- e = DBNextElt(e);
- }
-
- /* decide where to end picture */
-
- /* I changed everything here. I always use the combination .mk and */
- /* .rt so once finished I just space down the heigth of the picture */
- /* that is \n(g2u */
- if (flyback) { /* end picture at upper left */
- /* ptr.x = leftpoint;
- ptr.y = toppoint; */
- } else { /* end picture at lower left */
- /* ptr.x = leftpoint;
- ptr.y = bottompoint; */
- printf(".sp \\n(g2u\n");
- }
-
- /* tmove(&ptr); */ /* restore default line parameters */
-
- /* restore everything to the way it was before the .GS, then put */
- /* out the `.GE' line from user */
-
- /* printf("\\D't %du'\\D's %du'\n", DEFTHICK, DEFSTYLE); */
- /* groff doesn't understand the \Ds command */
-
- printf("\\D't %du'\n", DEFTHICK);
- if (flyback) /* make sure we end up at top of */
- printf(".sp -1\n"); /* picture if `flying back' */
- if (stipple) /* restore stipple to previous */
- printf(".st\n");
- printf(".br\n"
- ".ft \\n(g3\n"
- ".ps \\n(g4\n"
- "%s", inputline);
- } else
- interpret(inputline); /* take commands from the input file */
- } while (!done);
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: savestate ( )
- |
- | Results: all the current scaling / font size / font name / thickness
- | / pointscale settings are saved to be the defaults. Scaled
- | point sizes are NOT saved. The scaling is done each time a
- | new picture is started.
- |
- | Side Efct: scale, and def* are modified.
- *----------------------------------------------------------------------------*/
-
-void
-savestate()
-{
- register int i;
-
- for (i = 0; i < STYLES; i++) /* line thickness defaults */
- defthick[i] = thick[i];
- for (i = 0; i < FONTS; i++) /* font name defaults */
- deffont[i] = tfont[i];
- for (i = 0; i < SIZES; i++) /* font size defaults */
- defsize[i] = tsize[i];
- for (i = 0; i <= NSTIPPLES; i++) /* stipple font file default indices */
- defstipple_index[i] = stipple_index[i];
-
- defstipple = stipple; /* if stipple has been set, it's remembered */
- scale *= xscale; /* default scale of individual pictures */
- defpoint = pointscale; /* flag for scaling pointsizes from x factors */
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: savebounds (x_coordinate, y_coordinate)
- |
- | Results: Keeps track of the maximum and minimum extent of a picture
- | in the global variables: left-, right-, top- and
- | bottompoint. `savebounds' assumes that the points have been
- | oriented to the correct direction. No scaling has taken
- | place, though.
- *----------------------------------------------------------------------------*/
-
-void
-savebounds(double x,
- double y)
-{
- if (x < leftpoint)
- leftpoint = x;
- if (x > rightpoint)
- rightpoint = x;
- if (y < toppoint)
- toppoint = y;
- if (y > bottompoint)
- bottompoint = y;
-}
-
-
-/*----------------------------------------------------------------------------*
- | Routine: interpret (character_string)
- |
- | Results: Commands are taken from the input string and performed.
- | Commands are separated by the endofline, and are of the
- | format:
- | string1 string2
- |
- | where string1 is the command and string2 is the argument.
- |
- | Side Efct: Font and size strings, plus the gremlin file name and the
- | width and height variables are set by this routine.
- *----------------------------------------------------------------------------*/
-
-void
-interpret(char *line)
-{
- char str1[MAXINLINE];
- char str2[MAXINLINE];
- register char *chr;
- register int i;
- double par;
-
- str2[0] = '\0';
- sscanf(line, "%80s%80s", &str1[0], &str2[0]);
- for (chr = &str1[0]; *chr; chr++) /* convert command to */
- if (isupper(*chr))
- *chr = tolower(*chr); /* lower case */
-
- switch (str1[0]) {
-
- case '1':
- case '2': /* font sizes */
- case '3':
- case '4':
- i = atoi(str2);
- if (i > 0 && i < 1000)
- tsize[str1[0] - '1'] = i;
- else
- error("bad font size value at line %1", linenum);
- break;
-
- case 'r': /* roman */
- if (str2[0] < '0')
- goto nofont;
- tfont[0] = (char *) malloc(strlen(str2) + 1);
- strcpy(tfont[0], str2);
- break;
-
- case 'i': /* italics */
- if (str2[0] < '0')
- goto nofont;
- tfont[1] = (char *) malloc(strlen(str2) + 1);
- strcpy(tfont[1], str2);
- break;
-
- case 'b': /* bold */
- if (str2[0] < '0')
- goto nofont;
- tfont[2] = (char *) malloc(strlen(str2) + 1);
- strcpy(tfont[2], str2);
- break;
-
- case 's': /* special */
- if (str1[1] == 'c')
- goto scalecommand; /* or scale */
-
- if (str2[0] < '0') {
- nofont:
- error("no fontname specified in line %1", linenum);
- break;
- }
- if (str1[1] == 't')
- goto stipplecommand; /* or stipple */
-
- tfont[3] = (char *) malloc(strlen(str2) + 1);
- strcpy(tfont[3], str2);
- break;
-
- case 'l': /* l */
- if (isdigit(str1[1])) { /* set stipple index */
- int idx = atoi(str1 + 1), val;
-
- if (idx < 0 || idx > NSTIPPLES) {
- error("bad stipple number %1 at line %2", idx, linenum);
- break;
- }
- if (!defstipple_index)
- defstipple_index = other_stipple_index;
- val = atoi(str2);
- if (val >= 0 && val < 256)
- stipple_index[idx] = val;
- else
- error("bad stipple index value at line %1", linenum);
- break;
- }
-
- stipplecommand: /* set stipple name */
- stipple = (char *) malloc(strlen(str2) + 1);
- strcpy(stipple, str2);
- /* if its a `known' font (currently only `cf'), set indicies */
- if (strcmp(stipple, "cf") == 0)
- defstipple_index = cf_stipple_index;
- else
- defstipple_index = other_stipple_index;
- for (i = 0; i <= NSTIPPLES; i++)
- stipple_index[i] = defstipple_index[i];
- break;
-
- case 'a': /* text adjust */
- par = atof(str2);
- switch (str1[1]) {
- case '1':
- adj1 = par;
- break;
- case '2':
- adj2 = par;
- break;
- case '3':
- adj3 = par;
- break;
- case '4':
- adj4 = par;
- break;
- default:
- error("bad adjust command at line %1", linenum);
- break;
- }
- break;
-
- case 't': /* thick */
- thick[2] = defthick[0] * atof(str2);
- break;
-
- case 'm': /* medium */
- thick[5] = defthick[0] * atof(str2);
- break;
-
- case 'n': /* narrow */
- thick[0] = thick[1] = thick[3] = thick[4] =
- defthick[0] * atof(str2);
- break;
-
- case 'x': /* x */
- scalecommand: /* scale */
- par = atof(str2);
- if (par > 0.0)
- xscale *= par;
- else
- error("invalid scale value on line %1", linenum);
- break;
-
- case 'f': /* file */
- strcpy(gremlinfile, str2);
- break;
-
- case 'w': /* width */
- width = atof(str2);
- if (width < 0.0)
- width = -width;
- break;
-
- case 'h': /* height */
- height = atof(str2);
- if (height < 0.0)
- height = -height;
- break;
-
- case 'd': /* defaults */
- setdefault = 1;
- break;
-
- case 'p': /* pointscale */
- if (strcmp("off", str2))
- pointscale = 1;
- else
- pointscale = 0;
- break;
-
- default:
- error("unknown command `%1' on line %2", str1, linenum);
- exit(8);
- break;
- };
-}
-
-
-/*
- * return TRUE if picture contains a polygon
- * otherwise FALSE
- */
-
-int
-has_polygon(register ELT *elist)
-{
- while (!DBNullelt(elist)) {
- if (elist->type == POLYGON)
- return (1);
- elist = DBNextElt(elist);
- }
-
- return (0);
-}
-
-/* EOF */
diff --git a/contrib/groff/src/preproc/html/Makefile.sub b/contrib/groff/src/preproc/html/Makefile.sub
deleted file mode 100644
index 0763537a94e6..000000000000
--- a/contrib/groff/src/preproc/html/Makefile.sub
+++ /dev/null
@@ -1,7 +0,0 @@
-PROG=pre-grohtml$(EXEEXT)
-# MAN1=pre-grohtml.n
-MAN1=
-XLIBS=$(LIBGROFF)
-MLIB=$(LIBM)
-OBJS=pre-html.$(OBJEXT) pushback.$(OBJEXT)
-CCSRCS=$(srcdir)/pre-html.cpp $(srcdir)/pushback.cpp
diff --git a/contrib/groff/src/preproc/html/pre-html.cpp b/contrib/groff/src/preproc/html/pre-html.cpp
deleted file mode 100644
index 6f8a46aee0fc..000000000000
--- a/contrib/groff/src/preproc/html/pre-html.cpp
+++ /dev/null
@@ -1,1779 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
- Written by Gaius Mulley (gaius@glam.ac.uk).
-
-This file is part of groff.
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#define PREHTMLC
-
-#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 "defs.h"
-#include "searchpath.h"
-#include "paper.h"
-#include "device.h"
-#include "font.h"
-
-#include <errno.h>
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef _POSIX_VERSION
-# include <sys/wait.h>
-# define PID_T pid_t
-#else /* not _POSIX_VERSION */
-# define PID_T int
-#endif /* not _POSIX_VERSION */
-
-#include <stdarg.h>
-
-#include "nonposix.h"
-
-/* Establish some definitions to facilitate discrimination between
- differing runtime environments. */
-
-#undef MAY_FORK_CHILD_PROCESS
-#undef MAY_SPAWN_ASYNCHRONOUS_CHILD
-
-#if defined(__MSDOS__) || defined(_WIN32)
-
-// Most MS-DOS and Win32 environments will be missing the `fork' capability
-// (some like Cygwin have it, but it is best avoided).
-
-# define MAY_FORK_CHILD_PROCESS 0
-
-// On these systems, we use `spawn...', instead of `fork' ... `exec...'.
-# include <process.h> // for `spawn...'
-# include <fcntl.h> // for attributes of pipes
-
-# if defined(__CYGWIN__) || defined(_UWIN) || defined(_WIN32)
-
-// These Win32 implementations allow parent and `spawn...'ed child to
-// multitask asynchronously.
-
-# define MAY_SPAWN_ASYNCHRONOUS_CHILD 1
-
-# else
-
-// Others may adopt MS-DOS behaviour where parent must sleep,
-// from `spawn...' until child terminates.
-
-# define MAY_SPAWN_ASYNCHRONOUS_CHILD 0
-
-# endif /* not defined __CYGWIN__, _UWIN, or _WIN32 */
-
-# if defined(DEBUGGING) && !defined(DEBUG_FILE_DIR)
-/* When we are building a DEBUGGING version we need to tell pre-grohtml
- where to put intermediate files (the DEBUGGING version will preserve
- these on exit).
-
- On a UNIX host, we might simply use `/tmp', but MS-DOS and Win32 will
- probably not have this on all disk drives, so default to using
- `c:/temp' instead. (Note that user may choose to override this by
- supplying a definition such as
-
- -DDEBUG_FILE_DIR=d:/path/to/debug/files
-
- in the CPPFLAGS to `make'.) */
-
-# define DEBUG_FILE_DIR c:/temp
-# endif
-
-#else /* not __MSDOS__ or _WIN32 */
-
-// For non-Microsoft environments assume UNIX conventions,
-// so `fork' is required and child processes are asynchronous.
-# define MAY_FORK_CHILD_PROCESS 1
-# define MAY_SPAWN_ASYNCHRONOUS_CHILD 1
-
-# if defined(DEBUGGING) && !defined(DEBUG_FILE_DIR)
-/* For a DEBUGGING version, on the UNIX host, we can also usually rely
- on being able to use `/tmp' for temporary file storage. (Note that,
- as in the __MSDOS__ or _WIN32 case above, the user may override this
- by defining
-
- -DDEBUG_FILE_DIR=/path/to/debug/files
-
- in the CPPFLAGS.) */
-
-# define DEBUG_FILE_DIR /tmp
-# endif
-
-#endif /* not __MSDOS__ or _WIN32 */
-
-#ifdef DEBUGGING
-// For a DEBUGGING version, we need some additional macros,
-// to direct the captured debug mode output to appropriately named files
-// in the specified DEBUG_FILE_DIR.
-
-# define DEBUG_TEXT(text) #text
-# define DEBUG_NAME(text) DEBUG_TEXT(text)
-# define DEBUG_FILE(name) DEBUG_NAME(DEBUG_FILE_DIR) "/" name
-#endif
-
-extern "C" const char *Version_string;
-
-#include "pre-html.h"
-#include "pushback.h"
-#include "html-strings.h"
-
-#define DEFAULT_LINE_LENGTH 7 // inches wide
-#define DEFAULT_IMAGE_RES 100 // number of pixels per inch resolution
-#define IMAGE_BOARDER_PIXELS 0
-#define INLINE_LEADER_CHAR '\\'
-
-// Don't use colour names here! Otherwise there is a dependency on
-// a file called `rgb.txt' which maps names to colours.
-#define TRANSPARENT "-background rgb:f/f/f -transparent rgb:f/f/f"
-#define MIN_ALPHA_BITS 0
-#define MAX_ALPHA_BITS 4
-
-#define PAGE_TEMPLATE_SHORT "pg"
-#define PAGE_TEMPLATE_LONG "-page-"
-#define PS_TEMPLATE_SHORT "ps"
-#define PS_TEMPLATE_LONG "-ps-"
-#define REGION_TEMPLATE_SHORT "rg"
-#define REGION_TEMPLATE_LONG "-regions-"
-
-#if 0
-# define DEBUGGING
-#endif
-
-#if !defined(TRUE)
-# define TRUE (1==1)
-#endif
-#if !defined(FALSE)
-# define FALSE (1==0)
-#endif
-
-typedef enum {
- CENTERED, LEFT, RIGHT, INLINE
-} IMAGE_ALIGNMENT;
-
-static int postscriptRes = -1; // postscript resolution,
- // dots per inch
-static int stdoutfd = 1; // output file descriptor -
- // normally 1 but might move
- // -1 means closed
-static char *psFileName = NULL; // name of postscript file
-static char *psPageName = NULL; // name of file containing
- // postscript current page
-static char *regionFileName = NULL; // name of file containing all
- // image regions
-static char *imagePageName = NULL; // name of bitmap image containing
- // current page
-static const char *image_device = "pnmraw";
-static int image_res = DEFAULT_IMAGE_RES;
-static int vertical_offset = 0;
-static char *image_template = NULL; // image template filename
-static char *macroset_template= NULL; // image template passed to troff
- // by -D
-static int troff_arg = 0; // troff arg index
-static char *image_dir = NULL; // user specified image directory
-static int textAlphaBits = MAX_ALPHA_BITS;
-static int graphicAlphaBits = MAX_ALPHA_BITS;
-static char *antiAlias = NULL; // antialias arguments we pass to gs
-static int show_progress = FALSE; // should we display page numbers as
- // they are processed?
-static int currentPageNo = -1; // current image page number
-#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;
-static const char *image_gen = NULL; // the `gs' program
-
-const char *const FONT_ENV_VAR = "GROFF_FONT_PATH";
-static search_path font_path(FONT_ENV_VAR, FONTPATH, 0, 0);
-
-
-/*
- * Images are generated via postscript, gs, and the pnm utilities.
- */
-#define IMAGE_DEVICE "-Tps"
-
-
-static int do_file(const char *filename);
-
-
-/*
- * sys_fatal - Write a fatal error message.
- * Taken from src/roff/groff/pipeline.c.
- */
-
-void sys_fatal(const char *s)
-{
- fatal("%1: %2", s, strerror(errno));
-}
-
-/*
- * get_line - Copy 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 - Return 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);
- a_delete 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
- // portable than using "2> /dev/null", since it doesn't require a
- // Unixy shell.
- int save_stderr = dup(2);
- int save_stdout = dup(1);
- int fdnull = open(NULL_DEV, O_WRONLY|O_BINARY, 0666);
- if (save_stderr > 2 && fdnull > 2)
- dup2(fdnull, 2);
- if (redirect_stdout && save_stdout > 1 && fdnull > 1)
- dup2(fdnull, 1);
- if (fdnull >= 0)
- close(fdnull);
- int status = system(s);
- dup2(save_stderr, 2);
- if (redirect_stdout)
- dup2(save_stdout, 1);
- if (status == -1)
- 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);
-}
-
-/*
- * make_message - Create a string via malloc and place the result of the
- * va args into string. Finally the new string is returned.
- * Taken from man page of printf(3).
- */
-
-char *make_message(const char *fmt, ...)
-{
- /* Guess we need no more than 100 bytes. */
- int n, size = 100;
- char *p;
- char *np;
- va_list ap;
- if ((p = (char *)malloc(size)) == NULL)
- return NULL;
- while (1) {
- /* Try to print in the allocated space. */
- va_start(ap, fmt);
- n = vsnprintf(p, size, fmt, ap);
- va_end(ap);
- /* If that worked, return the string. */
- if (n > -1 && n < size - 1) { /* glibc 2.1 and pre-ANSI C 99 */
- if (size > n + 1) {
- np = strsave(p);
- free(p);
- return np;
- }
- return p;
- }
- /* Else try again with more space. */
- else /* glibc 2.0 */
- size *= 2; /* twice the old size */
- if ((np = (char *)realloc(p, size)) == NULL) {
- free(p); /* realloc failed, free old, p. */
- return NULL;
- }
- p = np; /* use realloc'ed, p */
- }
-}
-
-/*
- * the class and methods for retaining ascii text
- */
-
-struct char_block {
- enum { SIZE = 256 };
- char buffer[SIZE];
- int used;
- char_block *next;
-
- char_block();
-};
-
-/*
- * char_block - Constructor. Set the, used, and, next, fields to zero.
- */
-
-char_block::char_block()
-: used(0), next(0)
-{
- for (int i = 0; i < SIZE; i++)
- buffer[i] = 0;
-}
-
-class char_buffer {
-public:
- char_buffer();
- ~char_buffer();
- int read_file(FILE *fp);
- int do_html(int argc, char *argv[]);
- int do_image(int argc, char *argv[]);
- void emit_troff_output(int device_format_selector);
- void write_upto_newline(char_block **t, int *i, int is_html);
- int can_see(char_block **t, int *i, const char *string);
- int skip_spaces(char_block **t, int *i);
- void skip_until_newline(char_block **t, int *i);
-private:
- char_block *head;
- char_block *tail;
- int run_output_filter(int device_format_selector, int argc, char *argv[]);
-};
-
-/*
- * char_buffer - Constructor.
- */
-
-char_buffer::char_buffer()
-: head(0), tail(0)
-{
-}
-
-/*
- * char_buffer - Destructor. Throw away the whole buffer list.
- */
-
-char_buffer::~char_buffer()
-{
- while (head != NULL) {
- char_block *temp = head;
- head = head->next;
- delete temp;
- }
-}
-
-/*
- * read_file - Read in a complete file, fp, placing the contents inside
- * char_blocks.
- */
-
-int char_buffer::read_file(FILE *fp)
-{
- int n;
- while (!feof(fp)) {
- if (tail == NULL) {
- tail = new char_block;
- head = tail;
- }
- else {
- if (tail->used == char_block::SIZE) {
- tail->next = new char_block;
- tail = tail->next;
- }
- }
- // at this point we have a tail which is ready for the next SIZE
- // bytes of the file
- n = fread(tail->buffer, sizeof(char), char_block::SIZE-tail->used, fp);
- if (n <= 0)
- // error
- return 0;
- else
- tail->used += n * sizeof(char);
- }
- return 1;
-}
-
-/*
- * writeNbytes - Write n bytes to stdout.
- */
-
-static void writeNbytes(const char *s, int l)
-{
- int n = 0;
- int r;
-
- while (n < l) {
- r = write(stdoutfd, s, l - n);
- if (r < 0)
- sys_fatal("write");
- n += r;
- s += r;
- }
-}
-
-/*
- * writeString - Write a string to stdout.
- */
-
-static void writeString(const char *s)
-{
- writeNbytes(s, strlen(s));
-}
-
-/*
- * makeFileName - Create the image filename template
- * and the macroset image template.
- */
-
-static void makeFileName(void)
-{
- if ((image_dir != NULL) && (strchr(image_dir, '%') != NULL)) {
- error("cannot use a `%%' within the image directory name");
- exit(1);
- }
-
- if ((image_template != NULL) && (strchr(image_template, '%') != NULL)) {
- error("cannot use a `%%' within the image template");
- exit(1);
- }
-
- if (image_dir == NULL)
- image_dir = (char *)"";
- else if (strlen(image_dir) > 0
- && image_dir[strlen(image_dir) - 1] != '/') {
- image_dir = make_message("%s/", image_dir);
- if (image_dir == NULL)
- sys_fatal("make_message");
- }
-
- if (image_template == NULL)
- macroset_template = make_message("%sgrohtml-%d", image_dir,
- (int)getpid());
- else
- macroset_template = make_message("%s%s", image_dir, image_template);
-
- if (macroset_template == NULL)
- sys_fatal("make_message");
-
- image_template =
- (char *)malloc(strlen("-%d") + strlen(macroset_template) + 1);
- if (image_template == NULL)
- sys_fatal("malloc");
- strcpy(image_template, macroset_template);
- strcat(image_template, "-%d");
-}
-
-/*
- * setupAntiAlias - Set 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);
-}
-
-/*
- * checkImageDir - Check whether the image directory is available.
- */
-
-static void checkImageDir(void)
-{
- if (image_dir != NULL && strcmp(image_dir, "") != 0)
- if (!(mkdir(image_dir, 0777) == 0 || errno == EEXIST)) {
- error("cannot create directory `%1'", image_dir);
- exit(1);
- }
-}
-
-/*
- * write_end_image - End the image. Write out the image extents if we
- * are using -Tps.
- */
-
-static void write_end_image(int is_html)
-{
- /*
- * 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]");
-}
-
-/*
- * write_start_image - Write troff code which will:
- *
- * (i) disable html output for the following image
- * (ii) reset the max/min x/y registers during postscript
- * rendering.
- */
-
-static void write_start_image(IMAGE_ALIGNMENT pos, int is_html)
-{
- 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;
- }
- writeString(image_template);
- writeString(".png]");
- if (is_html)
- writeString("\\O[0]\\O[3]");
- else
- // reset min/max registers
- writeString("\\O[1]\\O[3]");
-}
-
-/*
- * write_upto_newline - Write the contents of the buffer until a newline
- * is seen. Check for HTML_IMAGE_INLINE_BEGIN and
- * HTML_IMAGE_INLINE_END; process them if they are
- * present.
- */
-
-void char_buffer::write_upto_newline(char_block **t, int *i, int is_html)
-{
- int j = *i;
-
- if (*t) {
- while (j < (*t)->used
- && (*t)->buffer[j] != '\n'
- && (*t)->buffer[j] != INLINE_LEADER_CHAR)
- j++;
- if (j < (*t)->used
- && (*t)->buffer[j] == '\n')
- j++;
- writeNbytes((*t)->buffer + (*i), j - (*i));
- if ((*t)->buffer[j] == INLINE_LEADER_CHAR) {
- if (can_see(t, &j, HTML_IMAGE_INLINE_BEGIN))
- write_start_image(INLINE, is_html);
- else if (can_see(t, &j, HTML_IMAGE_INLINE_END))
- write_end_image(is_html);
- else {
- if (j < (*t)->used) {
- *i = j;
- j++;
- writeNbytes((*t)->buffer + (*i), j - (*i));
- }
- }
- }
- if (j == (*t)->used) {
- *i = 0;
- *t = (*t)->next;
- if (*t && (*t)->buffer[j - 1] != '\n')
- write_upto_newline(t, i, is_html);
- }
- else
- // newline was seen
- *i = j;
- }
-}
-
-/*
- * can_see - Return TRUE if we can see string in t->buffer[i] onwards.
- */
-
-int char_buffer::can_see(char_block **t, int *i, const char *str)
-{
- int j = 0;
- int l = strlen(str);
- int k = *i;
- char_block *s = *t;
-
- while (s) {
- while (k < s->used && j < l && s->buffer[k] == str[j]) {
- j++;
- k++;
- }
- if (j == l) {
- *i = k;
- *t = s;
- return TRUE;
- }
- else if (k < s->used && s->buffer[k] != str[j])
- return( FALSE );
- s = s->next;
- k = 0;
- }
- return FALSE;
-}
-
-/*
- * skip_spaces - Return TRUE if we have not run out of data.
- * Consume spaces also.
- */
-
-int char_buffer::skip_spaces(char_block **t, int *i)
-{
- char_block *s = *t;
- int k = *i;
-
- while (s) {
- while (k < s->used && isspace(s->buffer[k]))
- k++;
- if (k == s->used) {
- k = 0;
- s = s->next;
- }
- else {
- *i = k;
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/*
- * skip_until_newline - Skip all characters until a newline is seen.
- * The newline is not consumed.
- */
-
-void char_buffer::skip_until_newline(char_block **t, int *i)
-{
- int j = *i;
-
- if (*t) {
- while (j < (*t)->used && (*t)->buffer[j] != '\n')
- j++;
- if (j == (*t)->used) {
- *i = 0;
- *t = (*t)->next;
- skip_until_newline(t, i);
- }
- else
- // newline was seen
- *i = j;
- }
-}
-
-#define DEVICE_FORMAT(filter) (filter == HTML_OUTPUT_FILTER)
-#define HTML_OUTPUT_FILTER 0
-#define IMAGE_OUTPUT_FILTER 1
-#define OUTPUT_STREAM(name) creat((name), S_IWUSR | S_IRUSR)
-#define PS_OUTPUT_STREAM OUTPUT_STREAM(psFileName)
-#define REGION_OUTPUT_STREAM OUTPUT_STREAM(regionFileName)
-
-/*
- * emit_troff_output - Write formatted buffer content to the troff
- * post-processor data pipeline.
- */
-
-void char_buffer::emit_troff_output(int device_format_selector)
-{
- // Handle output for BOTH html and image device formats
- // if `device_format_selector' is passed as
- //
- // HTML_FORMAT(HTML_OUTPUT_FILTER)
- // Buffer data is written to the output stream
- // with template image names translated to actual image names.
- //
- // HTML_FORMAT(IMAGE_OUTPUT_FILTER)
- // Buffer data is written to the output stream
- // with no translation, for image file creation in the post-processor.
-
- int idx = 0;
- char_block *element = head;
-
- while (element != NULL)
- write_upto_newline(&element, &idx, device_format_selector);
-
-#if 0
- if (close(stdoutfd) < 0)
- sys_fatal ("close");
-
- // now we grab fd=1 so that the next pipe cannot use fd=1
- if (stdoutfd == 1) {
- if (dup(2) != stdoutfd)
- sys_fatal ("dup failed to use fd=1");
- }
-#endif /* 0 */
-}
-
-/*
- * The image class remembers the position of all images in the
- * postscript file and assigns names for each image.
- */
-
-struct imageItem {
- imageItem *next;
- int X1;
- int Y1;
- int X2;
- int Y2;
- char *imageName;
- int resolution;
- int maxx;
- int pageNo;
-
- imageItem(int x1, int y1, int x2, int y2,
- int page, int res, int max_width, char *name);
- ~imageItem();
-};
-
-/*
- * imageItem - Constructor.
- */
-
-imageItem::imageItem(int x1, int y1, int x2, int y2,
- int page, int res, int max_width, char *name)
-{
- X1 = x1;
- Y1 = y1;
- X2 = x2;
- Y2 = y2;
- pageNo = page;
- resolution = res;
- maxx = max_width;
- imageName = name;
- next = NULL;
-}
-
-/*
- * imageItem - Destructor.
- */
-
-imageItem::~imageItem()
-{
- if (imageName)
- free(imageName);
-}
-
-/*
- * imageList - A class containing a list of imageItems.
- */
-
-class imageList {
-private:
- imageItem *head;
- imageItem *tail;
- int count;
-public:
- imageList();
- ~imageList();
- void add(int x1, int y1, int x2, int y2,
- int page, int res, int maxx, char *name);
- void createImages(void);
- int createPage(int pageno);
- void createImage(imageItem *i);
- int getMaxX(int pageno);
-};
-
-/*
- * imageList - Constructor.
- */
-
-imageList::imageList()
-: head(0), tail(0), count(0)
-{
-}
-
-/*
- * imageList - Destructor.
- */
-
-imageList::~imageList()
-{
- while (head != NULL) {
- imageItem *i = head;
- head = head->next;
- delete i;
- }
-}
-
-/*
- * createPage - Create one image of, page pageno, from the postscript file.
- */
-
-int imageList::createPage(int pageno)
-{
- char *s;
-
- if (currentPageNo == pageno)
- return 0;
-
- 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 | "
- "%s%s -q -dBATCH -dSAFER "
- "-dDEVICEHEIGHTPOINTS=792 "
- "-dDEVICEWIDTHPOINTS=%d -dFIXEDMEDIA=true "
- "-sDEVICE=%s -r%d %s "
- "-sOutputFile=%s %s -\n",
- image_gen,
- EXE_EXT,
- (getMaxX(pageno) * image_res) / postscriptRes,
- image_device,
- image_res,
- antiAlias,
- imagePageName,
- 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);
- free(s);
- currentPageNo = pageno;
- return 0;
-}
-
-/*
- * min - Return the minimum of two numbers.
- */
-
-int min(int x, int y)
-{
- if (x < y)
- return x;
- else
- return y;
-}
-
-/*
- * max - Return the maximum of two numbers.
- */
-
-int max(int x, int y)
-{
- if (x > y)
- return x;
- else
- return y;
-}
-
-/*
- * getMaxX - Return 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 - Generate a minimal png file from the set of page images.
- */
-
-void imageList::createImage(imageItem *i)
-{
- if (i->X1 != -1) {
- char *s;
- int x1 = max(min(i->X1, i->X2) * image_res / postscriptRes
- - IMAGE_BOARDER_PIXELS,
- 0);
- int y1 = max(image_res * vertical_offset / 72
- + min(i->Y1, i->Y2) * image_res / postscriptRes
- - IMAGE_BOARDER_PIXELS,
- 0);
- int x2 = max(i->X1, i->X2) * image_res / postscriptRes
- + IMAGE_BOARDER_PIXELS;
- int y2 = image_res * vertical_offset / 72
- + max(i->Y1, i->Y2) * image_res / postscriptRes
- + 1 + IMAGE_BOARDER_PIXELS;
- if (createPage(i->pageNo) == 0) {
- s = make_message("pnmcut%s %d %d %d %d < %s "
- "| pnmcrop -quiet | pnmtopng%s %s > %s\n",
- 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)
- if (debug) {
- fprintf(stderr, s);
- fflush(stderr);
- }
-#endif
- html_system(s, 0);
- free(s);
- }
- else {
- fprintf(stderr, "failed to generate image of page %d\n", i->pageNo);
- fflush(stderr);
- }
-#if defined(DEBUGGING)
- }
- else {
- if (debug) {
- fprintf(stderr, "ignoring image as x1 coord is -1\n");
- fflush(stderr);
- }
-#endif
- }
-}
-
-/*
- * add - Add an image description to the imageList.
- */
-
-void imageList::add(int x1, int y1, int x2, int y2,
- int page, int res, int maxx, char *name)
-{
- imageItem *i = new imageItem(x1, y1, x2, y2, page, res, maxx, name);
-
- if (head == NULL) {
- head = i;
- tail = i;
- }
- else {
- tail->next = i;
- tail = i;
- }
-}
-
-/*
- * createImages - For each 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.
-
-/*
- * generateImages - Parse the region file and generate images
- * from the postscript file. The region file
- * contains the x1,y1--x2,y2 extents of each
- * image.
- */
-
-static void generateImages(char *region_file_name)
-{
- pushBackBuffer *f=new pushBackBuffer(region_file_name);
-
- while (f->putPB(f->getPB()) != eof) {
- if (f->isString("grohtml-info:page")) {
- int page = f->readInt();
- int x1 = f->readInt();
- int y1 = f->readInt();
- int x2 = f->readInt();
- int y2 = f->readInt();
- int maxx = f->readInt();
- char *name = f->readString();
- int res = postscriptRes;
- listOfImages.add(x1, y1, x2, y2, page, res, maxx, name);
- while (f->putPB(f->getPB()) != '\n'
- && f->putPB(f->getPB()) != eof)
- (void)f->getPB();
- if (f->putPB(f->getPB()) == '\n')
- (void)f->getPB();
- }
- else {
- /* Write any error messages out to the user. */
- fputc(f->getPB(), stderr);
- }
- }
-
- listOfImages.createImages();
- if (show_progress) {
- fprintf(stderr, "done\n");
- fflush(stderr);
- }
- delete f;
-}
-
-/*
- * set_redirection - Set up I/O Redirection for handle, was, to refer to
- * stream on handle, willbe.
- */
-
-static void set_redirection(int was, int willbe)
-{
- // Nothing to do if `was' and `willbe' already have same handle.
- if (was != willbe) {
- // Otherwise attempt the specified redirection.
- if (dup2 (willbe, was) < 0) {
- // Redirection failed, so issue diagnostic and bail out.
- fprintf(stderr, "failed to replace fd=%d with %d\n", was, willbe);
- if (willbe == STDOUT_FILENO)
- fprintf(stderr,
- "likely that stdout should be opened before %d\n", was);
- sys_fatal("dup2");
- }
-
- // When redirection has been successfully completed assume redundant
- // handle `willbe' is no longer required, so close it.
- if (close(willbe) < 0)
- // Issue diagnostic if `close' fails.
- sys_fatal("close");
- }
-}
-
-/*
- * save_and_redirect - Get duplicate handle for stream, was, then
- * redirect, was, to refer to, willbe.
- */
-
-static int save_and_redirect(int was, int willbe)
-{
- if (was == willbe)
- // No redirection specified so don't do anything but silently bailing out.
- return (was);
-
- // Proceeding with redirection so first save and verify our duplicate
- // handle for `was'.
- int saved = dup(was);
- if (saved < 0) {
- fprintf(stderr, "unable to get duplicate handle for %d\n", was);
- sys_fatal("dup");
- }
-
- // Duplicate handle safely established so complete redirection.
- set_redirection(was, willbe);
-
- // Finally return the saved duplicate descriptor for the
- // original `was' stream.
- return saved;
-}
-
-/*
- * alterDeviceTo - If, toImage, is set
- * the argument list is altered to include
- * IMAGE_DEVICE and we invoke groff rather than troff.
- * Else
- * set -Thtml and groff.
- */
-
-static void alterDeviceTo(int argc, char *argv[], int toImage)
-{
- int i = 0;
-
- if (toImage) {
- while (i < argc) {
- if (strcmp(argv[i], "-Thtml") == 0)
- argv[i] = (char *)IMAGE_DEVICE;
- i++;
- }
- argv[troff_arg] = (char *)"groff"; /* rather than troff */
- }
- else {
- while (i < argc) {
- if (strcmp(argv[i], IMAGE_DEVICE) == 0)
- argv[i] = (char *)"-Thtml";
- i++;
- }
- argv[troff_arg] = (char *)"groff"; /* use groff -Z */
- }
-}
-
-/*
- * addZ - Append -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] = (char *)"-Z";
- while (i < argc) {
- new_argv[i + 1] = argv[i];
- i++;
- }
- argc++;
- new_argv[argc] = NULL;
- return new_argv;
-}
-
-/*
- * addRegDef - Append 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] = strsave(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");
-}
-
-int char_buffer::run_output_filter(int filter, int /* argc */, char **argv)
-{
- int pipedes[2];
- PID_T child_pid;
- int status;
-
- if (pipe(pipedes) < 0)
- sys_fatal("pipe");
-
-#if MAY_FORK_CHILD_PROCESS
- // This is the UNIX process model. To invoke our post-processor,
- // we must `fork' the current process.
-
- if ((child_pid = fork()) < 0)
- sys_fatal("fork");
-
- else if (child_pid == 0) {
- // This is the child process fork. We redirect its `stdin' stream
- // to read data emerging from our pipe. There is no point in saving,
- // since we won't be able to restore later!
-
- set_redirection(STDIN_FILENO, pipedes[0]);
-
- // The parent process will be writing this data, so we should release
- // the child's writeable handle on the pipe, since we have no use for it.
-
- if (close(pipedes[1]) < 0)
- sys_fatal("close");
-
- // The IMAGE_OUTPUT_FILTER needs special output redirection...
-
- if (filter == IMAGE_OUTPUT_FILTER) {
- // with BOTH `stdout' AND `stderr' diverted to files.
-
- set_redirection(STDOUT_FILENO, PS_OUTPUT_STREAM);
- set_redirection(STDERR_FILENO, REGION_OUTPUT_STREAM);
- }
-
- // Now we are ready to launch the output filter.
-
- execvp(argv[0], argv);
-
- // If we get to here then the `exec...' request for the output filter
- // failed. Diagnose it and bail out.
-
- error("couldn't exec %1: %2", argv[0], strerror(errno), ((char *)0));
- fflush(stderr); // just in case error() didn't
- exit(1);
- }
-
- else {
- // This is the parent process fork. We will be writing data to the
- // filter pipeline, and the child will be reading it. We have no further
- // use for our read handle on the pipe, and should close it.
-
- if (close(pipedes[0]) < 0)
- sys_fatal("close");
-
- // Now we redirect the `stdout' stream to the inlet end of the pipe,
- // and push out the appropiately formatted data to the filter.
-
- pipedes[1] = save_and_redirect(STDOUT_FILENO, pipedes[1]);
- emit_troff_output(DEVICE_FORMAT(filter));
-
- // After emitting all the data we close our connection to the inlet
- // end of the pipe so the child process will detect end of data.
-
- set_redirection(STDOUT_FILENO, pipedes[1]);
-
- // Finally, we must wait for the child process to complete.
-
- if (WAIT(&status, child_pid, _WAIT_CHILD) != child_pid)
- sys_fatal("wait");
- }
-
-#elif MAY_SPAWN_ASYNCHRONOUS_CHILD
-
- // We do not have `fork', (or we prefer not to use it),
- // but asynchronous processes are allowed, passing data through pipes.
- // This should be ok for most Win32 systems and is preferred to `fork'
- // for starting child processes under Cygwin.
-
- // Before we start the post-processor we bind its inherited `stdin'
- // stream to the readable end of our pipe, saving our own `stdin' stream
- // in `pipedes[0]'.
-
- pipedes[0] = save_and_redirect(STDIN_FILENO, pipedes[0]);
-
- // for the Win32 model,
- // we need special provision for saving BOTH `stdout' and `stderr'.
-
- int saved_stdout = dup(STDOUT_FILENO);
- int saved_stderr = STDERR_FILENO;
-
- // The IMAGE_OUTPUT_FILTER needs special output redirection...
-
- if (filter == IMAGE_OUTPUT_FILTER) {
- // with BOTH `stdout' AND `stderr' diverted to files while saving a
- // duplicate handle for `stderr'.
-
- set_redirection(STDOUT_FILENO, PS_OUTPUT_STREAM);
- saved_stderr = save_and_redirect(STDERR_FILENO, REGION_OUTPUT_STREAM);
- }
-
- // We then use an asynchronous spawn request to start the post-processor.
-
- if ((child_pid = spawnvp(_P_NOWAIT, argv[0], argv)) < 0) {
- // Should the spawn request fail we issue a diagnostic and bail out.
-
- error("cannot spawn %1: %2", argv[0], strerror(errno), ((char *)0));
- exit(1);
- }
-
- // Once the post-processor has been started we revert our `stdin'
- // to its original saved source, which also closes the readable handle
- // for the pipe.
-
- set_redirection(STDIN_FILENO, pipedes[0]);
-
- // if we redirected `stderr', for use by the image post-processor,
- // then we also need to reinstate its original assignment.
-
- if (filter == IMAGE_OUTPUT_FILTER)
- set_redirection(STDERR_FILENO, saved_stderr);
-
- // Now we redirect the `stdout' stream to the inlet end of the pipe,
- // and push out the appropiately formatted data to the filter.
-
- set_redirection(STDOUT_FILENO, pipedes[1]);
- emit_troff_output(DEVICE_FORMAT(filter));
-
- // After emitting all the data we close our connection to the inlet
- // end of the pipe so the child process will detect end of data.
-
- set_redirection(STDOUT_FILENO, saved_stdout);
-
- // And finally, we must wait for the child process to complete.
-
- if (WAIT(&status, child_pid, _WAIT_CHILD) != child_pid)
- sys_fatal("wait");
-
-#else /* can't do asynchronous pipes! */
-
- // TODO: code to support an MS-DOS style process model
- // should go here
-
-#endif /* MAY_FORK_CHILD_PROCESS or MAY_SPAWN_ASYNCHRONOUS_CHILD */
-
- return 0;
-}
-
-/*
- * do_html - Set the troff number htmlflip and
- * write out the buffer to troff -Thtml.
- */
-
-int char_buffer::do_html(int argc, char *argv[])
-{
- string s;
-
- alterDeviceTo(argc, argv, 0);
- 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 defined(DEBUGGING)
-# define HTML_DEBUG_STREAM OUTPUT_STREAM(htmlFileName)
- // slight security risk so only enabled if compiled with defined(DEBUGGING)
- if (debug) {
- int saved_stdout = save_and_redirect(STDOUT_FILENO, HTML_DEBUG_STREAM);
- emit_troff_output(DEVICE_FORMAT(HTML_OUTPUT_FILTER));
- set_redirection(STDOUT_FILENO, saved_stdout);
- }
-#endif
-
- return run_output_filter(HTML_OUTPUT_FILTER, argc, argv);
-}
-
-/*
- * do_image - Write out the buffer to troff -Tps.
- */
-
-int char_buffer::do_image(int argc, char *argv[])
-{
- string s;
-
- alterDeviceTo(argc, argv, 1);
- argv += troff_arg; // skip all arguments up to troff/groff
- argc -= troff_arg;
- 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 defined(DEBUGGING)
-# define IMAGE_DEBUG_STREAM OUTPUT_STREAM(troffFileName)
- // slight security risk so only enabled if compiled with defined(DEBUGGING)
- if (debug) {
- int saved_stdout = save_and_redirect(STDOUT_FILENO, IMAGE_DEBUG_STREAM);
- emit_troff_output(DEVICE_FORMAT(IMAGE_OUTPUT_FILTER));
- set_redirection(STDOUT_FILENO, saved_stdout);
- }
-#endif
-
- return run_output_filter(IMAGE_OUTPUT_FILTER, argc, argv);
-}
-
-static char_buffer inputFile;
-
-/*
- * usage - Emit usage arguments.
- */
-
-static void usage(FILE *stream)
-{
- fprintf(stream,
- "usage: %s troffname [-Iimage_name] [-Dimage_directory]\n"
- " [-P-o vertical_image_offset] [-P-i image_resolution]\n"
- " [troff flags]\n",
- program_name);
- fprintf(stream,
- " vertical_image_offset (default %d/72 of an inch)\n",
- vertical_offset);
- fprintf(stream,
- " image_resolution (default %d) pixels per inch\n",
- image_res);
- fprintf(stream,
- " image_name is the name of the stem for all images\n"
- " (default is grohtml-<pid>)\n");
- fprintf(stream,
- " place all png files into image_directory\n");
-}
-
-/*
- * scanArguments - Scan for all arguments including -P-i, -P-o, -P-D,
- * and -P-I. Return the argument index of the first
- * non-option.
- */
-
-static int scanArguments(int argc, char **argv)
-{
- 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:bdD:F:g:hi:I:j:lno:prs:S:v",
- long_options, NULL))
- != EOF)
- switch(c) {
- 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 'b':
- // handled by post-grohtml (set background color to white)
- break;
- case 'd':
-#if defined(DEBUGGING)
- debug = TRUE;
-#endif
- break;
- case 'D':
- image_dir = optarg;
- break;
- case 'F':
- font_path.command_line_dir(optarg);
- break;
- case 'g':
- graphicAlphaBits = min(max(MIN_ALPHA_BITS, atoi(optarg)),
- MAX_ALPHA_BITS);
- if (graphicAlphaBits == 3) {
- error("cannot use 3 bits of antialiasing information");
- exit(1);
- }
- break;
- case 'h':
- // handled by post-grohtml
- break;
- case 'i':
- image_res = atoi(optarg);
- break;
- case 'I':
- image_template = optarg;
- break;
- case 'j':
- // handled by post-grohtml (set job name for multiple file output)
- break;
- case 'l':
- // handled by post-grohtml (no automatic section links)
- break;
- case 'n':
- // handled by post-grohtml (generate simple heading anchors)
- break;
- case 'o':
- vertical_offset = atoi(optarg);
- break;
- case 'p':
- show_progress = TRUE;
- break;
- case 'r':
- // handled by post-grohtml (no header and footer lines)
- break;
- case 's':
- // handled by post-grohtml (use font size n as the html base font size)
- break;
- case 'S':
- // handled by post-grohtml (set file split level)
- break;
- case 'v':
- printf("GNU pre-grohtml (groff) version %s\n", Version_string);
- exit(0);
- case CHAR_MAX + 1: // --help
- usage(stdout);
- exit(0);
- 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++;
- }
- a_delete troff_name;
-
- return argc;
-}
-
-/*
- * makeTempFiles - Name the temporary files.
- */
-
-static int makeTempFiles(void)
-{
-#if defined(DEBUGGING)
- psFileName = DEBUG_FILE("prehtml-ps");
- regionFileName = DEBUG_FILE("prehtml-region");
- imagePageName = DEBUG_FILE("prehtml-page");
- psPageName = DEBUG_FILE("prehtml-psn");
- troffFileName = DEBUG_FILE("prehtml-troff");
- htmlFileName = DEBUG_FILE("prehtml-html");
-#else /* not DEBUGGING */
- FILE *f;
-
- /* psPageName contains a single page of postscript */
- f = xtmpfile(&psPageName,
- PS_TEMPLATE_LONG, PS_TEMPLATE_SHORT,
- TRUE);
- if (f == NULL) {
- sys_fatal("xtmpfile");
- return -1;
- }
- 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;
- }
- 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);
-
-#endif /* not DEBUGGING */
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- program_name = argv[0];
- int i;
- int found = 0;
- int ok = 1;
-
-#ifdef CAPTURE_MODE
- FILE *dump;
- fprintf(stderr, "%s: invoked with %d arguments ...\n", argv[0], argc);
- for (i = 0; i < argc; i++)
- fprintf(stderr, "%2d: %s\n", i, argv[i]);
- if ((dump = fopen(DEBUG_FILE("pre-html-data"), "wb")) != NULL) {
- while((i = fgetc(stdin)) >= 0)
- fputc(i, dump);
- fclose(dump);
- }
- exit(1);
-#endif /* CAPTURE_MODE */
- device = "html";
- if (!font::load_desc())
- fatal("cannot find devhtml/DESC exiting");
- image_gen = font::image_generator;
- if (image_gen == NULL || (strcmp(image_gen, "") == 0))
- fatal("devhtml/DESC must set the image_generator field, exiting");
- postscriptRes = get_resolution();
- i = scanArguments(argc, argv);
- setupAntiAlias();
- checkImageDir();
- makeFileName();
- while (i < argc) {
- if (argv[i][0] != '-') {
- /* found source file */
- ok = do_file(argv[i]);
- if (!ok)
- return 0;
- found = 1;
- }
- i++;
- }
-
- if (!found)
- do_file("-");
- if (makeTempFiles())
- return 1;
- ok = inputFile.do_image(argc, argv);
- if (ok == 0) {
- generateImages(regionFileName);
- ok = inputFile.do_html(argc, argv);
- }
- return ok;
-}
-
-static int do_file(const char *filename)
-{
- FILE *fp;
-
- current_filename = filename;
- if (strcmp(filename, "-") == 0)
- fp = stdin;
- else {
- fp = fopen(filename, "r");
- if (fp == 0) {
- error("can't open `%1': %2", filename, strerror(errno));
- return 0;
- }
- }
-
- if (inputFile.read_file(fp)) {
- // XXX
- }
-
- if (fp != stdin)
- fclose(fp);
- current_filename = NULL;
- return 1;
-}
diff --git a/contrib/groff/src/preproc/html/pre-html.h b/contrib/groff/src/preproc/html/pre-html.h
deleted file mode 100644
index 3eedb21c72bb..000000000000
--- a/contrib/groff/src/preproc/html/pre-html.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// -*- 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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-/*
- * defines functions implemented within pre-html.c
- */
-
-#if !defined(PREHTMLH)
-# define PREHTMLH
-# if defined(PREHTMLC)
-# define EXTERN
-# else
-# define EXTERN extern
-# endif
-
-
-extern void sys_fatal (const char *s);
-
-#undef EXTERN
-#endif
diff --git a/contrib/groff/src/preproc/html/pushback.cpp b/contrib/groff/src/preproc/html/pushback.cpp
deleted file mode 100644
index b71558783508..000000000000
--- a/contrib/groff/src/preproc/html/pushback.cpp
+++ /dev/null
@@ -1,329 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
- Written by Gaius Mulley (gaius@glam.ac.uk).
-
-This file is part of groff.
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, 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 ()
-{
- if (charStack != 0) {
- free(charStack);
- }
- close(0);
- /* restore stdin in file descriptor 0 */
- 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)
-{
- while ((putPB(getPB()) != '\n') && (! eofFound)) {
- 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 (const 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 double convertToFloat (int a, int b)
-{
- int c=10;
- double f;
-
- while (b>c) {
- c *= 10;
- }
- f = ((double)a) + (((double)b)/((double)c));
- return( f );
-}
-
-/*
- * readNumber - returns a float representing the word just read.
- */
-
-double pushBackBuffer::readNumber (void)
-{
- int i;
- char ch;
-
- i = readInt();
- if ((ch = getPB()) == '.') {
- return convertToFloat(i, readInt());
- }
- putPB(ch);
- return (double)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 *str = 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;
- str = (char *)malloc(strlen(buffer)+1);
- strcpy(str, buffer);
- }
- return( str );
-}
diff --git a/contrib/groff/src/preproc/html/pushback.h b/contrib/groff/src/preproc/html/pushback.h
deleted file mode 100644
index 3fddad66f11d..000000000000
--- a/contrib/groff/src/preproc/html/pushback.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// -*- C -*-
-/* Copyright (C) 2000, 2001, 2003, 2004 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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-
-#define eof (char)-1
-
-
-/*
- * defines the class and methods implemented within pushback.cpp
- */
-
-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);
- double readNumber (void);
- int readInt (void);
- char *readString (void);
- int isString (const char *string);
-};
-
-
diff --git a/contrib/groff/src/preproc/pic/Makefile.sub b/contrib/groff/src/preproc/pic/Makefile.sub
deleted file mode 100644
index 94b41fee92b7..000000000000
--- a/contrib/groff/src/preproc/pic/Makefile.sub
+++ /dev/null
@@ -1,31 +0,0 @@
-PROG=pic$(EXEEXT)
-MAN1=pic.n
-XLIBS=$(LIBGROFF)
-MLIB=$(LIBM)
-OBJS=\
- pic.$(OBJEXT) \
- lex.$(OBJEXT) \
- main.$(OBJEXT) \
- object.$(OBJEXT) \
- common.$(OBJEXT) \
- troff.$(OBJEXT) \
- tex.$(OBJEXT)
- # fig.$(OBJEXT)
-CCSRCS=\
- $(srcdir)/lex.cpp \
- $(srcdir)/main.cpp \
- $(srcdir)/object.cpp \
- $(srcdir)/common.cpp \
- $(srcdir)/troff.cpp \
- $(srcdir)/tex.cpp
-HDRS=\
- $(srcdir)/common.h \
- $(srcdir)/object.h \
- $(srcdir)/output.h \
- $(srcdir)/pic.h \
- $(srcdir)/position.h \
- $(srcdir)/text.h
-GRAM=$(srcdir)/pic.y
-YTABC=pic.cpp
-YTABH=pic_tab.h
-NAMEPREFIX=$(g)
diff --git a/contrib/groff/src/preproc/pic/TODO b/contrib/groff/src/preproc/pic/TODO
deleted file mode 100644
index a1d7554d4529..000000000000
--- a/contrib/groff/src/preproc/pic/TODO
+++ /dev/null
@@ -1,35 +0,0 @@
-In troff mode, dotted and dashed splines.
-
-Make DELIMITED have type lstr; this would allow us to give better
-error messages for problems within the body of for and if constructs.
-
-In troff mode without -x, fake \D't' with .ps commands.
-
-Perhaps an option to set command char.
-
-Add an output class for dumb line printers. It wouldn't be pretty but
-it would be better than nothing. Integrate it with texinfo. Useful
-for groff -Tascii as well.
-
-Option to allow better positioning of arrowheads on arcs.
-
-Perhaps add PostScript output mode.
-
-Change the interface to the output class so that output devices have
-the opportunity to handle arrowheads themselves.
-
-Consider whether the line thickness should scale.
-
-Consider whether the test in a for loop should be fuzzy (as it
-apparently is in grap).
-
-Possibly change fillval so that zero is black.
-
-Provide a way of getting text blocks (positioned with `.in' rather
-than \h), into pic. Should be possible to use block of diverted text
-in pic. Possibly something similar to T{ and T} in tbl.
-
-Option to provide macro backtraces.
-
-Have a path that is searched by `copy' statement. Set by environment
-variable or command line option.
diff --git a/contrib/groff/src/preproc/pic/common.cpp b/contrib/groff/src/preproc/pic/common.cpp
deleted file mode 100644
index 47a23cd920ef..000000000000
--- a/contrib/groff/src/preproc/pic/common.cpp
+++ /dev/null
@@ -1,647 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2003 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "pic.h"
-#include "common.h"
-
-// output a dashed circle as a series of arcs
-
-void common_output::dashed_circle(const position &cent, double rad,
- const line_type &lt)
-{
- assert(lt.type == line_type::dashed);
- line_type slt = lt;
- slt.type = line_type::solid;
- double dash_angle = lt.dash_width/rad;
- int ndashes;
- double gap_angle;
- if (dash_angle >= M_PI/4.0) {
- if (dash_angle < M_PI/2.0) {
- gap_angle = M_PI/2.0 - dash_angle;
- ndashes = 4;
- }
- else if (dash_angle < M_PI) {
- gap_angle = M_PI - dash_angle;
- ndashes = 2;
- }
- else {
- circle(cent, rad, slt, -1.0);
- return;
- }
- }
- else {
- ndashes = 4*int(ceil(M_PI/(4.0*dash_angle)));
- gap_angle = (M_PI*2.0)/ndashes - dash_angle;
- }
- for (int i = 0; i < ndashes; i++) {
- double start_angle = i*(dash_angle+gap_angle) - dash_angle/2.0;
- solid_arc(cent, rad, start_angle, start_angle + dash_angle, lt);
- }
-}
-
-// output a dotted circle as a series of dots
-
-void common_output::dotted_circle(const position &cent, double rad,
- const line_type &lt)
-{
- assert(lt.type == line_type::dotted);
- double gap_angle = lt.dash_width/rad;
- int ndots;
- if (gap_angle >= M_PI/2.0) {
- // always have at least 2 dots
- gap_angle = M_PI;
- ndots = 2;
- }
- else {
- ndots = 4*int(M_PI/(2.0*gap_angle));
- gap_angle = (M_PI*2.0)/ndots;
- }
- double ang = 0.0;
- for (int i = 0; i < ndots; i++, ang += gap_angle)
- dot(cent + position(cos(ang), sin(ang))*rad, lt);
-}
-
-// recursive function for dash drawing, used by dashed_ellipse
-
-void common_output::ellipse_arc(const position &cent,
- const position &z0, const position &z1,
- const distance &dim, const line_type &lt)
-{
- assert(lt.type == line_type::solid);
- assert(dim.x != 0 && dim.y != 0);
- double eps = 0.0001;
- position zml = (z0 + z1) / 2;
- // apply affine transformation (from ellipse to circle) to compute angle
- // of new position, then invert transformation to get exact position
- double psi = atan2(zml.y / dim.y, zml.x / dim.x);
- position zm = position(dim.x * cos(psi), dim.y * sin(psi));
- // to approximate the ellipse arc with one or more circle arcs, we
- // first compute the radius of curvature in zm
- double a_2 = dim.x * dim.x;
- double a_4 = a_2 * a_2;
- double b_2 = dim.y * dim.y;
- double b_4 = b_2 * b_2;
- double e_2 = a_2 - b_2;
- double temp = a_4 * zm.y * zm.y + b_4 * zm.x * zm.x;
- double rho = sqrt(temp / a_4 / b_4 * temp / a_4 / b_4 * temp);
- // compute center of curvature circle
- position M = position(e_2 * zm.x / a_2 * zm.x / a_2 * zm.x,
- -e_2 * zm.y / b_2 * zm.y / b_2 * zm.y);
- // compute distance between circle and ellipse arc at start and end
- double phi0 = atan2(z0.y - M.y, z0.x - M.x);
- double phi1 = atan2(z1.y - M.y, z1.x - M.x);
- position M0 = position(rho * cos(phi0), rho * sin(phi0)) + M;
- position M1 = position(rho * cos(phi1), rho * sin(phi1)) + M;
- double dist0 = hypot(z0 - M0) / sqrt(z0 * z0);
- double dist1 = hypot(z1 - M1) / sqrt(z1 * z1);
- if (dist0 < eps && dist1 < eps)
- solid_arc(M + cent, rho, phi0, phi1, lt);
- else {
- ellipse_arc(cent, z0, zm, dim, lt);
- ellipse_arc(cent, zm, z1, dim, lt);
- }
-}
-
-// output a dashed ellipse as a series of arcs
-
-void common_output::dashed_ellipse(const position &cent, const distance &dim,
- const line_type &lt)
-{
- assert(lt.type == line_type::dashed);
- double dim_x = dim.x / 2;
- double dim_y = dim.y / 2;
- line_type slt = lt;
- slt.type = line_type::solid;
- double dw = lt.dash_width;
- // we use an approximation to compute the ellipse length (found in:
- // Bronstein, Semendjajew, Taschenbuch der Mathematik)
- double lambda = (dim.x - dim.y) / (dim.x + dim.y);
- double le = M_PI / 2 * (dim.x + dim.y)
- * ((64 - 3 * lambda * lambda * lambda * lambda )
- / (64 - 16 * lambda * lambda));
- // for symmetry we make nmax a multiple of 8
- int nmax = 8 * int(le / dw / 8 + 0.5);
- if (nmax < 8) {
- nmax = 8;
- dw = le / 8;
- }
- int ndash = nmax / 2;
- double gapwidth = (le - dw * ndash) / ndash;
- double l = 0;
- position z = position(dim_x, 0);
- position zdot = z;
- int j = 0;
- int jmax = int(10 / lt.dash_width);
- for (int i = 0; i <= nmax; i++) {
- position zold = z;
- position zpre = zdot;
- double ld = (int(i / 2) + 0.5) * dw + int((i + 1) / 2) * gapwidth;
- double lold = 0;
- double dl = 1;
- // find next position for fixed arc length
- while (l < ld) {
- j++;
- lold = l;
- zold = z;
- double phi = j * 2 * M_PI / jmax;
- z = position(dim_x * cos(phi), dim_y * sin(phi));
- dl = hypot(z - zold);
- l += dl;
- }
- // interpolate linearly between the last two points,
- // using the length difference as the scaling factor
- double delta = (ld - lold) / dl;
- zdot = zold + (z - zold) * delta;
- // compute angle of new position on the affine circle
- // and use it to get the exact value on the ellipse
- double psi = atan2(zdot.y / dim_y, zdot.x / dim_x);
- zdot = position(dim_x * cos(psi), dim_y * sin(psi));
- if ((i % 2 == 0) && (i > 1))
- ellipse_arc(cent, zpre, zdot, dim / 2, slt);
- }
-}
-
-// output a dotted ellipse as a series of dots
-
-void common_output::dotted_ellipse(const position &cent, const distance &dim,
- const line_type &lt)
-{
- assert(lt.type == line_type::dotted);
- double dim_x = dim.x / 2;
- double dim_y = dim.y / 2;
- line_type slt = lt;
- slt.type = line_type::solid;
- // we use an approximation to compute the ellipse length (found in:
- // Bronstein, Semendjajew, Taschenbuch der Mathematik)
- double lambda = (dim.x - dim.y) / (dim.x + dim.y);
- double le = M_PI / 2 * (dim.x + dim.y)
- * ((64 - 3 * lambda * lambda * lambda * lambda )
- / (64 - 16 * lambda * lambda));
- // for symmetry we make nmax a multiple of 4
- int ndots = 4 * int(le / lt.dash_width / 4 + 0.5);
- if (ndots < 4)
- ndots = 4;
- double l = 0;
- position z = position(dim_x, 0);
- int j = 0;
- int jmax = int(10 / lt.dash_width);
- for (int i = 1; i <= ndots; i++) {
- position zold = z;
- double lold = l;
- double ld = i * le / ndots;
- double dl = 1;
- // find next position for fixed arc length
- while (l < ld) {
- j++;
- lold = l;
- zold = z;
- double phi = j * 2 * M_PI / jmax;
- z = position(dim_x * cos(phi), dim_y * sin(phi));
- dl = hypot(z - zold);
- l += dl;
- }
- // interpolate linearly between the last two points,
- // using the length difference as the scaling factor
- double delta = (ld - lold) / dl;
- position zdot = zold + (z - zold) * delta;
- // compute angle of new position on the affine circle
- // and use it to get the exact value on the ellipse
- double psi = atan2(zdot.y / dim_y, zdot.x / dim_x);
- zdot = position(dim_x * cos(psi), dim_y * sin(psi));
- dot(cent + zdot, slt);
- }
-}
-
-// return non-zero iff we can compute a center
-
-int compute_arc_center(const position &start, const position &cent,
- const position &end, position *result)
-{
- // This finds the point along the vector from start to cent that
- // is equidistant between start and end.
- distance c = cent - start;
- distance e = end - start;
- double n = c*e;
- if (n == 0.0)
- return 0;
- *result = start + c*((e*e)/(2.0*n));
- return 1;
-}
-
-// output a dashed arc as a series of arcs
-
-void common_output::dashed_arc(const position &start, const position &cent,
- const position &end, const line_type &lt)
-{
- assert(lt.type == line_type::dashed);
- position c;
- if (!compute_arc_center(start, cent, end, &c)) {
- line(start, &end, 1, lt);
- return;
- }
- distance start_offset = start - c;
- distance end_offset = end - c;
- double start_angle = atan2(start_offset.y, start_offset.x);
- double end_angle = atan2(end_offset.y, end_offset.x);
- double rad = hypot(c - start);
- double dash_angle = lt.dash_width/rad;
- double total_angle = end_angle - start_angle;
- while (total_angle < 0)
- total_angle += M_PI + M_PI;
- if (total_angle <= dash_angle*2.0) {
- solid_arc(cent, rad, start_angle, end_angle, lt);
- return;
- }
- int ndashes = int((total_angle - dash_angle)/(dash_angle*2.0) + .5);
- double dash_and_gap_angle = (total_angle - dash_angle)/ndashes;
- for (int i = 0; i <= ndashes; i++)
- solid_arc(cent, rad, start_angle + i*dash_and_gap_angle,
- start_angle + i*dash_and_gap_angle + dash_angle, lt);
-}
-
-// output a dotted arc as a series of dots
-
-void common_output::dotted_arc(const position &start, const position &cent,
- const position &end, const line_type &lt)
-{
- assert(lt.type == line_type::dotted);
- position c;
- if (!compute_arc_center(start, cent, end, &c)) {
- line(start, &end, 1, lt);
- return;
- }
- distance start_offset = start - c;
- distance end_offset = end - c;
- double start_angle = atan2(start_offset.y, start_offset.x);
- double total_angle = atan2(end_offset.y, end_offset.x) - start_angle;
- while (total_angle < 0)
- total_angle += M_PI + M_PI;
- double rad = hypot(c - start);
- int ndots = int(total_angle/(lt.dash_width/rad) + .5);
- if (ndots == 0)
- dot(start, lt);
- else {
- for (int i = 0; i <= ndots; i++) {
- double a = start_angle + (total_angle*i)/ndots;
- dot(cent + position(cos(a), sin(a))*rad, lt);
- }
- }
-}
-
-void common_output::solid_arc(const position &cent, double rad,
- double start_angle, double end_angle,
- const line_type &lt)
-{
- line_type slt = lt;
- slt.type = line_type::solid;
- arc(cent + position(cos(start_angle), sin(start_angle))*rad,
- cent,
- cent + position(cos(end_angle), sin(end_angle))*rad,
- slt);
-}
-
-
-void common_output::rounded_box(const position &cent, const distance &dim,
- double rad, const line_type &lt, double fill)
-{
- if (fill >= 0.0)
- filled_rounded_box(cent, dim, rad, fill);
- switch (lt.type) {
- case line_type::invisible:
- break;
- case line_type::dashed:
- dashed_rounded_box(cent, dim, rad, lt);
- break;
- case line_type::dotted:
- dotted_rounded_box(cent, dim, rad, lt);
- break;
- case line_type::solid:
- solid_rounded_box(cent, dim, rad, lt);
- break;
- default:
- assert(0);
- }
-}
-
-
-void common_output::dashed_rounded_box(const position &cent,
- const distance &dim, double rad,
- const line_type &lt)
-{
- line_type slt = lt;
- slt.type = line_type::solid;
-
- double hor_length = dim.x + (M_PI/2.0 - 2.0)*rad;
- int n_hor_dashes = int(hor_length/(lt.dash_width*2.0) + .5);
- double hor_gap_width = (n_hor_dashes != 0
- ? hor_length/n_hor_dashes - lt.dash_width
- : 0.0);
-
- double vert_length = dim.y + (M_PI/2.0 - 2.0)*rad;
- int n_vert_dashes = int(vert_length/(lt.dash_width*2.0) + .5);
- double vert_gap_width = (n_vert_dashes != 0
- ? vert_length/n_vert_dashes - lt.dash_width
- : 0.0);
- // Note that each corner arc has to be split into two for dashing,
- // because one part is dashed using vert_gap_width, and the other
- // using hor_gap_width.
- double offset = lt.dash_width/2.0;
- dash_arc(cent + position(dim.x/2.0 - rad, -dim.y/2.0 + rad), rad,
- -M_PI/4.0, 0, slt, lt.dash_width, vert_gap_width, &offset);
- dash_line(cent + position(dim.x/2.0, -dim.y/2.0 + rad),
- cent + position(dim.x/2.0, dim.y/2.0 - rad),
- slt, lt.dash_width, vert_gap_width, &offset);
- dash_arc(cent + position(dim.x/2.0 - rad, dim.y/2.0 - rad), rad,
- 0, M_PI/4.0, slt, lt.dash_width, vert_gap_width, &offset);
-
- offset = lt.dash_width/2.0;
- dash_arc(cent + position(dim.x/2.0 - rad, dim.y/2.0 - rad), rad,
- M_PI/4.0, M_PI/2, slt, lt.dash_width, hor_gap_width, &offset);
- dash_line(cent + position(dim.x/2.0 - rad, dim.y/2.0),
- cent + position(-dim.x/2.0 + rad, dim.y/2.0),
- slt, lt.dash_width, hor_gap_width, &offset);
- dash_arc(cent + position(-dim.x/2.0 + rad, dim.y/2.0 - rad), rad,
- M_PI/2, 3*M_PI/4.0, slt, lt.dash_width, hor_gap_width, &offset);
-
- offset = lt.dash_width/2.0;
- dash_arc(cent + position(-dim.x/2.0 + rad, dim.y/2.0 - rad), rad,
- 3.0*M_PI/4.0, M_PI, slt, lt.dash_width, vert_gap_width, &offset);
- dash_line(cent + position(-dim.x/2.0, dim.y/2.0 - rad),
- cent + position(-dim.x/2.0, -dim.y/2.0 + rad),
- slt, lt.dash_width, vert_gap_width, &offset);
- dash_arc(cent + position(-dim.x/2.0 + rad, -dim.y/2.0 + rad), rad,
- M_PI, 5.0*M_PI/4.0, slt, lt.dash_width, vert_gap_width, &offset);
-
- offset = lt.dash_width/2.0;
- dash_arc(cent + position(-dim.x/2.0 + rad, -dim.y/2.0 + rad), rad,
- 5*M_PI/4.0, 3*M_PI/2.0, slt, lt.dash_width, hor_gap_width, &offset);
- dash_line(cent + position(-dim.x/2.0 + rad, -dim.y/2.0),
- cent + position(dim.x/2.0 - rad, -dim.y/2.0),
- slt, lt.dash_width, hor_gap_width, &offset);
- dash_arc(cent + position(dim.x/2.0 - rad, -dim.y/2.0 + rad), rad,
- 3*M_PI/2, 7*M_PI/4, slt, lt.dash_width, hor_gap_width, &offset);
-}
-
-// Used by dashed_rounded_box.
-
-void common_output::dash_arc(const position &cent, double rad,
- double start_angle, double end_angle,
- const line_type &lt,
- double dash_width, double gap_width,
- double *offsetp)
-{
- double length = (end_angle - start_angle)*rad;
- double pos = 0.0;
- for (;;) {
- if (*offsetp >= dash_width) {
- double rem = dash_width + gap_width - *offsetp;
- if (pos + rem > length) {
- *offsetp += length - pos;
- break;
- }
- else {
- pos += rem;
- *offsetp = 0.0;
- }
- }
- else {
- double rem = dash_width - *offsetp;
- if (pos + rem > length) {
- solid_arc(cent, rad, start_angle + pos/rad, end_angle, lt);
- *offsetp += length - pos;
- break;
- }
- else {
- solid_arc(cent, rad, start_angle + pos/rad,
- start_angle + (pos + rem)/rad, lt);
- pos += rem;
- *offsetp = dash_width;
- }
- }
- }
-}
-
-// Used by dashed_rounded_box.
-
-void common_output::dash_line(const position &start, const position &end,
- const line_type &lt,
- double dash_width, double gap_width,
- double *offsetp)
-{
- distance dist = end - start;
- double length = hypot(dist);
- if (length == 0.0)
- return;
- double pos = 0.0;
- for (;;) {
- if (*offsetp >= dash_width) {
- double rem = dash_width + gap_width - *offsetp;
- if (pos + rem > length) {
- *offsetp += length - pos;
- break;
- }
- else {
- pos += rem;
- *offsetp = 0.0;
- }
- }
- else {
- double rem = dash_width - *offsetp;
- if (pos + rem > length) {
- line(start + dist*(pos/length), &end, 1, lt);
- *offsetp += length - pos;
- break;
- }
- else {
- position p(start + dist*((pos + rem)/length));
- line(start + dist*(pos/length), &p, 1, lt);
- pos += rem;
- *offsetp = dash_width;
- }
- }
- }
-}
-
-void common_output::dotted_rounded_box(const position &cent,
- const distance &dim, double rad,
- const line_type &lt)
-{
- line_type slt = lt;
- slt.type = line_type::solid;
-
- double hor_length = dim.x + (M_PI/2.0 - 2.0)*rad;
- int n_hor_dots = int(hor_length/lt.dash_width + .5);
- double hor_gap_width = (n_hor_dots != 0
- ? hor_length/n_hor_dots
- : lt.dash_width);
-
- double vert_length = dim.y + (M_PI/2.0 - 2.0)*rad;
- int n_vert_dots = int(vert_length/lt.dash_width + .5);
- double vert_gap_width = (n_vert_dots != 0
- ? vert_length/n_vert_dots
- : lt.dash_width);
- double epsilon = lt.dash_width/(rad*100.0);
-
- double offset = 0.0;
- dot_arc(cent + position(dim.x/2.0 - rad, -dim.y/2.0 + rad), rad,
- -M_PI/4.0, 0, slt, vert_gap_width, &offset);
- dot_line(cent + position(dim.x/2.0, -dim.y/2.0 + rad),
- cent + position(dim.x/2.0, dim.y/2.0 - rad),
- slt, vert_gap_width, &offset);
- dot_arc(cent + position(dim.x/2.0 - rad, dim.y/2.0 - rad), rad,
- 0, M_PI/4.0 - epsilon, slt, vert_gap_width, &offset);
-
- offset = 0.0;
- dot_arc(cent + position(dim.x/2.0 - rad, dim.y/2.0 - rad), rad,
- M_PI/4.0, M_PI/2, slt, hor_gap_width, &offset);
- dot_line(cent + position(dim.x/2.0 - rad, dim.y/2.0),
- cent + position(-dim.x/2.0 + rad, dim.y/2.0),
- slt, hor_gap_width, &offset);
- dot_arc(cent + position(-dim.x/2.0 + rad, dim.y/2.0 - rad), rad,
- M_PI/2, 3*M_PI/4.0 - epsilon, slt, hor_gap_width, &offset);
-
- offset = 0.0;
- dot_arc(cent + position(-dim.x/2.0 + rad, dim.y/2.0 - rad), rad,
- 3.0*M_PI/4.0, M_PI, slt, vert_gap_width, &offset);
- dot_line(cent + position(-dim.x/2.0, dim.y/2.0 - rad),
- cent + position(-dim.x/2.0, -dim.y/2.0 + rad),
- slt, vert_gap_width, &offset);
- dot_arc(cent + position(-dim.x/2.0 + rad, -dim.y/2.0 + rad), rad,
- M_PI, 5.0*M_PI/4.0 - epsilon, slt, vert_gap_width, &offset);
-
- offset = 0.0;
- dot_arc(cent + position(-dim.x/2.0 + rad, -dim.y/2.0 + rad), rad,
- 5*M_PI/4.0, 3*M_PI/2.0, slt, hor_gap_width, &offset);
- dot_line(cent + position(-dim.x/2.0 + rad, -dim.y/2.0),
- cent + position(dim.x/2.0 - rad, -dim.y/2.0),
- slt, hor_gap_width, &offset);
- dot_arc(cent + position(dim.x/2.0 - rad, -dim.y/2.0 + rad), rad,
- 3*M_PI/2, 7*M_PI/4 - epsilon, slt, hor_gap_width, &offset);
-}
-
-// Used by dotted_rounded_box.
-
-void common_output::dot_arc(const position &cent, double rad,
- double start_angle, double end_angle,
- const line_type &lt, double gap_width,
- double *offsetp)
-{
- double length = (end_angle - start_angle)*rad;
- double pos = 0.0;
- for (;;) {
- if (*offsetp == 0.0) {
- double ang = start_angle + pos/rad;
- dot(cent + position(cos(ang), sin(ang))*rad, lt);
- }
- double rem = gap_width - *offsetp;
- if (pos + rem > length) {
- *offsetp += length - pos;
- break;
- }
- else {
- pos += rem;
- *offsetp = 0.0;
- }
- }
-}
-
-// Used by dotted_rounded_box.
-
-void common_output::dot_line(const position &start, const position &end,
- const line_type &lt, double gap_width,
- double *offsetp)
-{
- distance dist = end - start;
- double length = hypot(dist);
- if (length == 0.0)
- return;
- double pos = 0.0;
- for (;;) {
- if (*offsetp == 0.0)
- dot(start + dist*(pos/length), lt);
- double rem = gap_width - *offsetp;
- if (pos + rem > length) {
- *offsetp += length - pos;
- break;
- }
- else {
- pos += rem;
- *offsetp = 0.0;
- }
- }
-}
-
-void common_output::solid_rounded_box(const position &cent,
- const distance &dim, double rad,
- const line_type &lt)
-{
- position tem = cent - dim/2.0;
- arc(tem + position(0.0, rad),
- tem + position(rad, rad),
- tem + position(rad, 0.0),
- lt);
- tem = cent + position(-dim.x/2.0, dim.y/2.0);
- arc(tem + position(rad, 0.0),
- tem + position(rad, -rad),
- tem + position(0.0, -rad),
- lt);
- tem = cent + dim/2.0;
- arc(tem + position(0.0, -rad),
- tem + position(-rad, -rad),
- tem + position(-rad, 0.0),
- lt);
- tem = cent + position(dim.x/2.0, -dim.y/2.0);
- arc(tem + position(-rad, 0.0),
- tem + position(-rad, rad),
- tem + position(0.0, rad),
- lt);
- position end;
- end = cent + position(-dim.x/2.0, dim.y/2.0 - rad);
- line(cent - dim/2.0 + position(0.0, rad), &end, 1, lt);
- end = cent + position(dim.x/2.0 - rad, dim.y/2.0);
- line(cent + position(-dim.x/2.0 + rad, dim.y/2.0), &end, 1, lt);
- end = cent + position(dim.x/2.0, -dim.y/2.0 + rad);
- line(cent + position(dim.x/2.0, dim.y/2.0 - rad), &end, 1, lt);
- end = cent + position(-dim.x/2.0 + rad, -dim.y/2.0);
- line(cent + position(dim.x/2.0 - rad, -dim.y/2.0), &end, 1, lt);
-}
-
-void common_output::filled_rounded_box(const position &cent,
- const distance &dim, double rad,
- double fill)
-{
- line_type ilt;
- ilt.type = line_type::invisible;
- circle(cent + position(dim.x/2.0 - rad, dim.y/2.0 - rad), rad, ilt, fill);
- circle(cent + position(-dim.x/2.0 + rad, dim.y/2.0 - rad), rad, ilt, fill);
- circle(cent + position(-dim.x/2.0 + rad, -dim.y/2.0 + rad), rad, ilt, fill);
- circle(cent + position(dim.x/2.0 - rad, -dim.y/2.0 + rad), rad, ilt, fill);
- position vec[4];
- vec[0] = cent + position(dim.x/2.0, dim.y/2.0 - rad);
- vec[1] = cent + position(-dim.x/2.0, dim.y/2.0 - rad);
- vec[2] = cent + position(-dim.x/2.0, -dim.y/2.0 + rad);
- vec[3] = cent + position(dim.x/2.0, -dim.y/2.0 + rad);
- polygon(vec, 4, ilt, fill);
- vec[0] = cent + position(dim.x/2.0 - rad, dim.y/2.0);
- vec[1] = cent + position(-dim.x/2.0 + rad, dim.y/2.0);
- vec[2] = cent + position(-dim.x/2.0 + rad, -dim.y/2.0);
- vec[3] = cent + position(dim.x/2.0 - rad, -dim.y/2.0);
- polygon(vec, 4, ilt, fill);
-}
diff --git a/contrib/groff/src/preproc/pic/common.h b/contrib/groff/src/preproc/pic/common.h
deleted file mode 100644
index 50238344d8a4..000000000000
--- a/contrib/groff/src/preproc/pic/common.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 1993, 2003
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-This file is part of groff.
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-class common_output : public output {
-private:
- void dash_line(const position &start, const position &end,
- const line_type &lt, double dash_width, double gap_width,
- double *offsetp);
- void dash_arc(const position &cent, double rad,
- double start_angle, double end_angle, const line_type &lt,
- double dash_width, double gap_width, double *offsetp);
- void dot_line(const position &start, const position &end,
- const line_type &lt, double gap_width, double *offsetp);
- void dot_arc(const position &cent, double rad,
- double start_angle, double end_angle, const line_type &lt,
- double gap_width, double *offsetp);
-protected:
- virtual void dot(const position &, const line_type &) = 0;
- void ellipse_arc(const position &, const position &,
- const position &, const distance &,
- const line_type &);
- void dashed_circle(const position &, double rad, const line_type &);
- void dotted_circle(const position &, double rad, const line_type &);
- void dashed_ellipse(const position &, const distance &, const line_type &);
- void dotted_ellipse(const position &, const distance &, const line_type &);
- void dashed_arc(const position &, const position &, const position &,
- const line_type &);
- void dotted_arc(const position &, const position &, const position &,
- const line_type &);
- virtual void solid_arc(const position &cent, double rad, double start_angle,
- double end_angle, const line_type &lt);
- void dashed_rounded_box(const position &, const distance &, double,
- const line_type &);
- void dotted_rounded_box(const position &, const distance &, double,
- const line_type &);
- void solid_rounded_box(const position &, const distance &, double,
- const line_type &);
- void filled_rounded_box(const position &, const distance &, double, double);
-public:
- void start_picture(double sc, const position &ll, const position &ur) = 0;
- void finish_picture() = 0;
- void circle(const position &, double rad, const line_type &, double) = 0;
- void text(const position &, text_piece *, int, double) = 0;
- void line(const position &, const position *, int n, const line_type &) = 0;
- void polygon(const position *, int n, const line_type &, double) = 0;
- void spline(const position &, const position *, int n,
- const line_type &) = 0;
- void arc(const position &, const position &, const position &,
- const line_type &) = 0;
- void ellipse(const position &, const distance &,
- 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,
- const position &end, position *result);
-
diff --git a/contrib/groff/src/preproc/pic/lex.cpp b/contrib/groff/src/preproc/pic/lex.cpp
deleted file mode 100644
index ceca36854648..000000000000
--- a/contrib/groff/src/preproc/pic/lex.cpp
+++ /dev/null
@@ -1,2001 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2003, 2004
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "pic.h"
-#include "ptable.h"
-#include "object.h"
-#include "pic_tab.h"
-
-declare_ptable(char)
-implement_ptable(char)
-
-PTABLE(char) macro_table;
-
-class macro_input : public input {
- char *s;
- char *p;
-public:
- macro_input(const char *);
- ~macro_input();
- int get();
- int peek();
-};
-
-class argument_macro_input : public input {
- char *s;
- char *p;
- char *ap;
- int argc;
- char *argv[9];
-public:
- argument_macro_input(const char *, int, char **);
- ~argument_macro_input();
- int get();
- int peek();
-};
-
-input::input() : next(0)
-{
-}
-
-input::~input()
-{
-}
-
-int input::get_location(const char **, int *)
-{
- return 0;
-}
-
-file_input::file_input(FILE *f, const char *fn)
-: fp(f), filename(fn), lineno(0), ptr("")
-{
-}
-
-file_input::~file_input()
-{
- fclose(fp);
-}
-
-int file_input::read_line()
-{
- for (;;) {
- line.clear();
- lineno++;
- for (;;) {
- int c = getc(fp);
- if (c == EOF)
- break;
- else if (invalid_input_char(c))
- lex_error("invalid input character code %1", c);
- else {
- line += char(c);
- if (c == '\n')
- break;
- }
- }
- if (line.length() == 0)
- return 0;
- if (!(line.length() >= 3 && line[0] == '.' && line[1] == 'P'
- && (line[2] == 'S' || line[2] == 'E' || line[2] == 'F')
- && (line.length() == 3 || line[3] == ' ' || line[3] == '\n'
- || compatible_flag))) {
- line += '\0';
- ptr = line.contents();
- return 1;
- }
- }
-}
-
-int file_input::get()
-{
- if (*ptr != '\0' || read_line())
- return (unsigned char)*ptr++;
- else
- return EOF;
-}
-
-int file_input::peek()
-{
- if (*ptr != '\0' || read_line())
- return (unsigned char)*ptr;
- else
- return EOF;
-}
-
-int file_input::get_location(const char **fnp, int *lnp)
-{
- *fnp = filename;
- *lnp = lineno;
- return 1;
-}
-
-macro_input::macro_input(const char *str)
-{
- p = s = strsave(str);
-}
-
-macro_input::~macro_input()
-{
- a_delete s;
-}
-
-int macro_input::get()
-{
- if (p == 0 || *p == '\0')
- return EOF;
- else
- return (unsigned char)*p++;
-}
-
-int macro_input::peek()
-{
- if (p == 0 || *p == '\0')
- return EOF;
- else
- return (unsigned char)*p;
-}
-
-// Character representing $1. Must be invalid input character.
-#define ARG1 14
-
-char *process_body(const char *body)
-{
- char *s = strsave(body);
- int j = 0;
- for (int i = 0; s[i] != '\0'; i++)
- if (s[i] == '$' && s[i+1] >= '0' && s[i+1] <= '9') {
- if (s[i+1] != '0')
- s[j++] = ARG1 + s[++i] - '1';
- }
- else
- s[j++] = s[i];
- s[j] = '\0';
- return s;
-}
-
-
-argument_macro_input::argument_macro_input(const char *body, int ac, char **av)
-: ap(0), argc(ac)
-{
- for (int i = 0; i < argc; i++)
- argv[i] = av[i];
- p = s = process_body(body);
-}
-
-
-argument_macro_input::~argument_macro_input()
-{
- for (int i = 0; i < argc; i++)
- a_delete argv[i];
- a_delete s;
-}
-
-int argument_macro_input::get()
-{
- if (ap) {
- if (*ap != '\0')
- return (unsigned char)*ap++;
- ap = 0;
- }
- if (p == 0)
- return EOF;
- while (*p >= ARG1 && *p <= ARG1 + 8) {
- int i = *p++ - ARG1;
- if (i < argc && argv[i] != 0 && argv[i][0] != '\0') {
- ap = argv[i];
- return (unsigned char)*ap++;
- }
- }
- if (*p == '\0')
- return EOF;
- return (unsigned char)*p++;
-}
-
-int argument_macro_input::peek()
-{
- if (ap) {
- if (*ap != '\0')
- return (unsigned char)*ap;
- ap = 0;
- }
- if (p == 0)
- return EOF;
- while (*p >= ARG1 && *p <= ARG1 + 8) {
- int i = *p++ - ARG1;
- if (i < argc && argv[i] != 0 && argv[i][0] != '\0') {
- ap = argv[i];
- return (unsigned char)*ap;
- }
- }
- if (*p == '\0')
- return EOF;
- return (unsigned char)*p;
-}
-
-class input_stack {
- static input *current_input;
- static int bol_flag;
-public:
- static void push(input *);
- static void clear();
- static int get_char();
- static int peek_char();
- static int get_location(const char **fnp, int *lnp);
- static void push_back(unsigned char c, int was_bol = 0);
- static int bol();
-};
-
-input *input_stack::current_input = 0;
-int input_stack::bol_flag = 0;
-
-inline int input_stack::bol()
-{
- return bol_flag;
-}
-
-void input_stack::clear()
-{
- while (current_input != 0) {
- input *tem = current_input;
- current_input = current_input->next;
- delete tem;
- }
- bol_flag = 1;
-}
-
-void input_stack::push(input *in)
-{
- in->next = current_input;
- current_input = in;
-}
-
-void lex_init(input *top)
-{
- input_stack::clear();
- input_stack::push(top);
-}
-
-void lex_cleanup()
-{
- while (input_stack::get_char() != EOF)
- ;
-}
-
-int input_stack::get_char()
-{
- while (current_input != 0) {
- int c = current_input->get();
- if (c != EOF) {
- bol_flag = c == '\n';
- return c;
- }
- // don't pop the top-level input off the stack
- if (current_input->next == 0)
- return EOF;
- input *tem = current_input;
- current_input = current_input->next;
- delete tem;
- }
- return EOF;
-}
-
-int input_stack::peek_char()
-{
- while (current_input != 0) {
- int c = current_input->peek();
- if (c != EOF)
- return c;
- if (current_input->next == 0)
- return EOF;
- input *tem = current_input;
- current_input = current_input->next;
- delete tem;
- }
- return EOF;
-}
-
-class char_input : public input {
- int c;
-public:
- char_input(int);
- int get();
- int peek();
-};
-
-char_input::char_input(int n) : c((unsigned char)n)
-{
-}
-
-int char_input::get()
-{
- int n = c;
- c = EOF;
- return n;
-}
-
-int char_input::peek()
-{
- return c;
-}
-
-void input_stack::push_back(unsigned char c, int was_bol)
-{
- push(new char_input(c));
- bol_flag = was_bol;
-}
-
-int input_stack::get_location(const char **fnp, int *lnp)
-{
- for (input *p = current_input; p; p = p->next)
- if (p->get_location(fnp, lnp))
- return 1;
- return 0;
-}
-
-string context_buffer;
-
-string token_buffer;
-double token_double;
-int token_int;
-
-void interpolate_macro_with_args(const char *body)
-{
- char *argv[9];
- int argc = 0;
- int i;
- for (i = 0; i < 9; i++)
- argv[i] = 0;
- int level = 0;
- int c;
- enum { NORMAL, IN_STRING, IN_STRING_QUOTED } state = NORMAL;
- do {
- token_buffer.clear();
- for (;;) {
- c = input_stack::get_char();
- if (c == EOF) {
- lex_error("end of input while scanning macro arguments");
- break;
- }
- if (state == NORMAL && level == 0 && (c == ',' || c == ')')) {
- if (token_buffer.length() > 0) {
- token_buffer += '\0';
- argv[argc] = strsave(token_buffer.contents());
- }
- // for `foo()', argc = 0
- if (argc > 0 || c != ')' || i > 0)
- argc++;
- break;
- }
- token_buffer += char(c);
- switch (state) {
- case NORMAL:
- if (c == '"')
- state = IN_STRING;
- else if (c == '(')
- level++;
- else if (c == ')')
- level--;
- break;
- case IN_STRING:
- if (c == '"')
- state = NORMAL;
- else if (c == '\\')
- state = IN_STRING_QUOTED;
- break;
- case IN_STRING_QUOTED:
- state = IN_STRING;
- break;
- }
- }
- } while (c != ')' && c != EOF);
- input_stack::push(new argument_macro_input(body, argc, argv));
-}
-
-static int docmp(const char *s1, int n1, const char *s2, int n2)
-{
- if (n1 < n2) {
- int r = memcmp(s1, s2, n1);
- return r ? r : -1;
- }
- else if (n1 > n2) {
- int r = memcmp(s1, s2, n2);
- return r ? r : 1;
- }
- else
- return memcmp(s1, s2, n1);
-}
-
-int lookup_keyword(const char *str, int len)
-{
- static struct keyword {
- const char *name;
- int token;
- } table[] = {
- { "Here", HERE },
- { "above", ABOVE },
- { "aligned", ALIGNED },
- { "and", AND },
- { "arc", ARC },
- { "arrow", ARROW },
- { "at", AT },
- { "atan2", ATAN2 },
- { "below", BELOW },
- { "between", BETWEEN },
- { "bottom", BOTTOM },
- { "box", BOX },
- { "by", BY },
- { "ccw", CCW },
- { "center", CENTER },
- { "chop", CHOP },
- { "circle", CIRCLE },
- { "color", COLORED },
- { "colored", COLORED },
- { "colour", COLORED },
- { "coloured", COLORED },
- { "command", COMMAND },
- { "copy", COPY },
- { "cos", COS },
- { "cw", CW },
- { "dashed", DASHED },
- { "define", DEFINE },
- { "diam", DIAMETER },
- { "diameter", DIAMETER },
- { "do", DO },
- { "dotted", DOTTED },
- { "down", DOWN },
- { "east", EAST },
- { "ellipse", ELLIPSE },
- { "else", ELSE },
- { "end", END },
- { "exp", EXP },
- { "figname", FIGNAME },
- { "fill", FILL },
- { "filled", FILL },
- { "for", FOR },
- { "from", FROM },
- { "height", HEIGHT },
- { "ht", HEIGHT },
- { "if", IF },
- { "int", INT },
- { "invis", INVISIBLE },
- { "invisible", INVISIBLE },
- { "last", LAST },
- { "left", LEFT },
- { "line", LINE },
- { "ljust", LJUST },
- { "log", LOG },
- { "lower", LOWER },
- { "max", K_MAX },
- { "min", K_MIN },
- { "move", MOVE },
- { "north", NORTH },
- { "of", OF },
- { "outline", OUTLINED },
- { "outlined", OUTLINED },
- { "plot", PLOT },
- { "print", PRINT },
- { "rad", RADIUS },
- { "radius", RADIUS },
- { "rand", RAND },
- { "reset", RESET },
- { "right", RIGHT },
- { "rjust", RJUST },
- { "same", SAME },
- { "sh", SH },
- { "shaded", SHADED },
- { "sin", SIN },
- { "solid", SOLID },
- { "south", SOUTH },
- { "spline", SPLINE },
- { "sprintf", SPRINTF },
- { "sqrt", SQRT },
- { "srand", SRAND },
- { "start", START },
- { "the", THE },
- { "then", THEN },
- { "thick", THICKNESS },
- { "thickness", THICKNESS },
- { "thru", THRU },
- { "to", TO },
- { "top", TOP },
- { "undef", UNDEF },
- { "until", UNTIL },
- { "up", UP },
- { "upper", UPPER },
- { "way", WAY },
- { "west", WEST },
- { "wid", WIDTH },
- { "width", WIDTH },
- { "with", WITH },
- };
-
- const keyword *start = table;
- const keyword *end = table + sizeof(table)/sizeof(table[0]);
- while (start < end) {
- // start <= target < end
- const keyword *mid = start + (end - start)/2;
-
- int cmp = docmp(str, len, mid->name, strlen(mid->name));
- if (cmp == 0)
- return mid->token;
- if (cmp < 0)
- end = mid;
- else
- start = mid + 1;
- }
- return 0;
-}
-
-int get_token_after_dot(int c)
-{
- // get_token deals with the case where c is a digit
- switch (c) {
- case 'h':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 't') {
- input_stack::get_char();
- context_buffer = ".ht";
- return DOT_HT;
- }
- else if (c == 'e') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'i') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'g') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'h') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 't') {
- input_stack::get_char();
- context_buffer = ".height";
- return DOT_HT;
- }
- input_stack::push_back('h');
- }
- input_stack::push_back('g');
- }
- input_stack::push_back('i');
- }
- input_stack::push_back('e');
- }
- input_stack::push_back('h');
- return '.';
- case 'x':
- input_stack::get_char();
- context_buffer = ".x";
- return DOT_X;
- case 'y':
- input_stack::get_char();
- context_buffer = ".y";
- return DOT_Y;
- case 'c':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'e') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'n') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 't') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'e') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'r') {
- input_stack::get_char();
- context_buffer = ".center";
- return DOT_C;
- }
- input_stack::push_back('e');
- }
- input_stack::push_back('t');
- }
- input_stack::push_back('n');
- }
- input_stack::push_back('e');
- }
- context_buffer = ".c";
- return DOT_C;
- case 'n':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'e') {
- input_stack::get_char();
- context_buffer = ".ne";
- return DOT_NE;
- }
- else if (c == 'w') {
- input_stack::get_char();
- context_buffer = ".nw";
- return DOT_NW;
- }
- else {
- context_buffer = ".n";
- return DOT_N;
- }
- break;
- case 'e':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'n') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'd') {
- input_stack::get_char();
- context_buffer = ".end";
- return DOT_END;
- }
- input_stack::push_back('n');
- context_buffer = ".e";
- return DOT_E;
- }
- context_buffer = ".e";
- return DOT_E;
- case 'w':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'i') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'd') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 't') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'h') {
- input_stack::get_char();
- context_buffer = ".width";
- return DOT_WID;
- }
- input_stack::push_back('t');
- }
- context_buffer = ".wid";
- return DOT_WID;
- }
- input_stack::push_back('i');
- }
- context_buffer = ".w";
- return DOT_W;
- case 's':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'e') {
- input_stack::get_char();
- context_buffer = ".se";
- return DOT_SE;
- }
- else if (c == 'w') {
- input_stack::get_char();
- context_buffer = ".sw";
- return DOT_SW;
- }
- else {
- if (c == 't') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'a') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'r') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 't') {
- input_stack::get_char();
- context_buffer = ".start";
- return DOT_START;
- }
- input_stack::push_back('r');
- }
- input_stack::push_back('a');
- }
- input_stack::push_back('t');
- }
- context_buffer = ".s";
- return DOT_S;
- }
- break;
- case 't':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'o') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'p') {
- input_stack::get_char();
- context_buffer = ".top";
- return DOT_N;
- }
- input_stack::push_back('o');
- }
- context_buffer = ".t";
- return DOT_N;
- case 'l':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'e') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'f') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 't') {
- input_stack::get_char();
- context_buffer = ".left";
- return DOT_W;
- }
- input_stack::push_back('f');
- }
- input_stack::push_back('e');
- }
- context_buffer = ".l";
- return DOT_W;
- case 'r':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'a') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'd') {
- input_stack::get_char();
- context_buffer = ".rad";
- return DOT_RAD;
- }
- input_stack::push_back('a');
- }
- else if (c == 'i') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'g') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'h') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 't') {
- input_stack::get_char();
- context_buffer = ".right";
- return DOT_E;
- }
- input_stack::push_back('h');
- }
- input_stack::push_back('g');
- }
- input_stack::push_back('i');
- }
- context_buffer = ".r";
- return DOT_E;
- case 'b':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'o') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 't') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 't') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'o') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'm') {
- input_stack::get_char();
- context_buffer = ".bottom";
- return DOT_S;
- }
- input_stack::push_back('o');
- }
- input_stack::push_back('t');
- }
- context_buffer = ".bot";
- return DOT_S;
- }
- input_stack::push_back('o');
- }
- context_buffer = ".b";
- return DOT_S;
- default:
- context_buffer = '.';
- return '.';
- }
-}
-
-int get_token(int lookup_flag)
-{
- context_buffer.clear();
- for (;;) {
- int n = 0;
- int bol = input_stack::bol();
- int c = input_stack::get_char();
- if (bol && c == command_char) {
- token_buffer.clear();
- token_buffer += c;
- // the newline is not part of the token
- for (;;) {
- c = input_stack::peek_char();
- if (c == EOF || c == '\n')
- break;
- input_stack::get_char();
- token_buffer += char(c);
- }
- context_buffer = token_buffer;
- return COMMAND_LINE;
- }
- switch (c) {
- case EOF:
- return EOF;
- case ' ':
- case '\t':
- break;
- case '\\':
- {
- int d = input_stack::peek_char();
- if (d != '\n') {
- context_buffer = '\\';
- return '\\';
- }
- input_stack::get_char();
- break;
- }
- case '#':
- do {
- c = input_stack::get_char();
- } while (c != '\n' && c != EOF);
- if (c == '\n')
- context_buffer = '\n';
- return c;
- case '"':
- context_buffer = '"';
- token_buffer.clear();
- for (;;) {
- c = input_stack::get_char();
- if (c == '\\') {
- context_buffer += '\\';
- c = input_stack::peek_char();
- if (c == '"') {
- input_stack::get_char();
- token_buffer += '"';
- context_buffer += '"';
- }
- else
- token_buffer += '\\';
- }
- else if (c == '\n') {
- error("newline in string");
- break;
- }
- else if (c == EOF) {
- error("missing `\"'");
- break;
- }
- else if (c == '"') {
- context_buffer += '"';
- break;
- }
- else {
- context_buffer += char(c);
- token_buffer += char(c);
- }
- }
- return TEXT;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- int overflow = 0;
- n = 0;
- for (;;) {
- if (n > (INT_MAX - 9)/10) {
- overflow = 1;
- break;
- }
- n *= 10;
- n += c - '0';
- context_buffer += char(c);
- c = input_stack::peek_char();
- if (c == EOF || !csdigit(c))
- break;
- c = input_stack::get_char();
- }
- token_double = n;
- if (overflow) {
- for (;;) {
- token_double *= 10.0;
- token_double += c - '0';
- context_buffer += char(c);
- c = input_stack::peek_char();
- if (c == EOF || !csdigit(c))
- break;
- c = input_stack::get_char();
- }
- // if somebody asks for 1000000000000th, we will silently
- // give them INT_MAXth
- double temp = token_double; // work around gas 1.34/sparc bug
- if (token_double > INT_MAX)
- n = INT_MAX;
- else
- n = int(temp);
- }
- }
- switch (c) {
- case 'i':
- case 'I':
- context_buffer += char(c);
- input_stack::get_char();
- return NUMBER;
- case '.':
- {
- context_buffer += '.';
- input_stack::get_char();
- got_dot:
- double factor = 1.0;
- for (;;) {
- c = input_stack::peek_char();
- if (c == EOF || !csdigit(c))
- break;
- input_stack::get_char();
- context_buffer += char(c);
- factor /= 10.0;
- if (c != '0')
- token_double += factor*(c - '0');
- }
- if (c != 'e' && c != 'E') {
- if (c == 'i' || c == 'I') {
- context_buffer += char(c);
- input_stack::get_char();
- }
- return NUMBER;
- }
- }
- // fall through
- case 'e':
- case 'E':
- {
- int echar = c;
- input_stack::get_char();
- c = input_stack::peek_char();
- int sign = '+';
- if (c == '+' || c == '-') {
- sign = c;
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == EOF || !csdigit(c)) {
- input_stack::push_back(sign);
- input_stack::push_back(echar);
- return NUMBER;
- }
- context_buffer += char(echar);
- context_buffer += char(sign);
- }
- else {
- if (c == EOF || !csdigit(c)) {
- input_stack::push_back(echar);
- return NUMBER;
- }
- context_buffer += char(echar);
- }
- input_stack::get_char();
- context_buffer += char(c);
- n = c - '0';
- for (;;) {
- c = input_stack::peek_char();
- if (c == EOF || !csdigit(c))
- break;
- input_stack::get_char();
- context_buffer += char(c);
- n = n*10 + (c - '0');
- }
- if (sign == '-')
- n = -n;
- if (c == 'i' || c == 'I') {
- context_buffer += char(c);
- input_stack::get_char();
- }
- token_double *= pow(10.0, n);
- return NUMBER;
- }
- case 'n':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'd') {
- input_stack::get_char();
- token_int = n;
- context_buffer += "nd";
- return ORDINAL;
- }
- input_stack::push_back('n');
- return NUMBER;
- case 'r':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'd') {
- input_stack::get_char();
- token_int = n;
- context_buffer += "rd";
- return ORDINAL;
- }
- input_stack::push_back('r');
- return NUMBER;
- case 't':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'h') {
- input_stack::get_char();
- token_int = n;
- context_buffer += "th";
- return ORDINAL;
- }
- input_stack::push_back('t');
- return NUMBER;
- case 's':
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 't') {
- input_stack::get_char();
- token_int = n;
- context_buffer += "st";
- return ORDINAL;
- }
- input_stack::push_back('s');
- return NUMBER;
- default:
- return NUMBER;
- }
- break;
- case '\'':
- {
- c = input_stack::peek_char();
- if (c == 't') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == 'h') {
- input_stack::get_char();
- context_buffer = "'th";
- return TH;
- }
- else
- input_stack::push_back('t');
- }
- context_buffer = "'";
- return '\'';
- }
- case '.':
- {
- c = input_stack::peek_char();
- if (c != EOF && csdigit(c)) {
- n = 0;
- token_double = 0.0;
- context_buffer = '.';
- goto got_dot;
- }
- return get_token_after_dot(c);
- }
- case '<':
- c = input_stack::peek_char();
- if (c == '-') {
- input_stack::get_char();
- c = input_stack::peek_char();
- if (c == '>') {
- input_stack::get_char();
- context_buffer = "<->";
- return DOUBLE_ARROW_HEAD;
- }
- context_buffer = "<-";
- return LEFT_ARROW_HEAD;
- }
- else if (c == '=') {
- input_stack::get_char();
- context_buffer = "<=";
- return LESSEQUAL;
- }
- context_buffer = "<";
- return '<';
- case '-':
- c = input_stack::peek_char();
- if (c == '>') {
- input_stack::get_char();
- context_buffer = "->";
- return RIGHT_ARROW_HEAD;
- }
- context_buffer = "-";
- return '-';
- case '!':
- c = input_stack::peek_char();
- if (c == '=') {
- input_stack::get_char();
- context_buffer = "!=";
- return NOTEQUAL;
- }
- context_buffer = "!";
- return '!';
- case '>':
- c = input_stack::peek_char();
- if (c == '=') {
- input_stack::get_char();
- context_buffer = ">=";
- return GREATEREQUAL;
- }
- context_buffer = ">";
- return '>';
- case '=':
- c = input_stack::peek_char();
- if (c == '=') {
- input_stack::get_char();
- context_buffer = "==";
- return EQUALEQUAL;
- }
- context_buffer = "=";
- return '=';
- case '&':
- c = input_stack::peek_char();
- if (c == '&') {
- input_stack::get_char();
- context_buffer = "&&";
- return ANDAND;
- }
- context_buffer = "&";
- return '&';
- case '|':
- c = input_stack::peek_char();
- if (c == '|') {
- input_stack::get_char();
- context_buffer = "||";
- return OROR;
- }
- context_buffer = "|";
- return '|';
- default:
- if (c != EOF && csalpha(c)) {
- token_buffer.clear();
- token_buffer = c;
- for (;;) {
- c = input_stack::peek_char();
- if (c == EOF || (!csalnum(c) && c != '_'))
- break;
- input_stack::get_char();
- token_buffer += char(c);
- }
- int tok = lookup_keyword(token_buffer.contents(),
- token_buffer.length());
- if (tok != 0) {
- context_buffer = token_buffer;
- return tok;
- }
- char *def = 0;
- if (lookup_flag) {
- token_buffer += '\0';
- def = macro_table.lookup(token_buffer.contents());
- token_buffer.set_length(token_buffer.length() - 1);
- if (def) {
- if (c == '(') {
- input_stack::get_char();
- interpolate_macro_with_args(def);
- }
- else
- input_stack::push(new macro_input(def));
- }
- }
- if (!def) {
- context_buffer = token_buffer;
- if (csupper(token_buffer[0]))
- return LABEL;
- else
- return VARIABLE;
- }
- }
- else {
- context_buffer = char(c);
- return (unsigned char)c;
- }
- break;
- }
- }
-}
-
-int get_delimited()
-{
- token_buffer.clear();
- int c = input_stack::get_char();
- while (c == ' ' || c == '\t' || c == '\n')
- c = input_stack::get_char();
- if (c == EOF) {
- lex_error("missing delimiter");
- return 0;
- }
- context_buffer = char(c);
- int had_newline = 0;
- int start = c;
- int level = 0;
- enum { NORMAL, IN_STRING, IN_STRING_QUOTED, DELIM_END } state = NORMAL;
- for (;;) {
- c = input_stack::get_char();
- if (c == EOF) {
- lex_error("missing closing delimiter");
- return 0;
- }
- if (c == '\n')
- had_newline = 1;
- else if (!had_newline)
- context_buffer += char(c);
- switch (state) {
- case NORMAL:
- if (start == '{') {
- if (c == '{') {
- level++;
- break;
- }
- if (c == '}') {
- if (--level < 0)
- state = DELIM_END;
- break;
- }
- }
- else {
- if (c == start) {
- state = DELIM_END;
- break;
- }
- }
- if (c == '"')
- state = IN_STRING;
- break;
- case IN_STRING_QUOTED:
- if (c == '\n')
- state = NORMAL;
- else
- state = IN_STRING;
- break;
- case IN_STRING:
- if (c == '"' || c == '\n')
- state = NORMAL;
- else if (c == '\\')
- state = IN_STRING_QUOTED;
- break;
- case DELIM_END:
- // This case it just to shut cfront 2.0 up.
- default:
- assert(0);
- }
- if (state == DELIM_END)
- break;
- token_buffer += c;
- }
- return 1;
-}
-
-void do_define()
-{
- int t = get_token(0); // do not expand what we are defining
- if (t != VARIABLE && t != LABEL) {
- lex_error("can only define variable or placename");
- return;
- }
- token_buffer += '\0';
- string nm = token_buffer;
- const char *name = nm.contents();
- if (!get_delimited())
- return;
- token_buffer += '\0';
- macro_table.define(name, strsave(token_buffer.contents()));
-}
-
-void do_undef()
-{
- int t = get_token(0); // do not expand what we are undefining
- if (t != VARIABLE && t != LABEL) {
- lex_error("can only define variable or placename");
- return;
- }
- token_buffer += '\0';
- macro_table.define(token_buffer.contents(), 0);
-}
-
-
-class for_input : public input {
- char *var;
- char *body;
- double from;
- double to;
- int by_is_multiplicative;
- double by;
- const char *p;
- int done_newline;
-public:
- for_input(char *, double, double, int, double, char *);
- ~for_input();
- int get();
- int peek();
-};
-
-for_input::for_input(char *vr, double f, double t,
- int bim, double b, char *bd)
-: var(vr), body(bd), from(f), to(t), by_is_multiplicative(bim), by(b),
- p(body), done_newline(0)
-{
-}
-
-for_input::~for_input()
-{
- a_delete var;
- a_delete body;
-}
-
-int for_input::get()
-{
- if (p == 0)
- return EOF;
- for (;;) {
- if (*p != '\0')
- return (unsigned char)*p++;
- if (!done_newline) {
- done_newline = 1;
- return '\n';
- }
- double val;
- if (!lookup_variable(var, &val)) {
- lex_error("body of `for' terminated enclosing block");
- return EOF;
- }
- if (by_is_multiplicative)
- val *= by;
- else
- val += by;
- define_variable(var, val);
- if ((from <= to && val > to)
- || (from >= to && val < to)) {
- p = 0;
- return EOF;
- }
- p = body;
- done_newline = 0;
- }
-}
-
-int for_input::peek()
-{
- if (p == 0)
- return EOF;
- if (*p != '\0')
- return (unsigned char)*p;
- if (!done_newline)
- return '\n';
- double val;
- if (!lookup_variable(var, &val))
- return EOF;
- if (by_is_multiplicative) {
- if (val * by > to)
- return EOF;
- }
- else {
- if ((from <= to && val + by > to)
- || (from >= to && val + by < to))
- return EOF;
- }
- if (*body == '\0')
- return EOF;
- return (unsigned char)*body;
-}
-
-void do_for(char *var, double from, double to, int by_is_multiplicative,
- double by, char *body)
-{
- define_variable(var, from);
- if ((by_is_multiplicative && by <= 0)
- || (by > 0 && from > to)
- || (by < 0 && from < to))
- return;
- input_stack::push(new for_input(var, from, to,
- by_is_multiplicative, by, body));
-}
-
-
-void do_copy(const char *filename)
-{
- errno = 0;
- FILE *fp = fopen(filename, "r");
- if (fp == 0) {
- lex_error("can't open `%1': %2", filename, strerror(errno));
- return;
- }
- input_stack::push(new file_input(fp, filename));
-}
-
-class copy_thru_input : public input {
- int done;
- char *body;
- char *until;
- const char *p;
- const char *ap;
- int argv[9];
- int argc;
- string line;
- int get_line();
- virtual int inget() = 0;
-public:
- copy_thru_input(const char *b, const char *u);
- ~copy_thru_input();
- int get();
- int peek();
-};
-
-class copy_file_thru_input : public copy_thru_input {
- input *in;
-public:
- copy_file_thru_input(input *, const char *b, const char *u);
- ~copy_file_thru_input();
- int inget();
-};
-
-copy_file_thru_input::copy_file_thru_input(input *i, const char *b,
- const char *u)
-: copy_thru_input(b, u), in(i)
-{
-}
-
-copy_file_thru_input::~copy_file_thru_input()
-{
- delete in;
-}
-
-int copy_file_thru_input::inget()
-{
- if (!in)
- return EOF;
- else
- return in->get();
-}
-
-class copy_rest_thru_input : public copy_thru_input {
-public:
- copy_rest_thru_input(const char *, const char *u);
- int inget();
-};
-
-copy_rest_thru_input::copy_rest_thru_input(const char *b, const char *u)
-: copy_thru_input(b, u)
-{
-}
-
-int copy_rest_thru_input::inget()
-{
- while (next != 0) {
- int c = next->get();
- if (c != EOF)
- return c;
- if (next->next == 0)
- return EOF;
- input *tem = next;
- next = next->next;
- delete tem;
- }
- return EOF;
-
-}
-
-copy_thru_input::copy_thru_input(const char *b, const char *u)
-: done(0)
-{
- ap = 0;
- body = process_body(b);
- p = 0;
- until = strsave(u);
-}
-
-
-copy_thru_input::~copy_thru_input()
-{
- a_delete body;
- a_delete until;
-}
-
-int copy_thru_input::get()
-{
- if (ap) {
- if (*ap != '\0')
- return (unsigned char)*ap++;
- ap = 0;
- }
- for (;;) {
- if (p == 0) {
- if (!get_line())
- break;
- p = body;
- }
- if (*p == '\0') {
- p = 0;
- return '\n';
- }
- while (*p >= ARG1 && *p <= ARG1 + 8) {
- int i = *p++ - ARG1;
- if (i < argc && line[argv[i]] != '\0') {
- ap = line.contents() + argv[i];
- return (unsigned char)*ap++;
- }
- }
- if (*p != '\0')
- return (unsigned char)*p++;
- }
- return EOF;
-}
-
-int copy_thru_input::peek()
-{
- if (ap) {
- if (*ap != '\0')
- return (unsigned char)*ap;
- ap = 0;
- }
- for (;;) {
- if (p == 0) {
- if (!get_line())
- break;
- p = body;
- }
- if (*p == '\0')
- return '\n';
- while (*p >= ARG1 && *p <= ARG1 + 8) {
- int i = *p++ - ARG1;
- if (i < argc && line[argv[i]] != '\0') {
- ap = line.contents() + argv[i];
- return (unsigned char)*ap;
- }
- }
- if (*p != '\0')
- return (unsigned char)*p;
- }
- return EOF;
-}
-
-int copy_thru_input::get_line()
-{
- if (done)
- return 0;
- line.clear();
- argc = 0;
- int c = inget();
- for (;;) {
- while (c == ' ')
- c = inget();
- if (c == EOF || c == '\n')
- break;
- if (argc == 9) {
- do {
- c = inget();
- } while (c != '\n' && c != EOF);
- break;
- }
- argv[argc++] = line.length();
- do {
- line += char(c);
- c = inget();
- } while (c != ' ' && c != '\n');
- line += '\0';
- }
- if (until != 0 && argc > 0 && strcmp(&line[argv[0]], until) == 0) {
- done = 1;
- return 0;
- }
- return argc > 0 || c == '\n';
-}
-
-class simple_file_input : public input {
- const char *filename;
- int lineno;
- FILE *fp;
-public:
- simple_file_input(FILE *, const char *);
- ~simple_file_input();
- int get();
- int peek();
- int get_location(const char **, int *);
-};
-
-simple_file_input::simple_file_input(FILE *p, const char *s)
-: filename(s), lineno(1), fp(p)
-{
-}
-
-simple_file_input::~simple_file_input()
-{
- // don't delete the filename
- fclose(fp);
-}
-
-int simple_file_input::get()
-{
- int c = getc(fp);
- while (invalid_input_char(c)) {
- error("invalid input character code %1", c);
- c = getc(fp);
- }
- if (c == '\n')
- lineno++;
- return c;
-}
-
-int simple_file_input::peek()
-{
- int c = getc(fp);
- while (invalid_input_char(c)) {
- error("invalid input character code %1", c);
- c = getc(fp);
- }
- if (c != EOF)
- ungetc(c, fp);
- return c;
-}
-
-int simple_file_input::get_location(const char **fnp, int *lnp)
-{
- *fnp = filename;
- *lnp = lineno;
- return 1;
-}
-
-
-void copy_file_thru(const char *filename, const char *body, const char *until)
-{
- errno = 0;
- FILE *fp = fopen(filename, "r");
- if (fp == 0) {
- lex_error("can't open `%1': %2", filename, strerror(errno));
- return;
- }
- input *in = new copy_file_thru_input(new simple_file_input(fp, filename),
- body, until);
- input_stack::push(in);
-}
-
-void copy_rest_thru(const char *body, const char *until)
-{
- input_stack::push(new copy_rest_thru_input(body, until));
-}
-
-void push_body(const char *s)
-{
- input_stack::push(new char_input('\n'));
- input_stack::push(new macro_input(s));
-}
-
-int delim_flag = 0;
-
-char *get_thru_arg()
-{
- int c = input_stack::peek_char();
- while (c == ' ') {
- input_stack::get_char();
- c = input_stack::peek_char();
- }
- if (c != EOF && csalpha(c)) {
- // looks like a macro
- input_stack::get_char();
- token_buffer = c;
- for (;;) {
- c = input_stack::peek_char();
- if (c == EOF || (!csalnum(c) && c != '_'))
- break;
- input_stack::get_char();
- token_buffer += char(c);
- }
- context_buffer = token_buffer;
- token_buffer += '\0';
- char *def = macro_table.lookup(token_buffer.contents());
- if (def)
- return strsave(def);
- // I guess it wasn't a macro after all; so push the macro name back.
- // -2 because we added a '\0'
- for (int i = token_buffer.length() - 2; i >= 0; i--)
- input_stack::push_back(token_buffer[i]);
- }
- if (get_delimited()) {
- token_buffer += '\0';
- return strsave(token_buffer.contents());
- }
- else
- return 0;
-}
-
-int lookahead_token = -1;
-string old_context_buffer;
-
-void do_lookahead()
-{
- if (lookahead_token == -1) {
- old_context_buffer = context_buffer;
- lookahead_token = get_token(1);
- }
-}
-
-int yylex()
-{
- if (delim_flag) {
- assert(lookahead_token == -1);
- if (delim_flag == 2) {
- if ((yylval.str = get_thru_arg()) != 0)
- return DELIMITED;
- else
- return 0;
- }
- else {
- if (get_delimited()) {
- token_buffer += '\0';
- yylval.str = strsave(token_buffer.contents());
- return DELIMITED;
- }
- else
- return 0;
- }
- }
- for (;;) {
- int t;
- if (lookahead_token >= 0) {
- t = lookahead_token;
- lookahead_token = -1;
- }
- else
- t = get_token(1);
- switch (t) {
- case '\n':
- return ';';
- case EOF:
- return 0;
- case DEFINE:
- do_define();
- break;
- case UNDEF:
- do_undef();
- break;
- case ORDINAL:
- yylval.n = token_int;
- return t;
- case NUMBER:
- yylval.x = token_double;
- return t;
- case COMMAND_LINE:
- case TEXT:
- token_buffer += '\0';
- if (!input_stack::get_location(&yylval.lstr.filename,
- &yylval.lstr.lineno)) {
- yylval.lstr.filename = 0;
- yylval.lstr.lineno = -1;
- }
- yylval.lstr.str = strsave(token_buffer.contents());
- return t;
- case LABEL:
- case VARIABLE:
- token_buffer += '\0';
- yylval.str = strsave(token_buffer.contents());
- return t;
- case LEFT:
- // change LEFT to LEFT_CORNER when followed by OF
- old_context_buffer = context_buffer;
- lookahead_token = get_token(1);
- if (lookahead_token == OF)
- return LEFT_CORNER;
- else
- return t;
- case RIGHT:
- // change RIGHT to RIGHT_CORNER when followed by OF
- old_context_buffer = context_buffer;
- lookahead_token = get_token(1);
- if (lookahead_token == OF)
- return RIGHT_CORNER;
- else
- return t;
- case UPPER:
- // recognise UPPER only before LEFT or RIGHT
- old_context_buffer = context_buffer;
- lookahead_token = get_token(1);
- if (lookahead_token != LEFT && lookahead_token != RIGHT) {
- yylval.str = strsave("upper");
- return VARIABLE;
- }
- else
- return t;
- case LOWER:
- // recognise LOWER only before LEFT or RIGHT
- old_context_buffer = context_buffer;
- lookahead_token = get_token(1);
- if (lookahead_token != LEFT && lookahead_token != RIGHT) {
- yylval.str = strsave("lower");
- return VARIABLE;
- }
- 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;
- lookahead_token = get_token(1);
- if (lookahead_token != OF) {
- yylval.str = strsave("top");
- return VARIABLE;
- }
- else
- return t;
- case BOTTOM:
- // recognise BOTTOM only before OF
- old_context_buffer = context_buffer;
- lookahead_token = get_token(1);
- if (lookahead_token != OF) {
- yylval.str = strsave("bottom");
- return VARIABLE;
- }
- else
- return t;
- case CENTER:
- // recognise CENTER only before OF
- old_context_buffer = context_buffer;
- lookahead_token = get_token(1);
- if (lookahead_token != OF) {
- yylval.str = strsave("center");
- return VARIABLE;
- }
- else
- return t;
- case START:
- // recognise START only before OF
- old_context_buffer = context_buffer;
- lookahead_token = get_token(1);
- if (lookahead_token != OF) {
- yylval.str = strsave("start");
- return VARIABLE;
- }
- else
- return t;
- case END:
- // recognise END only before OF
- old_context_buffer = context_buffer;
- lookahead_token = get_token(1);
- if (lookahead_token != OF) {
- yylval.str = strsave("end");
- return VARIABLE;
- }
- else
- return t;
- default:
- return t;
- }
- }
-}
-
-void lex_error(const char *message,
- const errarg &arg1,
- const errarg &arg2,
- const errarg &arg3)
-{
- const char *filename;
- int lineno;
- if (!input_stack::get_location(&filename, &lineno))
- error(message, arg1, arg2, arg3);
- else
- error_with_file_and_line(filename, lineno, message, arg1, arg2, arg3);
-}
-
-void lex_warning(const char *message,
- const errarg &arg1,
- const errarg &arg2,
- const errarg &arg3)
-{
- const char *filename;
- int lineno;
- if (!input_stack::get_location(&filename, &lineno))
- warning(message, arg1, arg2, arg3);
- else
- warning_with_file_and_line(filename, lineno, message, arg1, arg2, arg3);
-}
-
-void yyerror(const char *s)
-{
- const char *filename;
- int lineno;
- const char *context = 0;
- if (lookahead_token == -1) {
- if (context_buffer.length() > 0) {
- context_buffer += '\0';
- context = context_buffer.contents();
- }
- }
- else {
- if (old_context_buffer.length() > 0) {
- old_context_buffer += '\0';
- context = old_context_buffer.contents();
- }
- }
- if (!input_stack::get_location(&filename, &lineno)) {
- if (context) {
- if (context[0] == '\n' && context[1] == '\0')
- error("%1 before newline", s);
- else
- error("%1 before `%2'", s, context);
- }
- else
- error("%1 at end of picture", s);
- }
- else {
- if (context) {
- if (context[0] == '\n' && context[1] == '\0')
- error_with_file_and_line(filename, lineno, "%1 before newline", s);
- else
- error_with_file_and_line(filename, lineno, "%1 before `%2'",
- s, context);
- }
- else
- error_with_file_and_line(filename, lineno, "%1 at end of picture", s);
- }
-}
-
diff --git a/contrib/groff/src/preproc/pic/main.cpp b/contrib/groff/src/preproc/pic/main.cpp
deleted file mode 100644
index 0e05f77cd280..000000000000
--- a/contrib/groff/src/preproc/pic/main.cpp
+++ /dev/null
@@ -1,642 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989-1992, 2000, 2001, 2002, 2003
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "pic.h"
-
-extern int yyparse();
-extern "C" const char *Version_string;
-
-output *out;
-char *graphname; // the picture box name in TeX mode
-
-int flyback_flag;
-int zero_length_line_flag = 0;
-// Non-zero means we're using a groff driver.
-int driver_extension_flag = 1;
-int compatible_flag = 0;
-int safer_flag = 1;
-int command_char = '.'; // the character that introduces lines
- // that should be passed through tranparently
-static int lf_flag = 1; // non-zero if we should attempt to understand
- // lines beginning with `.lf'
-
-// Non-zero means a parse error was encountered.
-static int had_parse_error = 0;
-
-void do_file(const char *filename);
-
-class top_input : public input {
- FILE *fp;
- int bol;
- int eof;
- int push_back[3];
- int start_lineno;
-public:
- top_input(FILE *);
- int get();
- int peek();
- int get_location(const char **, int *);
-};
-
-top_input::top_input(FILE *p) : fp(p), bol(1), eof(0)
-{
- push_back[0] = push_back[1] = push_back[2] = EOF;
- start_lineno = current_lineno;
-}
-
-int top_input::get()
-{
- if (eof)
- return EOF;
- if (push_back[2] != EOF) {
- int c = push_back[2];
- push_back[2] = EOF;
- return c;
- }
- else if (push_back[1] != EOF) {
- int c = push_back[1];
- push_back[1] = EOF;
- return c;
- }
- else if (push_back[0] != EOF) {
- int c = push_back[0];
- push_back[0] = EOF;
- return c;
- }
- int c = getc(fp);
- while (invalid_input_char(c)) {
- error("invalid input character code %1", int(c));
- c = getc(fp);
- bol = 0;
- }
- if (bol && c == '.') {
- c = getc(fp);
- if (c == 'P') {
- c = getc(fp);
- if (c == 'F' || c == 'E') {
- int d = getc(fp);
- if (d != EOF)
- ungetc(d, fp);
- if (d == EOF || d == ' ' || d == '\n' || compatible_flag) {
- eof = 1;
- flyback_flag = c == 'F';
- return EOF;
- }
- push_back[0] = c;
- push_back[1] = 'P';
- return '.';
- }
- if (c == 'S') {
- c = getc(fp);
- if (c != EOF)
- ungetc(c, fp);
- if (c == EOF || c == ' ' || c == '\n' || compatible_flag) {
- error("nested .PS");
- eof = 1;
- return EOF;
- }
- push_back[0] = 'S';
- push_back[1] = 'P';
- return '.';
- }
- if (c != EOF)
- ungetc(c, fp);
- push_back[0] = 'P';
- return '.';
- }
- else {
- if (c != EOF)
- ungetc(c, fp);
- return '.';
- }
- }
- if (c == '\n') {
- bol = 1;
- current_lineno++;
- return '\n';
- }
- bol = 0;
- if (c == EOF) {
- eof = 1;
- error("end of file before .PE or .PF");
- error_with_file_and_line(current_filename, start_lineno - 1,
- ".PS was here");
- }
- return c;
-}
-
-int top_input::peek()
-{
- if (eof)
- return EOF;
- if (push_back[2] != EOF)
- return push_back[2];
- if (push_back[1] != EOF)
- return push_back[1];
- if (push_back[0] != EOF)
- return push_back[0];
- int c = getc(fp);
- while (invalid_input_char(c)) {
- error("invalid input character code %1", int(c));
- c = getc(fp);
- bol = 0;
- }
- if (bol && c == '.') {
- c = getc(fp);
- if (c == 'P') {
- c = getc(fp);
- if (c == 'F' || c == 'E') {
- int d = getc(fp);
- if (d != EOF)
- ungetc(d, fp);
- if (d == EOF || d == ' ' || d == '\n' || compatible_flag) {
- eof = 1;
- flyback_flag = c == 'F';
- return EOF;
- }
- push_back[0] = c;
- push_back[1] = 'P';
- push_back[2] = '.';
- return '.';
- }
- if (c == 'S') {
- c = getc(fp);
- if (c != EOF)
- ungetc(c, fp);
- if (c == EOF || c == ' ' || c == '\n' || compatible_flag) {
- error("nested .PS");
- eof = 1;
- return EOF;
- }
- push_back[0] = 'S';
- push_back[1] = 'P';
- push_back[2] = '.';
- return '.';
- }
- if (c != EOF)
- ungetc(c, fp);
- push_back[0] = 'P';
- push_back[1] = '.';
- return '.';
- }
- else {
- if (c != EOF)
- ungetc(c, fp);
- push_back[0] = '.';
- return '.';
- }
- }
- if (c != EOF)
- ungetc(c, fp);
- if (c == '\n')
- return '\n';
- return c;
-}
-
-int top_input::get_location(const char **filenamep, int *linenop)
-{
- *filenamep = current_filename;
- *linenop = current_lineno;
- return 1;
-}
-
-void do_picture(FILE *fp)
-{
- flyback_flag = 0;
- int c;
- a_delete graphname;
- graphname = strsave("graph"); // default picture name in TeX mode
- while ((c = getc(fp)) == ' ')
- ;
- if (c == '<') {
- string filename;
- while ((c = getc(fp)) == ' ')
- ;
- while (c != EOF && c != ' ' && c != '\n') {
- filename += char(c);
- c = getc(fp);
- }
- if (c == ' ') {
- do {
- c = getc(fp);
- } while (c != EOF && c != '\n');
- }
- if (c == '\n')
- current_lineno++;
- if (filename.length() == 0)
- error("missing filename after `<'");
- else {
- filename += '\0';
- const char *old_filename = current_filename;
- int old_lineno = current_lineno;
- // filenames must be permanent
- do_file(strsave(filename.contents()));
- current_filename = old_filename;
- current_lineno = old_lineno;
- }
- out->set_location(current_filename, current_lineno);
- }
- else {
- out->set_location(current_filename, current_lineno);
- string start_line;
- while (c != EOF) {
- if (c == '\n') {
- current_lineno++;
- break;
- }
- start_line += c;
- c = getc(fp);
- }
- if (c == EOF)
- return;
- start_line += '\0';
- double wid, ht;
- switch (sscanf(&start_line[0], "%lf %lf", &wid, &ht)) {
- case 1:
- ht = 0.0;
- break;
- case 2:
- break;
- default:
- ht = wid = 0.0;
- break;
- }
- out->set_desired_width_height(wid, ht);
- out->set_args(start_line.contents());
- lex_init(new top_input(fp));
- if (yyparse()) {
- had_parse_error = 1;
- lex_error("giving up on this picture");
- }
- parse_cleanup();
- lex_cleanup();
-
- // skip the rest of the .PF/.PE line
- while ((c = getc(fp)) != EOF && c != '\n')
- ;
- if (c == '\n')
- current_lineno++;
- out->set_location(current_filename, current_lineno);
- }
-}
-
-void do_file(const char *filename)
-{
- FILE *fp;
- if (strcmp(filename, "-") == 0)
- fp = stdin;
- else {
- errno = 0;
- fp = fopen(filename, "r");
- if (fp == 0) {
- delete out;
- fatal("can't open `%1': %2", filename, strerror(errno));
- }
- }
- out->set_location(filename, 1);
- current_filename = filename;
- current_lineno = 1;
- enum { START, MIDDLE, HAD_DOT, HAD_P, HAD_PS, HAD_l, HAD_lf } state = START;
- for (;;) {
- int c = getc(fp);
- if (c == EOF)
- break;
- switch (state) {
- case START:
- if (c == '.')
- state = HAD_DOT;
- else {
- putchar(c);
- if (c == '\n') {
- current_lineno++;
- state = START;
- }
- else
- state = MIDDLE;
- }
- break;
- case MIDDLE:
- putchar(c);
- if (c == '\n') {
- current_lineno++;
- state = START;
- }
- break;
- case HAD_DOT:
- if (c == 'P')
- state = HAD_P;
- else if (lf_flag && c == 'l')
- state = HAD_l;
- else {
- putchar('.');
- putchar(c);
- if (c == '\n') {
- current_lineno++;
- state = START;
- }
- else
- state = MIDDLE;
- }
- break;
- case HAD_P:
- if (c == 'S')
- state = HAD_PS;
- else {
- putchar('.');
- putchar('P');
- putchar(c);
- if (c == '\n') {
- current_lineno++;
- state = START;
- }
- else
- state = MIDDLE;
- }
- break;
- case HAD_PS:
- if (c == ' ' || c == '\n' || compatible_flag) {
- ungetc(c, fp);
- do_picture(fp);
- state = START;
- }
- else {
- fputs(".PS", stdout);
- putchar(c);
- state = MIDDLE;
- }
- break;
- case HAD_l:
- if (c == 'f')
- state = HAD_lf;
- else {
- putchar('.');
- putchar('l');
- putchar(c);
- if (c == '\n') {
- current_lineno++;
- state = START;
- }
- else
- state = MIDDLE;
- }
- break;
- case HAD_lf:
- if (c == ' ' || c == '\n' || compatible_flag) {
- string line;
- while (c != EOF) {
- line += c;
- if (c == '\n') {
- current_lineno++;
- break;
- }
- c = getc(fp);
- }
- line += '\0';
- interpret_lf_args(line.contents());
- printf(".lf%s", line.contents());
- state = START;
- }
- else {
- fputs(".lf", stdout);
- putchar(c);
- state = MIDDLE;
- }
- break;
- default:
- assert(0);
- }
- }
- switch (state) {
- case START:
- break;
- case MIDDLE:
- putchar('\n');
- break;
- case HAD_DOT:
- fputs(".\n", stdout);
- break;
- case HAD_P:
- fputs(".P\n", stdout);
- break;
- case HAD_PS:
- fputs(".PS\n", stdout);
- break;
- case HAD_l:
- fputs(".l\n", stdout);
- break;
- case HAD_lf:
- fputs(".lf\n", stdout);
- break;
- }
- if (fp != stdin)
- fclose(fp);
-}
-
-#ifdef FIG_SUPPORT
-void do_whole_file(const char *filename)
-{
- // Do not set current_filename.
- FILE *fp;
- if (strcmp(filename, "-") == 0)
- fp = stdin;
- else {
- errno = 0;
- fp = fopen(filename, "r");
- if (fp == 0)
- fatal("can't open `%1': %2", filename, strerror(errno));
- }
- lex_init(new file_input(fp, filename));
- if (yyparse())
- had_parse_error = 1;
- parse_cleanup();
- lex_cleanup();
-}
-#endif
-
-void usage(FILE *stream)
-{
- fprintf(stream, "usage: %s [ -nvC ] [ filename ... ]\n", program_name);
-#ifdef TEX_SUPPORT
- fprintf(stream, " %s -t [ -cvzC ] [ filename ... ]\n", program_name);
-#endif
-#ifdef FIG_SUPPORT
- fprintf(stream, " %s -f [ -v ] [ filename ]\n", program_name);
-#endif
-}
-
-#if defined(__MSDOS__) || defined(__EMX__)
-static char *fix_program_name(char *arg, char *dflt)
-{
- if (!arg)
- return dflt;
- char *prog = strchr(arg, '\0');
- for (;;) {
- if (prog == arg)
- break;
- --prog;
- if (strchr("\\/:", *prog)) {
- prog++;
- break;
- }
- }
- char *ext = strchr(prog, '.');
- if (ext)
- *ext = '\0';
- for (char *p = prog; *p; p++)
- if ('A' <= *p && *p <= 'Z')
- *p = 'a' + (*p - 'A');
- return prog;
-}
-#endif /* __MSDOS__ || __EMX__ */
-
-int main(int argc, char **argv)
-{
- setlocale(LC_NUMERIC, "C");
-#if defined(__MSDOS__) || defined(__EMX__)
- argv[0] = fix_program_name(argv[0], "pic");
-#endif /* __MSDOS__ || __EMX__ */
- program_name = argv[0];
- static char stderr_buf[BUFSIZ];
- setbuf(stderr, stderr_buf);
- int opt;
-#ifdef TEX_SUPPORT
- int tex_flag = 0;
- int tpic_flag = 0;
-#endif
-#ifdef FIG_SUPPORT
- int whole_file_flag = 0;
- int fig_flag = 0;
-#endif
- static const struct option long_options[] = {
- { "help", no_argument, 0, CHAR_MAX + 1 },
- { "version", no_argument, 0, 'v' },
- { NULL, 0, 0, 0 }
- };
- while ((opt = getopt_long(argc, argv, "T:CDSUtcvnxzpf", long_options, NULL))
- != EOF)
- switch (opt) {
- case 'C':
- compatible_flag = 1;
- break;
- case 'D':
- case 'T':
- break;
- case 'S':
- safer_flag = 1;
- break;
- case 'U':
- safer_flag = 0;
- break;
- case 'f':
-#ifdef FIG_SUPPORT
- whole_file_flag++;
- fig_flag++;
-#else
- fatal("fig support not included");
-#endif
- break;
- case 'n':
- driver_extension_flag = 0;
- break;
- case 'p':
- case 'x':
- warning("-%1 option is obsolete", char(opt));
- break;
- case 't':
-#ifdef TEX_SUPPORT
- tex_flag++;
-#else
- fatal("TeX support not included");
-#endif
- break;
- case 'c':
-#ifdef TEX_SUPPORT
- tpic_flag++;
-#else
- fatal("TeX support not included");
-#endif
- break;
- case 'v':
- {
- printf("GNU pic (groff) version %s\n", Version_string);
- exit(0);
- break;
- }
- case 'z':
- // zero length lines will be printed as dots
- zero_length_line_flag++;
- break;
- case CHAR_MAX + 1: // --help
- usage(stdout);
- exit(0);
- break;
- case '?':
- usage(stderr);
- exit(1);
- break;
- default:
- assert(0);
- }
- parse_init();
-#ifdef TEX_SUPPORT
- if (tpic_flag) {
- out = make_tpic_output();
- lf_flag = 0;
- }
- else if (tex_flag) {
- out = make_tex_output();
- command_char = '\\';
- lf_flag = 0;
- }
- else
-#endif
-#ifdef FIG_SUPPORT
- if (fig_flag)
- out = make_fig_output();
- else
-#endif
- out = make_troff_output();
-#ifdef FIG_SUPPORT
- if (whole_file_flag) {
- if (optind >= argc)
- do_whole_file("-");
- else if (argc - optind > 1) {
- usage(stderr);
- exit(1);
- } else
- do_whole_file(argv[optind]);
- }
- else {
-#endif
- if (optind >= argc)
- do_file("-");
- else
- for (int i = optind; i < argc; i++)
- do_file(argv[i]);
-#ifdef FIG_SUPPORT
- }
-#endif
- delete out;
- if (ferror(stdout) || fflush(stdout) < 0)
- fatal("output error");
- return had_parse_error;
-}
-
diff --git a/contrib/groff/src/preproc/pic/object.cpp b/contrib/groff/src/preproc/pic/object.cpp
deleted file mode 100644
index aefbd45e3940..000000000000
--- a/contrib/groff/src/preproc/pic/object.cpp
+++ /dev/null
@@ -1,2017 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004, 2005
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "pic.h"
-#include "ptable.h"
-#include "object.h"
-
-void print_object_list(object *);
-
-line_type::line_type()
-: type(solid), thickness(1.0)
-{
-}
-
-output::output() : args(0), desired_height(0.0), desired_width(0.0)
-{
-}
-
-output::~output()
-{
- a_delete args;
-}
-
-void output::set_desired_width_height(double wid, double ht)
-{
- desired_width = wid;
- desired_height = ht;
-}
-
-void output::set_args(const char *s)
-{
- a_delete args;
- if (s == 0 || *s == '\0')
- args = 0;
- else
- args = strsave(s);
-}
-
-int output::supports_filled_polygons()
-{
- return 0;
-}
-
-void output::begin_block(const position &, const position &)
-{
-}
-
-void output::end_block()
-{
-}
-
-double output::compute_scale(double sc, const position &ll, const position &ur)
-{
- distance dim = ur - ll;
- if (desired_width != 0.0 || desired_height != 0.0) {
- sc = 0.0;
- if (desired_width != 0.0) {
- if (dim.x == 0.0)
- error("width specified for picture with zero width");
- else
- sc = dim.x/desired_width;
- }
- if (desired_height != 0.0) {
- if (dim.y == 0.0)
- error("height specified for picture with zero height");
- else {
- double tem = dim.y/desired_height;
- if (tem > sc)
- sc = tem;
- }
- }
- return sc == 0.0 ? 1.0 : sc;
- }
- else {
- if (sc <= 0.0)
- sc = 1.0;
- distance sdim = dim/sc;
- double max_width = 0.0;
- lookup_variable("maxpswid", &max_width);
- double max_height = 0.0;
- lookup_variable("maxpsht", &max_height);
- if ((max_width > 0.0 && sdim.x > max_width)
- || (max_height > 0.0 && sdim.y > max_height)) {
- double xscale = dim.x/max_width;
- double yscale = dim.y/max_height;
- return xscale > yscale ? xscale : yscale;
- }
- else
- return sc;
- }
-}
-
-position::position(const place &pl)
-{
- if (pl.obj != 0) {
- // Use two statements to work around bug in SGI C++.
- object *tem = pl.obj;
- *this = tem->origin();
- }
- else {
- x = pl.x;
- y = pl.y;
- }
-}
-
-position::position() : x(0.0), y(0.0)
-{
-}
-
-position::position(double a, double b) : x(a), y(b)
-{
-}
-
-
-int operator==(const position &a, const position &b)
-{
- return a.x == b.x && a.y == b.y;
-}
-
-int operator!=(const position &a, const position &b)
-{
- return a.x != b.x || a.y != b.y;
-}
-
-position &position::operator+=(const position &a)
-{
- x += a.x;
- y += a.y;
- return *this;
-}
-
-position &position::operator-=(const position &a)
-{
- x -= a.x;
- y -= a.y;
- return *this;
-}
-
-position &position::operator*=(double a)
-{
- x *= a;
- y *= a;
- return *this;
-}
-
-position &position::operator/=(double a)
-{
- x /= a;
- y /= a;
- return *this;
-}
-
-position operator-(const position &a)
-{
- return position(-a.x, -a.y);
-}
-
-position operator+(const position &a, const position &b)
-{
- return position(a.x + b.x, a.y + b.y);
-}
-
-position operator-(const position &a, const position &b)
-{
- return position(a.x - b.x, a.y - b.y);
-}
-
-position operator/(const position &a, double n)
-{
- return position(a.x/n, a.y/n);
-}
-
-position operator*(const position &a, double n)
-{
- return position(a.x*n, a.y*n);
-}
-
-// dot product
-
-double operator*(const position &a, const position &b)
-{
- return a.x*b.x + a.y*b.y;
-}
-
-double hypot(const position &a)
-{
- return groff_hypot(a.x, a.y);
-}
-
-struct arrow_head_type {
- double height;
- double width;
- int solid;
-};
-
-void draw_arrow(const position &pos, const distance &dir,
- const arrow_head_type &aht, const line_type &lt,
- char *outline_color_for_fill)
-{
- double hyp = hypot(dir);
- if (hyp == 0.0) {
- error("cannot draw arrow on object with zero length");
- return;
- }
- position base = -dir;
- base *= aht.height/hyp;
- position n(dir.y, -dir.x);
- n *= aht.width/(hyp*2.0);
- line_type slt = lt;
- slt.type = line_type::solid;
- if (aht.solid && out->supports_filled_polygons()) {
- position v[3];
- v[0] = pos;
- v[1] = pos + base + n;
- v[2] = pos + base - n;
- // fill with outline color
- out->set_color(outline_color_for_fill, outline_color_for_fill);
- // make stroke thin to avoid arrow sticking
- slt.thickness = 0.1;
- out->polygon(v, 3, slt, 1);
- }
- else {
- // use two line segments to avoid arrow sticking
- out->line(pos + base - n, &pos, 1, slt);
- out->line(pos + base + n, &pos, 1, slt);
- }
-}
-
-object::object() : prev(0), next(0)
-{
-}
-
-object::~object()
-{
-}
-
-void object::move_by(const position &)
-{
-}
-
-void object::print()
-{
-}
-
-void object::print_text()
-{
-}
-
-int object::blank()
-{
- return 0;
-}
-
-struct bounding_box {
- int blank;
- position ll;
- position ur;
-
- bounding_box();
- void encompass(const position &);
-};
-
-bounding_box::bounding_box()
-: blank(1)
-{
-}
-
-void bounding_box::encompass(const position &pos)
-{
- if (blank) {
- ll = pos;
- ur = pos;
- blank = 0;
- }
- else {
- if (pos.x < ll.x)
- ll.x = pos.x;
- if (pos.y < ll.y)
- ll.y = pos.y;
- if (pos.x > ur.x)
- ur.x = pos.x;
- if (pos.y > ur.y)
- ur.y = pos.y;
- }
-}
-
-void object::update_bounding_box(bounding_box *)
-{
-}
-
-position object::origin()
-{
- return position(0.0,0.0);
-}
-
-position object::north()
-{
- return origin();
-}
-
-position object::south()
-{
- return origin();
-}
-
-position object::east()
-{
- return origin();
-}
-
-position object::west()
-{
- return origin();
-}
-
-position object::north_east()
-{
- return origin();
-}
-
-position object::north_west()
-{
- return origin();
-}
-
-position object::south_east()
-{
- return origin();
-}
-
-position object::south_west()
-{
- return origin();
-}
-
-position object::start()
-{
- return origin();
-}
-
-position object::end()
-{
- return origin();
-}
-
-position object::center()
-{
- return origin();
-}
-
-double object::width()
-{
- return 0.0;
-}
-
-double object::radius()
-{
- return 0.0;
-}
-
-double object::height()
-{
- return 0.0;
-}
-
-place *object::find_label(const char *)
-{
- return 0;
-}
-
-segment::segment(const position &a, int n, segment *p)
-: is_absolute(n), pos(a), next(p)
-{
-}
-
-text_item::text_item(char *t, const char *fn, int ln)
-: next(0), text(t), filename(fn), lineno(ln)
-{
- adj.h = CENTER_ADJUST;
- adj.v = NONE_ADJUST;
-}
-
-text_item::~text_item()
-{
- a_delete text;
-}
-
-object_spec::object_spec(object_type t) : type(t)
-{
- flags = 0;
- tbl = 0;
- segment_list = 0;
- segment_width = segment_height = 0.0;
- segment_is_absolute = 0;
- text = 0;
- shaded = 0;
- outlined = 0;
- with = 0;
- dir = RIGHT_DIRECTION;
-}
-
-object_spec::~object_spec()
-{
- delete tbl;
- while (segment_list != 0) {
- segment *tem = segment_list;
- segment_list = segment_list->next;
- delete tem;
- }
- object *p = oblist.head;
- while (p != 0) {
- object *tem = p;
- p = p->next;
- delete tem;
- }
- while (text != 0) {
- text_item *tem = text;
- text = text->next;
- delete tem;
- }
- delete with;
- a_delete shaded;
- a_delete outlined;
-}
-
-class command_object : public object {
- char *s;
- const char *filename;
- int lineno;
-public:
- command_object(char *, const char *, int);
- ~command_object();
- object_type type() { return OTHER_OBJECT; }
- void print();
-};
-
-command_object::command_object(char *p, const char *fn, int ln)
-: s(p), filename(fn), lineno(ln)
-{
-}
-
-command_object::~command_object()
-{
- a_delete s;
-}
-
-void command_object::print()
-{
- out->command(s, filename, lineno);
-}
-
-object *make_command_object(char *s, const char *fn, int ln)
-{
- return new command_object(s, fn, ln);
-}
-
-class mark_object : public object {
-public:
- mark_object();
- object_type type();
-};
-
-object *make_mark_object()
-{
- return new mark_object();
-}
-
-mark_object::mark_object()
-{
-}
-
-object_type mark_object::type()
-{
- return MARK_OBJECT;
-}
-
-object_list::object_list() : head(0), tail(0)
-{
-}
-
-void object_list::append(object *obj)
-{
- if (tail == 0) {
- obj->next = obj->prev = 0;
- head = tail = obj;
- }
- else {
- obj->prev = tail;
- obj->next = 0;
- tail->next = obj;
- tail = obj;
- }
-}
-
-void object_list::wrap_up_block(object_list *ol)
-{
- object *p;
- for (p = tail; p && p->type() != MARK_OBJECT; p = p->prev)
- ;
- assert(p != 0);
- ol->head = p->next;
- if (ol->head) {
- ol->tail = tail;
- ol->head->prev = 0;
- }
- else
- ol->tail = 0;
- tail = p->prev;
- if (tail)
- tail->next = 0;
- else
- head = 0;
- delete p;
-}
-
-text_piece::text_piece()
-: text(0), filename(0), lineno(-1)
-{
- adj.h = CENTER_ADJUST;
- adj.v = NONE_ADJUST;
-}
-
-text_piece::~text_piece()
-{
- a_delete text;
-}
-
-class graphic_object : public object {
- int ntext;
- text_piece *text;
- int aligned;
-protected:
- line_type lt;
- char *outline_color;
- char *color_fill;
-public:
- graphic_object();
- ~graphic_object();
- object_type type() = 0;
- void print_text();
- void add_text(text_item *, int);
- void set_dotted(double);
- 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), outline_color(0), color_fill(0)
-{
-}
-
-void graphic_object::set_dotted(double wid)
-{
- lt.type = line_type::dotted;
- lt.dash_width = wid;
-}
-
-void graphic_object::set_dashed(double wid)
-{
- lt.type = line_type::dashed;
- lt.dash_width = wid;
-}
-
-void graphic_object::set_thickness(double th)
-{
- lt.thickness = th;
-}
-
-void graphic_object::set_fill(double)
-{
-}
-
-void graphic_object::set_fill_color(char *c)
-{
- color_fill = strsave(c);
-}
-
-void graphic_object::set_outline_color(char *c)
-{
- outline_color = strsave(c);
-}
-
-char *graphic_object::get_outline_color()
-{
- return outline_color;
-}
-
-void graphic_object::set_invisible()
-{
- lt.type = line_type::invisible;
-}
-
-void graphic_object::add_text(text_item *t, int a)
-{
- aligned = a;
- int len = 0;
- text_item *p;
- for (p = t; p; p = p->next)
- len++;
- if (len == 0)
- text = 0;
- else {
- text = new text_piece[len];
- for (p = t, len = 0; p; p = p->next, len++) {
- text[len].text = p->text;
- p->text = 0;
- text[len].adj = p->adj;
- text[len].filename = p->filename;
- text[len].lineno = p->lineno;
- }
- }
- ntext = len;
-}
-
-void graphic_object::print_text()
-{
- double angle = 0.0;
- if (aligned) {
- position d(end() - start());
- if (d.x != 0.0 || d.y != 0.0)
- angle = atan2(d.y, d.x);
- }
- if (text != 0) {
- out->set_color(color_fill, get_outline_color());
- out->text(center(), text, ntext, angle);
- out->reset_color();
- }
-}
-
-graphic_object::~graphic_object()
-{
- if (text)
- ad_delete(ntext) text;
-}
-
-class rectangle_object : public graphic_object {
-protected:
- position cent;
- position dim;
-public:
- rectangle_object(const position &);
- double width() { return dim.x; }
- double height() { return dim.y; }
- position origin() { return cent; }
- position center() { return cent; }
- position north() { return position(cent.x, cent.y + dim.y/2.0); }
- position south() { return position(cent.x, cent.y - dim.y/2.0); }
- position east() { return position(cent.x + dim.x/2.0, cent.y); }
- position west() { return position(cent.x - dim.x/2.0, cent.y); }
- position north_east() { return position(cent.x + dim.x/2.0, cent.y + dim.y/2.0); }
- position north_west() { return position(cent.x - dim.x/2.0, cent.y + dim.y/2.0); }
- position south_east() { return position(cent.x + dim.x/2.0, cent.y - dim.y/2.0); }
- position south_west() { return position(cent.x - dim.x/2.0, cent.y - dim.y/2.0); }
- object_type type() = 0;
- void update_bounding_box(bounding_box *);
- void move_by(const position &);
-};
-
-rectangle_object::rectangle_object(const position &d)
-: dim(d)
-{
-}
-
-void rectangle_object::update_bounding_box(bounding_box *p)
-{
- p->encompass(cent - dim/2.0);
- p->encompass(cent + dim/2.0);
-}
-
-void rectangle_object::move_by(const position &a)
-{
- cent += a;
-}
-
-class closed_object : public rectangle_object {
-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), color_fill(0)
-{
-}
-
-void closed_object::set_fill(double f)
-{
- assert(f >= 0.0);
- fill = f;
-}
-
-void closed_object::set_fill_color(char *f)
-{
- color_fill = strsave(f);
-}
-
-class box_object : public closed_object {
- double xrad;
- double yrad;
-public:
- box_object(const position &, double);
- object_type type() { return BOX_OBJECT; }
- void print();
- position north_east();
- position north_west();
- position south_east();
- position south_west();
-};
-
-box_object::box_object(const position &pos, double r)
-: closed_object(pos), xrad(dim.x > 0 ? r : -r), yrad(dim.y > 0 ? r : -r)
-{
-}
-
-const double CHOP_FACTOR = 1.0 - 1.0/M_SQRT2;
-
-position box_object::north_east()
-{
- return position(cent.x + dim.x/2.0 - CHOP_FACTOR*xrad,
- cent.y + dim.y/2.0 - CHOP_FACTOR*yrad);
-}
-
-position box_object::north_west()
-{
- return position(cent.x - dim.x/2.0 + CHOP_FACTOR*xrad,
- cent.y + dim.y/2.0 - CHOP_FACTOR*yrad);
-}
-
-position box_object::south_east()
-{
- return position(cent.x + dim.x/2.0 - CHOP_FACTOR*xrad,
- cent.y - dim.y/2.0 + CHOP_FACTOR*yrad);
-}
-
-position box_object::south_west()
-{
- return position(cent.x - dim.x/2.0 + CHOP_FACTOR*xrad,
- cent.y - dim.y/2.0 + CHOP_FACTOR*yrad);
-}
-
-void box_object::print()
-{
- 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];
- vec[0] = cent + position(dim2.x, -dim2.y);
- vec[1] = cent + position(dim2.x, dim2.y);
- vec[2] = cent + position(-dim2.x, dim2.y);
- vec[3] = cent + position(-dim2.x, -dim2.y);
- out->polygon(vec, 4, lt, fill);
- }
- else {
- 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)
-{
- static double last_box_height;
- static double last_box_width;
- static double last_box_radius;
- static int have_last_box = 0;
- if (!(flags & HAS_HEIGHT)) {
- if ((flags & IS_SAME) && have_last_box)
- height = last_box_height;
- else
- lookup_variable("boxht", &height);
- }
- if (!(flags & HAS_WIDTH)) {
- if ((flags & IS_SAME) && have_last_box)
- width = last_box_width;
- else
- lookup_variable("boxwid", &width);
- }
- if (!(flags & HAS_RADIUS)) {
- if ((flags & IS_SAME) && have_last_box)
- radius = last_box_radius;
- else
- lookup_variable("boxrad", &radius);
- }
- last_box_width = width;
- last_box_height = height;
- last_box_radius = radius;
- have_last_box = 1;
- radius = fabs(radius);
- if (radius*2.0 > fabs(width))
- radius = fabs(width/2.0);
- if (radius*2.0 > fabs(height))
- radius = fabs(height/2.0);
- box_object *p = new box_object(position(width, height), radius);
- if (!position_rectangle(p, curpos, dirp)) {
- delete p;
- p = 0;
- }
- return p;
-}
-
-// return non-zero for success
-
-int object_spec::position_rectangle(rectangle_object *p,
- position *curpos, direction *dirp)
-{
- position pos;
- dir = *dirp; // ignore any direction in attribute list
- position motion;
- switch (dir) {
- case UP_DIRECTION:
- motion.y = p->height()/2.0;
- break;
- case DOWN_DIRECTION:
- motion.y = -p->height()/2.0;
- break;
- case LEFT_DIRECTION:
- motion.x = -p->width()/2.0;
- break;
- case RIGHT_DIRECTION:
- motion.x = p->width()/2.0;
- break;
- default:
- assert(0);
- }
- if (flags & HAS_AT) {
- pos = at;
- if (flags & HAS_WITH) {
- place offset;
- place here;
- here.obj = p;
- if (!with->follow(here, &offset))
- return 0;
- pos -= offset;
- }
- }
- else {
- pos = *curpos;
- pos += motion;
- }
- p->move_by(pos);
- pos += motion;
- *curpos = pos;
- return 1;
-}
-
-class block_object : public rectangle_object {
- object_list oblist;
- PTABLE(place) *tbl;
-public:
- block_object(const position &, const object_list &ol, PTABLE(place) *t);
- ~block_object();
- place *find_label(const char *);
- object_type type();
- void move_by(const position &);
- void print();
-};
-
-block_object::block_object(const position &d, const object_list &ol,
- PTABLE(place) *t)
-: rectangle_object(d), oblist(ol), tbl(t)
-{
-}
-
-block_object::~block_object()
-{
- delete tbl;
- object *p = oblist.head;
- while (p != 0) {
- object *tem = p;
- p = p->next;
- delete tem;
- }
-}
-
-void block_object::print()
-{
- out->begin_block(south_west(), north_east());
- print_object_list(oblist.head);
- out->end_block();
-}
-
-static void adjust_objectless_places(PTABLE(place) *tbl, const position &a)
-{
- // Adjust all the labels that aren't attached to objects.
- PTABLE_ITERATOR(place) iter(tbl);
- const char *key;
- place *pl;
- while (iter.next(&key, &pl))
- if (key && csupper(key[0]) && pl->obj == 0) {
- pl->x += a.x;
- pl->y += a.y;
- }
-}
-
-void block_object::move_by(const position &a)
-{
- cent += a;
- for (object *p = oblist.head; p; p = p->next)
- p->move_by(a);
- adjust_objectless_places(tbl, a);
-}
-
-
-place *block_object::find_label(const char *name)
-{
- return tbl->lookup(name);
-}
-
-object_type block_object::type()
-{
- return BLOCK_OBJECT;
-}
-
-graphic_object *object_spec::make_block(position *curpos, direction *dirp)
-{
- bounding_box bb;
- for (object *p = oblist.head; p; p = p->next)
- p->update_bounding_box(&bb);
- position dim;
- if (!bb.blank) {
- position m = -(bb.ll + bb.ur)/2.0;
- for (object *p = oblist.head; p; p = p->next)
- p->move_by(m);
- adjust_objectless_places(tbl, m);
- dim = bb.ur - bb.ll;
- }
- if (flags & HAS_WIDTH)
- dim.x = width;
- if (flags & HAS_HEIGHT)
- dim.y = height;
- block_object *block = new block_object(dim, oblist, tbl);
- if (!position_rectangle(block, curpos, dirp)) {
- delete block;
- block = 0;
- }
- tbl = 0;
- oblist.head = oblist.tail = 0;
- return block;
-}
-
-class text_object : public rectangle_object {
-public:
- text_object(const position &);
- object_type type() { return TEXT_OBJECT; }
-};
-
-text_object::text_object(const position &d)
-: rectangle_object(d)
-{
-}
-
-graphic_object *object_spec::make_text(position *curpos, direction *dirp)
-{
- if (!(flags & HAS_HEIGHT)) {
- lookup_variable("textht", &height);
- int nitems = 0;
- for (text_item *t = text; t; t = t->next)
- nitems++;
- height *= nitems;
- }
- if (!(flags & HAS_WIDTH))
- lookup_variable("textwid", &width);
- text_object *p = new text_object(position(width, height));
- if (!position_rectangle(p, curpos, dirp)) {
- delete p;
- p = 0;
- }
- return p;
-}
-
-
-class ellipse_object : public closed_object {
-public:
- ellipse_object(const position &);
- position north_east() { return position(cent.x + dim.x/(M_SQRT2*2.0),
- cent.y + dim.y/(M_SQRT2*2.0)); }
- position north_west() { return position(cent.x - dim.x/(M_SQRT2*2.0),
- cent.y + dim.y/(M_SQRT2*2.0)); }
- position south_east() { return position(cent.x + dim.x/(M_SQRT2*2.0),
- cent.y - dim.y/(M_SQRT2*2.0)); }
- position south_west() { return position(cent.x - dim.x/(M_SQRT2*2.0),
- cent.y - dim.y/(M_SQRT2*2.0)); }
- double radius() { return dim.x/2.0; }
- object_type type() { return ELLIPSE_OBJECT; }
- void print();
-};
-
-ellipse_object::ellipse_object(const position &d)
-: closed_object(d)
-{
-}
-
-void ellipse_object::print()
-{
- 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)
-{
- static double last_ellipse_height;
- static double last_ellipse_width;
- static int have_last_ellipse = 0;
- if (!(flags & HAS_HEIGHT)) {
- if ((flags & IS_SAME) && have_last_ellipse)
- height = last_ellipse_height;
- else
- lookup_variable("ellipseht", &height);
- }
- if (!(flags & HAS_WIDTH)) {
- if ((flags & IS_SAME) && have_last_ellipse)
- width = last_ellipse_width;
- else
- lookup_variable("ellipsewid", &width);
- }
- last_ellipse_width = width;
- last_ellipse_height = height;
- have_last_ellipse = 1;
- ellipse_object *p = new ellipse_object(position(width, height));
- if (!position_rectangle(p, curpos, dirp)) {
- delete p;
- return 0;
- }
- return p;
-}
-
-class circle_object : public ellipse_object {
-public:
- circle_object(double);
- object_type type() { return CIRCLE_OBJECT; }
- void print();
-};
-
-circle_object::circle_object(double diam)
-: ellipse_object(position(diam, diam))
-{
-}
-
-void circle_object::print()
-{
- 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)
-{
- static double last_circle_radius;
- static int have_last_circle = 0;
- if (!(flags & HAS_RADIUS)) {
- if ((flags & IS_SAME) && have_last_circle)
- radius = last_circle_radius;
- else
- lookup_variable("circlerad", &radius);
- }
- last_circle_radius = radius;
- have_last_circle = 1;
- circle_object *p = new circle_object(radius*2.0);
- if (!position_rectangle(p, curpos, dirp)) {
- delete p;
- return 0;
- }
- return p;
-}
-
-class move_object : public graphic_object {
- position strt;
- position en;
-public:
- move_object(const position &s, const position &e);
- position origin() { return en; }
- object_type type() { return MOVE_OBJECT; }
- void update_bounding_box(bounding_box *);
- void move_by(const position &);
-};
-
-move_object::move_object(const position &s, const position &e)
-: strt(s), en(e)
-{
-}
-
-void move_object::update_bounding_box(bounding_box *p)
-{
- p->encompass(strt);
- p->encompass(en);
-}
-
-void move_object::move_by(const position &a)
-{
- strt += a;
- en += a;
-}
-
-graphic_object *object_spec::make_move(position *curpos, direction *dirp)
-{
- static position last_move;
- static int have_last_move = 0;
- *dirp = dir;
- // 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)
- segment_pos = last_move;
- else {
- switch (dir) {
- case UP_DIRECTION:
- segment_pos.y = segment_height;
- break;
- case DOWN_DIRECTION:
- segment_pos.y = -segment_height;
- break;
- case LEFT_DIRECTION:
- segment_pos.x = -segment_width;
- break;
- case RIGHT_DIRECTION:
- segment_pos.x = segment_width;
- break;
- default:
- assert(0);
- }
- }
- }
- segment_list = new segment(segment_pos, segment_is_absolute, segment_list);
- // Reverse the segment_list so that it's in forward order.
- segment *old = segment_list;
- segment_list = 0;
- while (old != 0) {
- segment *tem = old->next;
- old->next = segment_list;
- segment_list = old;
- old = tem;
- }
- // Compute the end position.
- position endpos = startpos;
- for (segment *s = segment_list; s; s = s->next)
- if (s->is_absolute)
- endpos = s->pos;
- else
- endpos += s->pos;
- have_last_move = 1;
- last_move = endpos - startpos;
- move_object *p = new move_object(startpos, endpos);
- *curpos = endpos;
- return p;
-}
-
-class linear_object : public graphic_object {
-protected:
- char arrow_at_start;
- char arrow_at_end;
- arrow_head_type aht;
- position strt;
- position en;
-public:
- linear_object(const position &s, const position &e);
- position start() { return strt; }
- position end() { return en; }
- void move_by(const position &);
- void update_bounding_box(bounding_box *) = 0;
- object_type type() = 0;
- void add_arrows(int at_start, int at_end, const arrow_head_type &);
-};
-
-class line_object : public linear_object {
-protected:
- position *v;
- int n;
-public:
- line_object(const position &s, const position &e, position *, int);
- ~line_object();
- position origin() { return strt; }
- position center() { return (strt + en)/2.0; }
- position north() { return (en.y - strt.y) > 0 ? en : strt; }
- position south() { return (en.y - strt.y) < 0 ? en : strt; }
- position east() { return (en.x - strt.x) > 0 ? en : strt; }
- position west() { return (en.x - strt.x) < 0 ? en : strt; }
- object_type type() { return LINE_OBJECT; }
- void update_bounding_box(bounding_box *);
- void print();
- void move_by(const position &);
-};
-
-class arrow_object : public line_object {
-public:
- arrow_object(const position &, const position &, position *, int);
- object_type type() { return ARROW_OBJECT; }
-};
-
-class spline_object : public line_object {
-public:
- spline_object(const position &, const position &, position *, int);
- object_type type() { return SPLINE_OBJECT; }
- void print();
- void update_bounding_box(bounding_box *);
-};
-
-linear_object::linear_object(const position &s, const position &e)
-: arrow_at_start(0), arrow_at_end(0), strt(s), en(e)
-{
-}
-
-void linear_object::move_by(const position &a)
-{
- strt += a;
- en += a;
-}
-
-void linear_object::add_arrows(int at_start, int at_end,
- const arrow_head_type &a)
-{
- arrow_at_start = at_start;
- arrow_at_end = at_end;
- aht = a;
-}
-
-line_object::line_object(const position &s, const position &e,
- position *p, int i)
-: linear_object(s, e), v(p), n(i)
-{
-}
-
-void line_object::print()
-{
- if (lt.type == line_type::invisible)
- return;
- out->set_color(0, graphic_object::get_outline_color());
- // shorten line length to avoid arrow sticking.
- position sp = strt;
- if (arrow_at_start) {
- position base = v[0] - strt;
- double hyp = hypot(base);
- if (hyp == 0.0) {
- error("cannot draw arrow on object with zero length");
- return;
- }
- if (aht.solid && out->supports_filled_polygons()) {
- base *= aht.height / hyp;
- draw_arrow(strt, strt - v[0], aht, lt,
- graphic_object::get_outline_color());
- sp = strt + base;
- } else {
- base *= fabs(lt.thickness) / hyp / 72 / 4;
- sp = strt + base;
- draw_arrow(sp, sp - v[0], aht, lt,
- graphic_object::get_outline_color());
- }
- }
- if (arrow_at_end) {
- position base = v[n-1] - (n > 1 ? v[n-2] : strt);
- double hyp = hypot(base);
- if (hyp == 0.0) {
- error("cannot draw arrow on object with zero length");
- return;
- }
- if (aht.solid && out->supports_filled_polygons()) {
- base *= aht.height / hyp;
- draw_arrow(en, v[n-1] - (n > 1 ? v[n-2] : strt), aht, lt,
- graphic_object::get_outline_color());
- v[n-1] = en - base;
- } else {
- base *= fabs(lt.thickness) / hyp / 72 / 4;
- v[n-1] = en - base;
- draw_arrow(v[n-1], v[n-1] - (n > 1 ? v[n-2] : strt), aht, lt,
- graphic_object::get_outline_color());
- }
- }
- out->line(sp, v, n, lt);
- out->reset_color();
-}
-
-void line_object::update_bounding_box(bounding_box *p)
-{
- p->encompass(strt);
- for (int i = 0; i < n; i++)
- p->encompass(v[i]);
-}
-
-void line_object::move_by(const position &pos)
-{
- linear_object::move_by(pos);
- for (int i = 0; i < n; i++)
- v[i] += pos;
-}
-
-void spline_object::update_bounding_box(bounding_box *p)
-{
- p->encompass(strt);
- p->encompass(en);
- /*
-
- If
-
- p1 = q1/2 + q2/2
- p2 = q1/6 + q2*5/6
- p3 = q2*5/6 + q3/6
- p4 = q2/2 + q3/2
- [ the points for the Bezier cubic ]
-
- and
-
- t = .5
-
- then
-
- (1-t)^3*p1 + 3*t*(t - 1)^2*p2 + 3*t^2*(1-t)*p3 + t^3*p4
- [ the equation for the Bezier cubic ]
-
- = .125*q1 + .75*q2 + .125*q3
-
- */
- for (int i = 1; i < n; i++)
- p->encompass((i == 1 ? strt : v[i-2])*.125 + v[i-1]*.75 + v[i]*.125);
-}
-
-arrow_object::arrow_object(const position &s, const position &e,
- position *p, int i)
-: line_object(s, e, p, i)
-{
-}
-
-spline_object::spline_object(const position &s, const position &e,
- position *p, int i)
-: line_object(s, e, p, i)
-{
-}
-
-void spline_object::print()
-{
- if (lt.type == line_type::invisible)
- return;
- out->set_color(0, graphic_object::get_outline_color());
- // shorten line length for spline to avoid arrow sticking
- position sp = strt;
- if (arrow_at_start) {
- position base = v[0] - strt;
- double hyp = hypot(base);
- if (hyp == 0.0) {
- error("cannot draw arrow on object with zero length");
- return;
- }
- if (aht.solid && out->supports_filled_polygons()) {
- base *= aht.height / hyp;
- draw_arrow(strt, strt - v[0], aht, lt,
- graphic_object::get_outline_color());
- sp = strt + base*0.1; // to reserve spline shape
- } else {
- base *= fabs(lt.thickness) / hyp / 72 / 4;
- sp = strt + base;
- draw_arrow(sp, sp - v[0], aht, lt,
- graphic_object::get_outline_color());
- }
- }
- if (arrow_at_end) {
- position base = v[n-1] - (n > 1 ? v[n-2] : strt);
- double hyp = hypot(base);
- if (hyp == 0.0) {
- error("cannot draw arrow on object with zero length");
- return;
- }
- if (aht.solid && out->supports_filled_polygons()) {
- base *= aht.height / hyp;
- draw_arrow(en, v[n-1] - (n > 1 ? v[n-2] : strt), aht, lt,
- graphic_object::get_outline_color());
- v[n-1] = en - base*0.1; // to reserve spline shape
- } else {
- base *= fabs(lt.thickness) / hyp / 72 / 4;
- v[n-1] = en - base;
- draw_arrow(v[n-1], v[n-1] - (n > 1 ? v[n-2] : strt), aht, lt,
- graphic_object::get_outline_color());
- }
- }
- out->spline(sp, v, n, lt);
- out->reset_color();
-}
-
-line_object::~line_object()
-{
- a_delete v;
-}
-
-linear_object *object_spec::make_line(position *curpos, direction *dirp)
-{
- static position last_line;
- static int have_last_line = 0;
- *dirp = dir;
- // 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) && (type == LINE_OBJECT || type == ARROW_OBJECT)
- && have_last_line)
- segment_pos = last_line;
- else
- switch (dir) {
- case UP_DIRECTION:
- segment_pos.y = segment_height;
- break;
- case DOWN_DIRECTION:
- segment_pos.y = -segment_height;
- break;
- case LEFT_DIRECTION:
- segment_pos.x = -segment_width;
- break;
- case RIGHT_DIRECTION:
- segment_pos.x = segment_width;
- break;
- default:
- assert(0);
- }
- }
- segment_list = new segment(segment_pos, segment_is_absolute, segment_list);
- // reverse the segment_list so that it's in forward order
- segment *old = segment_list;
- segment_list = 0;
- while (old != 0) {
- segment *tem = old->next;
- old->next = segment_list;
- segment_list = old;
- old = tem;
- }
- // Absolutise all movements
- position endpos = startpos;
- int nsegments = 0;
- segment *s;
- for (s = segment_list; s; s = s->next, nsegments++)
- if (s->is_absolute)
- endpos = s->pos;
- else {
- endpos += s->pos;
- s->pos = endpos;
- s->is_absolute = 1; // to avoid confusion
- }
- // handle chop
- line_object *p = 0;
- position *v = new position[nsegments];
- int i = 0;
- for (s = segment_list; s; s = s->next, i++)
- v[i] = s->pos;
- if (flags & IS_DEFAULT_CHOPPED) {
- lookup_variable("circlerad", &start_chop);
- end_chop = start_chop;
- flags |= IS_CHOPPED;
- }
- if (flags & IS_CHOPPED) {
- position start_chop_vec, end_chop_vec;
- if (start_chop != 0.0) {
- start_chop_vec = v[0] - startpos;
- start_chop_vec *= start_chop / hypot(start_chop_vec);
- }
- if (end_chop != 0.0) {
- end_chop_vec = (v[nsegments - 1]
- - (nsegments > 1 ? v[nsegments - 2] : startpos));
- end_chop_vec *= end_chop / hypot(end_chop_vec);
- }
- startpos += start_chop_vec;
- v[nsegments - 1] -= end_chop_vec;
- endpos -= end_chop_vec;
- }
- switch (type) {
- case SPLINE_OBJECT:
- p = new spline_object(startpos, endpos, v, nsegments);
- break;
- case ARROW_OBJECT:
- p = new arrow_object(startpos, endpos, v, nsegments);
- break;
- case LINE_OBJECT:
- p = new line_object(startpos, endpos, v, nsegments);
- break;
- default:
- assert(0);
- }
- have_last_line = 1;
- last_line = endpos - startpos;
- *curpos = endpos;
- return p;
-}
-
-class arc_object : public linear_object {
- int clockwise;
- position cent;
- double rad;
-public:
- arc_object(int, const position &, const position &, const position &);
- position origin() { return cent; }
- position center() { return cent; }
- double radius() { return rad; }
- position north();
- position south();
- position east();
- position west();
- position north_east();
- position north_west();
- position south_east();
- position south_west();
- void update_bounding_box(bounding_box *);
- object_type type() { return ARC_OBJECT; }
- void print();
- void move_by(const position &pos);
-};
-
-arc_object::arc_object(int cw, const position &s, const position &e,
- const position &c)
-: linear_object(s, e), clockwise(cw), cent(c)
-{
- rad = hypot(c - s);
-}
-
-void arc_object::move_by(const position &pos)
-{
- linear_object::move_by(pos);
- cent += pos;
-}
-
-// we get arc corners from the corresponding circle
-
-position arc_object::north()
-{
- position result(cent);
- result.y += rad;
- return result;
-}
-
-position arc_object::south()
-{
- position result(cent);
- result.y -= rad;
- return result;
-}
-
-position arc_object::east()
-{
- position result(cent);
- result.x += rad;
- return result;
-}
-
-position arc_object::west()
-{
- position result(cent);
- result.x -= rad;
- return result;
-}
-
-position arc_object::north_east()
-{
- position result(cent);
- result.x += rad/M_SQRT2;
- result.y += rad/M_SQRT2;
- return result;
-}
-
-position arc_object::north_west()
-{
- position result(cent);
- result.x -= rad/M_SQRT2;
- result.y += rad/M_SQRT2;
- return result;
-}
-
-position arc_object::south_east()
-{
- position result(cent);
- result.x += rad/M_SQRT2;
- result.y -= rad/M_SQRT2;
- return result;
-}
-
-position arc_object::south_west()
-{
- position result(cent);
- result.x -= rad/M_SQRT2;
- result.y -= rad/M_SQRT2;
- return result;
-}
-
-
-void arc_object::print()
-{
- if (lt.type == line_type::invisible)
- return;
- out->set_color(0, graphic_object::get_outline_color());
- // handle arrow direction; make shorter line for arc
- position sp, ep, b;
- if (clockwise) {
- sp = en;
- ep = strt;
- } else {
- sp = strt;
- ep = en;
- }
- if (arrow_at_start) {
- double theta = aht.height / rad;
- if (clockwise)
- theta = - theta;
- b = strt - cent;
- b = position(b.x*cos(theta) - b.y*sin(theta),
- b.x*sin(theta) + b.y*cos(theta)) + cent;
- if (clockwise)
- ep = b;
- else
- sp = b;
- if (aht.solid && out->supports_filled_polygons()) {
- draw_arrow(strt, strt - b, aht, lt,
- graphic_object::get_outline_color());
- } else {
- position v = b;
- theta = fabs(lt.thickness) / 72 / 4 / rad;
- if (clockwise)
- theta = - theta;
- b = strt - cent;
- b = position(b.x*cos(theta) - b.y*sin(theta),
- b.x*sin(theta) + b.y*cos(theta)) + cent;
- draw_arrow(b, b - v, aht, lt,
- graphic_object::get_outline_color());
- out->line(b, &v, 1, lt);
- }
- }
- if (arrow_at_end) {
- double theta = aht.height / rad;
- if (!clockwise)
- theta = - theta;
- b = en - cent;
- b = position(b.x*cos(theta) - b.y*sin(theta),
- b.x*sin(theta) + b.y*cos(theta)) + cent;
- if (clockwise)
- sp = b;
- else
- ep = b;
- if (aht.solid && out->supports_filled_polygons()) {
- draw_arrow(en, en - b, aht, lt,
- graphic_object::get_outline_color());
- } else {
- position v = b;
- theta = fabs(lt.thickness) / 72 / 4 / rad;
- if (!clockwise)
- theta = - theta;
- b = en - cent;
- b = position(b.x*cos(theta) - b.y*sin(theta),
- b.x*sin(theta) + b.y*cos(theta)) + cent;
- draw_arrow(b, b - v, aht, lt,
- graphic_object::get_outline_color());
- out->line(b, &v, 1, lt);
- }
- }
- out->arc(sp, cent, ep, lt);
- out->reset_color();
-}
-
-inline double max(double a, double b)
-{
- return a > b ? a : b;
-}
-
-void arc_object::update_bounding_box(bounding_box *p)
-{
- p->encompass(strt);
- p->encompass(en);
- position start_offset = strt - cent;
- if (start_offset.x == 0.0 && start_offset.y == 0.0)
- return;
- position end_offset = en - cent;
- if (end_offset.x == 0.0 && end_offset.y == 0.0)
- return;
- double start_quad = atan2(start_offset.y, start_offset.x)/(M_PI/2.0);
- double end_quad = atan2(end_offset.y, end_offset.x)/(M_PI/2.0);
- if (clockwise) {
- double temp = start_quad;
- start_quad = end_quad;
- end_quad = temp;
- }
- if (start_quad < 0.0)
- start_quad += 4.0;
- while (end_quad <= start_quad)
- end_quad += 4.0;
- double r = max(hypot(start_offset), hypot(end_offset));
- for (int q = int(start_quad) + 1; q < end_quad; q++) {
- position offset;
- switch (q % 4) {
- case 0:
- offset.x = r;
- break;
- case 1:
- offset.y = r;
- break;
- case 2:
- offset.x = -r;
- break;
- case 3:
- offset.y = -r;
- break;
- }
- p->encompass(cent + offset);
- }
-}
-
-// We ignore the with attribute. The at attribute always refers to the center.
-
-linear_object *object_spec::make_arc(position *curpos, direction *dirp)
-{
- *dirp = dir;
- int cw = (flags & IS_CLOCKWISE) != 0;
- // compute the start
- position startpos;
- if (flags & HAS_FROM)
- startpos = from;
- else
- startpos = *curpos;
- if (!(flags & HAS_RADIUS))
- lookup_variable("arcrad", &radius);
- // compute the end
- position endpos;
- if (flags & HAS_TO)
- endpos = to;
- else {
- position m(radius, radius);
- // Adjust the signs.
- if (cw) {
- if (dir == DOWN_DIRECTION || dir == LEFT_DIRECTION)
- m.x = -m.x;
- if (dir == DOWN_DIRECTION || dir == RIGHT_DIRECTION)
- m.y = -m.y;
- *dirp = direction((dir + 3) % 4);
- }
- else {
- if (dir == UP_DIRECTION || dir == LEFT_DIRECTION)
- m.x = -m.x;
- if (dir == DOWN_DIRECTION || dir == LEFT_DIRECTION)
- m.y = -m.y;
- *dirp = direction((dir + 1) % 4);
- }
- endpos = startpos + m;
- }
- // compute the center
- position centerpos;
- if (flags & HAS_AT)
- centerpos = at;
- else if (startpos == endpos)
- centerpos = startpos;
- else {
- position h = (endpos - startpos)/2.0;
- double d = hypot(h);
- if (radius <= 0)
- radius = .25;
- // make the radius big enough
- while (radius < d)
- radius *= 2.0;
- double alpha = acos(d/radius);
- double theta = atan2(h.y, h.x);
- if (cw)
- theta -= alpha;
- else
- theta += alpha;
- centerpos = position(cos(theta), sin(theta))*radius + startpos;
- }
- arc_object *p = new arc_object(cw, startpos, endpos, centerpos);
- *curpos = endpos;
- return p;
-}
-
-graphic_object *object_spec::make_linear(position *curpos, direction *dirp)
-{
- linear_object *obj;
- if (type == ARC_OBJECT)
- obj = make_arc(curpos, dirp);
- else
- obj = make_line(curpos, dirp);
- if (type == ARROW_OBJECT
- && (flags & (HAS_LEFT_ARROW_HEAD|HAS_RIGHT_ARROW_HEAD)) == 0)
- flags |= HAS_RIGHT_ARROW_HEAD;
- if (obj && (flags & (HAS_LEFT_ARROW_HEAD|HAS_RIGHT_ARROW_HEAD))) {
- arrow_head_type a;
- int at_start = (flags & HAS_LEFT_ARROW_HEAD) != 0;
- int at_end = (flags & HAS_RIGHT_ARROW_HEAD) != 0;
- if (flags & HAS_HEIGHT)
- a.height = height;
- else
- lookup_variable("arrowht", &a.height);
- if (flags & HAS_WIDTH)
- a.width = width;
- else
- lookup_variable("arrowwid", &a.width);
- double solid;
- lookup_variable("arrowhead", &solid);
- a.solid = solid != 0.0;
- obj->add_arrows(at_start, at_end, a);
- }
- return obj;
-}
-
-object *object_spec::make_object(position *curpos, direction *dirp)
-{
- graphic_object *obj = 0;
- switch (type) {
- case BLOCK_OBJECT:
- obj = make_block(curpos, dirp);
- break;
- case BOX_OBJECT:
- obj = make_box(curpos, dirp);
- break;
- case TEXT_OBJECT:
- obj = make_text(curpos, dirp);
- break;
- case ELLIPSE_OBJECT:
- obj = make_ellipse(curpos, dirp);
- break;
- case CIRCLE_OBJECT:
- obj = make_circle(curpos, dirp);
- break;
- case MOVE_OBJECT:
- obj = make_move(curpos, dirp);
- break;
- case ARC_OBJECT:
- case LINE_OBJECT:
- case SPLINE_OBJECT:
- case ARROW_OBJECT:
- obj = make_linear(curpos, dirp);
- break;
- case MARK_OBJECT:
- case OTHER_OBJECT:
- default:
- assert(0);
- break;
- }
- if (obj) {
- if (flags & IS_INVISIBLE)
- obj->set_invisible();
- if (text != 0)
- obj->add_text(text, (flags & IS_ALIGNED) != 0);
- if (flags & IS_DOTTED)
- obj->set_dotted(dash_width);
- else if (flags & IS_DASHED)
- obj->set_dashed(dash_width);
- double th;
- if (flags & HAS_THICKNESS)
- th = thickness;
- 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_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;
-}
-
-struct string_list {
- string_list *next;
- char *str;
- string_list(char *);
- ~string_list();
-};
-
-string_list::string_list(char *s)
-: next(0), str(s)
-{
-}
-
-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.
-
- 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), 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), is_position(0)
-{
- label_list = new string_list(l);
-}
-
-path::~path()
-{
- while (label_list) {
- string_list *tem = label_list;
- label_list = label_list->next;
- delete tem;
- }
- delete ypath;
-}
-
-void path::append(corner c)
-{
- assert(crn == 0);
- crn = c;
-}
-
-void path::append(char *s)
-{
- string_list **p;
- for (p = &label_list; *p; p = &(*p)->next)
- ;
- *p = new string_list(s);
-}
-
-void path::set_ypath(path *p)
-{
- ypath = p;
-}
-
-// return non-zero for success
-
-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) {
- lex_error("object does not contain a place `%1'", lb->str);
- return 0;
- }
- if (crn == 0 || p->obj == 0)
- *result = *p;
- else {
- position ps = ((p->obj)->*(crn))();
- result->x = ps.x;
- result->y = ps.y;
- result->obj = 0;
- }
- if (ypath) {
- place tem;
- if (!ypath->follow(pl, &tem))
- return 0;
- result->y = tem.y;
- if (result->obj != tem.obj)
- result->obj = 0;
- }
- return 1;
-}
-
-void print_object_list(object *p)
-{
- for (; p; p = p->next) {
- p->print();
- p->print_text();
- }
-}
-
-void print_picture(object *obj)
-{
- bounding_box bb;
- for (object *p = obj; p; p = p->next)
- p->update_bounding_box(&bb);
- double scale;
- lookup_variable("scale", &scale);
- out->start_picture(scale, bb.ll, bb.ur);
- print_object_list(obj);
- out->finish_picture();
-}
-
diff --git a/contrib/groff/src/preproc/pic/object.h b/contrib/groff/src/preproc/pic/object.h
deleted file mode 100644
index 9f7f4bc33708..000000000000
--- a/contrib/groff/src/preproc/pic/object.h
+++ /dev/null
@@ -1,225 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-This file is part of groff.
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-struct place;
-
-enum object_type {
- OTHER_OBJECT,
- BOX_OBJECT,
- CIRCLE_OBJECT,
- ELLIPSE_OBJECT,
- ARC_OBJECT,
- SPLINE_OBJECT,
- LINE_OBJECT,
- ARROW_OBJECT,
- MOVE_OBJECT,
- TEXT_OBJECT,
- BLOCK_OBJECT,
- MARK_OBJECT
- };
-
-struct bounding_box;
-
-struct object {
- object *prev;
- object *next;
- object();
- virtual ~object();
- virtual position origin();
- virtual double width();
- virtual double radius();
- virtual double height();
- virtual position north();
- virtual position south();
- virtual position east();
- virtual position west();
- virtual position north_east();
- virtual position north_west();
- virtual position south_east();
- virtual position south_west();
- virtual position start();
- virtual position end();
- virtual position center();
- virtual place *find_label(const char *);
- virtual void move_by(const position &);
- virtual int blank();
- virtual void update_bounding_box(bounding_box *);
- virtual object_type type() = 0;
- virtual void print();
- virtual void print_text();
-};
-
-typedef position (object::*corner)();
-
-struct place {
- object *obj;
- double x, y;
-};
-
-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);
- void append(char *);
- void set_ypath(path *);
- int follow(const place &, place *) const;
-};
-
-struct object_list {
- object *head;
- object *tail;
- object_list();
- void append(object *);
- void wrap_up_block(object_list *);
-};
-
-declare_ptable(place)
-
-// these go counterclockwise
-enum direction {
- RIGHT_DIRECTION,
- UP_DIRECTION,
- LEFT_DIRECTION,
- DOWN_DIRECTION
- };
-
-struct graphics_state {
- double x, y;
- direction dir;
-};
-
-struct saved_state : public graphics_state {
- saved_state *prev;
- PTABLE(place) *tbl;
-};
-
-
-struct text_item {
- text_item *next;
- char *text;
- adjustment adj;
- const char *filename;
- int lineno;
-
- text_item(char *, const char *, int);
- ~text_item();
-};
-
-const unsigned long IS_DOTTED = 01;
-const unsigned long IS_DASHED = 02;
-const unsigned long IS_CLOCKWISE = 04;
-const unsigned long IS_INVISIBLE = 020;
-const unsigned long HAS_LEFT_ARROW_HEAD = 040;
-const unsigned long HAS_RIGHT_ARROW_HEAD = 0100;
-const unsigned long HAS_SEGMENT = 0200;
-const unsigned long IS_SAME = 0400;
-const unsigned long HAS_FROM = 01000;
-const unsigned long HAS_AT = 02000;
-const unsigned long HAS_WITH = 04000;
-const unsigned long HAS_HEIGHT = 010000;
-const unsigned long HAS_WIDTH = 020000;
-const unsigned long HAS_RADIUS = 040000;
-const unsigned long HAS_TO = 0100000;
-const unsigned long IS_CHOPPED = 0200000;
-const unsigned long IS_DEFAULT_CHOPPED = 0400000;
-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;
- position pos;
- segment *next;
- segment(const position &, int, segment *);
-};
-
-class rectangle_object;
-class graphic_object;
-class linear_object;
-
-struct object_spec {
- unsigned long flags;
- object_type type;
- object_list oblist;
- PTABLE(place) *tbl;
- double dash_width;
- position from;
- position to;
- position at;
- position by;
- path *with;
- text_item *text;
- double height;
- double radius;
- double width;
- double segment_width;
- double segment_height;
- double start_chop;
- double end_chop;
- double thickness;
- double fill;
- char *shaded;
- char *outlined;
- direction dir;
- segment *segment_list;
- position segment_pos;
- int segment_is_absolute;
-
- object_spec(object_type);
- ~object_spec();
- object *make_object(position *, direction *);
- graphic_object *make_box(position *, direction *);
- graphic_object *make_block(position *, direction *);
- graphic_object *make_text(position *, direction *);
- graphic_object *make_ellipse(position *, direction *);
- graphic_object *make_circle(position *, direction *);
- linear_object *make_line(position *, direction *);
- linear_object *make_arc(position *, direction *);
- graphic_object *make_linear(position *, direction *);
- graphic_object *make_move(position *, direction *);
- int position_rectangle(rectangle_object *p, position *curpos,
- direction *dirp);
-};
-
-
-object *make_object(object_spec *, position *, direction *);
-
-object *make_mark_object();
-object *make_command_object(char *, const char *, int);
-
-int lookup_variable(const char *name, double *val);
-void define_variable(const char *name, double val);
-
-void print_picture(object *);
-
diff --git a/contrib/groff/src/preproc/pic/output.h b/contrib/groff/src/preproc/pic/output.h
deleted file mode 100644
index aa03e776bb00..000000000000
--- a/contrib/groff/src/preproc/pic/output.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2001 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-struct line_type {
- enum { invisible, solid, dotted, dashed } type;
- double dash_width;
- double thickness; // the thickness is in points
-
- line_type();
-};
-
-
-class output {
-protected:
- char *args;
- double desired_height; // zero if no height specified
- double desired_width; // zero if no depth specified
- double compute_scale(double, const position &, const position &);
-public:
- output();
- virtual ~output();
- void set_desired_width_height(double wid, double ht);
- void set_args(const char *);
- virtual void start_picture(double sc, const position &ll, const position &ur) = 0;
- virtual void finish_picture() = 0;
- virtual void circle(const position &, double rad,
- const line_type &, double) = 0;
- virtual void text(const position &, text_piece *, int, double) = 0;
- virtual void line(const position &, const position *, int n,
- const line_type &) = 0;
- virtual void polygon(const position *, int n,
- const line_type &, double) = 0;
- virtual void spline(const position &, const position *, int n,
- const line_type &) = 0;
- virtual void arc(const position &, const position &, const position &,
- const line_type &) = 0;
- virtual void ellipse(const position &, const distance &,
- 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) = 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();
-};
-
-extern output *out;
-
-/* #define FIG_SUPPORT 1 */
-#define TEX_SUPPORT 1
-
-output *make_troff_output();
-
-#ifdef TEX_SUPPORT
-output *make_tex_output();
-output *make_tpic_output();
-#endif /* TEX_SUPPORT */
-
-#ifdef FIG_SUPPORT
-output *make_fig_output();
-#endif /* FIG_SUPPORT */
diff --git a/contrib/groff/src/preproc/pic/pic.h b/contrib/groff/src/preproc/pic/pic.h
deleted file mode 100644
index e3b850a96ef0..000000000000
--- a/contrib/groff/src/preproc/pic/pic.h
+++ /dev/null
@@ -1,123 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2003, 2005
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include "lib.h"
-
-#include <math.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#ifdef NEED_DECLARATION_RAND
-#undef rand
-extern "C" {
- int rand();
-}
-#endif /* NEED_DECLARATION_RAND */
-
-#ifdef NEED_DECLARATION_SRAND
-#undef srand
-extern "C" {
-#ifdef RET_TYPE_SRAND_IS_VOID
- void srand(unsigned int);
-#else
- int srand(unsigned int);
-#endif
-}
-#endif /* NEED_DECLARATION_SRAND */
-
-#ifndef HAVE_FMOD
-extern "C" {
- double fmod(double, double);
-}
-#endif
-
-#include "assert.h"
-#include "cset.h"
-#include "stringclass.h"
-#include "errarg.h"
-#include "error.h"
-#include "position.h"
-#include "text.h"
-#include "output.h"
-
-#ifndef M_SQRT2
-#define M_SQRT2 1.41421356237309504880
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-class input {
- input *next;
-public:
- input();
- virtual ~input();
- virtual int get() = 0;
- virtual int peek() = 0;
- virtual int get_location(const char **, int *);
- friend class input_stack;
- friend class copy_rest_thru_input;
-};
-
-class file_input : public input {
- FILE *fp;
- const char *filename;
- int lineno;
- string line;
- const char *ptr;
- int read_line();
-public:
- file_input(FILE *, const char *);
- ~file_input();
- int get();
- int peek();
- int get_location(const char **, int *);
-};
-
-void lex_init(input *);
-int get_location(char **, int *);
-
-void do_copy(const char *file);
-void parse_init();
-void parse_cleanup();
-
-void lex_error(const char *message,
- const errarg &arg1 = empty_errarg,
- const errarg &arg2 = empty_errarg,
- const errarg &arg3 = empty_errarg);
-
-void lex_warning(const char *message,
- const errarg &arg1 = empty_errarg,
- const errarg &arg2 = empty_errarg,
- const errarg &arg3 = empty_errarg);
-
-void lex_cleanup();
-
-extern int flyback_flag;
-extern int command_char;
-// zero_length_line_flag is non-zero if zero-length lines are drawn
-// as dots by the output device
-extern int zero_length_line_flag;
-extern int driver_extension_flag;
-extern int compatible_flag;
-extern int safer_flag;
-extern char *graphname;
diff --git a/contrib/groff/src/preproc/pic/pic.man b/contrib/groff/src/preproc/pic/pic.man
deleted file mode 100644
index c54cfbef5911..000000000000
--- a/contrib/groff/src/preproc/pic/pic.man
+++ /dev/null
@@ -1,1109 +0,0 @@
-.ig
-Copyright (C) 1989-2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-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
-. ds lx L\h'-0.36m'\v'-0.22v'\s-2A\s0\h'-0.15m'\v'0.22v'\*(tx
-.\}
-.el \{\
-. ds tx TeX
-. ds lx LaTeX
-.\}
-.
-.ie \n(.g .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
-.B \-t
-[
-.B \-cvzCSU
-]
-[
-.I filename
-\&.\|.\|.\&
-]
-.
-.
-.SH DESCRIPTION
-.
-This manual page describes the GNU version of
-.BR pic ,
-which is part of the groff document formatting system.
-.B pic
-compiles descriptions of pictures embedded within
-.B troff
-or \*(tx input files into commands that are understood by \*(tx or
-.BR troff .
-Each picture starts with a line beginning with
-.B .PS
-and ends with a line beginning with
-.BR .PE .
-Anything outside of
-.B .PS
-and
-.B .PE
-is passed through without change.
-.LP
-It is the user's responsibility to provide appropriate definitions of the
-.B PS
-and
-.B PE
-macros.
-When the macro package being used does not supply such definitions
-(for example, old versions of \-ms),
-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
-.B \-\^\-
-can be used to mark the end of the options.
-A filename of
-.B \-
-refers to the standard input.
-.
-.TP
-.B \-C
-Recognize
-.B .PS
-and
-.B .PE
-even when followed by a character other than space or newline.
-.
-.TP
-.B \-S
-Safer mode; do not execute
-.B sh
-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.
-You should use this if you are using a postprocessor that doesn't support
-these extensions.
-The extensions are described in
-.BR groff_out (@MAN5EXT@).
-The
-.B \-n
-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
-.BR tpic .
-Implies
-.BR \-t .
-Lines beginning with
-.B \e
-are not passed through transparently.
-Lines beginning with
-.B .
-are passed through with the initial
-.B .
-changed to
-.BR \e .
-A line beginning with
-.B .ps
-is given special treatment:
-it takes an optional integer argument specifying
-the line thickness (pen size) in milliinches;
-a missing argument restores the previous line thickness;
-the default line thickness is 8 milliinches.
-The line thickness thus specified takes effect only
-when a non-negative line thickness has not been
-specified by use of the
-.B thickness
-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
-.B troff
-device
-.IR dev .
-This is unnecessary because the
-.B troff
-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 .
-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.
-In \*(tx mode,
-.B pic
-will define a vbox called
-.B \egraph
-for each picture.
-Use the
-.B figname
-command to change the name of the vbox.
-You must yourself print that vbox using, for example, the command
-.RS
-.LP
-.B
-\ecenterline{\ebox\egraph}
-.RE
-.LP
-Actually, since the vbox has a height of zero (it is defined with
-\evtop) this will produce slightly more vertical space above the
-picture than below it;
-.RS
-.LP
-.B
-\ecenterline{\eraise 1em\ebox\egraph}
-.RE
-.LP
-would avoid this.
-.LP
-To make the vbox having a positive height and a depth of zero
-(as used e.g.\& by \*(lx's
-.BR \%graphics.sty ),
-define the following macro in your document:
-.RS
-.LP
-.B \edef\egpicbox#1{%
-.br
-.B " \evbox{\eunvbox\ecsname #1\eendcsname\ekern 0pt}}"
-.RE
-.LP
-Now you can simply say
-.B \egpicbox{graph}
-instead of \ebox\egraph.
-.LP
-You must use a \*(tx driver that supports the
-.B tpic
-specials, version 2.
-.LP
-Lines beginning with
-.B \e
-are passed through transparently; a
-.B %
-is added to the end of the line to avoid unwanted spaces.
-You can safely use this feature to change fonts or to
-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
-Set
-.I variable
-to
-.IR expr1 .
-While the value of
-.I variable
-is less than or equal to
-.IR expr2 ,
-do
-.I body
-and increment
-.I variable
-by
-.IR expr3 ;
-if
-.B by
-is not given, increment
-.I variable
-by 1.
-If
-.I expr3
-is prefixed by
-.B *
-then
-.I variable
-will instead be multiplied by
-.IR expr3 .
-The value of
-.I expr3
-can be negative for the additive case;
-.I variable
-is then tested whether it is greater than or equal to
-.IR expr2 .
-For the multiplicative case,
-.I expr3
-must be greater than zero.
-If the constraints aren't met, the loop isn't executed.
-.I X
-can be any character not occurring in
-.IR body .
-.
-.TP
-\fBif\fR \fIexpr\fR \fBthen\fR \fIX\fR \fIif-true\fR \fIX\fR \
-[\fBelse\fR \fIY\fR \fIif-false\fR \fIY\fR]
-Evaluate
-.IR expr ;
-if it is non-zero then do
-.IR if-true ,
-otherwise do
-.IR if-false .
-.I X
-can be any character not occurring in
-.IR if-true .
-.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.
-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.
-Each
-.I arg
-must be an expression, a position, or text.
-This has a similar effect to a line beginning with
-.B .\&
-or
-.BR \e ,
-but allows the values of variables to be passed through.
-For example,
-.RS
-.IP
-.ft B
-.nf
-\&.PS
-x = 14
-command ".ds string x is " x "."
-\&.PE
-\e*[string]
-.ft
-.fi
-.RE
-.IP
-prints
-.RS
-.IP
-.B x is 14.
-.RE
-.
-.TP
-\fBsh\fR \fIX\fR \fIcommand\fR \fIX\fR
-Pass
-.I command
-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]
-.ns
-.TP
-\fBcopy\fR [\fB"\fIfilename\fB"\fR] \fBthru\fR \fImacro\fR \
-[\fBuntil\fR \fB"\fIword\*(ic\fB"\fR]
-This construct does
-.I body
-once for each line of
-.IR filename ;
-the line is split into blank-delimited words,
-and occurrences of
-.BI $ i
-in
-.IR body ,
-for
-.I i
-between 1 and 9,
-are replaced by the
-.IR i -th
-word of the line.
-If
-.I filename
-is not given, lines are taken from the current input up to
-.BR .PE .
-If an
-.B until
-clause is specified,
-lines will be read only until a line the first word of which is
-.IR word ;
-that line will then be discarded.
-.I X
-can be any character not occurring in
-.IR body .
-For example,
-.RS
-.IP
-.ft B
-.nf
-\&.PS
-copy thru % circle at ($1,$2) % until "END"
-1 2
-3 4
-5 6
-END
-box
-\&.PE
-.ft
-.fi
-.RE
-.IP
-is equivalent to
-.RS
-.IP
-.ft B
-.nf
-\&.PS
-circle at (1,2)
-circle at (3,4)
-circle at (5,6)
-box
-\&.PE
-.ft
-.fi
-.RE
-.IP
-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\fR[\fB,\fR]\fI variable2 .\^.\^.
-Reset pre-defined variables
-.IR variable1 ,
-.I variable2
-\&.\^.\^. to their default values.
-If no arguments are given, reset all pre-defined variables
-to their default values.
-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
-.I text
-as a format string for sprintf
-with an argument of
-.IR expr .
-If
-.I text
-is omitted a format string of
-.B "\(ts%g\(ts"
-is used.
-Attributes can be specified in the same way as for a normal text
-object.
-Be very careful that you specify an appropriate format string;
-.B pic
-does only very limited checking of the string.
-This is deprecated in favour of
-.BR sprintf .
-.
-.TP
-.IB variable\ := \ expr
-This is similar to
-.B =
-except
-.I variable
-must already be defined,
-and
-.I expr
-will be assigned to
-.I variable
-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 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
-.RS
-.IP
-.B 5 3
-.RE
-.
-.LP
-Arguments of the form
-.IP
-.I X anything X
-.LP
-are also allowed to be of the form
-.IP
-.BI {\ anything\ }
-.LP
-In this case
-.I anything
-can contain balanced occurrences of
-.B {
-and
-.BR } .
-Strings may contain
-.I X
-or imbalanced occurrences of
-.B {
-and
-.BR } .
-.
-.SS Expressions
-.
-The syntax for expressions has been significantly extended:
-.
-.LP
-.IB x\ ^\ y
-(exponentiation)
-.br
-.BI sin( x )
-.br
-.BI cos( x )
-.br
-.BI atan2( y , \ x )
-.br
-.BI log( x )
-(base 10)
-.br
-.BI exp( x )
-(base 10, ie
-.ie t 10\v'-.4m'\fIx\*(ic\fR\v'.4m')
-.el 10^\fIx\fR)
-.br
-.BI sqrt( x )
-.br
-.BI int( x )
-.br
-.B rand()
-(return a random number between 0 and 1)
-.br
-.BI rand( x )
-(return a random number between 1 and
-.IR x ;
-deprecated)
-.br
-.BI srand( x )
-(set the random number seed)
-.br
-.BI max( e1 , \ e2 )
-.br
-.BI min( e1 , \ e2 )
-.br
-.BI ! e
-.br
-\fIe1\fB && \fIe2\fR
-.br
-\fIe1\fB || \fIe2\fR
-.br
-\fIe1\fB == \fIe2\fR
-.br
-\fIe1\fB != \fIe2\fR
-.br
-\fIe1\fB >= \fIe2\fR
-.br
-\fIe1\fB > \fIe2\fR
-.br
-\fIe1\fB <= \fIe2\fR
-.br
-\fIe1\fB < \fIe2\fR
-.br
-\fB"\fIstr1\*(ic\fB" == "\fIstr2\*(ic\fB"\fR
-.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
-.
-A bare expression,
-.IR expr ,
-is acceptable as an attribute;
-it is equivalent to
-.IR dir\ expr ,
-where
-.I dir
-is the current direction.
-For example
-.LP
-.RS
-.B line 2i
-.RE
-.LP
-means draw a line 2\ inches long in the current direction.
-The `i' (or `I') character is ignored; to use another measurement unit,
-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
-.RS
-.LP
-.B
-x = 5e\-2
-.RE
-.
-.LP
-Text attributes can be compounded.
-For example,
-.RS
-.LP
-.B
-"foo" above ljust
-.RE
-.LP
-is valid.
-.
-.LP
-There is no limit to the depth to which blocks can be examined.
-For example,
-.RS
-.LP
-.B
-[A: [B: [C: box ]]] with .A.B.C.sw at 1,2
-.br
-.B
-circle at last [\^].A.B.C
-.RE
-.LP
-is acceptable.
-.
-.LP
-Arcs now have compass points
-determined by the circle of which the arc is a part.
-.
-.LP
-Circles, ellipses, and arcs can be dotted or dashed.
-In \*(tx mode splines can be dotted or dashed also.
-.
-.LP
-Boxes can have rounded corners.
-The
-.B rad
-attribute specifies the radius of the quarter-circles at each corner.
-If no
-.B rad
-or
-.B diam
-attribute is given, a radius of
-.B boxrad
-is used.
-Initially,
-.B boxrad
-has a value of\ 0.
-A box with rounded corners can be dotted or dashed.
-.
-.LP
-The
-.B .PS
-line can have a second argument specifying a maximum height for
-the picture.
-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 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.
-The implicit motion associated with the object is also determined
-by this box.
-The dimensions of this box are taken from the width and height attributes;
-if the width attribute is not supplied then the width will be taken to be
-.BR textwid ;
-if the height attribute is not supplied then the height will be taken to be
-the number of text strings associated with the object
-times
-.BR textht .
-Initially
-.B textwid
-and
-.B textht
-have a value of 0.
-.
-.LP
-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)
-.LP
-can also be used;
-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.
-.
-.LP
-The thickness of the lines used to draw objects is controlled by the
-.B linethick
-variable.
-This gives the thickness of lines in points.
-A negative value means use the default thickness:
-in \*(tx output mode, this means use a thickness of 8 milliinches;
-in \*(tx output mode with the
-.B -c
-option, this means use the line thickness specified by
-.B .ps
-lines;
-in troff output mode, this means use a thickness proportional
-to the pointsize.
-A zero value means draw the thinnest possible line supported by
-the output device.
-Initially it has a value of -1.
-There is also a
-.BR thick [ ness ]
-attribute.
-For example,
-.RS
-.LP
-.B circle thickness 1.5
-.RE
-.LP
-would draw a circle using a line with a thickness of 1.5 points.
-The thickness of lines is not affected by the
-value of the
-.B scale
-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 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
-with a proportionally gray shade.
-A value greater than 1 can also be used:
-this means fill with the
-shade of gray that is currently being used for text and lines.
-Normally this will be black, but output devices may provide
-a mechanism for changing this.
-Without an argument, then the value of the variable
-.B fillval
-will be used.
-Initially this has a value of 0.5.
-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
-.B colo\fR[\fPu\fR]\fPr\fR[\fPed\fR]
-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
-To change the name of the vbox in \*(tx mode, set the pseudo-variable
-.B figname
-(which is actually a specially parsed command) within a picture.
-Example:
-.RS
-.LP
-.B .PS
-.br
-.B figname = foobar;
-.br
-.B ...
-.br
-.B .PE
-.RE
-.LP
-The picture is then available in the box
-.BR \efoobar .
-.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 \-n
-option has not been given.
-Initially
-.B arrowhead
-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
-is device-independent.
-The
-.B \-T
-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 if the postprocessor is
-.BR grops .
-Any text associated with an object having the
-.B aligned
-attribute will be rotated about the center of the object
-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
-is allowed
-.BI ` expr 'th
-is also allowed.
-Note that
-.B 'th
-is a single token: no space is allowed between the
-.B '
-and the
-.BR th .
-For example,
-.IP
-.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
-.B pic
-code with
-.B .PS
-and
-.B .PE
-requests;
-.B roff
-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
-without adding any page information, so you must check which
-.B .PS
-and
-.B .PE
-requests are actually called.
-For example, the mm macro package adds a page number, which is very
-annoying.
-At the moment, calling standard
-.B groff
-without any macro package works.
-Alternatively, you can define your own requests, e.g. to do nothing:
-.LP
-.RS
-.nf
-.ft B
-\&.de PS
-\&..
-\&.de PE
-\&..
-.ft
-.fi
-.RE
-.
-.LP
-.B groff
-itself does not provide direct conversion into other graphics file
-formats.
-But there are lots of possibilities if you first transform your picture
-into PostScript\*R format using the
-.B groff
-option
-.BR -Tps .
-Since this
-.IR ps -file
-lacks BoundingBox information it is not very useful by itself, but it
-may be fed into other conversion programs, usually named
-.BI ps2 other
-or
-.BI psto other
-or the like.
-Moreover, the PostScript interpreter
-.B ghostscript
-.RB ( gs )
-has built-in graphics conversion devices that are called with the option
-.LP
-.RS
-.BI "gs -sDEVICE=" <devname>
-.RE
-.LP
-Call
-.LP
-.RS
-.B gs --help
-.RE
-.LP
-for a list of the available devices.
-.
-.LP
-As the Encapsulated PostScript File Format
-.B EPS
-is getting more and more important, and the conversion wasn't regarded
-trivial in the past you might be interested to know that there is a
-conversion tool named
-.B ps2eps
-which does the right job.
-It is much better than the tool
-.B ps2epsi
-packaged with
-.BR gs .
-.LP
-For bitmapped graphic formats, you should use
-.BR pstopnm ;
-the resulting (intermediate)
-.B PNM
-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
-Example definitions of the
-.B PS
-and
-.B PE
-macros.
-.
-.
-.SH "SEE ALSO"
-.
-.BR @g@troff (@MAN1EXT@),
-.BR groff_out (@MAN5EXT@),
-.BR tex (1),
-.BR gs (1),
-.BR ps2eps (1),
-.BR pstopnm (1),
-.BR ps2epsi (1),
-.BR pnm (5)
-.LP
-Tpic: Pic for \*(tx
-.LP
-Brian W. Kernighan,
-PIC \(em A Graphics Language for Typesetting (User Manual).
-AT&T Bell Laboratories, Computing Science Technical Report No.\ 116
-<http://cm.bell-labs.com/cm/cs/cstr/116.ps.gz>
-(revised May, 1991).
-.LP
-.B ps2eps
-is available from CTAN mirrors, e.g.
-.br
-<ftp://ftp.dante.de/tex-archive/support/ps2eps/>
-.LP
-W. Richard Stevens - Turning PIC Into HTML
-.br
-<http://www.kohala.com/start/troff/pic2html.html>
-.LP
-W. Richard Stevens - Examples of picMacros
-.br
-<http://www.kohala.com/start/troff/pic.examples.ps>
-.
-.
-.SH BUGS
-.
-Input characters that are invalid for
-.B groff
-(i.e., those with
-.SM ASCII
-code 0, or 013 octal, or between 015 and 037 octal, or between 0200 and 0237
-octal) are rejected even in \*(tx mode.
-.LP
-The interpretation of
-.B fillval
-is incompatible with the pic in 10th edition Unix,
-which interprets 0 as black and 1 as white.
-.LP
-PostScript\*R is a registered trademark of Adobe Systems Incorporation.
-.
-.\" Local Variables:
-.\" mode: nroff
-.\" End:
diff --git a/contrib/groff/src/preproc/pic/pic.y b/contrib/groff/src/preproc/pic/pic.y
deleted file mode 100644
index 83d0fe0222ad..000000000000
--- a/contrib/groff/src/preproc/pic/pic.y
+++ /dev/null
@@ -1,1898 +0,0 @@
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2004, 2005
- Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
-%{
-#include "pic.h"
-#include "ptable.h"
-#include "object.h"
-
-extern int delim_flag;
-extern void copy_rest_thru(const char *, const char *);
-extern void copy_file_thru(const char *, const char *, const char *);
-extern void push_body(const char *);
-extern void do_for(char *var, double from, double to,
- int by_is_multiplicative, double by, char *body);
-extern void do_lookahead();
-
-/* Maximum number of characters produced by printf("%g") */
-#define GDIGITS 14
-
-int yylex();
-void yyerror(const char *);
-
-void reset(const char *nm);
-void reset_all();
-
-place *lookup_label(const char *);
-void define_label(const char *label, const place *pl);
-
-direction current_direction;
-position current_position;
-
-implement_ptable(place)
-
-PTABLE(place) top_table;
-
-PTABLE(place) *current_table = &top_table;
-saved_state *current_saved_state = 0;
-
-object_list olist;
-
-const char *ordinal_postfix(int n);
-const char *object_type_name(object_type type);
-char *format_number(const char *form, double n);
-char *do_sprintf(const char *form, const double *v, int nv);
-
-%}
-
-
-%union {
- char *str;
- int n;
- double x;
- struct { double x, y; } pair;
- struct { double x; char *body; } if_data;
- struct { char *str; const char *filename; int lineno; } lstr;
- struct { double *v; int nv; int maxv; } dv;
- struct { double val; int is_multiplicative; } by;
- place pl;
- object *obj;
- corner crn;
- path *pth;
- object_spec *spec;
- saved_state *pstate;
- graphics_state state;
- object_type obtype;
-}
-
-%token <str> LABEL
-%token <str> VARIABLE
-%token <x> NUMBER
-%token <lstr> TEXT
-%token <lstr> COMMAND_LINE
-%token <str> DELIMITED
-%token <n> ORDINAL
-%token TH
-%token LEFT_ARROW_HEAD
-%token RIGHT_ARROW_HEAD
-%token DOUBLE_ARROW_HEAD
-%token LAST
-%token UP
-%token DOWN
-%token LEFT
-%token RIGHT
-%token BOX
-%token CIRCLE
-%token ELLIPSE
-%token ARC
-%token LINE
-%token ARROW
-%token MOVE
-%token SPLINE
-%token HEIGHT
-%token RADIUS
-%token FIGNAME
-%token WIDTH
-%token DIAMETER
-%token UP
-%token DOWN
-%token RIGHT
-%token LEFT
-%token FROM
-%token TO
-%token AT
-%token WITH
-%token BY
-%token THEN
-%token SOLID
-%token DOTTED
-%token DASHED
-%token CHOP
-%token SAME
-%token INVISIBLE
-%token LJUST
-%token RJUST
-%token ABOVE
-%token BELOW
-%token OF
-%token THE
-%token WAY
-%token BETWEEN
-%token AND
-%token HERE
-%token DOT_N
-%token DOT_E
-%token DOT_W
-%token DOT_S
-%token DOT_NE
-%token DOT_SE
-%token DOT_NW
-%token DOT_SW
-%token DOT_C
-%token DOT_START
-%token DOT_END
-%token DOT_X
-%token DOT_Y
-%token DOT_HT
-%token DOT_WID
-%token DOT_RAD
-%token SIN
-%token COS
-%token ATAN2
-%token LOG
-%token EXP
-%token SQRT
-%token K_MAX
-%token K_MIN
-%token INT
-%token RAND
-%token SRAND
-%token COPY
-%token THRU
-%token TOP
-%token BOTTOM
-%token UPPER
-%token LOWER
-%token SH
-%token PRINT
-%token CW
-%token CCW
-%token FOR
-%token DO
-%token IF
-%token ELSE
-%token ANDAND
-%token OROR
-%token NOTEQUAL
-%token EQUALEQUAL
-%token LESSEQUAL
-%token GREATEREQUAL
-%token LEFT_CORNER
-%token RIGHT_CORNER
-%token NORTH
-%token SOUTH
-%token EAST
-%token WEST
-%token CENTER
-%token END
-%token START
-%token RESET
-%token UNTIL
-%token PLOT
-%token THICKNESS
-%token FILL
-%token COLORED
-%token OUTLINED
-%token SHADED
-%token ALIGNED
-%token SPRINTF
-%token COMMAND
-
-%token DEFINE
-%token UNDEF
-
-%left '.'
-
-/* this ensures that plot 17 "%g" parses as (plot 17 "%g") */
-%left PLOT
-%left TEXT SPRINTF
-
-/* give text adjustments higher precedence than TEXT, so that
-box "foo" above ljust == box ("foo" above ljust)
-*/
-
-%left LJUST RJUST ABOVE BELOW
-
-%left LEFT RIGHT
-/* 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 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
-
-/* these must have higher precedence than CHOP so that `label %prec CHOP'
-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 NORTH SOUTH EAST WEST CENTER START END
-
-%left ','
-%left OROR
-%left ANDAND
-%left EQUALEQUAL NOTEQUAL
-%left '<' '>' LESSEQUAL GREATEREQUAL
-
-%left BETWEEN OF
-%left AND
-
-%left '+' '-'
-%left '*' '/' '%'
-%right '!'
-%right '^'
-
-%type <x> expr any_expr text_expr
-%type <by> optional_by
-%type <pair> expr_pair position_not_place
-%type <if_data> simple_if
-%type <obj> nth_primitive
-%type <crn> corner
-%type <pth> path label_path relative_path
-%type <pl> place label element element_list middle_element_list
-%type <spec> object_spec
-%type <pair> position
-%type <obtype> object_type
-%type <n> optional_ordinal_last ordinal
-%type <str> macro_name until
-%type <dv> sprintf_args
-%type <lstr> text print_args print_arg
-
-%%
-
-top:
- optional_separator
- | element_list
- {
- if (olist.head)
- print_picture(olist.head);
- }
- ;
-
-
-element_list:
- optional_separator middle_element_list optional_separator
- { $$ = $2; }
- ;
-
-middle_element_list:
- element
- { $$ = $1; }
- | middle_element_list separator element
- { $$ = $1; }
- ;
-
-optional_separator:
- /* empty */
- | separator
- ;
-
-separator:
- ';'
- | separator ';'
- ;
-
-placeless_element:
- FIGNAME '=' macro_name
- {
- a_delete graphname;
- graphname = new char[strlen($3) + 1];
- strcpy(graphname, $3);
- a_delete $3;
- }
- |
- VARIABLE '=' any_expr
- {
- define_variable($1, $3);
- a_delete $1;
- }
- | VARIABLE ':' '=' any_expr
- {
- place *p = lookup_label($1);
- if (!p) {
- lex_error("variable `%1' not defined", $1);
- YYABORT;
- }
- p->obj = 0;
- p->x = $4;
- p->y = 0.0;
- a_delete $1;
- }
- | UP
- { current_direction = UP_DIRECTION; }
- | DOWN
- { current_direction = DOWN_DIRECTION; }
- | LEFT
- { current_direction = LEFT_DIRECTION; }
- | RIGHT
- { current_direction = RIGHT_DIRECTION; }
- | COMMAND_LINE
- {
- olist.append(make_command_object($1.str, $1.filename,
- $1.lineno));
- }
- | COMMAND print_args
- {
- olist.append(make_command_object($2.str, $2.filename,
- $2.lineno));
- }
- | PRINT print_args
- {
- fprintf(stderr, "%s\n", $2.str);
- a_delete $2.str;
- fflush(stderr);
- }
- | SH
- { delim_flag = 1; }
- DELIMITED
- {
- delim_flag = 0;
- if (safer_flag)
- lex_error("unsafe to run command `%1'", $3);
- else
- system($3);
- a_delete $3;
- }
- | COPY TEXT
- {
- if (yychar < 0)
- do_lookahead();
- do_copy($2.str);
- // do not delete the filename
- }
- | COPY TEXT THRU
- { delim_flag = 2; }
- DELIMITED
- { delim_flag = 0; }
- until
- {
- if (yychar < 0)
- do_lookahead();
- copy_file_thru($2.str, $5, $7);
- // do not delete the filename
- a_delete $5;
- a_delete $7;
- }
- | COPY THRU
- { delim_flag = 2; }
- DELIMITED
- { delim_flag = 0; }
- until
- {
- if (yychar < 0)
- do_lookahead();
- copy_rest_thru($4, $6);
- a_delete $4;
- a_delete $6;
- }
- | FOR VARIABLE '=' expr TO expr optional_by DO
- { delim_flag = 1; }
- DELIMITED
- {
- delim_flag = 0;
- if (yychar < 0)
- do_lookahead();
- do_for($2, $4, $6, $7.is_multiplicative, $7.val, $10);
- }
- | simple_if
- {
- if (yychar < 0)
- do_lookahead();
- if ($1.x != 0.0)
- push_body($1.body);
- a_delete $1.body;
- }
- | simple_if ELSE
- { delim_flag = 1; }
- DELIMITED
- {
- delim_flag = 0;
- if (yychar < 0)
- do_lookahead();
- if ($1.x != 0.0)
- push_body($1.body);
- else
- push_body($4);
- a_delete $1.body;
- a_delete $4;
- }
- | reset_variables
- | RESET
- { define_variable("scale", 1.0); }
- ;
-
-macro_name:
- VARIABLE
- | LABEL
- ;
-
-reset_variables:
- RESET VARIABLE
- {
- reset($2);
- a_delete $2;
- }
- | reset_variables VARIABLE
- {
- reset($2);
- a_delete $2;
- }
- | reset_variables ',' VARIABLE
- {
- reset($3);
- a_delete $3;
- }
- ;
-
-print_args:
- print_arg
- { $$ = $1; }
- | print_args print_arg
- {
- $$.str = new char[strlen($1.str) + strlen($2.str) + 1];
- strcpy($$.str, $1.str);
- strcat($$.str, $2.str);
- a_delete $1.str;
- a_delete $2.str;
- if ($1.filename) {
- $$.filename = $1.filename;
- $$.lineno = $1.lineno;
- }
- else if ($2.filename) {
- $$.filename = $2.filename;
- $$.lineno = $2.lineno;
- }
- }
- ;
-
-print_arg:
- expr %prec ','
- {
- $$.str = new char[GDIGITS + 1];
- sprintf($$.str, "%g", $1);
- $$.filename = 0;
- $$.lineno = 0;
- }
- | text
- { $$ = $1; }
- | 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;
- }
- ;
-
-until:
- /* empty */
- { $$ = 0; }
- | UNTIL TEXT
- { $$ = $2.str; }
- ;
-
-any_expr:
- expr
- { $$ = $1; }
- | text_expr
- { $$ = $1; }
- ;
-
-text_expr:
- text EQUALEQUAL text
- {
- $$ = strcmp($1.str, $3.str) == 0;
- a_delete $1.str;
- a_delete $3.str;
- }
- | text NOTEQUAL text
- {
- $$ = strcmp($1.str, $3.str) != 0;
- a_delete $1.str;
- a_delete $3.str;
- }
- | text_expr ANDAND text_expr
- { $$ = ($1 != 0.0 && $3 != 0.0); }
- | text_expr ANDAND expr
- { $$ = ($1 != 0.0 && $3 != 0.0); }
- | expr ANDAND text_expr
- { $$ = ($1 != 0.0 && $3 != 0.0); }
- | text_expr OROR text_expr
- { $$ = ($1 != 0.0 || $3 != 0.0); }
- | text_expr OROR expr
- { $$ = ($1 != 0.0 || $3 != 0.0); }
- | expr OROR text_expr
- { $$ = ($1 != 0.0 || $3 != 0.0); }
- | '!' text_expr
- { $$ = ($2 == 0.0); }
- ;
-
-
-optional_by:
- /* empty */
- {
- $$.val = 1.0;
- $$.is_multiplicative = 0;
- }
- | BY expr
- {
- $$.val = $2;
- $$.is_multiplicative = 0;
- }
- | BY '*' expr
- {
- $$.val = $3;
- $$.is_multiplicative = 1;
- }
- ;
-
-element:
- object_spec
- {
- $$.obj = $1->make_object(&current_position,
- &current_direction);
- if ($$.obj == 0)
- YYABORT;
- delete $1;
- if ($$.obj)
- olist.append($$.obj);
- else {
- $$.x = current_position.x;
- $$.y = current_position.y;
- }
- }
- | LABEL ':' optional_separator element
- {
- $$ = $4;
- define_label($1, & $$);
- a_delete $1;
- }
- | LABEL ':' optional_separator position_not_place
- {
- $$.obj = 0;
- $$.x = $4.x;
- $$.y = $4.y;
- define_label($1, & $$);
- a_delete $1;
- }
- | LABEL ':' optional_separator place
- {
- $$ = $4;
- define_label($1, & $$);
- a_delete $1;
- }
- | '{'
- {
- $<state>$.x = current_position.x;
- $<state>$.y = current_position.y;
- $<state>$.dir = current_direction;
- }
- element_list '}'
- {
- current_position.x = $<state>2.x;
- current_position.y = $<state>2.y;
- current_direction = $<state>2.dir;
- }
- optional_element
- {
- $$ = $3;
- }
- | placeless_element
- {
- $$.obj = 0;
- $$.x = current_position.x;
- $$.y = current_position.y;
- }
- ;
-
-optional_element:
- /* empty */
- {}
- | element
- {}
- ;
-
-object_spec:
- BOX
- { $$ = new object_spec(BOX_OBJECT); }
- | CIRCLE
- { $$ = new object_spec(CIRCLE_OBJECT); }
- | ELLIPSE
- { $$ = new object_spec(ELLIPSE_OBJECT); }
- | ARC
- {
- $$ = new object_spec(ARC_OBJECT);
- $$->dir = current_direction;
- }
- | LINE
- {
- $$ = new object_spec(LINE_OBJECT);
- lookup_variable("lineht", & $$->segment_height);
- lookup_variable("linewid", & $$->segment_width);
- $$->dir = current_direction;
- }
- | ARROW
- {
- $$ = new object_spec(ARROW_OBJECT);
- lookup_variable("lineht", & $$->segment_height);
- lookup_variable("linewid", & $$->segment_width);
- $$->dir = current_direction;
- }
- | MOVE
- {
- $$ = new object_spec(MOVE_OBJECT);
- lookup_variable("moveht", & $$->segment_height);
- lookup_variable("movewid", & $$->segment_width);
- $$->dir = current_direction;
- }
- | SPLINE
- {
- $$ = new object_spec(SPLINE_OBJECT);
- lookup_variable("lineht", & $$->segment_height);
- lookup_variable("linewid", & $$->segment_width);
- $$->dir = current_direction;
- }
- | text %prec TEXT
- {
- $$ = new object_spec(TEXT_OBJECT);
- $$->text = new text_item($1.str, $1.filename, $1.lineno);
- }
- | PLOT expr
- {
- $$ = new object_spec(TEXT_OBJECT);
- $$->text = new text_item(format_number(0, $2), 0, -1);
- }
- | PLOT expr text
- {
- $$ = new object_spec(TEXT_OBJECT);
- $$->text = new text_item(format_number($3.str, $2),
- $3.filename, $3.lineno);
- a_delete $3.str;
- }
- | '['
- {
- saved_state *p = new saved_state;
- $<pstate>$ = p;
- p->x = current_position.x;
- p->y = current_position.y;
- p->dir = current_direction;
- p->tbl = current_table;
- p->prev = current_saved_state;
- current_position.x = 0.0;
- current_position.y = 0.0;
- current_table = new PTABLE(place);
- current_saved_state = p;
- olist.append(make_mark_object());
- }
- element_list ']'
- {
- current_position.x = $<pstate>2->x;
- current_position.y = $<pstate>2->y;
- current_direction = $<pstate>2->dir;
- $$ = new object_spec(BLOCK_OBJECT);
- olist.wrap_up_block(& $$->oblist);
- $$->tbl = current_table;
- current_table = $<pstate>2->tbl;
- current_saved_state = $<pstate>2->prev;
- delete $<pstate>2;
- }
- | object_spec HEIGHT expr
- {
- $$ = $1;
- $$->height = $3;
- $$->flags |= HAS_HEIGHT;
- }
- | object_spec RADIUS expr
- {
- $$ = $1;
- $$->radius = $3;
- $$->flags |= HAS_RADIUS;
- }
- | object_spec WIDTH expr
- {
- $$ = $1;
- $$->width = $3;
- $$->flags |= HAS_WIDTH;
- }
- | object_spec DIAMETER expr
- {
- $$ = $1;
- $$->radius = $3/2.0;
- $$->flags |= HAS_RADIUS;
- }
- | object_spec expr %prec HEIGHT
- {
- $$ = $1;
- $$->flags |= HAS_SEGMENT;
- switch ($$->dir) {
- case UP_DIRECTION:
- $$->segment_pos.y += $2;
- break;
- case DOWN_DIRECTION:
- $$->segment_pos.y -= $2;
- break;
- case RIGHT_DIRECTION:
- $$->segment_pos.x += $2;
- break;
- case LEFT_DIRECTION:
- $$->segment_pos.x -= $2;
- break;
- }
- }
- | object_spec UP
- {
- $$ = $1;
- $$->dir = UP_DIRECTION;
- $$->flags |= HAS_SEGMENT;
- $$->segment_pos.y += $$->segment_height;
- }
- | object_spec UP expr
- {
- $$ = $1;
- $$->dir = UP_DIRECTION;
- $$->flags |= HAS_SEGMENT;
- $$->segment_pos.y += $3;
- }
- | object_spec DOWN
- {
- $$ = $1;
- $$->dir = DOWN_DIRECTION;
- $$->flags |= HAS_SEGMENT;
- $$->segment_pos.y -= $$->segment_height;
- }
- | object_spec DOWN expr
- {
- $$ = $1;
- $$->dir = DOWN_DIRECTION;
- $$->flags |= HAS_SEGMENT;
- $$->segment_pos.y -= $3;
- }
- | object_spec RIGHT
- {
- $$ = $1;
- $$->dir = RIGHT_DIRECTION;
- $$->flags |= HAS_SEGMENT;
- $$->segment_pos.x += $$->segment_width;
- }
- | object_spec RIGHT expr
- {
- $$ = $1;
- $$->dir = RIGHT_DIRECTION;
- $$->flags |= HAS_SEGMENT;
- $$->segment_pos.x += $3;
- }
- | object_spec LEFT
- {
- $$ = $1;
- $$->dir = LEFT_DIRECTION;
- $$->flags |= HAS_SEGMENT;
- $$->segment_pos.x -= $$->segment_width;
- }
- | object_spec LEFT expr
- {
- $$ = $1;
- $$->dir = LEFT_DIRECTION;
- $$->flags |= HAS_SEGMENT;
- $$->segment_pos.x -= $3;
- }
- | object_spec FROM position
- {
- $$ = $1;
- $$->flags |= HAS_FROM;
- $$->from.x = $3.x;
- $$->from.y = $3.y;
- }
- | object_spec TO position
- {
- $$ = $1;
- if ($$->flags & HAS_SEGMENT)
- $$->segment_list = new segment($$->segment_pos,
- $$->segment_is_absolute,
- $$->segment_list);
- $$->flags |= HAS_SEGMENT;
- $$->segment_pos.x = $3.x;
- $$->segment_pos.y = $3.y;
- $$->segment_is_absolute = 1;
- $$->flags |= HAS_TO;
- $$->to.x = $3.x;
- $$->to.y = $3.y;
- }
- | object_spec AT position
- {
- $$ = $1;
- $$->flags |= HAS_AT;
- $$->at.x = $3.x;
- $$->at.y = $3.y;
- if ($$->type != ARC_OBJECT) {
- $$->flags |= HAS_FROM;
- $$->from.x = $3.x;
- $$->from.y = $3.y;
- }
- }
- | object_spec WITH path
- {
- $$ = $1;
- $$->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;
- $$->flags |= HAS_SEGMENT;
- $$->segment_pos.x += $3.x;
- $$->segment_pos.y += $3.y;
- }
- | object_spec THEN
- {
- $$ = $1;
- if ($$->flags & HAS_SEGMENT) {
- $$->segment_list = new segment($$->segment_pos,
- $$->segment_is_absolute,
- $$->segment_list);
- $$->flags &= ~HAS_SEGMENT;
- $$->segment_pos.x = $$->segment_pos.y = 0.0;
- $$->segment_is_absolute = 0;
- }
- }
- | object_spec SOLID
- {
- $$ = $1; // nothing
- }
- | object_spec DOTTED
- {
- $$ = $1;
- $$->flags |= IS_DOTTED;
- lookup_variable("dashwid", & $$->dash_width);
- }
- | object_spec DOTTED expr
- {
- $$ = $1;
- $$->flags |= IS_DOTTED;
- $$->dash_width = $3;
- }
- | object_spec DASHED
- {
- $$ = $1;
- $$->flags |= IS_DASHED;
- lookup_variable("dashwid", & $$->dash_width);
- }
- | object_spec DASHED expr
- {
- $$ = $1;
- $$->flags |= IS_DASHED;
- $$->dash_width = $3;
- }
- | object_spec FILL
- {
- $$ = $1;
- $$->flags |= IS_DEFAULT_FILLED;
- }
- | object_spec FILL expr
- {
- $$ = $1;
- $$->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;
- // line chop chop means line chop 0 chop 0
- if ($$->flags & IS_DEFAULT_CHOPPED) {
- $$->flags |= IS_CHOPPED;
- $$->flags &= ~IS_DEFAULT_CHOPPED;
- $$->start_chop = $$->end_chop = 0.0;
- }
- else if ($$->flags & IS_CHOPPED) {
- $$->end_chop = 0.0;
- }
- else {
- $$->flags |= IS_DEFAULT_CHOPPED;
- }
- }
- | object_spec CHOP expr
- {
- $$ = $1;
- if ($$->flags & IS_DEFAULT_CHOPPED) {
- $$->flags |= IS_CHOPPED;
- $$->flags &= ~IS_DEFAULT_CHOPPED;
- $$->start_chop = 0.0;
- $$->end_chop = $3;
- }
- else if ($$->flags & IS_CHOPPED) {
- $$->end_chop = $3;
- }
- else {
- $$->start_chop = $$->end_chop = $3;
- $$->flags |= IS_CHOPPED;
- }
- }
- | object_spec SAME
- {
- $$ = $1;
- $$->flags |= IS_SAME;
- }
- | object_spec INVISIBLE
- {
- $$ = $1;
- $$->flags |= IS_INVISIBLE;
- }
- | object_spec LEFT_ARROW_HEAD
- {
- $$ = $1;
- $$->flags |= HAS_LEFT_ARROW_HEAD;
- }
- | object_spec RIGHT_ARROW_HEAD
- {
- $$ = $1;
- $$->flags |= HAS_RIGHT_ARROW_HEAD;
- }
- | object_spec DOUBLE_ARROW_HEAD
- {
- $$ = $1;
- $$->flags |= (HAS_LEFT_ARROW_HEAD|HAS_RIGHT_ARROW_HEAD);
- }
- | object_spec CW
- {
- $$ = $1;
- $$->flags |= IS_CLOCKWISE;
- }
- | object_spec CCW
- {
- $$ = $1;
- $$->flags &= ~IS_CLOCKWISE;
- }
- | object_spec text %prec TEXT
- {
- $$ = $1;
- text_item **p;
- for (p = & $$->text; *p; p = &(*p)->next)
- ;
- *p = new text_item($2.str, $2.filename, $2.lineno);
- }
- | object_spec LJUST
- {
- $$ = $1;
- if ($$->text) {
- text_item *p;
- for (p = $$->text; p->next; p = p->next)
- ;
- p->adj.h = LEFT_ADJUST;
- }
- }
- | object_spec RJUST
- {
- $$ = $1;</