summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwlemb <wlemb>2001-10-27 17:09:53 +0000
committerwlemb <wlemb>2001-10-27 17:09:53 +0000
commit02ee3972626120a554836833c713be0f7204a9c4 (patch)
treeca56cb5d88cc63a6cf2df3412301c833ccea67b9
parentabb77de1a36f925cdb8e28e5c76465880d63fa19 (diff)
downloadgroff-02ee3972626120a554836833c713be0f7204a9c4.tar.gz
* src/roff/troff/input.cc (substring_macro): Fix computation of
boundary values.
-rw-r--r--ChangeLog5
-rw-r--r--src/roff/troff/input.cc18
2 files changed, 17 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 048a5ef9..f26c3114 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-10-27 Werner LEMBERG <wl@gnu.org>
+
+ * src/roff/troff/input.cc (substring_macro): Fix computation of
+ boundary values.
+
2001-10-20 Werner LEMBERG <wl@gnu.org>
Undo change from 2001-08-28.
diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc
index b557553c..09e05029 100644
--- a/src/roff/troff/input.cc
+++ b/src/roff/troff/input.cc
@@ -3959,13 +3959,13 @@ void substring_macro()
error("cannot substring request");
else {
if (start <= 0)
- start += m->length;
+ start += m->length - 1;
else
start--;
int end = 0;
if (!has_arg() || get_integer(&end)) {
if (end <= 0)
- end += m->length;
+ end += m->length - 1;
else
end--;
if (start > end) {
@@ -3973,16 +3973,22 @@ void substring_macro()
start = end;
end = tem;
}
- if (start >= m->length || start == end) {
+ if (start >= m->length || end < 0) {
m->length = 0;
if (m->p) {
if (--(m->p->count) <= 0)
delete m->p;
m->p = 0;
}
+ skip_line();
+ return;
}
- else if (start == 0)
- m->length = end;
+ if (start < 0)
+ start = 0;
+ if (end >= m->length)
+ end = m->length - 1;
+ if (start == 0)
+ m->length = end + 1;
else {
string_iterator iter(*m);
int i;
@@ -3990,7 +3996,7 @@ void substring_macro()
if (iter.get(0) == EOF)
break;
macro mac;
- for (; i < end; i++) {
+ for (; i <= end; i++) {
node *nd;
int c = iter.get(&nd);
if (c == EOF)