bug-groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #59795] [PATCH] troff/env.cpp: fix wrong restoration of link adjust


From: Bjarni Ingi Gislason
Subject: [bug #59795] [PATCH] troff/env.cpp: fix wrong restoration of link adjustment after '.na' and '.ad'
Date: Fri, 1 Jan 2021 08:10:35 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

URL:
  <https://savannah.gnu.org/bugs/?59795>

                 Summary: [PATCH] troff/env.cpp: fix wrong restoration of link
adjustment after  '.na' and '.ad'
                 Project: GNU troff
            Submitted by: bjarniig
            Submitted on: Fri 01 Jan 2021 01:10:33 PM UTC
                Category: Core
                Severity: 3 - Normal
              Item Group: Incorrect behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None

    _______________________________________________________

Details:

src/roff/troff/env.cpp: fix wrong restoration of link adjustment after
'.na' and '.ad'

a) Example:

.ad l
\n(.j
.na
\n(.j
.ad
\n(.j

  Result:

0 0 1

  instead of

0 0 0

  The '.na' request does

1) .j = 0 no change

2) .j > 0 changes the value to the next lower even number

  The 'ad' request does (without an argument)

1) .j = 0 changes the value to the next higher uneven number

2) .j > 0 same change as for .j = 0

  This works correctly when the current value for .j > 0,
but not for .j = 0, as it must be unchanged (links) and
not "both" (.j = 1).

b) Use a name for the maximal defined value of '.j'.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 src/roff/troff/env.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index bade3927..bd90244f 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -35,7 +35,8 @@ along with this program.  If not, see
<http://www.gnu.org/licenses/>. */
 
 symbol default_family("T");
 
-enum { ADJUST_LEFT = 0, ADJUST_BOTH = 1, ADJUST_CENTER = 3, ADJUST_RIGHT = 5
};
+enum { ADJUST_LEFT = 0, ADJUST_BOTH = 3, ADJUST_CENTER = 5,
+  ADJUST_RIGHT = 7, ADJUST_MAX = 7 };
 
 enum {
   // Not all combinations are valid; see hyphenate_request() below.
@@ -2503,7 +2504,8 @@ void title()
 
 void adjust()
 {
-  curenv->adjust_mode |= 1;
+  if ( curenv->adjust_mode != 0 )
+    curenv->adjust_mode |= 1;
   if (has_arg()) {
     switch (tok.ch()) {
     case 'l':
@@ -2524,8 +2526,8 @@ void adjust()
       if (get_integer(&n)) {
        if (n < 0)
          warning(WARN_RANGE, "negative adjustment mode");
-       else if (n > 5) {
-         curenv->adjust_mode = 5;
+       else if (n > ADJUST_MAX) {
+         curenv->adjust_mode = ADJUST_MAX;
          warning(WARN_RANGE, "adjustment mode '%1' out of range", n);
        }
        else
-- 
2.29.2






    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59795>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]