aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2019-01-05 00:36:50 +0000
committerIngo Schwarze <schwarze@openbsd.org>2019-01-05 00:36:50 +0000
commit3aebc3c30c9b70518679c6e3c9610ac4ffc32b61 (patch)
treea40abeffa2939b4f032a27582c271b995112d39b
parent974a808d4eb167475c20c49e55a273647ce3e23a (diff)
downloadmandoc-3aebc3c30c9b70518679c6e3c9610ac4ffc32b61.tar.gz
mandoc-3aebc3c30c9b70518679c6e3c9610ac4ffc32b61.tar.zst
mandoc-3aebc3c30c9b70518679c6e3c9610ac4ffc32b61.zip
Some high-level block macros have an effect similar to temporarily
suspending no-fill mode during their head. Model this with an additional roff parser state flag ROFF_NONOFILL. That is much simpler than it would be to save and restore the ROFF_NOFILL flag itself, in particular since the latter can be switched (with lasting effect) by the .nf and .fi requests even while its effect is temporarily suspended. This commit does not change formatting yet, but prepares for future formatting simplifications and improvements.
-rw-r--r--man.c12
-rw-r--r--man_macro.c6
-rw-r--r--man_term.c9
-rw-r--r--roff.c6
-rw-r--r--roff_int.h5
5 files changed, 22 insertions, 16 deletions
diff --git a/man.c b/man.c
index 6bdb4d91..f0e4002b 100644
--- a/man.c
+++ b/man.c
@@ -1,7 +1,7 @@
-/* $Id: man.c,v 1.186 2018/12/31 10:04:39 schwarze Exp $ */
+/* $Id: man.c,v 1.187 2019/01/05 00:36:50 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2011 Joerg Sonnenberger <joerg@netbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -92,9 +92,9 @@ man_descope(struct roff_man *man, int line, int offs, char *start)
}
if ( ! (man->flags & MAN_BLINE))
return;
- man->flags &= ~MAN_BLINE;
man_unscope(man, man->last->parent);
roff_body_alloc(man, line, offs, man->last->tok);
+ man->flags &= ~(MAN_BLINE | ROFF_NONOFILL);
}
static int
@@ -268,9 +268,9 @@ man_pmacro(struct roff_man *man, int ln, char *buf, int offs)
man_macro(tok)->flags & MAN_NSCOPED)
return 1;
- man->flags &= ~MAN_BLINE;
man_unscope(man, man->last->parent);
roff_body_alloc(man, ln, ppos, man->last->tok);
+ man->flags &= ~(MAN_BLINE | ROFF_NONOFILL);
return 1;
}
@@ -313,7 +313,7 @@ man_breakscope(struct roff_man *man, int tok)
n = man->last;
man_unscope(man, n);
roff_body_alloc(man, n->line, n->pos, n->tok);
- man->flags &= ~MAN_BLINE;
+ man->flags &= ~(MAN_BLINE | ROFF_NONOFILL);
}
/*
@@ -340,6 +340,6 @@ man_breakscope(struct roff_man *man, int tok)
"%s breaks %s", roff_name[tok], roff_name[n->tok]);
roff_node_delete(man, n);
- man->flags &= ~MAN_BLINE;
+ man->flags &= ~(MAN_BLINE | ROFF_NONOFILL);
}
}
diff --git a/man_macro.c b/man_macro.c
index c438cfe5..eec4896c 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,7 +1,7 @@
-/* $Id: man_macro.c,v 1.142 2018/12/31 10:04:39 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.143 2019/01/05 00:36:50 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2012-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2012-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -338,6 +338,7 @@ blk_imp(MACRO_PROT_ARGS)
struct roff_node *n;
rew_scope(man, tok);
+ man->flags |= ROFF_NONOFILL;
if (tok == MAN_SH || tok == MAN_SS)
man->flags &= ~ROFF_NOFILL;
roff_block_alloc(man, line, ppos, tok);
@@ -369,6 +370,7 @@ blk_imp(MACRO_PROT_ARGS)
man_unscope(man, n);
roff_body_alloc(man, line, ppos, tok);
+ man->flags &= ~ROFF_NONOFILL;
}
void
diff --git a/man_term.c b/man_term.c
index c463d56f..8978398c 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,7 +1,7 @@
-/* $Id: man_term.c,v 1.225 2018/12/31 11:01:37 schwarze Exp $ */
+/* $Id: man_term.c,v 1.226 2019/01/05 00:36:50 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2015, 2017-2019 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
@@ -419,7 +419,10 @@ pre_HP(DECL_ARGS)
return 0;
}
- if ((n->flags & NODE_NOFILL) == 0) {
+ if (n->child == NULL)
+ return 0;
+
+ if ((n->child->flags & NODE_NOFILL) == 0) {
p->flags |= TERMP_NOBREAK | TERMP_BRIND;
p->trailspace = 2;
}
diff --git a/roff.c b/roff.c
index 076f55ec..decf1b65 100644
--- a/roff.c
+++ b/roff.c
@@ -1,7 +1,7 @@
-/* $Id: roff.c,v 1.359 2018/12/31 08:18:12 schwarze Exp $ */
+/* $Id: roff.c,v 1.360 2019/01/05 00:36:50 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2015, 2017-2019 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
@@ -889,7 +889,7 @@ roff_node_alloc(struct roff_man *man, int line, int pos,
n->flags |= NODE_SYNPRETTY;
else
n->flags &= ~NODE_SYNPRETTY;
- if (man->flags & ROFF_NOFILL)
+ if ((man->flags & (ROFF_NOFILL | ROFF_NONOFILL)) == ROFF_NOFILL)
n->flags |= NODE_NOFILL;
else
n->flags &= ~NODE_NOFILL;
diff --git a/roff_int.h b/roff_int.h
index e13b53e6..d033f86a 100644
--- a/roff_int.h
+++ b/roff_int.h
@@ -1,7 +1,7 @@
-/* $Id: roff_int.h,v 1.15 2018/12/31 07:46:07 schwarze Exp $ */
+/* $Id: roff_int.h,v 1.16 2019/01/05 00:36:50 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013-2015, 2017-2019 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
@@ -54,6 +54,7 @@ struct roff_man {
#define MDOC_PHRASEQF (1 << 13) /* Quote first word encountered. */
#define MDOC_PHRASEQL (1 << 14) /* Quote last word of this phrase. */
#define MDOC_PHRASEQN (1 << 15) /* Quote first word of the next phrase. */
+#define ROFF_NONOFILL (1 << 16) /* Temporarily suspend no-fill mode. */
#define MAN_NEWLINE MDOC_NEWLINE
enum roff_sec lastsec; /* Last section seen. */
enum roff_sec lastnamed; /* Last standard section seen. */