]>
git.cameronkatri.com Git - mandoc.git/blob - html.c
1 /* $Id: html.c,v 1.274 2021/08/10 12:55:03 schwarze Exp $ */
3 * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2011-2015, 2017-2021 Ingo Schwarze <schwarze@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 * Common functions for mandoc(1) HTML formatters.
19 * For use by individual formatters and by the main program.
23 #include <sys/types.h>
36 #include "mandoc_aux.h"
37 #include "mandoc_ohash.h"
48 #define HTML_INPHRASE (1 << 0) /* Can appear in phrasing context. */
49 #define HTML_TOPHRASE (1 << 1) /* Establishes phrasing context. */
50 #define HTML_NOSTACK (1 << 2) /* Does not have an end tag. */
51 #define HTML_NLBEFORE (1 << 3) /* Output line break before opening. */
52 #define HTML_NLBEGIN (1 << 4) /* Output line break after opening. */
53 #define HTML_NLEND (1 << 5) /* Output line break before closing. */
54 #define HTML_NLAFTER (1 << 6) /* Output line break after closing. */
55 #define HTML_NLAROUND (HTML_NLBEFORE | HTML_NLAFTER)
56 #define HTML_NLINSIDE (HTML_NLBEGIN | HTML_NLEND)
57 #define HTML_NLALL (HTML_NLAROUND | HTML_NLINSIDE)
58 #define HTML_INDENT (1 << 7) /* Indent content by two spaces. */
59 #define HTML_NOINDENT (1 << 8) /* Exception: never indent content. */
62 static const struct htmldata htmltags
[TAG_MAX
] = {
64 {"head", HTML_NLALL
| HTML_INDENT
},
65 {"meta", HTML_NOSTACK
| HTML_NLALL
},
66 {"link", HTML_NOSTACK
| HTML_NLALL
},
67 {"style", HTML_NLALL
| HTML_INDENT
},
68 {"title", HTML_NLAROUND
},
70 {"div", HTML_NLAROUND
},
71 {"section", HTML_NLALL
},
72 {"table", HTML_NLALL
| HTML_INDENT
},
73 {"tr", HTML_NLALL
| HTML_INDENT
},
74 {"td", HTML_NLAROUND
},
75 {"li", HTML_NLAROUND
| HTML_INDENT
},
76 {"ul", HTML_NLALL
| HTML_INDENT
},
77 {"ol", HTML_NLALL
| HTML_INDENT
},
78 {"dl", HTML_NLALL
| HTML_INDENT
},
79 {"dt", HTML_NLAROUND
},
80 {"dd", HTML_NLAROUND
| HTML_INDENT
},
81 {"h1", HTML_TOPHRASE
| HTML_NLAROUND
},
82 {"h2", HTML_TOPHRASE
| HTML_NLAROUND
},
83 {"p", HTML_TOPHRASE
| HTML_NLAROUND
| HTML_INDENT
},
84 {"pre", HTML_TOPHRASE
| HTML_NLAROUND
| HTML_NOINDENT
},
85 {"a", HTML_INPHRASE
| HTML_TOPHRASE
},
86 {"b", HTML_INPHRASE
| HTML_TOPHRASE
},
87 {"cite", HTML_INPHRASE
| HTML_TOPHRASE
},
88 {"code", HTML_INPHRASE
| HTML_TOPHRASE
},
89 {"i", HTML_INPHRASE
| HTML_TOPHRASE
},
90 {"small", HTML_INPHRASE
| HTML_TOPHRASE
},
91 {"span", HTML_INPHRASE
| HTML_TOPHRASE
},
92 {"var", HTML_INPHRASE
| HTML_TOPHRASE
},
93 {"br", HTML_INPHRASE
| HTML_NOSTACK
| HTML_NLALL
},
94 {"mark", HTML_INPHRASE
},
95 {"math", HTML_INPHRASE
| HTML_NLALL
| HTML_INDENT
},
114 /* Avoid duplicate HTML id= attributes. */
117 int ord
; /* Ordinal number of the latest occurrence. */
118 char id
[]; /* The id= attribute without any ordinal suffix. */
120 static struct ohash id_unique
;
122 static void html_reset_internal(struct html
*);
123 static void print_byte(struct html
*, char);
124 static void print_endword(struct html
*);
125 static void print_indent(struct html
*);
126 static void print_word(struct html
*, const char *);
128 static void print_ctag(struct html
*, struct tag
*);
129 static int print_escape(struct html
*, char);
130 static int print_encode(struct html
*, const char *, const char *, int);
131 static void print_href(struct html
*, const char *, const char *, int);
132 static void print_metaf(struct html
*);
136 html_alloc(const struct manoutput
*outopts
)
140 h
= mandoc_calloc(1, sizeof(struct html
));
143 h
->metac
= h
->metal
= ESCAPE_FONTROMAN
;
144 h
->style
= outopts
->style
;
145 if ((h
->base_man1
= outopts
->man
) == NULL
)
147 else if ((h
->base_man2
= strchr(h
->base_man1
, ';')) != NULL
)
148 *h
->base_man2
++ = '\0';
149 h
->base_includes
= outopts
->includes
;
150 if (outopts
->fragment
)
151 h
->oflags
|= HTML_FRAGMENT
;
153 h
->oflags
|= HTML_TOC
;
155 mandoc_ohash_init(&id_unique
, 4, offsetof(struct id_entry
, id
));
161 html_reset_internal(struct html
*h
)
164 struct id_entry
*entry
;
167 while ((tag
= h
->tag
) != NULL
) {
171 entry
= ohash_first(&id_unique
, &slot
);
172 while (entry
!= NULL
) {
174 entry
= ohash_next(&id_unique
, &slot
);
176 ohash_delete(&id_unique
);
182 html_reset_internal(p
);
183 mandoc_ohash_init(&id_unique
, 4, offsetof(struct id_entry
, id
));
189 html_reset_internal(p
);
194 print_gen_head(struct html
*h
)
198 print_otag(h
, TAG_META
, "?", "charset", "utf-8");
199 print_otag(h
, TAG_META
, "??", "name", "viewport",
200 "content", "width=device-width, initial-scale=1.0");
201 if (h
->style
!= NULL
) {
202 print_otag(h
, TAG_LINK
, "?h??", "rel", "stylesheet",
203 h
->style
, "type", "text/css", "media", "all");
208 * Print a minimal embedded style sheet.
211 t
= print_otag(h
, TAG_STYLE
, "");
212 print_text(h
, "table.head, table.foot { width: 100%; }");
214 print_text(h
, "td.head-rtitle, td.foot-os { text-align: right; }");
216 print_text(h
, "td.head-vol { text-align: center; }");
218 print_text(h
, ".Nd, .Bf, .Op { display: inline; }");
220 print_text(h
, ".Pa, .Ad { font-style: italic; }");
222 print_text(h
, ".Ms { font-weight: bold; }");
224 print_text(h
, ".Bl-diag ");
226 print_text(h
, " dt { font-weight: bold; }");
228 print_text(h
, "code.Nm, .Fl, .Cm, .Ic, code.In, .Fd, .Fn, .Cd "
229 "{ font-weight: bold; font-family: inherit; }");
234 html_setfont(struct html
*h
, enum mandoc_esc font
)
237 case ESCAPE_FONTPREV
:
240 case ESCAPE_FONTITALIC
:
241 case ESCAPE_FONTBOLD
:
243 case ESCAPE_FONTROMAN
:
249 font
= ESCAPE_FONTROMAN
;
260 print_metaf(struct html
*h
)
263 print_tagq(h
, h
->metaf
);
267 case ESCAPE_FONTITALIC
:
268 h
->metaf
= print_otag(h
, TAG_I
, "");
270 case ESCAPE_FONTBOLD
:
271 h
->metaf
= print_otag(h
, TAG_B
, "");
274 h
->metaf
= print_otag(h
, TAG_B
, "");
275 print_otag(h
, TAG_I
, "");
278 h
->metaf
= print_otag(h
, TAG_SPAN
, "c", "Li");
281 h
->metaf
= print_otag(h
, TAG_SPAN
, "c", "Li");
282 print_otag(h
, TAG_B
, "");
285 h
->metaf
= print_otag(h
, TAG_SPAN
, "c", "Li");
286 print_otag(h
, TAG_I
, "");
294 html_close_paragraph(struct html
*h
)
296 struct tag
*this, *next
;
302 flags
= htmltags
[this->tag
].flags
;
303 if (flags
& (HTML_INPHRASE
| HTML_TOPHRASE
))
305 if ((flags
& HTML_INPHRASE
) == 0)
312 * ROFF_nf switches to no-fill mode, ROFF_fi to fill mode.
313 * TOKEN_NONE does not switch. The old mode is returned.
316 html_fillmode(struct html
*h
, enum roff_tok want
)
321 for (t
= h
->tag
; t
!= NULL
; t
= t
->next
)
322 if (t
->tag
== TAG_PRE
)
325 had
= t
== NULL
? ROFF_fi
: ROFF_nf
;
333 html_close_paragraph(h
);
334 print_otag(h
, TAG_PRE
, "");
346 * Allocate a string to be used for the "id=" attribute of an HTML
347 * element and/or as a segment identifier for a URI in an <a> element.
348 * The function may fail and return NULL if the node lacks text data
349 * to create the attribute from.
350 * The caller is responsible for free(3)ing the returned string.
352 * If the "unique" argument is non-zero, the "id_unique" ohash table
353 * is used for de-duplication. If the "unique" argument is 1,
354 * it is the first time the function is called for this tag and
355 * location, so if an ordinal suffix is needed, it is incremented.
356 * If the "unique" argument is 2, it is the second time the function
357 * is called for this tag and location, so the ordinal suffix
361 html_make_id(const struct roff_node
*n
, int unique
)
363 const struct roff_node
*nch
;
364 struct id_entry
*entry
;
370 buf
= mandoc_strdup(n
->tag
);
378 for (nch
= n
->child
; nch
!= NULL
; nch
= nch
->next
)
379 if (nch
->type
!= ROFFT_TEXT
)
387 if (n
->child
== NULL
|| n
->child
->type
!= ROFFT_TEXT
)
389 buf
= mandoc_strdup(n
->child
->string
);
395 * In ID attributes, only use ASCII characters that are
396 * permitted in URL-fragment strings according to the
398 * https://url.spec.whatwg.org/#url-fragment-string
399 * In addition, reserve '~' for ordinal suffixes.
402 for (cp
= buf
; *cp
!= '\0'; cp
++)
403 if (isalnum((unsigned char)*cp
) == 0 &&
404 strchr("!$&'()*+,-./:;=?@_", *cp
) == NULL
)
410 /* Avoid duplicate HTML id= attributes. */
412 slot
= ohash_qlookup(&id_unique
, buf
);
413 if ((entry
= ohash_find(&id_unique
, slot
)) == NULL
) {
414 len
= strlen(buf
) + 1;
415 entry
= mandoc_malloc(sizeof(*entry
) + len
);
417 memcpy(entry
->id
, buf
, len
);
418 ohash_insert(&id_unique
, slot
, entry
);
419 } else if (unique
== 1)
422 if (entry
->ord
> 1) {
424 mandoc_asprintf(&buf
, "%s~%d", cp
, entry
->ord
);
431 print_escape(struct html
*h
, char c
)
436 print_word(h
, "<");
439 print_word(h
, ">");
442 print_word(h
, "&");
445 print_word(h
, """);
448 print_word(h
, " ");
462 print_encode(struct html
*h
, const char *p
, const char *pend
, int norecurse
)
467 int c
, len
, breakline
, nospace
;
469 static const char rejs
[10] = { ' ', '\\', '<', '>', '&', '"',
470 ASCII_NBRSP
, ASCII_HYPH
, ASCII_BREAK
, '\0' };
473 pend
= strchr(p
, '\0');
479 if (HTML_SKIPCHAR
& h
->flags
&& '\\' != *p
) {
480 h
->flags
&= ~HTML_SKIPCHAR
;
485 for (sz
= strcspn(p
, rejs
); sz
-- && p
< pend
; p
++)
489 (p
>= pend
|| *p
== ' ' || *p
== ASCII_NBRSP
)) {
490 print_otag(h
, TAG_BR
, "");
492 while (p
< pend
&& (*p
== ' ' || *p
== ASCII_NBRSP
))
506 if (print_escape(h
, *p
++))
509 esc
= mandoc_escape(&p
, &seq
, &len
);
512 case ESCAPE_FONTPREV
:
513 case ESCAPE_FONTBOLD
:
514 case ESCAPE_FONTITALIC
:
516 case ESCAPE_FONTROMAN
:
520 if (0 == norecurse
) {
521 h
->flags
|= HTML_NOSPACE
;
522 if (html_setfont(h
, esc
))
524 h
->flags
&= ~HTML_NOSPACE
;
527 case ESCAPE_SKIPCHAR
:
528 h
->flags
|= HTML_SKIPCHAR
;
536 if (h
->flags
& HTML_SKIPCHAR
) {
537 h
->flags
&= ~HTML_SKIPCHAR
;
543 /* Skip past "u" header. */
544 c
= mchars_num2uc(seq
+ 1, len
- 1);
546 case ESCAPE_NUMBERED
:
547 c
= mchars_num2char(seq
, len
);
552 c
= mchars_spec2cp(seq
, len
);
560 print_word(h
, "html");
569 case ESCAPE_OVERSTRIKE
:
577 if ((c
< 0x20 && c
!= 0x09) ||
578 (c
> 0x7E && c
< 0xA0))
581 (void)snprintf(numbuf
, sizeof(numbuf
), "&#x%.4X;", c
);
582 print_word(h
, numbuf
);
583 } else if (print_escape(h
, c
) == 0)
591 print_href(struct html
*h
, const char *name
, const char *sec
, int man
)
599 if (h
->base_man2
!= NULL
) {
600 mandoc_asprintf(&filename
, "%s.%s", name
, sec
);
601 if (stat(filename
, &sb
) == -1)
606 pp
= h
->base_includes
;
608 while ((p
= strchr(pp
, '%')) != NULL
) {
609 print_encode(h
, pp
, p
, 1);
610 if (man
&& p
[1] == 'S') {
614 print_encode(h
, sec
, NULL
, 1);
615 } else if ((man
&& p
[1] == 'N') ||
616 (man
== 0 && p
[1] == 'I'))
617 print_encode(h
, name
, NULL
, 1);
619 print_encode(h
, p
, p
+ 2, 1);
623 print_encode(h
, pp
, NULL
, 1);
627 print_otag(struct html
*h
, enum htmltag tag
, const char *fmt
, ...)
633 int style_written
, tflags
;
635 tflags
= htmltags
[tag
].flags
;
637 /* Flow content is not allowed in phrasing context. */
639 if ((tflags
& HTML_INPHRASE
) == 0) {
640 for (t
= h
->tag
; t
!= NULL
; t
= t
->next
) {
643 assert((htmltags
[t
->tag
].flags
& HTML_TOPHRASE
) == 0);
648 * Always wrap phrasing elements in a paragraph
649 * unless already contained in some flow container;
650 * never put them directly into a section.
653 } else if (tflags
& HTML_TOPHRASE
&& h
->tag
->tag
== TAG_SECTION
)
654 print_otag(h
, TAG_P
, "c", "Pp");
656 /* Push this tag onto the stack of open scopes. */
658 if ((tflags
& HTML_NOSTACK
) == 0) {
659 t
= mandoc_malloc(sizeof(struct tag
));
668 if (tflags
& HTML_NLBEFORE
)
672 else if ((h
->flags
& HTML_NOSPACE
) == 0) {
673 if (h
->flags
& HTML_KEEP
)
674 print_word(h
, " ");
676 if (h
->flags
& HTML_PREKEEP
)
677 h
->flags
|= HTML_KEEP
;
682 if ( ! (h
->flags
& HTML_NONOSPACE
))
683 h
->flags
&= ~HTML_NOSPACE
;
685 h
->flags
|= HTML_NOSPACE
;
687 /* Print out the tag name and attributes. */
690 print_word(h
, htmltags
[tag
].name
);
694 while (*fmt
!= '\0' && *fmt
!= 's') {
696 /* Parse attributes and arguments. */
698 arg1
= va_arg(ap
, char *);
712 arg1
= va_arg(ap
, char *);
718 arg2
= va_arg(ap
, char *);
722 /* Print the attributes. */
730 print_href(h
, arg1
, NULL
, 0);
734 print_href(h
, arg1
, arg2
, 1);
739 print_encode(h
, arg1
, NULL
, 1);
743 print_encode(h
, arg1
, NULL
, 1);
750 while (*fmt
++ == 's') {
751 arg1
= va_arg(ap
, char *);
752 arg2
= va_arg(ap
, char *);
756 if (style_written
== 0) {
757 print_word(h
, "style=\"");
771 /* Accommodate for "well-formed" singleton escaping. */
773 if (htmltags
[tag
].flags
& HTML_NOSTACK
)
778 if (tflags
& HTML_NLBEGIN
)
781 h
->flags
|= HTML_NOSPACE
;
783 if (tflags
& HTML_INDENT
)
785 if (tflags
& HTML_NOINDENT
)
792 * Print an element with an optional "id=" attribute.
793 * If the element has phrasing content and an "id=" attribute,
794 * also add a permalink: outside if it can be in phrasing context,
798 print_otag_id(struct html
*h
, enum htmltag elemtype
, const char *cattr
,
801 struct roff_node
*nch
;
807 if (n
->flags
& NODE_ID
)
808 id
= html_make_id(n
, 1);
809 if (n
->flags
& NODE_HREF
)
810 href
= id
== NULL
? html_make_id(n
, 2) : id
;
811 if (href
!= NULL
&& htmltags
[elemtype
].flags
& HTML_INPHRASE
)
812 ret
= print_otag(h
, TAG_A
, "chR", "permalink", href
);
813 t
= print_otag(h
, elemtype
, "ci", cattr
, id
);
816 if (href
!= NULL
&& (nch
= n
->child
) != NULL
) {
817 /* man(7) is safe, it tags phrasing content only. */
818 if (n
->tok
> MDOC_MAX
||
819 htmltags
[elemtype
].flags
& HTML_TOPHRASE
)
821 else /* For mdoc(7), beware of nested blocks. */
822 while (nch
!= NULL
&& nch
->type
== ROFFT_TEXT
)
825 print_otag(h
, TAG_A
, "chR", "permalink", href
);
835 print_ctag(struct html
*h
, struct tag
*tag
)
839 if (tag
->closed
== 0) {
846 tflags
= htmltags
[tag
->tag
].flags
;
847 if (tflags
& HTML_INDENT
)
849 if (tflags
& HTML_NOINDENT
)
851 if (tflags
& HTML_NLEND
)
856 print_word(h
, htmltags
[tag
->tag
].name
);
858 if (tflags
& HTML_NLAFTER
)
861 if (tag
->refcnt
== 0) {
868 print_gen_decls(struct html
*h
)
870 print_word(h
, "<!DOCTYPE html>");
875 print_gen_comment(struct html
*h
, struct roff_node
*n
)
879 print_word(h
, "<!-- This is an automatically generated file."
883 while (n
!= NULL
&& n
->type
== ROFFT_COMMENT
) {
884 if (strstr(n
->string
, "-->") == NULL
&&
885 (wantblank
|| *n
->string
!= '\0')) {
888 print_word(h
, n
->string
);
889 wantblank
= *n
->string
!= '\0';
895 print_word(h
, " -->");
901 print_text(struct html
*h
, const char *word
)
903 print_tagged_text(h
, word
, NULL
);
907 print_tagged_text(struct html
*h
, const char *word
, struct roff_node
*n
)
913 * Always wrap text in a paragraph unless already contained in
914 * some flow container; never put it directly into a section.
917 if (h
->tag
->tag
== TAG_SECTION
)
918 print_otag(h
, TAG_P
, "c", "Pp");
920 /* Output whitespace before this text? */
922 if (h
->col
&& (h
->flags
& HTML_NOSPACE
) == 0) {
923 if ( ! (HTML_KEEP
& h
->flags
)) {
924 if (HTML_PREKEEP
& h
->flags
)
925 h
->flags
|= HTML_KEEP
;
928 print_word(h
, " ");
932 * Optionally switch fonts, optionally write a permalink, then
933 * print the text, optionally surrounded by HTML whitespace.
936 assert(h
->metaf
== NULL
);
940 if (n
!= NULL
&& (href
= html_make_id(n
, 2)) != NULL
) {
941 t
= print_otag(h
, TAG_A
, "chR", "permalink", href
);
946 if ( ! print_encode(h
, word
, NULL
, 0)) {
947 if ( ! (h
->flags
& HTML_NONOSPACE
))
948 h
->flags
&= ~HTML_NOSPACE
;
949 h
->flags
&= ~HTML_NONEWLINE
;
951 h
->flags
|= HTML_NOSPACE
| HTML_NONEWLINE
;
953 if (h
->metaf
!= NULL
) {
954 print_tagq(h
, h
->metaf
);
956 } else if (t
!= NULL
)
959 h
->flags
&= ~HTML_IGNDELIM
;
963 print_tagq(struct html
*h
, const struct tag
*until
)
965 struct tag
*this, *next
;
967 for (this = h
->tag
; this != NULL
; this = next
) {
968 next
= this == until
? NULL
: this->next
;
974 * Close out all open elements up to but excluding suntil.
975 * Note that a paragraph just inside stays open together with it
976 * because paragraphs include subsequent phrasing content.
979 print_stagq(struct html
*h
, const struct tag
*suntil
)
981 struct tag
*this, *next
;
983 for (this = h
->tag
; this != NULL
; this = next
) {
985 if (this == suntil
|| (next
== suntil
&&
986 (this->tag
== TAG_P
|| this->tag
== TAG_PRE
)))
993 /***********************************************************************
994 * Low level output functions.
995 * They implement line breaking using a short static buffer.
996 ***********************************************************************/
999 * Buffer one HTML output byte.
1000 * If the buffer is full, flush and deactivate it and start a new line.
1001 * If the buffer is inactive, print directly.
1004 print_byte(struct html
*h
, char c
)
1006 if ((h
->flags
& HTML_BUFFER
) == 0) {
1012 if (h
->col
+ h
->bufcol
< sizeof(h
->buf
)) {
1013 h
->buf
[h
->bufcol
++] = c
;
1022 fwrite(h
->buf
, h
->bufcol
, 1, stdout
);
1024 h
->col
= (h
->indent
+ 1) * 2 + h
->bufcol
+ 1;
1026 h
->flags
&= ~HTML_BUFFER
;
1030 * If something was printed on the current output line, end it.
1031 * Not to be called right after print_indent().
1034 print_endline(struct html
*h
)
1041 fwrite(h
->buf
, h
->bufcol
, 1, stdout
);
1046 h
->flags
|= HTML_NOSPACE
;
1047 h
->flags
&= ~HTML_BUFFER
;
1051 * Flush the HTML output buffer.
1052 * If it is inactive, activate it.
1055 print_endword(struct html
*h
)
1062 if ((h
->flags
& HTML_BUFFER
) == 0) {
1064 h
->flags
|= HTML_BUFFER
;
1065 } else if (h
->bufcol
) {
1067 fwrite(h
->buf
, h
->bufcol
, 1, stdout
);
1068 h
->col
+= h
->bufcol
+ 1;
1074 * If at the beginning of a new output line,
1075 * perform indentation and mark the line as containing output.
1076 * Make sure to really produce some output right afterwards,
1077 * but do not use print_otag() for producing it.
1080 print_indent(struct html
*h
)
1084 if (h
->col
|| h
->noindent
)
1087 h
->col
= h
->indent
* 2;
1088 for (i
= 0; i
< h
->col
; i
++)
1093 * Print or buffer some characters
1094 * depending on the current HTML output buffer state.
1097 print_word(struct html
*h
, const char *cp
)
1100 print_byte(h
, *cp
++);