source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Finally expand and delete the macro SCALE_VS_INIT().
Date: Sun, 11 Sep 2022 04:14:18 -0500 (EST)	[thread overview]
Message-ID: <336b328aacb992ae@mandoc.bsd.lv> (raw)

Log Message:
-----------
Finally expand and delete the macro SCALE_VS_INIT().
It's nothing but obfuscation and only used at three places in a single file.
Removing it also makes the code three lines shorter.
The ugliness was already pointed out six years ago by mmcc@.

Modified Files:
--------------
    mandoc:
        out.h
        mdoc_term.c

Revision Data
-------------
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_term.c,v
retrieving revision 1.381
retrieving revision 1.382
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.381 -r1.382
--- mdoc_term.c
+++ mdoc_term.c
@@ -569,8 +569,8 @@ a2width(const struct termp *p, const cha
 
 	end = a2roffsu(v, &su, SCALE_MAX);
 	if (end == NULL || *end != '\0') {
-		SCALE_HS_INIT(&su, term_strlen(p, v));
-		su.scale /= term_strlen(p, "0");
+		su.unit = SCALE_EN;
+		su.scale = term_strlen(p, v) / term_strlen(p, "0");
 	}
 	return term_hen(p, &su);
 }
@@ -706,9 +706,9 @@ termp_it_pre(DECL_ARGS)
 		for (i = 0, nn = n->prev;
 		    nn->prev && i < (int)ncols;
 		    nn = nn->prev, i++) {
-			SCALE_HS_INIT(&su,
-			    term_strlen(p, bl->norm->Bl.cols[i]));
-			su.scale /= term_strlen(p, "0");
+			su.unit = SCALE_EN;
+			su.scale = term_strlen(p, bl->norm->Bl.cols[i]) /
+			    term_strlen(p, "0");
 			offset += term_hen(p, &su) + dcol;
 		}
 
@@ -725,8 +725,9 @@ termp_it_pre(DECL_ARGS)
 		 * Use the declared column widths, extended as explained
 		 * in the preceding paragraph.
 		 */
-		SCALE_HS_INIT(&su, term_strlen(p, bl->norm->Bl.cols[i]));
-		su.scale /= term_strlen(p, "0");
+		su.unit = SCALE_EN;
+		su.scale = term_strlen(p, bl->norm->Bl.cols[i]) /
+		    term_strlen(p, "0");
 		width = term_hen(p, &su) + dcol;
 		break;
 	default:
Index: out.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/out.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -Lout.h -Lout.h -u -p -r1.34 -r1.35
--- out.h
+++ out.h
@@ -57,11 +57,6 @@ struct	rofftbl {
 	void		*arg; /* passed to sulen, slen, and len */
 };
 
-#define	SCALE_HS_INIT(p, v) \
-	do { (p)->unit = SCALE_EN; \
-	     (p)->scale = (v); } \
-	while (/* CONSTCOND */ 0)
-
 
 struct	tbl_span;
 
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


                 reply	other threads:[~2022-09-11  9:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=336b328aacb992ae@mandoc.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).