diff options
author | wlemb <wlemb> | 2003-10-27 08:10:56 +0000 |
---|---|---|
committer | wlemb <wlemb> | 2003-10-27 08:10:56 +0000 |
commit | 1b6b1ae675b4df397807631699464f3fa77a9727 (patch) | |
tree | de6b1f45eac38e007f6e064a65e99fc704850fe0 | |
parent | 0d9c97fbaff9fbf2ea216951b9608ad5e8859c18 (diff) | |
download | groff-1b6b1ae675b4df397807631699464f3fa77a9727.tar.gz |
* src/preproc/pic/troff.cpp (troff_output::simple_circle,
troff_output::simple_ellipse, troff_output::simple_arc,
troff_output::simple_line, troff_output::simple_spline,
troff_output::simple_polygon): Insert a space before arguments.
(troff_output::set_fill): Emit `\&' before `\D'Fg...' since the
latter doesn't produce a node, so the following `.sp -1' would do
the wrong thing.
Don't emit `.sp -1' after \M. This also doesn't produce a token
(and we don't have to care about compatibility mode).
(troff_output::set_color, troff_output::reset_color): Don't emit
`.sp -1' after \M and \m.
* src/roff/troff/input.cpp (old_have_input): New global variable.
(input_stack::get): Handle `old_have_input'.
(process_input_stack) <token::TOKEN_NEWLINE>: Call
`trapping_blank_line' depending on `old_have_input', not
`have_input'.
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | src/preproc/pic/troff.cpp | 28 | ||||
-rw-r--r-- | src/roff/troff/input.cpp | 7 |
3 files changed, 41 insertions, 14 deletions
@@ -1,3 +1,23 @@ +2003-10-26 Werner LEMBERG <wl@gnu.org> + + * src/preproc/pic/troff.cpp (troff_output::simple_circle, + troff_output::simple_ellipse, troff_output::simple_arc, + troff_output::simple_line, troff_output::simple_spline, + troff_output::simple_polygon): Insert a space before arguments. + (troff_output::set_fill): Emit `\&' before `\D'Fg...' since the + latter doesn't produce a node, so the following `.sp -1' would do + the wrong thing. + Don't emit `.sp -1' after \M. This also doesn't produce a token + (and we don't have to care about compatibility mode). + (troff_output::set_color, troff_output::reset_color): Don't emit + `.sp -1' after \M and \m. + + * src/roff/troff/input.cpp (old_have_input): New global variable. + (input_stack::get): Handle `old_have_input'. + (process_input_stack) <token::TOKEN_NEWLINE>: Call + `trapping_blank_line' depending on `old_have_input', not + `have_input'. + 2003-10-20 Keith Marshall <keith.d.marshall@ntlworld.com> * src/libs/libgroff/tmpfile.cpp [__MSDOS__, _Win32] diff --git a/src/preproc/pic/troff.cpp b/src/preproc/pic/troff.cpp index ddda45db..22bf897d 100644 --- a/src/preproc/pic/troff.cpp +++ b/src/preproc/pic/troff.cpp @@ -324,7 +324,7 @@ void troff_output::simple_circle(int filled, const position ¢, double rad) position c = transform(cent); printf("\\h'%.3fi'" "\\v'%.3fi'" - "\\D'%c%.3fi'" + "\\D'%c %.3fi'" "\n.sp -1\n", c.x - rad/scale, c.y, @@ -338,7 +338,7 @@ void troff_output::simple_ellipse(int filled, const position ¢, position c = transform(cent); printf("\\h'%.3fi'" "\\v'%.3fi'" - "\\D'%c%.3fi %.3fi'" + "\\D'%c %.3fi %.3fi'" "\n.sp -1\n", c.x - dim.x/(2.0*scale), c.y, @@ -355,7 +355,7 @@ void troff_output::simple_arc(const position &start, const distance ¢, distance ev = transform(end) - c; printf("\\h'%.3fi'" "\\v'%.3fi'" - "\\D'a%.3fi %.3fi %.3fi %.3fi'" + "\\D'a %.3fi %.3fi %.3fi %.3fi'" "\n.sp -1\n", s.x, s.y, cv.x, cv.y, ev.x, ev.y); } @@ -366,7 +366,7 @@ void troff_output::simple_line(const position &start, const position &end) distance ev = transform(end) - s; printf("\\h'%.3fi'" "\\v'%.3fi'" - "\\D'l%.3fi %.3fi'" + "\\D'l %.3fi %.3fi'" "\n.sp -1\n", s.x, s.y, ev.x, ev.y); } @@ -378,7 +378,7 @@ void troff_output::simple_spline(const position &start, printf("\\h'%.3fi'" "\\v'%.3fi'", pos.x, pos.y); - fputs("\\D'~", stdout); + fputs("\\D'~ ", stdout); for (int i = 0; i < n; i++) { position temp = transform(v[i]); distance d = temp - pos; @@ -398,7 +398,7 @@ void troff_output::simple_polygon(int filled, const position *v, int n) printf("\\h'%.3fi'" "\\v'%.3fi'", pos.x, pos.y); - printf("\\D'%c", (filled ? 'P' : 'p')); + printf("\\D'%c ", (filled ? 'P' : 'p')); for (int i = 1; i < n; i++) { position temp = transform(v[i]); distance d = temp - pos; @@ -480,13 +480,15 @@ void troff_output::line_thickness(double p) void troff_output::set_fill(double f) { if (driver_extension_flag && f != last_fill) { - printf("\\D'Fg %.3f'\n.sp -1\n", 1.0 - f); + // \D'Fg ...' emits a node only in compatibility mode, + // thus we add a dummy node + printf("\\&\\D'Fg %.3f'\n.sp -1\n", 1.0 - f); last_fill = f; } if (last_filled) { free(last_filled); last_filled = 0; - printf("\\M[]\n.sp -1\n"); + printf("\\M[]\n"); } } @@ -496,12 +498,14 @@ void troff_output::set_color(char *color_fill, char *color_outlined) if (last_filled || last_outlined) { reset_color(); } + // \m and \M emit a node in compatibility mode only, + // but that won't work anyway if (color_fill) { - printf("\\M[%s]\n.sp -1\n", color_fill); + printf("\\M[%s]\n", color_fill); last_filled = strsave(color_fill); } if (color_outlined) { - printf("\\m[%s]\n.sp -1\n", color_outlined); + printf("\\m[%s]\n", color_outlined); last_outlined = strsave(color_outlined); } } @@ -511,12 +515,12 @@ void troff_output::reset_color() { if (driver_extension_flag) { if (last_filled) { - printf("\\M[]\n.sp -1\n"); + printf("\\M[]\n"); a_delete last_filled; last_filled = 0; } if (last_outlined) { - printf("\\m[]\n.sp -1\n"); + printf("\\m[]\n"); a_delete last_outlined; last_outlined = 0; } diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp index 26d11687..50039a18 100644 --- a/src/roff/troff/input.cpp +++ b/src/roff/troff/input.cpp @@ -110,6 +110,7 @@ int begin_level = 0; // number of nested .begin requests int have_input = 0; // whether \f, \F, \D'F...', \H, \m, \M, // \R, \s, or \S has been processed in // token::next() +int old_have_input = 0; // value of have_input right before \n int tcommand_flag = 0; int safer_flag = 1; // safer by default @@ -442,8 +443,10 @@ inline int input_stack::get_level() inline int input_stack::get(node **np) { int res = (top->ptr < top->eptr) ? *top->ptr++ : finish_get(np); - if (res == '\n') + if (res == '\n') { + old_have_input = have_input; have_input = 0; + } return res; } @@ -2642,7 +2645,7 @@ void process_input_stack() } case token::TOKEN_NEWLINE: { - if (bol && !have_input + if (bol && !old_have_input && !curenv->get_prev_line_interrupted()) trapping_blank_line(); else { |