/* $Id: docbook2mdoc.c,v 1.93 2019/04/07 13:16:21 schwarze Exp $ */ /* * Copyright (c) 2014 Kristaps Dzonsons * Copyright (c) 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 * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include "node.h" #include "macro.h" #include "format.h" /* * The implementation of the mdoc(7) formatter. */ static void pnode_print(struct format *, struct pnode *); static void pnode_printtext(struct format *f, struct pnode *n) { char *cp; char last; if (n->bsz == 0) { assert(n->real < n->b); return; } if (f->linestate == LINE_NEW) { last = '\n'; f->linestate = LINE_TEXT; } else { last = ' '; if (n->spc || f->linestate == LINE_MACRO) putchar(' '); } if (n->node == NODE_ESCAPE) { fputs(n->b, stdout); return; } /* * Remove the prefix '-' from