summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwlemb <wlemb>2002-04-14 10:22:55 +0000
committerwlemb <wlemb>2002-04-14 10:22:55 +0000
commite9c0c7e398d4a279cf7078591f5036fe9fac6b96 (patch)
treee06207ec5d55c97e29cf67130b0e354f55271d9c
parent7782388159e2d3d64093167e2fcdf9dd1a1721cc (diff)
downloadgroff-e9c0c7e398d4a279cf7078591f5036fe9fac6b96.tar.gz
Implement \f[] as an alternative to \fP. Change \mP and \MP to
\m[] and \M[], respectively. * src/roff/troff/symbol.cc (EMPTY_SYMBOL): New global variable. (symbol::symbol): Handle NULL string and empty string differently. * src/roff/troff/symbol.h (symbol::is_empty): New inline function. * src/roff/troff/input.cc (read_escape_name, read_long_escape_name): Add optional parameter. Updated calling functions. (get_copy, do_glyph_color, do_fill_color, token::next): Use `symbol::is_empty'. * src/roff/troff/env.cc (environment::set_font): Ditto. * src/preproc/pic/troff.cc (troff_output::set_fill, troff_output::reset_color: Updated. * tmac/www.tmac: Updated. * NEWS, man/groff_diff.man, man/groff.man, doc/groff.texinfo, doc/homepage.ms, src/devices/grotty/grotty.man, tmac/groff_www.man: Updated. * src/include/printer.h, src/libs/libdriver/printer.cc (printer::change_fill_color): New member function. * src/libs/libdriver/input.cc (parse_D_command): Use it.
-rw-r--r--ChangeLog30
-rw-r--r--NEWS11
-rw-r--r--doc/groff.texinfo18
-rwxr-xr-xdoc/homepage.ms2
-rw-r--r--man/groff.man16
-rw-r--r--man/groff_diff.man12
-rw-r--r--src/devices/grotty/grotty.man4
-rw-r--r--src/include/printer.h54
-rw-r--r--src/libs/libdriver/input.cc59
-rw-r--r--src/libs/libdriver/printer.cc37
-rw-r--r--src/preproc/pic/troff.cc6
-rw-r--r--src/roff/troff/env.cc2
-rw-r--r--src/roff/troff/input.cc54
-rw-r--r--src/roff/troff/symbol.cc10
-rw-r--r--src/roff/troff/symbol.h9
-rw-r--r--tmac/groff_www.man2
-rw-r--r--tmac/www.tmac8
17 files changed, 220 insertions, 114 deletions
diff --git a/ChangeLog b/ChangeLog
index 22fb8aca..fee1f1cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2002-04-13 Werner LEMBERG <wl@gnu.org>
+
+ Implement \f[] as an alternative to \fP. Change \mP and \MP to
+ \m[] and \M[], respectively.
+
+ * src/roff/troff/symbol.cc (EMPTY_SYMBOL): New global variable.
+ (symbol::symbol): Handle NULL string and empty string differently.
+ * src/roff/troff/symbol.h (symbol::is_empty): New inline function.
+ * src/roff/troff/input.cc (read_escape_name, read_long_escape_name):
+ Add optional parameter.
+ Updated calling functions.
+ (get_copy, do_glyph_color, do_fill_color, token::next): Use
+ `symbol::is_empty'.
+ * src/roff/troff/env.cc (environment::set_font): Ditto.
+
+ * src/preproc/pic/troff.cc (troff_output::set_fill,
+ troff_output::reset_color: Updated.
+
+ * tmac/www.tmac: Updated.
+
+ * NEWS, man/groff_diff.man, man/groff.man, doc/groff.texinfo,
+ doc/homepage.ms, src/devices/grotty/grotty.man, tmac/groff_www.man:
+ Updated.
+
+2002-04-13 Bernd Warken <bwarken@mayn.de>
+
+ * src/include/printer.h, src/libs/libdriver/printer.cc
+ (printer::change_fill_color): New member function.
+ * src/libs/libdriver/input.cc (parse_D_command): Use it.
+
2002-04-12 Werner LEMBERG <wl@gnu.org>
* doc/groff.texinfo: Completed pass on gtroff reference.
diff --git a/NEWS b/NEWS
index 7c226e18..37f8d5ed 100644
--- a/NEWS
+++ b/NEWS
@@ -18,10 +18,10 @@ o Color support has been added to troff and pic (and to the device drivers
follow). A new function `defcolor' defines colors; the escape sequence
`\m' sets the drawing color, the escape sequence `\M' specifies the
background color for closed objects created with \D'...' commands.
- Similar to fonts, `\mP' and `\MP' switch back to the previous color. `\m'
- and `\M' correspond to the new troff output command sets starting with `m'
- and `DF'. The device-specific default color is called `default' and can't
- be redefined.
+ `\m[]' and `\M[]' switch back to the previous color. `\m' and `\M'
+ correspond to the new troff output command sets starting with `m' and
+ `DF'. The device-specific default color is called `default' and can't be
+ redefined.
The old `Df' output command is mapped onto `DFg'; all color output
commands don't change the current font position (consequently, `Df'
@@ -39,6 +39,9 @@ o Color support has been added to troff and pic (and to the device drivers
More details can be found in the groff_diff.7 manual page and in
groff.texinfo.
+o Similar to \m and \M, \f[] switches back to the previous font. \fP
+ (and \f[P]) is still valid for backwards compatibility.
+
o Two new glyph symbols are available: `eu' is the official Euro symbol;
`Eu' is a font-specific glyph variant.
diff --git a/doc/groff.texinfo b/doc/groff.texinfo
index 05d5727e..0f1c5ad1 100644
--- a/doc/groff.texinfo
+++ b/doc/groff.texinfo
@@ -7516,11 +7516,11 @@ with the @code{styles} command in the @file{DESC} file), use it within
the current font family (as set with the @code{fam} request or with
the @code{family} command in the @file{DESC} file).
-@cindex previous font (@code{ft}, @code{\fP})
-@cindex font, previous (@code{ft}, @code{\fP})
+@cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
+@cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
With no argument or using @samp{P} as an argument, @code{.ft} switches
-to the previous font. Use @code{\fP} or @code{\f[P]} to do this with
-the escape.
+to the previous font. Use @code{\f[]} to do this with the escape. The
+old syntax forms @code{\fP} or @code{\f[P]} are also supported.
Fonts are generally specified as upper-case strings, which are usually
1@w{ }to 4 characters representing an abbreviation or acronym of the
@@ -7544,7 +7544,7 @@ expects a single character as an argument) to change the font on
the fly:
@Example
-.mc \f[I]x\f[P]
+.mc \f[I]x\f[]
@endExample
@xref{Font Positions}, for an alternative syntax.
@@ -10866,10 +10866,10 @@ Set drawing color. The following example shows how to turn the next four
words red.
@Example
-\m[red]these are in red\mP and these words are in black.
+\m[red]these are in red\m[] and these words are in black.
@endExample
-The escape @code{\mP} returns to the previous color.
+The escape @code{\m[]} returns to the previous color.
The drawing color is associated with the current environment
(@pxref{Environments}).
@@ -10884,10 +10884,10 @@ Set background color for filled objects drawn with the
A red ellipse can be created with the following code:
@Example
-\M[red]\h'0.5i'\D'E 2i 1i'\Mp
+\M[red]\h'0.5i'\D'E 2i 1i'\M[]
@endExample
-The escape @code{\MP} returns to the previous fill color.
+The escape @code{\M[]} returns to the previous fill color.
The fill color is associated with the current environment
(@pxref{Environments}).
diff --git a/doc/homepage.ms b/doc/homepage.ms
index b4668ffd..6bc07b1d 100755
--- a/doc/homepage.ms
+++ b/doc/homepage.ms
@@ -24,7 +24,7 @@
.defcolor darkgreen rgb 0.1f 0.5f 0.2f
.defcolor darkblue rgb 0.1f 0.2f 0.6f
.
-.ds GNU \m[darkred]G\mP\m[darkgreen]N\mP\m[darkblue]U\mP
+.ds GNU \m[darkred]G\m[]\m[darkgreen]N\m[]\m[darkblue]U\m[]
.
.HTL
.
diff --git a/man/groff.man b/man/groff.man
index 8fd71ef4..71ae61ca 100644
--- a/man/groff.man
+++ b/man/groff.man
@@ -2,7 +2,7 @@
.ig
groff.man
-Last update: 15 Mar 2002
+Last update: 14 Apr 2002
This file is part of groff, the GNU roff type-setting system.
@@ -1543,6 +1543,8 @@ will be special.
.REQ .ft
Return to previous font.
Same as
+.request \[rs]f[]
+or
.request \[rs]fP .
.
.REQ .ft font
@@ -2514,6 +2516,9 @@ Equivalent to an escape character, but is not interpreted in copy-mode.
Change to font with 1-character name or 1-digit number
.IR F .
.
+.ESC fP
+Switch back to previous font.
+.
.ESC f( fo
Change to font with 2-characer name or 2-digit number
.IR fo .
@@ -2522,6 +2527,9 @@ Change to font with 2-characer name or 2-digit number
Change to font with arbitrary length name or number expression
.IR font .
.
+.ESC[] f ""
+Switch back to previous font.
+.
.ESC[] g reg
Return format of register with name
.I reg
@@ -2567,6 +2575,9 @@ Alternative forms
and
.escarg m c .
.
+.ESC[] m ""
+Switch back to previous color.
+.
.ESC[] M color
Change filling color for closed drawn objects to color
.IR color .
@@ -2576,6 +2587,9 @@ Alternative forms
and
.escarg M c .
.
+.ESC[] M ""
+Switch to previous fill color.
+.
.ESC n r
The numerical value stored in the register variable with the
1-character name
diff --git a/man/groff_diff.man b/man/groff_diff.man
index f2564848..f39b2506 100644
--- a/man/groff_diff.man
+++ b/man/groff_diff.man
@@ -3,7 +3,7 @@
.ig
groff_diff.man
-Last update : 6 Jan 2002
+Last update : 14 Apr 2002
This file is part of groff, the GNU roff type-setting system.
It is the source of the man-page groff_diff(7).
@@ -185,6 +185,12 @@ Print the special character called
Set font
.IR xxx .
.
+Additionally,
+.B \[rs]f[]
+is a new syntax equal to
+.BR \[rs]fP ,
+i.e., to return to the previous font.
+.
.TP
.BI \[rs]*[ xxx ]
Interpolate string
@@ -414,7 +420,7 @@ argument).
.TQ
.BI \[rs]m[ xxx ]
Set drawing color.
-.B \[rs]mP
+.B \[rs]m[]
switches back to the previous color.
.
.TP
@@ -426,7 +432,7 @@ switches back to the previous color.
Set background color for filled objects drawn with the
.BI \[rs]D' .\|.\|. '
commands.
-.B \[rs]MP
+.B \[rs]M[]
switches back to the previous color.
.
.TP
diff --git a/src/devices/grotty/grotty.man b/src/devices/grotty/grotty.man
index 0f0e24e9..214b8147 100644
--- a/src/devices/grotty/grotty.man
+++ b/src/devices/grotty/grotty.man
@@ -72,8 +72,8 @@ By default,
.B grotty
emits SGR escape sequences (from ISO 6429, also called ANSI color escapes)
to change text attributes (bold, italic, colors).
-This makes it possible to have have eight different \M[green]background\M[P]
-and \m[red]foreground\m[P] colors; additionally, bold and italic
+This makes it possible to have have eight different \M[green]background\M[]
+and \m[red]foreground\m[] colors; additionally, bold and italic
attributes can be used \f[BI]at the same time\f[P] (by using the BI font).
.LP
The following colors are defined in
diff --git a/src/include/printer.h b/src/include/printer.h
index 726277b9..4d5cbf52 100644
--- a/src/include/printer.h
+++ b/src/include/printer.h
@@ -1,23 +1,40 @@
// -*- C++ -*-
+
+// <groff_src_dir>/src/include/printer.h
+
/* 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.
+ Written by James Clark (jjc@jclark.com)
+
+ Last update: 12 Apr 2002
+
+ 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.
-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.
+ You should have received a copy of the GNU General Public License
+ along with groff; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
-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.
+/* Description
-You should have received a copy of the GNU General Public License along
-with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ The class `printer' performs the postprocessing. Each
+ postprocessor only need to implement a derived class of `printer' and
+ a suitable function `make_printer' for the device-dependent tasks.
+ Then the methods of class `printer' are called automatically by
+ `do_file()' in `input.cc'.
+*/
#include "color.h"
@@ -50,17 +67,22 @@ public:
int *widthp = 0);
void set_special_char(const char *nm, const environment *env,
int *widthp = 0);
- void set_numbered_char(int n, const environment *env, int *widthp = 0);
+ void set_numbered_char(int n, const environment *env,
+ int *widthp = 0);
int set_char_and_width(const char *nm, const environment *env,
int *widthp, font **f);
font *get_font_from_index(int fontno);
virtual void draw(int code, int *p, int np, const environment *env);
- virtual void change_color(const environment *env);
+ // perform change of line color (text, outline) in the print-out
+ virtual void change_color(const environment * const env);
+ // perform change of fill color in the print-out
+ virtual void change_fill_color(const environment * const env);
virtual void begin_page(int) = 0;
virtual void end_page(int page_length) = 0;
virtual font *make_font(const char *nm);
virtual void end_of_line();
- virtual void special(char *arg, const environment *env, char type = 'p');
+ virtual void special(char *arg, const environment *env,
+ char type = 'p');
protected:
font_pointer_list *font_list;
diff --git a/src/libs/libdriver/input.cc b/src/libs/libdriver/input.cc
index 697af23b..7008ee8d 100644
--- a/src/libs/libdriver/input.cc
+++ b/src/libs/libdriver/input.cc
@@ -8,7 +8,7 @@
Written by James Clark (jjc@jclark.com)
Major rewrite 2001 by Bernd Warken (bwarken@mayn.de)
- Last update: 10 Apr 2002
+ Last update: 12 Apr 2002
This file is part of groff, the GNU roff text processing system.
@@ -60,6 +60,7 @@
- Unknown subcommands of `D' and `x' are now ignored like in the
classical case, but a warning is issued. This was also
implemented for the other commands.
+ - A warning is emitted if `x stop' is missing.
- `DC' and `DE' commands didn't position to the right end after
drawing (now they do), see discussion below.
- So far, `x stop' was ignored. Now it terminates the processing
@@ -85,16 +86,12 @@
checks whether its argument agrees with the file name used so far,
otherwise a warning is issued. Then the new name is remembered
and used for the following error messages.
- - Positioning of drawing commands is corrected according to the
- classical rule, see the discussion below.
- - Setting commands (`Dt', `Df', `DF') and polygons (`Dp' and `DP')
- do not change position now.
- - Filled circles and ellipses (`DC' and `DE') position at their
- most right point (outlined ones `Dc' and `De' did this anyway).
- - As before, all open graphical objects position to their final
- drawing point (alternate sum of the command arguments).
- There is a macro STUPID_DRAWING_POSITIONING that implements the
- old behavior for testing purposes.
+ - For the positioning after drawing commands, an alternative, easier
+ scheme is provided, but not yet activated; it can be chosen by
+ undefining the preprocessor macro STUPID_DRAWING_POSITIONING.
+ It extends the rule of the classical troff output language in a
+ logical way instead of the rather strange actual positioning.
+ For details, see the discussion below.
- For the `D' commands that only set the environment, the calling of
pr->send_draw() was removed because this doesn't make sense for
the `DF' commands; the (changed) environment is sent with the
@@ -138,19 +135,18 @@
- Various comments were added.
TODO
- - Add scaling facility for classical device independence and
- non-groff devices.
- - Should a missing `x stop' be warned?
- Get rid of the stupid drawing positioning.
- Can the `Dt' command be completely handled by setting environment
within do_file() instead of sending to pr?
- Integer arguments must be >= 32 bits, use conditional #define.
- - Classical troff output had a quasi device independence by scaling
- the intermediate output to the resolution of the postprocessor
- device if different from the one specified with `x T', groff does
- not. So implement full quasi device indepedence, including
- the mapping of the strange classical devices to the postprocessor
- device (seems to be reasonably easy).
+ - Add scaling facility for classical device independence and
+ non-groff devices. Classical troff output had a quasi device
+ independence by scaling the intermediate output to the resolution
+ of the postprocessor device if different from the one specified
+ with `x T', groff have not. So implement full quasi device
+ indepedence, including the mapping of the strange classical
+ devices to the postprocessor device (seems to be reasonably
+ easy).
- The external, global pointer variables are not optimally handled.
- `pr' isn't used outside besides initialization and deletion.
So it could be replaced by a static local variable. For
@@ -159,14 +155,16 @@
- The global variables `current_filename' and `current_lineno' are
only used for error reporting. So implement a static class
`Error' (`::' calls).
- - Stop using global `device'; design a new scheme based on
- postprocessors.
+ - The global `device' is the name used during the formatting
+ process; there should be a new variable for the device name used
+ during the postprocessing.
- Implement the B-spline drawing `D~' for all graphical devices.
- Make `environment' a class with an overflow check for its members
and a delete method to get rid of delete_current_env().
+ - Implement the `EnvStack' to use `new' instead of `malloc'.
- The class definitions of this document could go into a new file.
- - Once things will have been settled the comments in this document
- could be strongly reduced.
+ - The comments in this section should go to a `Changelog' or some
+ `README' file in this directory.
*/
/*
@@ -229,6 +227,15 @@
classical specification with its clear end-of-drawing rule that is
suitable for all cases. But a macro STUPID_DRAWING_POSITIONING is
provided for testing the funny former behavior.
+
+ The new rule implies the following behavior.
+ - Setting commands (`Dt', `Df', `DF') and polygons (`Dp' and `DP')
+ do not change position now.
+ - Filled circles and ellipses (`DC' and `DE') position at their
+ most right point (outlined ones `Dc' and `De' did this anyway).
+ - As before, all open graphical objects position to their final
+ drawing point (alternate sum of the command arguments).
+
*/
#ifndef STUPID_DRAWING_POSITIONING
@@ -1353,7 +1360,7 @@ parse_D_command()
delete current_env->fill;
current_env->fill = new color(current_env->col);
}
- pr->change_color(current_env);
+ pr->change_fill_color(current_env);
// skip unused `vertical' component (\D'...' always emits pairs)
(void) get_integer_arg();
// no positioning
@@ -1362,7 +1369,7 @@ parse_D_command()
}
case 'F': // DF: set fill color, several formats
parse_color_command(current_env->fill);
- pr->change_color(current_env);
+ pr->change_fill_color(current_env);
// no positioning (setting-only command)
skip_line_x();
break;
diff --git a/src/libs/libdriver/printer.cc b/src/libs/libdriver/printer.cc
index 922f0b5f..c97e2ce6 100644
--- a/src/libs/libdriver/printer.cc
+++ b/src/libs/libdriver/printer.cc
@@ -1,23 +1,30 @@
// -*- C++ -*-
+
+// <groff_src_dir>/src/libs/libdriver/printer.cc
+
/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002
Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
+ Written by James Clark (jjc@jclark.com)
+
+ Last update: 12 Apr 2002
-This file is part of groff.
+ 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 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.
+ groff is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
-You should have received a copy of the GNU General Public License along
-with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with groff; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
#include "driver.h"
@@ -110,6 +117,10 @@ void printer::change_color(const environment *)
{
}
+void printer::change_fill_color(const environment *)
+{
+}
+
void printer::set_ascii_char(unsigned char c, const environment *env,
int *widthp)
{
diff --git a/src/preproc/pic/troff.cc b/src/preproc/pic/troff.cc
index 469ffa20..7ee7293f 100644
--- a/src/preproc/pic/troff.cc
+++ b/src/preproc/pic/troff.cc
@@ -484,7 +484,7 @@ void troff_output::set_fill(double f)
if (last_filled) {
free(last_filled);
last_filled = 0;
- printf("\\MP\n.sp -1\n");
+ printf("\\M[]\n.sp -1\n");
}
}
@@ -509,12 +509,12 @@ void troff_output::reset_color()
{
if (driver_extension_flag) {
if (last_filled) {
- printf("\\MP\n.sp -1\n");
+ printf("\\M[]\n.sp -1\n");
free(last_filled);
last_filled = 0;
}
if (last_outlined) {
- printf("\\mP\n.sp -1\n");
+ printf("\\m[]\n.sp -1\n");
free(last_outlined);
last_outlined = 0;
}
diff --git a/src/roff/troff/env.cc b/src/roff/troff/env.cc
index 933f68f9..7e1cc734 100644
--- a/src/roff/troff/env.cc
+++ b/src/roff/troff/env.cc
@@ -438,7 +438,7 @@ void environment::set_font(symbol nm)
{
if (interrupted)
return;
- if (nm == symbol("P")) {
+ if (nm == symbol("P") || nm.is_empty()) {
if (family->make_definite(prev_fontno) < 0)
return;
int tem = fontno;
diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc
index 19817f5e..0ddbc10b 100644
--- a/src/roff/troff/input.cc
+++ b/src/roff/troff/input.cc
@@ -130,7 +130,8 @@ static void copy_mode_error(const char *,
const errarg & = empty_errarg,
const errarg & = empty_errarg);
-static symbol read_escape_name();
+static symbol read_escape_name(int no_empty = 1);
+static symbol read_long_escape_name(int no_empty = 1);
static void interpolate_string(symbol);
static void interpolate_macro(symbol);
static void interpolate_number_format(symbol);
@@ -724,7 +725,7 @@ static symbol read_two_char_escape_name()
return symbol(buf);
}
-static symbol read_long_escape_name()
+static symbol read_long_escape_name(int no_empty)
{
int start_level = input_stack::get_level();
char abuf[ABUF_SIZE];
@@ -759,8 +760,9 @@ static symbol read_long_escape_name()
buf[i] = 0;
if (buf == abuf) {
if (i == 0) {
- copy_mode_error("empty escape name");
- return NULL_SYMBOL;
+ if (no_empty)
+ copy_mode_error("empty escape name");
+ return EMPTY_SYMBOL;
}
return symbol(abuf);
}
@@ -771,7 +773,7 @@ static symbol read_long_escape_name()
}
}
-static symbol read_escape_name()
+static symbol read_escape_name(int no_empty)
{
int c = get_char_for_escape_name();
if (c == 0)
@@ -779,7 +781,7 @@ static symbol read_escape_name()
if (c == '(')
return read_two_char_escape_name();
if (c == '[' && !compatible_flag)
- return read_long_escape_name();
+ return read_long_escape_name(no_empty);
char buf[2];
buf[0] = c;
buf[1] = '\0';
@@ -848,7 +850,7 @@ static int get_copy(node **nd, int defining)
{
(void)input_stack::get(0);
symbol s = read_escape_name();
- if (!s.is_null())
+ if (!(s.is_null() || s.is_empty()))
interpolate_arg(s);
break;
}
@@ -856,7 +858,7 @@ static int get_copy(node **nd, int defining)
{
(void)input_stack::get(0);
symbol s = read_escape_name();
- if (!s.is_null())
+ if (!(s.is_null() || s.is_empty()))
interpolate_string(s);
break;
}
@@ -874,7 +876,7 @@ static int get_copy(node **nd, int defining)
(void)input_stack::get(0);
int inc;
symbol s = read_increment_and_escape_name(&inc);
- if (!s.is_null())
+ if (!(s.is_null() || s.is_empty()))
interpolate_number_reg(s, inc);
break;
}
@@ -882,7 +884,7 @@ static int get_copy(node **nd, int defining)
{
(void)input_stack::get(0);
symbol s = read_escape_name();
- if (!s.is_null())
+ if (!(s.is_null() || s.is_empty()))
interpolate_number_format(s);
break;
}
@@ -893,7 +895,7 @@ static int get_copy(node **nd, int defining)
{
(void)input_stack::get(0);
symbol s = read_escape_name();
- if (!s.is_null())
+ if (!(s.is_null() || s.is_empty()))
interpolate_environment_variable(s);
break;
}
@@ -1033,7 +1035,7 @@ static node *do_glyph_color(symbol nm)
{
if (nm.is_null())
return 0;
- if (nm == symbol("P"))
+ if (nm.is_empty())
curenv->set_glyph_color(curenv->get_prev_glyph_color());
else {
color *tem = lookup_color(nm);
@@ -1049,7 +1051,7 @@ static node *do_fill_color(symbol nm)
{
if (nm.is_null())
return 0;
- if (nm == symbol("P"))
+ if (nm.is_empty())
curenv->set_fill_color(curenv->get_prev_fill_color());
else {
color *tem = lookup_color(nm);
@@ -1738,14 +1740,14 @@ void token::next()
case '$':
{
symbol nm = read_escape_name();
- if (!nm.is_null())
+ if (!(nm.is_null() || nm.is_empty()))
interpolate_arg(nm);
break;
}
case '*':
{
symbol nm = read_escape_name();
- if (!nm.is_null())
+ if (!(nm.is_null() || nm.is_empty()))
interpolate_string(nm);
break;
}
@@ -1789,14 +1791,14 @@ void token::next()
goto handle_escape_char;
case 'f':
{
- symbol s = read_escape_name();
+ symbol s = read_escape_name(0);
if (s.is_null())
break;
const char *p;
for (p = s.contents(); *p != '\0'; p++)
if (!csdigit(*p))
break;
- if (*p)
+ if (*p || s.is_empty())
curenv->set_font(s);
else
curenv->set_font(atoi(s.contents()));
@@ -1807,7 +1809,7 @@ void token::next()
case 'g':
{
symbol s = read_escape_name();
- if (!s.is_null())
+ if (!(s.is_null() || s.is_empty()))
interpolate_number_format(s);
break;
}
@@ -1825,7 +1827,7 @@ void token::next()
break;
case 'k':
nm = read_escape_name();
- if (nm.is_null())
+ if (nm.is_null() || nm.is_empty())
break;
type = TOKEN_MARK_INPUT;
return;
@@ -1846,13 +1848,13 @@ void token::next()
return;
}
case 'm':
- nd = do_glyph_color(read_escape_name());
+ nd = do_glyph_color(read_escape_name(0));
if (!nd)
break;
type = TOKEN_NODE;
return;
case 'M':
- nd = do_fill_color(read_escape_name());
+ nd = do_fill_color(read_escape_name(0));
if (!nd)
break;
type = TOKEN_NODE;
@@ -1861,7 +1863,7 @@ void token::next()
{
int inc;
symbol nm = read_increment_and_escape_name(&inc);
- if (!nm.is_null())
+ if (!(nm.is_null() || nm.is_empty()))
interpolate_number_reg(nm, inc);
break;
}
@@ -1921,7 +1923,7 @@ void token::next()
case 'V':
{
symbol nm = read_escape_name();
- if (!nm.is_null())
+ if (!(nm.is_null() || nm.is_empty()))
interpolate_environment_variable(nm);
break;
}
@@ -1943,7 +1945,7 @@ void token::next()
case 'Y':
{
symbol s = read_escape_name();
- if (s.is_null())
+ if (s.is_null() || s.is_empty())
break;
request_or_macro *p = lookup_request(s);
macro *m = p->to_macro();
@@ -1987,7 +1989,7 @@ void token::next()
case '[':
if (!compatible_flag) {
nm = read_long_escape_name();
- if (nm.is_null())
+ if (nm.is_null() || nm.is_empty())
break;
type = TOKEN_SPECIAL;
return;
@@ -4631,7 +4633,7 @@ extern int image_no; // from node.cc
static node *do_suppress(symbol nm)
{
- if (nm.is_null()) {
+ if (nm.is_null() || nm.is_empty()) {
error("expecting an argument to escape \\O");
return 0;
}
diff --git a/src/roff/troff/symbol.cc b/src/roff/troff/symbol.cc
index ce09e393..6245301e 100644
--- a/src/roff/troff/symbol.cc
+++ b/src/roff/troff/symbol.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -29,6 +29,7 @@ char *symbol::block = 0;
int symbol::block_size = 0;
const symbol NULL_SYMBOL;
+const symbol EMPTY_SYMBOL("");
#ifdef BLOCK_SIZE
#undef BLOCK_SIZE
@@ -73,10 +74,14 @@ inline void unused(void *) { }
symbol::symbol(const char *p, int how)
{
- if (p == 0 || *p == 0) {
+ if (p == 0) {
s = 0;
return;
}
+ if (*p == 0) {
+ s = "";
+ return;
+ }
if (table == 0) {
table_size = table_sizes[0];
table = (const char **)new char*[table_size];
@@ -147,4 +152,3 @@ symbol concat(symbol s1, symbol s2)
a_delete buf;
return res;
}
-
diff --git a/src/roff/troff/symbol.h b/src/roff/troff/symbol.h
index 88e0fff3..5b7c9b19 100644
--- a/src/roff/troff/symbol.h
+++ b/src/roff/troff/symbol.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -36,10 +36,12 @@ public:
int operator !=(symbol) const;
const char *contents() const;
int is_null() const;
+ int is_empty() const;
};
extern const symbol NULL_SYMBOL;
+extern const symbol EMPTY_SYMBOL;
inline symbol::symbol() : s(0)
{
@@ -70,4 +72,9 @@ inline int symbol::is_null() const
return s == 0;
}
+inline int symbol::is_empty() const
+{
+ return s != 0 && *s == 0;
+}
+
symbol concat(symbol, symbol);
diff --git a/tmac/groff_www.man b/tmac/groff_www.man
index e070c3ce..3ac6baab 100644
--- a/tmac/groff_www.man
+++ b/tmac/groff_www.man
@@ -155,7 +155,7 @@ If this is processed by a device other than
it appears as:
.RS
.IP
-\m[blue]foo\mP \[la]\fChttp://foo.org\fP\[ra]:
+\m[blue]foo\m[] \[la]\fChttp://foo.org\fP\[ra]:
.RE
.IP
The URL macro can be of any type; for example we can reference
diff --git a/tmac/www.tmac b/tmac/www.tmac
index 3d2d9351..479ea1e7 100644
--- a/tmac/www.tmac
+++ b/tmac/www.tmac
@@ -72,7 +72,7 @@
. ie \\n[www-html] \
. HTML <a href="\\$1">\\$2</a>\\$3
. el \
-. nop \m[blue]\\$2\mP \%\[la]\fC\\$1\fP\[ra]\\$3
+. nop \m[blue]\\$2\m[] \%\[la]\fC\\$1\fP\[ra]\\$3
..
.\"
.\" FTP url description [after]
@@ -105,9 +105,9 @@
. \}
. el \{\
. ie '\\$2'' \
-. nop \%\m[blue]\fC\\$1\fP\mP\\$3
+. nop \%\m[blue]\fC\\$1\fP\m[]\\$3
. el \
-. nop \m[blue]\\$2\mP \%\[la]\fC\\$1\fP\[ra]\\$3
+. nop \m[blue]\\$2\m[] \%\[la]\fC\\$1\fP\[ra]\\$3
. \}
..
.\"
@@ -506,7 +506,7 @@
' ti \w'\\[dcap]'u
. \}
. \}
-. nop \\mP\\$2
+. nop \\m[]\\$2
..
.\"
.\" now set up TS, TE, EQ, EN default macros