diff options
author | wlemb <wlemb> | 2004-07-19 20:04:20 +0000 |
---|---|---|
committer | wlemb <wlemb> | 2004-07-19 20:04:20 +0000 |
commit | 505d4e20ebc03786fad32ef7183a3bcc8f111974 (patch) | |
tree | 417a12e1f2b76c4555d4b376bd195b0dd3014938 /src/preproc/pic | |
parent | bd7baaa6bc3d65b0aa3a45336dea4afe18ad5637 (diff) | |
download | groff-505d4e20ebc03786fad32ef7183a3bcc8f111974.tar.gz |
* src/preproc/pic/lex.cpp (for_input): Add member `from'.
Update constructor.
(do_for, for_input::get, for_input::peek): Handle negative `by'.
* src/preproc/pic/pic.man, doc/pic.ms, NEWS: Document it.
Diffstat (limited to 'src/preproc/pic')
-rw-r--r-- | src/preproc/pic/lex.cpp | 26 | ||||
-rw-r--r-- | src/preproc/pic/pic.man | 10 |
2 files changed, 27 insertions, 9 deletions
diff --git a/src/preproc/pic/lex.cpp b/src/preproc/pic/lex.cpp index b8aa9ebc..3373052a 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, 2003 +/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) @@ -1329,21 +1329,23 @@ void do_undef() 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, int, double, char *); + for_input(char *, double, double, int, double, char *); ~for_input(); int get(); int peek(); }; -for_input::for_input(char *vr, double t, int bim, double b, char *bd) -: var(vr), body(bd), to(t), by_is_multiplicative(bim), by(b), p(body), - done_newline(0) +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) { } @@ -1374,7 +1376,8 @@ int for_input::get() else val += by; define_variable(var, val); - if (val > to) { + if ((from <= to && val > to) + || (from >= to && val < to)) { p = 0; return EOF; } @@ -1399,7 +1402,8 @@ int for_input::peek() return EOF; } else { - if (val + by > to) + if ((from <= to && val + by > to) + || (from >= to && val + by < to)) return EOF; } if (*body == '\0') @@ -1411,8 +1415,12 @@ void do_for(char *var, double from, double to, int by_is_multiplicative, double by, char *body) { define_variable(var, from); - if (from <= to) - input_stack::push(new for_input(var, to, by_is_multiplicative, by, body)); + 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)); } diff --git a/src/preproc/pic/pic.man b/src/preproc/pic/pic.man index 6a20c199..c54cfbef 100644 --- a/src/preproc/pic/pic.man +++ b/src/preproc/pic/pic.man @@ -322,6 +322,16 @@ 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 . |