Alien-Judy
view release on metacpan or search on metacpan
src/judy-1.0.5/tool/jhton.c view on Meta::CPAN
time_t currtime; // for ctime().
// Extract "weird" header values:
//
// These must be found in the docnodes tree and prepared for emitting nroff.
ExtractHeader(g_Pdnhead, &filerev,
PPageName, &pagesection, &lcletter, &revision);
if (filerev == PCNULL)
{
Error(ERREXIT, NOERRNO, "HTML file lacks comment lines; it must "
"contain at least one comment line, and the first one must "
"contain revision information");
}
// Emit file header; note, ctime() output already contains a newline:
(void) time(&currtime);
(void) printf(".\\\" Auto-translated to nroff -man from %s by %s at %s",
Filename, gc_myname, ctime(&currtime));
(void) printf(".\\\" %s\n", filerev);
(void) printf(".TA %c\n", lcletter);
(void) printf(".TH %s %s\n", *PPageName, pagesection);
(void) puts( ".ds )H Hewlett-Packard Company");
(void) printf(".ds ]W %s\n", revision);
} // EmitNroffHeader()
// ****************************************************************************
// E M I T N R O F F B O D Y
//
// Given a current node in the docnodes tree, the current <DL> level, a flag
// whether below a <PRE> node, the manual entry page name, and in
// g_prevlinenum, the previous input line number that resulted in output,
// recursively emit nroff body text. Translate the HTML docnodes as described
// in the comments prior to EmitNroffHeader(), and also translate certain HTML
// escaped chars back to literal form. Hope the results are legal nroff
// without spurious unintended nroff commands embedded.
//
// Note: This function recurses two ways; first, to the child subtree, and
// second, to the next sibling at the current level.
FUNCTION void EmitNroffBody(
Pdn_t Pdn, // current top of subtree.
int DLLevel, // <DL> level, top = 0.
int InPRE, // bit flags for <PRE> handling.
char * PageName) // such as "Judy1".
{
int DLcount = 0; // set to 1 if hit <DL> here.
char * suffix = PCNULL; // to print after children, before siblings.
// When about to emit text, if the previous output came from a lower input line
// number, start with a newline; otherwise do not, and let the text
// concatenate:
//
// Use CHECKPREV except when the text to be emitted is forced to a new line.
#ifdef CPPRINT // for special debugging:
#define CHECKPREVPRINT printf("\ncp %d %d\n", g_prevlinenum, Pdn->dn_linenum)
#else
#define CHECKPREVPRINT // null
#endif
#define CHECKPREV \
CHECKPREVPRINT; \
{ if (g_prevlinenum && (g_prevlinenum < (Pdn->dn_linenum))) PUTC('\n');}
// To support CHECKPREV, call SETPREV() after emitting text that might need a
// line break to a new line, or SETPREVNONL to ensure NO newline, that is, the
// next text concatenates on the same line:
//
// Note: For a correct line number, SETPREV() must account for any newlines in
// the text just emitted.
#define SETPREV(Text) g_prevlinenum = (Pdn->dn_linenum) + CountNewlines(Text)
#define SETPREVNONL g_prevlinenum = g_linenumlim // no newline.
// Check if under a lower-level <DL>, for continuing an indented paragraph:
#define UNDER_DL ((DLLevel > 1) \
&& ((Pdn->dn_Pparent) != PDNNULL) \
&& ((Pdn->dn_Pparent->dn_type) == DN_TYPE_DL))
// SWITCH ON DOCNODE TYPE:
if (Pdn->dn_noemit) // upstream node said to skip this one.
goto NextNode;
switch (Pdn->dn_type)
{
// DOCUMENT TEXT:
//
// Just emit it with HTML escaped chars modified, with backslashes doubled,
// with no trailing newline, and if not within <PRE> text, with any leading
// whitespace deleted, so that, for example, something like "\fI text\fP" does
// not result.
case DN_TYPE_TEXT:
assert((Pdn->dn_text) != PCNULL);
CHECKPREV;
EmitText(Pdn->dn_text, InPRE, Pdn->dn_linenum);
SETPREV(Pdn->dn_text);
break;
// IGNORE THESE TYPES:
//
// See EmitNroffHeader() for nroff equivalents already emitted in some cases.
// In some cases, mark all child nodes no-emit to ignore them.
case DN_TYPE_HTML:
case DN_TYPE_HEAD:
case DN_TYPE_BODY:
case DN_TYPE_COMM: break;
( run in 0.355 second using v1.01-cache-2.11-cpan-39bf76dae61 )