From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 16344 invoked from network); 3 Apr 2022 20:15:27 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 3 Apr 2022 20:15:27 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 12286c77 for ; Sun, 3 Apr 2022 15:15:22 -0500 (EST) Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 56672581 for ; Sun, 3 Apr 2022 15:15:20 -0500 (EST) Received: by mail-pg1-f179.google.com with SMTP id q19so6677843pgm.6 for ; Sun, 03 Apr 2022 13:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=uUPXkiUZadq+fUrJw6BzLvtOH8tCzxQZ/PMrB0RSwW8=; b=TirghxO4GbCxNTlvyFQqwVHLhU4acNkSx4123zdt4Cdr1mf91h2xmJN/Iv3JM3r09Q Q2MIa/opf4SnunEOv5vMEqVBnqGn707C4X92u/UTujbk+KIW9y/Q4yi0lPA3gMMgZGSU gXP3TRU+YiJ4P5xGoi5KgEvPNlqX6XMUkTllYkoQHY3GUqO7+sg/zHCOITkoRu6VguXY 5XMAineET5RawR8dYldxum+b76UlRzCC7rd3WVUV7ZWcpkEtHG17WVHeb42yb3xcp+VH ju5AbcwND8L+1pDT8sqLlaILI47XIGhU0Ru8QF4oTyuT9091jrrQfydHlWJlHNxiySf6 CigQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=uUPXkiUZadq+fUrJw6BzLvtOH8tCzxQZ/PMrB0RSwW8=; b=qIOkx3cJiF4uucTbVU1dtKFLzHTj6/qDNlNCRd3eZUVmfUfSpunQZdOhdgETbPv1GW 0Dn/BpikTa89LdRLCFp5SB56uys5z9oRI9uoqyZW1WlZXwbIsQXAyZzDeFtWcngrw0Gz arRQX3M1q2luK+Jel3vpUbXLNbSI/qbQK0popDqQJbYgZ/wmS4rBfNTgFxKdGc4ECWjQ aLybQg3vEkgWzkL/x5137tUC8+fuFrxOklpOe/kC2RmpO/hkrY9e+XMPxkeq9AfcsPi4 dTdfLH9k5LF/l1DwIYhiYq18Fd0ED1RxYheLz5XTeItzheR7Um1Xx/LDx0S2o8QqQG3A WLxA== X-Gm-Message-State: AOAM530kluwFq3S5TOsPzp0/7Di3p6IISkEVWsgwTNF8yIvdbme9NRq6 5Uom24Po9+IZy4HrSw92lM4uYdzqo3w= X-Google-Smtp-Source: ABdhPJx6MV5LvABvkIw1P5sMSYrPXLpxuewnpI5+2BT9aw8R7jO1VO4zHXevMVPuZVGlM04f9mhw2A== X-Received: by 2002:a05:6a00:114b:b0:4f7:915:3ec3 with SMTP id b11-20020a056a00114b00b004f709153ec3mr55128118pfm.8.1649016919365; Sun, 03 Apr 2022 13:15:19 -0700 (PDT) Received: from pine.sigxcpu.com ([2601:601:9d00:8f80:11d4:c75:f090:78b9]) by smtp.gmail.com with ESMTPSA id c21-20020a637255000000b003822e80f132sm8068487pgn.12.2022.04.03.13.15.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 13:15:19 -0700 (PDT) Date: Sun, 3 Apr 2022 13:14:27 -0700 From: Simon Branch To: discuss@mandoc.bsd.lv Subject: tbl: incorrect width calculation in cs[s..] Message-ID: <20220403201427.bugtqtlzdcygb45l@pine.sigxcpu.com> X-Mailinglist: mandoc-discuss Reply-To: discuss@mandoc.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello! mandoc has some slightly odd behavior when formatting a table like this, where the author wants a centered title: .TS tab(#); csss l1 l3 l1 l. heading 00#NUL#01#SOH .TE Groff outputs this: heading 00 NUL 01 SOH mandoc outputs this: heading 00 NUL 01 SOH There are three problems here: - The space after the first column isn't counted. - The imaginary spaces after the last column are counted, even though they aren't output. - Mandoc assumes that each column has three trailing spaces. In other words, the control flow works like this: - Start with the first column's width. - If there are any continuation columns, add their widths and trailing spaces. But I think it should work like this: - Start with the first column's width. - If there are any continuation columns, add the widths of the rest of the columns, and all the trailing spaces *except* for the ones after the last column. This might still be incorrect (?) if there are more columns after "cs...", but I think a partial fix is better than no fix at all. Index: tbl_term.c =================================================================== RCS file: /cvs/mandoc/tbl_term.c,v retrieving revision 1.75 diff -u -r1.75 tbl_term.c --- tbl_term.c 10 Aug 2021 12:55:04 -0000 1.75 +++ tbl_term.c 3 Apr 2022 04:39:18 -0000 @@ -820,8 +820,11 @@ width = col->width; ic = dp->layout->col; hspans = dp->hspans; - while (hspans--) - width += tp->tbl.cols[++ic].width + 3; + while (hspans--) { + width += tp->tbl.cols[ic].spacing; + ic++; + width += tp->tbl.cols[ic].width; + } padr = width > len ? width - len : 0; padl = 0; -- To unsubscribe send an email to discuss+unsubscribe@mandoc.bsd.lv