source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: reduce indentation for better readability
Date: Tue, 3 Feb 2015 13:38:29 -0500 (EST)	[thread overview]
Message-ID: <9552467719374830602.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
reduce indentation for better readability

Modified Files:
--------------
    mdocml:
        tree.c

Revision Data
-------------
Index: tree.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tree.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -Ltree.c -Ltree.c -u -p -r1.60 -r1.61
--- tree.c
+++ tree.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -40,14 +40,14 @@ void
 tree_mdoc(void *arg, const struct mdoc *mdoc)
 {
 
-	print_mdoc(mdoc_node(mdoc), 0);
+	print_mdoc(mdoc_node(mdoc)->child, 0);
 }
 
 void
 tree_man(void *arg, const struct man *man)
 {
 
-	print_man(man_node(man), 0);
+	print_man(man_node(man)->child, 0);
 }
 
 static void
@@ -58,6 +58,9 @@ print_mdoc(const struct mdoc_node *n, in
 	size_t		  argc;
 	struct mdoc_argv *argv;
 
+	if (n == NULL)
+		return;
+
 	argv = NULL;
 	argc = 0;
 	t = p = NULL;
@@ -142,7 +145,7 @@ print_mdoc(const struct mdoc_node *n, in
 		print_span(n->span, indent);
 	} else {
 		for (i = 0; i < indent; i++)
-			putchar('\t');
+			putchar(' ');
 
 		printf("%s (%s)", p, t);
 
@@ -166,9 +169,10 @@ print_mdoc(const struct mdoc_node *n, in
 	}
 
 	if (n->eqn)
-		print_box(n->eqn->root->first, indent + 1);
+		print_box(n->eqn->root->first, indent + 4);
 	if (n->child)
-		print_mdoc(n->child, indent + 1);
+		print_mdoc(n->child, indent +
+		    (n->type == MDOC_BLOCK ? 2 : 4));
 	if (n->next)
 		print_mdoc(n->next, indent);
 }
@@ -179,6 +183,9 @@ print_man(const struct man_node *n, int 
 	const char	 *p, *t;
 	int		  i;
 
+	if (n == NULL)
+		return;
+
 	t = p = NULL;
 
 	switch (n->type) {
@@ -241,7 +248,7 @@ print_man(const struct man_node *n, int 
 		print_span(n->span, indent);
 	} else {
 		for (i = 0; i < indent; i++)
-			putchar('\t');
+			putchar(' ');
 		printf("%s (%s) ", p, t);
 		if (MAN_LINE & n->flags)
 			putchar('*');
@@ -249,9 +256,10 @@ print_man(const struct man_node *n, int 
 	}
 
 	if (n->eqn)
-		print_box(n->eqn->root->first, indent + 1);
+		print_box(n->eqn->root->first, indent + 4);
 	if (n->child)
-		print_man(n->child, indent + 1);
+		print_man(n->child, indent +
+		    (n->type == MAN_BLOCK ? 2 : 4));
 	if (n->next)
 		print_man(n->next, indent);
 }
@@ -270,7 +278,7 @@ print_box(const struct eqn_box *ep, int 
 	if (NULL == ep)
 		return;
 	for (i = 0; i < indent; i++)
-		putchar('\t');
+		putchar(' ');
 
 	t = NULL;
 	switch (ep->type) {
@@ -318,7 +326,7 @@ print_box(const struct eqn_box *ep, int 
 		printf(" args=%zu", ep->args);
 	putchar('\n');
 
-	print_box(ep->first, indent + 1);
+	print_box(ep->first, indent + 4);
 	print_box(ep->next, indent);
 }
 
@@ -329,7 +337,7 @@ print_span(const struct tbl_span *sp, in
 	int		 i;
 
 	for (i = 0; i < indent; i++)
-		putchar('\t');
+		putchar(' ');
 
 	switch (sp->pos) {
 	case TBL_SPAN_HORIZ:
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2015-02-03 18:38 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=9552467719374830602.enqueue@fantadrom.bsd.lv \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.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).