[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 24/31: [pic]: Recognize `.PY` as synonym of `.PF`.
From: |
G. Branden Robinson |
Subject: |
[groff] 24/31: [pic]: Recognize `.PY` as synonym of `.PF`. |
Date: |
Wed, 17 Aug 2022 01:26:06 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 1ac8764fa7f3b91e7d2a84261edbdc84c1ae4158
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Aug 14 23:52:40 2022 -0500
[pic]: Recognize `.PY` as synonym of `.PF`.
* src/preproc/pic/main.cpp:
* src/preproc/pic/pic.h: Add new Boolean variable,
`want_alternate_flyback` to record `.PY` usage.
* src/preproc/pic/main.cpp (top_input::get, top_input::peek): Recognize
it. Update diagnostic messages to mention it.
(main): Define `PY` troff macro as empty if not defined.
* src/preproc/pic/troff.cpp (troff_output::finish_picture): Don't
advance the vertical position if `want_alternate_flyback`. Write out
the `PY` macro call if it was on the input.
* src/preproc/pic/pic.1.man: Document it.
* tmac/pic.tmac (PY): Define the same as `PF`.
* NEWS: Add item.
Fixes <https://savannah.gnu.org/bugs/?62901>.
Also drop old-style Emacs file-local variable settings.
---
ChangeLog | 24 ++++++++++++++++++++++++
NEWS | 10 ++++++++++
src/preproc/pic/main.cpp | 15 ++++++++++-----
src/preproc/pic/pic.1.man | 47 ++++++++++++++++++++++++++++++++++-------------
src/preproc/pic/pic.h | 2 +-
src/preproc/pic/troff.cpp | 9 +++++++--
tmac/pic.tmac | 5 +++--
7 files changed, 89 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1ae835017..4bddb824d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2022-08-14 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [pic]: Recognize `.PY` as synonym of `.PF`.
+
+ * src/preproc/pic/main.cpp:
+ * src/preproc/pic/pic.h: Add new Boolean variable,
+ `want_alternate_flyback` to record `.PY` usage.
+
+ * src/preproc/pic/main.cpp (top_input::get, top_input::peek):
+ Recognize it. Update diagnostic messages to mention it.
+ (main): Define `PY` troff macro as empty if not defined.
+
+ * src/preproc/pic/troff.cpp (troff_output::finish_picture):
+ Don't advance the vertical position if `want_alternate_flyback`.
+ Write out the `PY` macro call if it was on the input.
+
+ * src/preproc/pic/pic.1.man: Document it.
+
+ * tmac/pic.tmac (PY): Define the same as `PF`.
+
+ * NEWS: Add item.
+
+ Fixes <https://savannah.gnu.org/bugs/?62901>.
+
2022-08-14 G. Branden Robinson <g.branden.robinson@gmail.com>
[pic]: Refactor `flyback_flag`.
diff --git a/NEWS b/NEWS
index ec8447044..1ddf66b6f 100644
--- a/NEWS
+++ b/NEWS
@@ -115,6 +115,16 @@ o The GNU extension
to use 'o' and 'n' as left and right delimiters, respectively. If
yours does, consider swapping them, or select others.
+pic
+---
+
+o The token `.PY` is now recognized as a synonym of `.PF` to work around
+ a name space collision with the m (mm) macro package, which uses the
+ same name for a page footer management macro. (This problem dates
+ back at least to Unix System V Release 2, 1983.) You should continue
+ to use `.PF` to end pictures with flyback unless a similar problem
+ faces your document.
+
Macro packages
--------------
diff --git a/src/preproc/pic/main.cpp b/src/preproc/pic/main.cpp
index 233e4c177..114ca2158 100644
--- a/src/preproc/pic/main.cpp
+++ b/src/preproc/pic/main.cpp
@@ -25,6 +25,8 @@ output *out;
char *graphname; // the picture box name in TeX mode
bool want_flyback = false;
+// groff pic supports '.PY' to work around mm package stepping on 'PF'.
+bool want_alternate_flyback = false;
int zero_length_line_flag = 0;
// Non-zero means we're using a groff driver.
int driver_extension_flag = 1;
@@ -88,13 +90,14 @@ int top_input::get()
c = getc(fp);
if (c == 'P') {
c = getc(fp);
- if (c == 'F' || c == 'E') {
+ if (c == 'E' || c == 'F' || c == 'Y') {
int d = getc(fp);
if (d != EOF)
ungetc(d, fp);
if (d == EOF || d == ' ' || d == '\n' || compatible_flag) {
eof = 1;
want_flyback = (c == 'F');
+ want_alternate_flyback = (c == 'Y');
return EOF;
}
push_back[0] = c;
@@ -133,7 +136,7 @@ int top_input::get()
bol = 0;
if (c == EOF) {
eof = 1;
- error("end of file before .PE or .PF");
+ error("end of file before .PE, .PF, or .PY");
error_with_file_and_line(current_filename, start_lineno - 1,
".PS was here");
}
@@ -160,13 +163,14 @@ int top_input::peek()
c = getc(fp);
if (c == 'P') {
c = getc(fp);
- if (c == 'F' || c == 'E') {
+ if (c == 'E' || c == 'F' || c == 'Y') {
int d = getc(fp);
if (d != EOF)
ungetc(d, fp);
if (d == EOF || d == ' ' || d == '\n' || compatible_flag) {
eof = 1;
want_flyback = (c == 'F');
+ want_alternate_flyback = (c == 'Y');
return EOF;
}
push_back[0] = c;
@@ -287,7 +291,7 @@ void do_picture(FILE *fp)
parse_cleanup();
lex_cleanup();
- // skip the rest of the .PF/.PE line
+ // skip the rest of the .PE/.PF/.PY line
while ((c = getc(fp)) != EOF && c != '\n')
;
if (c == '\n')
@@ -622,7 +626,8 @@ int main(int argc, char **argv)
out = make_troff_output();
printf(".do if !dPS .ds PS\n"
".do if !dPE .ds PE\n"
- ".do if !dPF .ds PF\n");
+ ".do if !dPF .ds PF\n"
+ ".do if !dPY .ds PY\n");
}
#ifdef FIG_SUPPORT
if (whole_file_flag) {
diff --git a/src/preproc/pic/pic.1.man b/src/preproc/pic/pic.1.man
index 7c4a4eca5..6dc803e4b 100644
--- a/src/preproc/pic/pic.1.man
+++ b/src/preproc/pic/pic.1.man
@@ -101,10 +101,11 @@ It copies the contents of each
to the standard output stream,
except that lines between
.B .PS
-and either
-.B .PE
+and any of
+.BR .PE ,
+.BR .PF ,
or
-.B .PF
+.B .PY
are interpreted as picture descriptions.
.
Ending a
@@ -114,6 +115,8 @@ picture with
leaves the page position at the bottom of the picture;
ending it with
.B .PF
+or
+.B .PY
leaves the position at the top.
.
Normally,
@@ -134,24 +137,40 @@ is
the standard input stream is read.
.
.
-.LP
+.P
It is the user's responsibility to provide appropriate definitions
of the
.BR PS ,
.BR PE ,
-and
+and one or both of the
.B PF
+and
+.B PY
macros.
.
-When the macro package being used does not supply such definitions
-(for example,
-old versions of \-ms),
-appropriate definitions can be
-obtained with
+When a macro package does not supply these,
+appropriate definitions can be obtained with
.BR \-mpic ;
these will center each picture.
.
.
+.P
+GNU
+.I pic \" GNU
+supports
+.B PY
+as a synonym of
+.B PF
+to work around a name space collision with the
+.I mm
+macro package,
+which uses the same name for a page footer management macro.
+.
+Use
+.B PF
+preferentially unless a similar problem faces your document.
+.
+.
.\" ====================================================================
.SH Options
.\" ====================================================================
@@ -207,8 +226,9 @@ variable.
Recognize
.BR .PS ,
.BR .PE ,
+.BR .PF ,
and
-.B .PF
+.B .PY
even when followed by a character other than space or newline.
.
.
@@ -1443,11 +1463,12 @@ package.
.
.TP
.I @MACRODIR@/pic.tmac
-Example definitions of the
+offers simple definitions of the
.BR PS ,
.BR PE ,
+.BR PF ,
and
-.B PF
+.B PY
macros.
.
.
diff --git a/src/preproc/pic/pic.h b/src/preproc/pic/pic.h
index d052c1a89..8baca154e 100644
--- a/src/preproc/pic/pic.h
+++ b/src/preproc/pic/pic.h
@@ -1,4 +1,3 @@
-// -*- C++ -*-
/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -112,6 +111,7 @@ void lex_warning(const char *message,
void lex_cleanup();
extern bool want_flyback;
+extern bool want_alternate_flyback;
extern int command_char;
// zero_length_line_flag is non-zero if zero-length lines are drawn
// as dots by the output device
diff --git a/src/preproc/pic/troff.cpp b/src/preproc/pic/troff.cpp
index ad8998446..3dc87a721 100644
--- a/src/preproc/pic/troff.cpp
+++ b/src/preproc/pic/troff.cpp
@@ -298,14 +298,19 @@ void troff_output::finish_picture()
line_thickness(BAD_THICKNESS);
last_fill = -1.0; // force it to be reset for each picture
reset_color();
- if (!want_flyback)
+ if (!(want_flyback || want_alternate_flyback))
printf(".sp %.3fi+1\n", height);
printf(".if \\n(" FILL_REG " .fi\n");
printf(".br\n");
printf(".nr " EQN_NO_EXTRA_SPACE_REG " 0\n");
// this is a little gross
set_location(current_filename, current_lineno);
- fputs(want_flyback ? ".PF\n" : ".PE\n", stdout);
+ if (want_flyback)
+ fputs(".PF\n", stdout);
+ else if (want_alternate_flyback)
+ fputs(".PY\n", stdout);
+ else
+ fputs(".PE\n", stdout);
}
void troff_output::command(const char *s,
diff --git a/tmac/pic.tmac b/tmac/pic.tmac
index 6bbe874a6..d4aaaa479 100644
--- a/tmac/pic.tmac
+++ b/tmac/pic.tmac
@@ -1,5 +1,3 @@
-.\" -*- nroff -*-
-.\"
.\" pic.tmac
.\"
.de PS
@@ -15,6 +13,9 @@
.PF
.sp .3v+.5m
..
+.de PY
+.in
+..
.
.\" Local Variables:
.\" mode: nroff
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 24/31: [pic]: Recognize `.PY` as synonym of `.PF`.,
G. Branden Robinson <=