From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id cafc3a2b for ; Fri, 4 Jan 2019 19:37:20 -0500 (EST) Date: Fri, 4 Jan 2019 19:37:20 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: Some high-level block macros have an effect similar to X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <05f98125be8fc1dc@fantadrom.bsd.lv> Log Message: ----------- 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. Modified Files: -------------- mandoc: man.c man_macro.c man_term.c roff.c roff_int.h Revision Data ------------- Index: roff_int.h =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff_int.h,v retrieving revision 1.15 retrieving revision 1.16 diff -Lroff_int.h -Lroff_int.h -u -p -r1.15 -r1.16 --- roff_int.h +++ roff_int.h @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze + * Copyright (c) 2013-2015, 2017-2019 Ingo Schwarze * * 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. */ Index: man_term.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/man_term.c,v retrieving revision 1.225 retrieving revision 1.226 diff -Lman_term.c -Lman_term.c -u -p -r1.225 -r1.226 --- man_term.c +++ man_term.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons - * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze + * Copyright (c) 2010-2015, 2017-2019 Ingo Schwarze * * 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; } Index: roff.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff.c,v retrieving revision 1.359 retrieving revision 1.360 diff -Lroff.c -Lroff.c -u -p -r1.359 -r1.360 --- roff.c +++ roff.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons - * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze + * Copyright (c) 2010-2015, 2017-2019 Ingo Schwarze * * 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, in 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; Index: man.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/man.c,v retrieving revision 1.186 retrieving revision 1.187 diff -Lman.c -Lman.c -u -p -r1.186 -r1.187 --- man.c +++ man.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze + * Copyright (c) 2013-2015, 2017-2019 Ingo Schwarze * Copyright (c) 2011 Joerg Sonnenberger * * Permission to use, copy, modify, and distribute this software for any @@ -92,9 +92,9 @@ man_descope(struct roff_man *man, int li } 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, 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 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 "%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); } } Index: man_macro.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/man_macro.c,v retrieving revision 1.142 retrieving revision 1.143 diff -Lman_macro.c -Lman_macro.c -u -p -r1.142 -r1.143 --- man_macro.c +++ man_macro.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2012-2015, 2017, 2018 Ingo Schwarze + * Copyright (c) 2012-2015, 2017-2019 Ingo Schwarze * Copyright (c) 2013 Franco Fichtner * * 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 -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv