summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog25
-rw-r--r--NEWS6
-rw-r--r--PROBLEMS8
-rw-r--r--README.CVS2
-rw-r--r--doc/pic.ms86
-rw-r--r--src/preproc/pic/lex.cpp3
-rw-r--r--src/preproc/pic/main.cpp3
-rw-r--r--src/preproc/pic/object.cpp6
-rw-r--r--src/preproc/pic/pic.h1
-rw-r--r--src/preproc/pic/pic.man25
-rw-r--r--src/preproc/pic/pic.y16
-rw-r--r--src/preproc/pic/tex.cpp27
12 files changed, 180 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 6215804e5..4c766d1d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2003-04-19 Werner LEMBERG <wl@gnu.org>
+
+ Add keyword `figname' to pic, specifying the name of the picture
+ box in TeX mode. Based on a patch from William J Poser
+ <wjposer@unagi.cis.upenn.edu>.
+
+ * src/preproc/pic/pic.y: New token `FIGNAME'.
+ (macro_name): New rule of type <str>.
+ (placeless_element): Handle `FIGNAME'.
+ * src/preproc/pic/lex.cpp (lookup_keyword): Add `figname'.
+ * src/preproc/pic/main.cpp (graphname): New global variable.
+ (do_picture): Initialize `graphname'.
+ * src/preproc/pic/pic.h: Updated.
+ * src/preproc/pic/tex.cpp (tex_output::start_picture): Use
+ `graphname'.
+ Simplify TeX code.
+ (tex_output::text): Beautify output.
+ * src/preproc/pic/object.cpp (object_spec::~object_spec): Deallocate
+ `shaded' and `outlined' unconditionally.
+ * NEWS, src/preproc/pic/pic.man, doc/pic.ms: Updated.
+ Minor improvements.
+
+ * PROBLEMS, README.CVS: Mention that bison version 1.875b or
+ greater is necessary.
+
2003-04-17 Hartmut Henkel <hartmut_henkel@gmx.de>
Add option -r to soelim to avoid emission of `.lf' lines.
diff --git a/NEWS b/NEWS
index 40b1d6d2f..7a905b542 100644
--- a/NEWS
+++ b/NEWS
@@ -134,6 +134,12 @@ Grotty
o New option `-r'. It is similar to the -i option except it tells grotty to
use the `reverse video' attribute to render italic fonts.
+Pic
+---
+
+o New command `figname' to set the name of a picture's output box in TeX
+ mode.
+
Refer
-----
diff --git a/PROBLEMS b/PROBLEMS
index ee400593e..f679c3a37 100644
--- a/PROBLEMS
+++ b/PROBLEMS
@@ -613,8 +613,12 @@ Compilation Problems
y.tab.c: In function `int yyparse()':
y.tab.c: `size_t' undeclared in namespace `std'
-This is a bug in bison 1.32. Don't use this version. 1.28 or 1.33 works
-fine. Alternatively, use yacc or byacc.
+* bison reports conflicts (either on stderr or in the `pic.output'
+ file) while processing `pic.y', and the produced pic binary doesn't
+ work at all.
+
+You need bison version 1.875b or greater. Alternatively, use yacc or
+byacc.
----------------------------------------------------------------------
diff --git a/README.CVS b/README.CVS
index b1386ba26..ca284dcf8 100644
--- a/README.CVS
+++ b/README.CVS
@@ -2,5 +2,5 @@ You need the following tools to build groff directly from CVS:
the netpbm package
texinfo >= 4.3
- bison or yacc
+ bison >= 1.875b or byacc
ghostscript
diff --git a/doc/pic.ms b/doc/pic.ms
index d07390146..f22b1e200 100644
--- a/doc/pic.ms
+++ b/doc/pic.ms
@@ -37,6 +37,8 @@ to and reference for \fIgpic\/\fP(1), the implementation distributed by
the Free Software Foundation for use with \fIgroff\/\fP(1).
.AE
.\"%%TUTORIAL%%
+.
+.
.NH 1
Introduction to PIC
.NH 2
@@ -68,6 +70,8 @@ Where differences between Documenter's Work Bench (1991) \fBpic\fP and GNU
end of this document.
.PP
In this document, the \fIgpic\/\fP(1) extensions will be marked as such.
+.
+.
.NH 1
Invoking PIC
.PP
@@ -98,6 +102,8 @@ pic:pic.ms:<nnn>: giving up on this picture
.LP
where \[la]nnn\[ra] is a line number, and \[la]token\[ra] is a token near (usually
just after) the error location.
+.
+.
.NH 1
Basic PIC Concepts
.PP
@@ -293,6 +299,8 @@ surrounded by an invisible box of a size either specified by width
and height attributes or by the defaults \fBtextwid\fR and
\fBtextht\fR. Both are initially zero (because we don't know the
default font size).
+.
+.
.NH 1
Sizes and Spacing
.PP
@@ -412,6 +420,8 @@ box; box wid 1 ht 1; box same; box
.PE
.CE "5: The \fBsame\fP keyword"
+.
+.
.NH 1
Generalized Lines and Splines
.NH 2
@@ -506,6 +516,8 @@ move up 0.2;
Note the arrow decorations. Arrowheads can be applied naturally to
any path-based object, line or spline. We'll see how in the next
section.
+.
+.
.NH 1
Decorating Objects
.NH 2
@@ -683,6 +695,8 @@ request (see the manual page of GNU \fItroff\/\fP(1) for more details).
.PP
\fBpic\fP assumes that at the beginning of a picture both glyph and fill
color are set to the default value.
+.
+.
.NH 1
More About Text Placement
.PP
@@ -723,6 +737,8 @@ 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.
+.
+.
.NH 1
More About Direction Changes
.PP
@@ -808,6 +824,8 @@ object to be joined to the right.
The meaning of the command \fBmove to last circle .s\fP should be obvious.
In order to see how it generalizes, we'll need to go into detail on two
important topics; locations and object names.
+.
+.
.NH 1
Naming Objects
.PP
@@ -894,6 +912,8 @@ Labels are not constants but variables (you can view colon as a sort
of assignment). You can say something like \fBA: A + (1,0);\fP
and the effect will be to reassign the label \fBA\fR to designate a
position one inch to the right of its old value.
+.
+.
.NH 1
Describing locations
.PP
@@ -1200,6 +1220,8 @@ If you say \fBline .\|.\|.\& chop \fIr1\fP chop \fIr2\fP\fR with \fIr1\fP
and \fIr2\fP both numbers, you can vary the amount of chopping at both
ends. You can use this in combination with trigonometric functions
to write code that will deal with more complex intersections.
+.
+.
.NH 1
Object Groups
.PP
@@ -1337,6 +1359,8 @@ The combination of block variable scoping, assignability of labels and
the macro facility that we'll describe later on can be used to
simulate functions with local variables (just wrap the macro body in
block braces).
+.
+.
.NH 1
Style Variables
.PP
@@ -1395,6 +1419,8 @@ You can give it a list of variable names as arguments (optionally
separated by commas), in which case it resets only those.
.PP
State variables retain their values across pictures until reset.
+.
+.
.NH 1
Expressions, Variables, and Assignment
.PP
@@ -1476,6 +1502,8 @@ version.
.PP
The function \fBsprintf()\fP behaves like a C \fIsprintf\/\fP(3)
function that only takes %, %e, %f, and %g format strings.
+.
+.
.NH 1
Macros
.PP
@@ -1614,6 +1642,8 @@ Macros persist through pictures. To undefine a macro, say \fBundef\fP
.DE
.LP
would undefine the two macros in the jumper block example.
+.
+.
.NH 1
Import/Export Commands
.PP
@@ -1628,7 +1658,7 @@ The statement
.DE
.LP
inserts the contents of \fIfilename\fR in the \fBpic\fP input stream.
-Any \fB.PS\fP/\fB.PE\fP pair in the file will be ignored. This, you
+Any \fB.PS\fP/\fB.PE\fP pair in the file will be ignored. You
can use this to include pre-generated images.
.PP
A variant of this statement replicates the \fBcopy thru\fP feature of
@@ -1728,6 +1758,8 @@ inclusion. The delimiters shown as {} here may also be two copies of
any one character not present in the shell command text. In either
case, the body may contain balanced {} pairs. Strings in the body
may contain balanced or unbalanced braces in any case.
+.
+.
.NH 1
Control-flow constructs
.PP
@@ -1828,6 +1860,8 @@ All the usual relational operators my be used in conditional expressions;
String comparison is also supported using \fB==\fP and \fB!=\fP. String
comparisons may need to be parenthesized to avoid syntactic
ambiguities.
+.
+.
.NH 1
Interface To [gt]roff
.PP
@@ -1933,6 +1967,8 @@ box "@space 0 {H( omega )} over {1 - H( omega )}@"
arrow
.PE
.CE "1: Equations within pictures"
+.
+.
.NH 1
Interface to TeX
.PP
@@ -1942,7 +1978,9 @@ Interface to TeX
option.
In \*[tx] mode, pic will define a vbox called
.B \egraph
-for each picture.
+for each picture; the name can be changed with the pseudo-variable
+.B figname
+(which is actually a specially parsed command).
You must yourself print that vbox using, for example, the command
.RS
.LP
@@ -1976,6 +2014,27 @@ Lines beginning with a period are not given any special treatment.
.PP
The \*[tx] mode of \fIpic\/\fP(1) will \fInot\fP translate \fBtroff\fP
font and size changes included in text strings!
+.PP
+Here an example how to use \fBfigname\fP.
+.KS
+.DS
+.CW
+\&.PS
+figname = foo;
+\&...
+\&.PE
+
+\&.PS
+figname = bar;
+\&...
+\&.PE
+
+\ecenterline{\ebox\efoo \ehss \ebox\ebar}
+.DE
+.R
+.KE
+.
+.
.NH 1
Obsolete Commands
.PP
@@ -1997,6 +2056,8 @@ Be very careful that you specify an appropriate format string;
\fBpic\fP does only very limited checking of the string.
This is deprecated in favour of
\fBsprintf\fP.
+.
+.
.NH 1
Some Larger Examples
.PP
@@ -2210,6 +2271,8 @@ arrow from Top.D.end to Anchor.ne
.CE "2: Hypothetical production flow for dual-mode publishing"
.LP
.\"%%REFERENCE%%
+.
+.
.NH 1
PIC Reference
.PP
@@ -2328,6 +2391,7 @@ In the following, either `|' or a new line starts an alternative.
LABEL : [;] <command> [<position>]
{ <command> ... }
VARIABLE [:] = <any-expr>
+ figname = MACRONAME
up | down | left | right
COMMAND-LINE
command <print-arg> ...
@@ -2377,6 +2441,12 @@ if {
.PP
This restriction doesn't hold for the body after the `do' in a `for'
construction.
+.PP
+At the beginning of each picture, `figname' is reset to the vbox name
+`graph'; this command has only a meaning in \*[tx] mode. While the grammar
+rules allow digits and the underscore in the value of `figname', \*[tx]
+normally accepts uppercase and lowercase letters only as box names
+(\fBpic\fP doesn't use `\ecsname' to circumvent this limitation).
.DS
.CW
<any-expr> ::=
@@ -2488,7 +2558,7 @@ box.
.PP
A text item consists of a string or sprintf-expression, optionally
followed by positioning information. Text (or strings specified with
-`sprintf' may contain [gtn]roff font changes, size changes, and local
+`sprintf') may contain [gtn]roff font changes, size changes, and local
motions, provided those changes are undone before the end of the current
item.
.PP
@@ -2550,8 +2620,8 @@ ways to specify positions:
.DE
.DS
.CW
-<xxx-of> ::=
- xxx \fR# followed by `of'\fP
+<\,\f(CIxxx\/\fP-of> ::=
+ \f(CIxxx\fP \fR# followed by `of'\fP
.R
.DE
.DS
@@ -2593,7 +2663,7 @@ The \[lq]'th\[rq] form (which allows you to select a previous object with
an expression, as opposed to a numeric literal) is not documented in DWB's
\fIpic\/\fR(1).
.PP
-The \[la]\|\fIxxx\fP-of\|\[ra] rule is special: The lexical parser checks whether
+The \[la]\,\fIxxx\/\fP-of\|\[ra] rule is special: The lexical parser checks whether
\fIxxx\fP is followed by the token `of' without eliminating it so that
the grammar parser can still see `of'. Valid examples of specifying a
place with corner and label are thus
@@ -2739,6 +2809,8 @@ The arguments (if any) will be substituted for tokens $1, $2 .\|.\|.\& $n
appearing in the replacement text. To undefine a macro, say \fBundef\fP
\fIname\fR, specifying the name to be undefined.
.\"%%POSTLUDE%%
+.
+.
.NH 1
History and Acknowledgements
.PP
@@ -2775,6 +2847,8 @@ integrate in descriptions of the GNU \fIgpic\/\fP(1) features.
The GNU \fBgpic\fR implementation was written by James Clark
\[la]\,\fIjjc@jclark.com\/\fP\[ra]. It is currently maintained by Werner
Lemberg \[la]\,\fIwl@gnu.org\/\fP\[ra].
+.
+.
.NH 1
Bibliography
.IP 1.
diff --git a/src/preproc/pic/lex.cpp b/src/preproc/pic/lex.cpp
index 14a4cc313..b8aa9ebcf 100644
--- a/src/preproc/pic/lex.cpp
+++ b/src/preproc/pic/lex.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2003
Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -467,6 +467,7 @@ int lookup_keyword(const char *str, int len)
{ "else", ELSE },
{ "end", END },
{ "exp", EXP },
+ { "figname", FIGNAME },
{ "fill", FILL },
{ "filled", FILL },
{ "for", FOR },
diff --git a/src/preproc/pic/main.cpp b/src/preproc/pic/main.cpp
index eb6db525a..8788fa6d5 100644
--- a/src/preproc/pic/main.cpp
+++ b/src/preproc/pic/main.cpp
@@ -25,6 +25,7 @@ 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;
@@ -221,6 +222,8 @@ 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 == '<') {
diff --git a/src/preproc/pic/object.cpp b/src/preproc/pic/object.cpp
index 21bce3e4d..d5c0d6c06 100644
--- a/src/preproc/pic/object.cpp
+++ b/src/preproc/pic/object.cpp
@@ -436,10 +436,8 @@ object_spec::~object_spec()
delete tem;
}
delete with;
- if (shaded)
- a_delete shaded;
- if (outlined)
- a_delete outlined;
+ a_delete shaded;
+ a_delete outlined;
}
class command_object : public object {
diff --git a/src/preproc/pic/pic.h b/src/preproc/pic/pic.h
index 1b74e6736..166e4e759 100644
--- a/src/preproc/pic/pic.h
+++ b/src/preproc/pic/pic.h
@@ -126,3 +126,4 @@ 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/src/preproc/pic/pic.man b/src/preproc/pic/pic.man
index 406246fa5..40dc6c7b9 100644
--- a/src/preproc/pic/pic.man
+++ b/src/preproc/pic/pic.man
@@ -1,5 +1,5 @@
.ig
-Copyright (C) 1989-2000, 2001, 2002 Free Software Foundation, Inc.
+Copyright (C) 1989-2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -95,7 +95,7 @@ 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.
+These will center each picture.
.
.
.SH OPTIONS
@@ -233,6 +233,9 @@ In \*(tx mode,
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
@@ -799,6 +802,24 @@ 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.
diff --git a/src/preproc/pic/pic.y b/src/preproc/pic/pic.y
index ed263b5ab..2ee1decf8 100644
--- a/src/preproc/pic/pic.y
+++ b/src/preproc/pic/pic.y
@@ -108,6 +108,7 @@ char *do_sprintf(const char *form, const double *v, int nv);
%token SPLINE
%token HEIGHT
%token RADIUS
+%token FIGNAME
%token WIDTH
%token DIAMETER
%token UP
@@ -266,7 +267,7 @@ works */
%type <pair> position
%type <obtype> object_type
%type <n> optional_ordinal_last ordinal
-%type <str> until
+%type <str> macro_name until
%type <dv> sprintf_args
%type <lstr> text print_args print_arg
@@ -305,6 +306,14 @@ 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);
@@ -425,6 +434,11 @@ placeless_element:
{ define_variable("scale", 1.0); }
;
+macro_name:
+ VARIABLE
+ | LABEL
+ ;
+
reset_variables:
RESET VARIABLE
{
diff --git a/src/preproc/pic/tex.cpp b/src/preproc/pic/tex.cpp
index a9192acd1..b7790f256 100644
--- a/src/preproc/pic/tex.cpp
+++ b/src/preproc/pic/tex.cpp
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2003 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -114,10 +114,14 @@ void tex_output::start_picture(double sc, const position &ll,
a height of 0 rather than the height of the hbox; this
might be non-zero if text from text attributes lies outside pic's
idea of the bounding box of the picture. */
- fputs("\\expandafter\\ifx\\csname graph\\endcsname\\relax \\csname newbox\\endcsname\\graph\\fi\n"
- "\\expandafter\\ifx\\csname graphtemp\\endcsname\\relax \\csname newdimen\\endcsname\\graphtemp\\fi\n"
- "\\setbox\\graph=\\vtop{\\vskip 0pt\\hbox{%\n",
- stdout);
+ printf("\\expandafter\\ifx\\csname %s\\endcsname\\relax\n"
+ " \\newbox\\%s\n"
+ "\\fi\n"
+ "\\expandafter\\ifx\\graphtemp\\relax\n"
+ " \\newdimen\\graphtemp\n"
+ "\\fi\n"
+ "\\setbox\\%s=\\vtop{\\vskip 0pt\\hbox{%%\n",
+ graphname, graphname, graphname);
pen_size = -2.0;
}
@@ -141,14 +145,15 @@ void tex_output::text(const position &center, text_piece *v, int n, double)
else if (v[i].adj.v == BELOW_ADJUST)
j++;
if (j == 0) {
- printf(" \\graphtemp=.5ex\\advance\\graphtemp by %.3fin\n", c.y);
+ printf(" \\graphtemp=.5ex\n"
+ " \\advance\\graphtemp by %.3fin\n", c.y);
}
else {
- printf(" \\graphtemp=\\baselineskip"
- "\\multiply\\graphtemp by %d"
- "\\divide\\graphtemp by 2\n"
- " \\advance\\graphtemp by .5ex"
- "\\advance\\graphtemp by %.3fin\n",
+ printf(" \\graphtemp=\\baselineskip\n"
+ " \\multiply\\graphtemp by %d\n"
+ " \\divide\\graphtemp by 2\n"
+ " \\advance\\graphtemp by .5ex\n"
+ " \\advance\\graphtemp by %.3fin\n",
j, c.y);
}
printf(" \\rlap{\\kern %.3fin\\lower\\graphtemp", c.x);