Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents 5d5e7e0 + 027623d commit f8ff15fce469872006c33586a776a6ab292f8f3a @randy1 committed Mar 22, 2011
Showing with 11,809 additions and 3,003 deletions.
  1. +5 −6 Makefile.inc1
  2. +4 −0 Makefile_upgrade.inc
  3. +19 −4 UPDATING
  4. +19 −5 bin/ps/ps.c
  5. +1 −1 contrib/amd/libamu/mount_fs.c
  6. +4 −0 contrib/gcc-4.4/gcc/config/i386/i386.c
  7. +2 −1 contrib/gcc-4.4/gcc/tree-inline.c
  8. +43 −0 contrib/mdocml/ChangeLog.xsl
  9. +345 −0 contrib/mdocml/Makefile
  10. +5 −0 contrib/mdocml/README.DRAGONFLY
  11. +8 −3 {usr.bin/mandoc → contrib/mdocml}/arch.c
  12. +5 −3 {usr.bin/mandoc → contrib/mdocml}/arch.in
  13. +8 −3 {usr.bin/mandoc → contrib/mdocml}/att.c
  14. +2 −2 {usr.bin/mandoc → contrib/mdocml}/att.in
  15. +82 −37 {usr.bin/mandoc → contrib/mdocml}/chars.c
  16. +6 −4 {usr.bin/mandoc → contrib/mdocml}/chars.h
  17. +425 −0 contrib/mdocml/chars.in
  18. +95 −0 contrib/mdocml/compat.c
  19. +25 −0 contrib/mdocml/config.h.post
  20. +6 −0 contrib/mdocml/config.h.pre
  21. +146 −0 contrib/mdocml/example.style.css
  22. BIN contrib/mdocml/external.png
  23. +165 −120 {usr.bin/mandoc → contrib/mdocml}/html.c
  24. +44 −44 {usr.bin/mandoc → contrib/mdocml}/html.h
  25. +48 −0 contrib/mdocml/index.css
  26. +398 −0 contrib/mdocml/index.sgml
  27. +7 −2 {usr.bin/mandoc → contrib/mdocml}/lib.c
  28. +29 −3 {usr.bin/mandoc → contrib/mdocml}/lib.in
  29. +26 −58 {usr.bin/mandoc → contrib/mdocml}/libman.h
  30. +6 −3 {usr.bin/mandoc → contrib/mdocml}/libmandoc.h
  31. +147 −0 contrib/mdocml/libmdoc.h
  32. +62 −0 contrib/mdocml/libroff.h
  33. +1,040 −0 contrib/mdocml/main.c
  34. +13 −5 {usr.bin/mandoc → contrib/mdocml}/main.h
  35. +82 −155 {usr.bin/mandoc → contrib/mdocml}/man.3
  36. +262 −373 {usr.bin/mandoc → contrib/mdocml}/man.7
  37. +176 −242 {usr.bin/mandoc → contrib/mdocml}/man.c
  38. +46 −44 {usr.bin/mandoc → contrib/mdocml}/man.h
  39. +44 −0 contrib/mdocml/man_argv.c
  40. +13 −10 {usr.bin/mandoc → contrib/mdocml}/man_hash.c
  41. +214 −278 {usr.bin/mandoc → contrib/mdocml}/man_html.c
  42. +43 −131 {usr.bin/mandoc → contrib/mdocml}/man_macro.c
  43. +278 −179 {usr.bin/mandoc → contrib/mdocml}/man_term.c
  44. +577 −0 contrib/mdocml/man_validate.c
  45. +569 −0 contrib/mdocml/mandoc.1
  46. +487 −0 contrib/mdocml/mandoc.c
  47. +315 −0 contrib/mdocml/mandoc.h
  48. +18 −64 {share/man/man7 → contrib/mdocml}/mandoc_char.7
  49. +165 −153 {usr.bin/mandoc → contrib/mdocml}/mdoc.3
  50. +2,925 −0 contrib/mdocml/mdoc.7
  51. +916 −0 contrib/mdocml/mdoc.c
  52. +436 −0 contrib/mdocml/mdoc.h
  53. +175 −136 {usr.bin/mandoc → contrib/mdocml}/mdoc_argv.c
  54. +11 −6 {usr.bin/mandoc → contrib/mdocml}/mdoc_hash.c
  55. +817 −928 {usr.bin/mandoc → contrib/mdocml}/mdoc_html.c
Sorry, we could not display the entire diff because too many files (314) changed.
View
11 Makefile.inc1
@@ -1,6 +1,5 @@
#
# $FreeBSD: src/Makefile.inc1,v 1.141.2.62 2003/04/06 19:54:00 dwmalone Exp $
-# $DragonFly: src/Makefile.inc1,v 1.118 2008/06/24 20:22:30 thomas Exp $
#
# Build-time options are documented in make.conf(5).
#
@@ -120,7 +119,7 @@ DESTDIRBASE?= ${OBJTREE}${.CURDIR}
.MAKEFLAGS:= ${.MAKEFLAGS:NDESTDIR=*}
# This sets the compiler we use to build the world/kernel with
-WORLD_CCVER?= gcc41
+WORLD_CCVER?= gcc44
WORLD_BINUTILSVER?= binutils217
# temporary until everybody has converted to x86_64
@@ -794,12 +793,12 @@ bootstrap-tools:
_share= share/syscons/scrnmaps
.endif
+.if !defined(NO_GCC41)
_gcc41_cross= gnu/usr.bin/cc41
_gcc41_tools= gnu/usr.bin/cc41/cc_prep gnu/usr.bin/cc41/cc_tools
-.if !defined(NO_GCC44)
+.endif
_gcc44_cross= gnu/usr.bin/cc44
_gcc44_tools= gnu/usr.bin/cc44/cc_prep gnu/usr.bin/cc44/cc_tools
-.endif
_custom_cross= libexec/customcc
_binutils= gnu/usr.bin/${WORLD_BINUTILSVER}
@@ -851,14 +850,14 @@ hierarchy:
# to specify the correct CCVER or 'cc' will not exec the correct compiler.
#
libraries:
+.if !defined(NO_GCC41)
cd ${.CURDIR}; \
HOST_CCVER=${HOST_CCVER} CCVER=gcc41 \
${MAKE} -f Makefile.inc1 _startup_libs41;
-.if !defined(NO_GCC44)
+.endif
cd ${.CURDIR}; \
HOST_CCVER=${HOST_CCVER} CCVER=gcc44 \
${MAKE} -f Makefile.inc1 _startup_libs44;
-.endif
cd ${.CURDIR}; \
${MAKE} -f Makefile.inc1 _startup_libs; \
${MAKE} -f Makefile.inc1 _prebuild_libs; \
View
4 Makefile_upgrade.inc
@@ -1568,6 +1568,10 @@ TO_REMOVE+=/usr/share/man/cat/man9/kref_init.9.gz
TO_REMOVE+=/usr/include/dev/video/meteor/meteor_reg.h
TO_REMOVE+=/usr/share/man/cat4/i386/meteor.4.gz
TO_REMOVE+=/usr/share/man/man4/i386/meteor.4.gz
+TO_REMOVE+=/usr/share/man/cat3/SLIST_REMOVE_NEXT.3.gz
+TO_REMOVE+=/usr/share/man/man3/SLIST_REMOVE_NEXT.3.gz
+TO_REMOVE+=/usr/share/man/cat3/STAILQ_REMOVE_NEXT.3.gz
+TO_REMOVE+=/usr/share/man/man3/STAILQ_REMOVE_NEXT.3.gz
# XXX Remove when pfsync(4) has been fixed
TO_REMOVE+=/usr/share/man/cat4/pfsync.4.gz
View
23 UPDATING
@@ -12,8 +12,23 @@
+ UPGRADING DRAGONFLY FROM 2.8 to later versions +
+-----------------------------------------------------------------------+
+GCC 4.4
+-------
+
+GCC 4.4 has been made DragonFly's default compiler.
+
+That means that any settings that set CCVER to 'gcc44' are not needed
+anymore. Instead, CCVER can be set to 'gcc41' to go back to using
+GCC 4.1.
+
+The NO_GCC44 option has been removed and will not affect the build
+anymore. There is now a NO_GCC41 option that will prevent GCC 4.1 from
+building in a similar fashion.
+
+Note that you must do a full buildworld/buildkernel for upgrading.
+
pkg_radd settings
-=================
+-----------------
The config file for pkg_radd has moved from /etc/settings.conf to
/etc/pkg_radd.conf. Save the contents of settings.conf before upgrading
@@ -26,14 +41,14 @@ exists. pkg_radd will continue to work with defaults.
+-----------------------------------------------------------------------+
OpenSSL
-========
+--------
OpenSSL has been upgraded, and SHLIB_MAJOR was bumped for libssh and libcrypto.
This shouldn't break any 3rd-party software, but you'll need to recompile your
3rd-party software if you want it to link against the new version of OpenSSL.
Loader
-=======
+-------
A new loader (dloader) has been added which better handles booting from
multiple kernel/module versions.
@@ -51,7 +66,7 @@ Note that you must installworld and run the 'upgrade' target before
installing the new kernel.
BIND
-=====
+-----
BIND has been removed from the base system. The ldns and drill tools have
been added for basic functionality. Use 'drill' where you would normally
View
24 bin/ps/ps.c
@@ -602,6 +602,8 @@ pscomp(const void *arg_a, const void *arg_b)
{
const KINFO *a = *(KINFO * const *)arg_a;
const KINFO *b = *(KINFO * const *)arg_b;
+ double di;
+ segsz_t si;
int i;
#define VSIZE(k) (KI_PROC(k, vm_dsize) + KI_PROC(k, vm_ssize) + \
@@ -611,11 +613,23 @@ pscomp(const void *arg_a, const void *arg_b)
if (sortby == SORTIAC)
return (KI_PROC(a)->p_usdata.bsd4.interactive - KI_PROC(b)->p_usdata.bsd4.interactive);
#endif
- if (sortby == SORTCPU)
- return (getpcpu(b) - getpcpu(a));
- if (sortby == SORTMEM)
- return (VSIZE(b) - VSIZE(a));
- i = KI_PROC(a, tdev) - KI_PROC(b, tdev);
+ if (sortby == SORTCPU) {
+ di = getpcpu(b) - getpcpu(a);
+ if (di < 0.0)
+ return(-1);
+ if (di > 0.0)
+ return(+1);
+ /* fall through */
+ }
+ if (sortby == SORTMEM) {
+ si = VSIZE(b) - VSIZE(a);
+ if (si < 0)
+ return(-1);
+ if (si > 0)
+ return(+1);
+ /* fall through */
+ }
+ i = KI_PROC(a, tdev) - KI_PROC(b, tdev);
if (i == 0)
i = KI_PROC(a, pid) - KI_PROC(b, pid);
return (i);
View
2 contrib/amd/libamu/mount_fs.c
@@ -694,7 +694,7 @@ compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct sockaddr_
#if defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS)
nap->maxgrouplist = hasmntval(mntp, MNTTAB_OPT_MAXGROUPS);
- if (nap->maxgrouplist != NULL)
+ if (nap->maxgrouplist != 0)
nap->flags |= MNT2_NFS_OPT_MAXGRPS;
#endif /* defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS) */
View
4 contrib/gcc-4.4/gcc/config/i386/i386.c
@@ -28742,9 +28742,13 @@ ix86_mangle_type (const_tree type)
static tree
ix86_stack_protect_fail (void)
{
+#if 0 /* XXX swildner */
return TARGET_64BIT
? default_external_stack_protect_fail ()
: default_hidden_stack_protect_fail ();
+#else
+ return default_external_stack_protect_fail ();
+#endif
}
/* Select a format to encode pointers in exception handling data. CODE
View
3 contrib/gcc-4.4/gcc/tree-inline.c
@@ -3249,7 +3249,8 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
&& strlen (reason)
&& !lookup_attribute ("noinline", DECL_ATTRIBUTES (fn))
/* Avoid warnings during early inline pass. */
- && cgraph_global_info_ready)
+ && cgraph_global_info_ready
+ && strcmp(reason, "call is unlikely and code size would grow"))
{
warning (OPT_Winline, "inlining failed in call to %q+F: %s",
fn, reason);
View
43 contrib/mdocml/ChangeLog.xsl
@@ -0,0 +1,43 @@
+<?xml version='1.0' encoding="utf-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
+<xsl:output encoding="utf-8" method="html" indent="yes" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" />
+<xsl:template match="/changelog">
+<html>
+ <head>
+ <title>mdocml - CVS-ChangeLog</title>
+ <link rel="stylesheet" href="index.css" type="text/css" media="all" />
+ </head>
+ <body>
+ <xsl:for-each select="entry">
+ <div class="clhead">
+ <xsl:text>Files modified by </xsl:text>
+ <xsl:value-of select="concat(author, ': ', date, ' (', time, ')')" />
+ </div>
+ <div class="clbody">
+ <strong>
+ <xsl:text>Note: </xsl:text>
+ </strong>
+ <xsl:value-of select="msg"/>
+ <ul class="clbody">
+ <xsl:for-each select="file">
+ <li>
+ <xsl:value-of select="name"/>
+ <span class="rev">
+ <xsl:text> &#8212; Rev: </xsl:text>
+ <xsl:value-of select="revision"/>
+ <xsl:text>, Status: </xsl:text>
+ <xsl:value-of select="cvsstate"/>
+ <xsl:if test="tag">
+ <xsl:text>, Tag: </xsl:text>
+ <xsl:value-of select="tag" />
+ </xsl:if>
+ </span>
+ </li>
+ </xsl:for-each>
+ </ul>
+ </div>
+ </xsl:for-each>
+ </body>
+</html>
+</xsl:template>
+</xsl:stylesheet>
View
345 contrib/mdocml/Makefile
@@ -0,0 +1,345 @@
+.SUFFIXES: .html .xml .sgml .1 .3 .7 .md5 .tar.gz
+.SUFFIXES: .1.txt .3.txt .7.txt
+.SUFFIXES: .1.xhtml .3.xhtml .7.xhtml
+.SUFFIXES: .1.sgml .3.sgml .7.sgml
+.SUFFIXES: .h .h.html
+.SUFFIXES: .1.ps .3.ps .7.ps
+.SUFFIXES: .1.pdf .3.pdf .7.pdf
+
+PREFIX = /usr/local
+BINDIR = $(PREFIX)/bin
+INCLUDEDIR = $(PREFIX)/include
+LIBDIR = $(PREFIX)/lib
+MANDIR = $(PREFIX)/man
+EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
+INSTALL = install
+INSTALL_PROGRAM = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 0444
+INSTALL_LIB = $(INSTALL) -m 0644
+INSTALL_MAN = $(INSTALL_DATA)
+
+VERSION = 1.10.9
+VDATE = 07 January 2010
+
+VFLAGS = -DVERSION="\"$(VERSION)\""
+WFLAGS = -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
+CFLAGS += -g $(WFLAGS) $(VFLAGS) -DHAVE_CONFIG_H
+
+# Specify this if you want to hard-code the operating system to appear
+# in the lower-left hand corner of -mdoc manuals.
+# CFLAGS += -DOSNAME="\"OpenBSD 4.5\""
+
+LINTFLAGS += $(VFLAGS)
+
+ROFFLNS = roff.ln tbl.ln tbl_opts.ln tbl_layout.ln tbl_data.ln
+
+ROFFSRCS = roff.c tbl.c tbl_opts.c tbl_layout.c tbl_data.c
+
+ROFFOBJS = roff.o tbl.o tbl_opts.o tbl_layout.o tbl_data.o
+
+MANDOCLNS = mandoc.ln
+
+MANDOCSRCS = mandoc.c
+
+MANDOCOBJS = mandoc.o
+
+MDOCLNS = mdoc_macro.ln mdoc.ln mdoc_hash.ln mdoc_strings.ln \
+ mdoc_argv.ln mdoc_validate.ln \
+ lib.ln att.ln arch.ln vol.ln msec.ln st.ln
+
+MDOCOBJS = mdoc_macro.o mdoc.o mdoc_hash.o mdoc_strings.o \
+ mdoc_argv.o mdoc_validate.o lib.o att.o \
+ arch.o vol.o msec.o st.o
+
+MDOCSRCS = mdoc_macro.c mdoc.c mdoc_hash.c mdoc_strings.c \
+ mdoc_argv.c mdoc_validate.c lib.c att.c \
+ arch.c vol.c msec.c st.c
+
+MANLNS = man_macro.ln man.ln man_hash.ln man_validate.ln \
+ man_argv.ln
+
+MANOBJS = man_macro.o man.o man_hash.o man_validate.o \
+ man_argv.o
+MANSRCS = man_macro.c man.c man_hash.c man_validate.c \
+ man_argv.c
+
+MAINLNS = main.ln mdoc_term.ln chars.ln term.ln tree.ln \
+ compat.ln man_term.ln html.ln mdoc_html.ln \
+ man_html.ln out.ln term_ps.ln term_ascii.ln \
+ tbl_term.ln tbl_html.ln
+
+MAINOBJS = main.o mdoc_term.o chars.o term.o tree.o compat.o \
+ man_term.o html.o mdoc_html.o man_html.o out.o \
+ term_ps.o term_ascii.o tbl_term.o tbl_html.o
+
+MAINSRCS = main.c mdoc_term.c chars.c term.c tree.c compat.c \
+ man_term.c html.c mdoc_html.c man_html.c out.c \
+ term_ps.c term_ascii.c tbl_term.c tbl_html.c
+
+LLNS = llib-llibmdoc.ln llib-llibman.ln llib-lmandoc.ln \
+ llib-llibmandoc.ln llib-llibroff.ln
+
+LNS = $(MAINLNS) $(MDOCLNS) $(MANLNS) \
+ $(MANDOCLNS) $(ROFFLNS)
+
+LIBS = libmdoc.a libman.a libmandoc.a libroff.a
+
+OBJS = $(MDOCOBJS) $(MAINOBJS) $(MANOBJS) \
+ $(MANDOCOBJS) $(ROFFOBJS)
+
+SRCS = $(MDOCSRCS) $(MAINSRCS) $(MANSRCS) \
+ $(MANDOCSRCS) $(ROFFSRCS)
+
+DATAS = arch.in att.in lib.in msec.in st.in \
+ vol.in chars.in
+
+HEADS = mdoc.h libmdoc.h man.h libman.h term.h \
+ libmandoc.h html.h chars.h out.h main.h roff.h \
+ mandoc.h libroff.h
+
+GSGMLS = mandoc.1.sgml mdoc.3.sgml mdoc.7.sgml \
+ mandoc_char.7.sgml man.7.sgml man.3.sgml roff.7.sgml \
+ roff.3.sgml tbl.7.sgml
+
+SGMLS = index.sgml
+
+XHTMLS = mandoc.1.xhtml mdoc.3.xhtml \
+ man.3.xhtml mdoc.7.xhtml man.7.xhtml mandoc_char.7.xhtml \
+ roff.7.xhtml roff.3.xhtml tbl.7.xhtml
+
+HTMLS = ChangeLog.html index.html man.h.html mdoc.h.html \
+ mandoc.h.html roff.h.html mandoc.1.html mdoc.3.html \
+ man.3.html mdoc.7.html man.7.html mandoc_char.7.html \
+ roff.7.html roff.3.html tbl.7.html
+
+PSS = mandoc.1.ps mdoc.3.ps man.3.ps mdoc.7.ps man.7.ps \
+ mandoc_char.7.ps roff.7.ps roff.3.ps tbl.7.ps
+
+PDFS = mandoc.1.pdf mdoc.3.pdf man.3.pdf mdoc.7.pdf man.7.pdf \
+ mandoc_char.7.pdf roff.7.pdf roff.3.pdf tbl.7.pdf
+
+XSLS = ChangeLog.xsl
+
+TEXTS = mandoc.1.txt mdoc.3.txt man.3.txt mdoc.7.txt man.7.txt \
+ mandoc_char.7.txt ChangeLog.txt \
+ roff.7.txt roff.3.txt tbl.7.txt
+
+EXAMPLES = example.style.css
+
+XMLS = ChangeLog.xml
+
+STATICS = index.css style.css external.png
+
+MD5S = mdocml-$(VERSION).md5
+
+TARGZS = mdocml-$(VERSION).tar.gz
+
+MANS = mandoc.1 mdoc.3 mdoc.7 mandoc_char.7 man.7 \
+ man.3 roff.7 roff.3 tbl.7
+
+BINS = mandoc
+
+TESTS = test-strlcat.c test-strlcpy.c
+
+CONFIGS = config.h.pre config.h.post
+
+DOCLEAN = $(BINS) $(LNS) $(LLNS) $(LIBS) $(OBJS) $(HTMLS) \
+ $(TARGZS) tags $(MD5S) $(XMLS) $(TEXTS) $(GSGMLS) \
+ config.h config.log $(PSS) $(PDFS) $(XHTMLS)
+
+DOINSTALL = $(SRCS) $(HEADS) Makefile $(MANS) $(SGMLS) $(STATICS) \
+ $(DATAS) $(XSLS) $(EXAMPLES) $(TESTS) $(CONFIGS)
+
+all: $(BINS)
+
+lint: $(LLNS)
+
+clean:
+ rm -f $(DOCLEAN)
+
+dist: mdocml-$(VERSION).tar.gz
+
+www: all $(GSGMLS) $(HTMLS) $(XHTMLS) $(TEXTS) $(MD5S) $(TARGZS) $(PSS) $(PDFS)
+
+ps: $(PSS)
+
+pdf: $(PDFS)
+
+installwww: www
+ $(INSTALL_DATA) $(HTMLS) $(XHTMLS) $(PSS) $(PDFS) $(TEXTS) $(STATICS) $(DESTDIR)$(PREFIX)/
+ $(INSTALL_DATA) mdocml-$(VERSION).tar.gz $(DESTDIR)$(PREFIX)/snapshots/
+ $(INSTALL_DATA) mdocml-$(VERSION).md5 $(DESTDIR)$(PREFIX)/snapshots/
+ $(INSTALL_DATA) mdocml-$(VERSION).tar.gz $(DESTDIR)$(PREFIX)/snapshots/mdocml.tar.gz
+ $(INSTALL_DATA) mdocml-$(VERSION).md5 $(DESTDIR)$(PREFIX)/snapshots/mdocml.md5
+
+install:
+ mkdir -p $(DESTDIR)$(BINDIR)
+ mkdir -p $(DESTDIR)$(EXAMPLEDIR)
+ mkdir -p $(DESTDIR)$(MANDIR)/man1
+ mkdir -p $(DESTDIR)$(MANDIR)/man7
+ $(INSTALL_PROGRAM) mandoc $(DESTDIR)$(BINDIR)
+ $(INSTALL_MAN) mandoc.1 $(DESTDIR)$(MANDIR)/man1
+ $(INSTALL_MAN) man.7 mdoc.7 roff.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
+ $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
+
+uninstall:
+ rm -f $(DESTDIR)$(BINDIR)/mandoc
+ rm -f $(DESTDIR)$(MANDIR)/man1/mandoc.1
+ rm -f $(DESTDIR)$(MANDIR)/man7/mdoc.7
+ rm -f $(DESTDIR)$(MANDIR)/man7/roff.7
+ rm -f $(DESTDIR)$(MANDIR)/man7/tbl.7
+ rm -f $(DESTDIR)$(MANDIR)/man7/man.7
+ rm -f $(DESTDIR)$(MANDIR)/man7/mandoc_char.7
+ rm -f $(DESTDIR)$(EXAMPLEDIR)/example.style.css
+
+$(OBJS): config.h
+
+$(LNS): config.h
+
+man_macro.ln man_macro.o: man_macro.c libman.h
+
+lib.ln lib.o: lib.c lib.in libmdoc.h
+
+att.ln att.o: att.c att.in libmdoc.h
+
+arch.ln arch.o: arch.c arch.in libmdoc.h
+
+vol.ln vol.o: vol.c vol.in libmdoc.h
+
+chars.ln chars.o: chars.c chars.in chars.h
+
+msec.ln msec.o: msec.c msec.in libmdoc.h
+
+st.ln st.o: st.c st.in libmdoc.h
+
+mdoc_macro.ln mdoc_macro.o: mdoc_macro.c libmdoc.h
+
+mdoc_term.ln mdoc_term.o: mdoc_term.c term.h mdoc.h
+
+mdoc_strings.ln mdoc_strings.o: mdoc_strings.c libmdoc.h
+
+man_hash.ln man_hash.o: man_hash.c libman.h
+
+mdoc_hash.ln mdoc_hash.o: mdoc_hash.c libmdoc.h
+
+mdoc.ln mdoc.o: mdoc.c libmdoc.h
+
+man.ln man.o: man.c libman.h
+
+main.ln main.o: main.c mdoc.h man.h roff.h
+
+compat.ln compat.o: compat.c
+
+term.ln term.o: term.c term.h man.h mdoc.h chars.h
+
+term_ps.ln term_ps.o: term_ps.c term.h main.h
+
+term_ascii.ln term_ascii.o: term_ascii.c term.h main.h
+
+html.ln html.o: html.c html.h chars.h
+
+mdoc_html.ln mdoc_html.o: mdoc_html.c html.h mdoc.h
+
+man_html.ln man_html.o: man_html.c html.h man.h out.h
+
+out.ln out.o: out.c out.h
+
+mandoc.ln mandoc.o: mandoc.c libmandoc.h
+
+tree.ln tree.o: tree.c man.h mdoc.h
+
+mdoc_argv.ln mdoc_argv.o: mdoc_argv.c libmdoc.h
+
+man_argv.ln man_argv.o: man_argv.c libman.h
+
+man_validate.ln man_validate.o: man_validate.c libman.h
+
+mdoc_validate.ln mdoc_validate.o: mdoc_validate.c libmdoc.h
+
+libmdoc.h: mdoc.h
+
+ChangeLog.xml:
+ cvs2cl --xml --xml-encoding iso-8859-15 -t --noxmlns -f $@
+
+ChangeLog.txt:
+ cvs2cl -t -f $@
+
+ChangeLog.html: ChangeLog.xml ChangeLog.xsl
+ xsltproc -o $@ ChangeLog.xsl ChangeLog.xml
+
+mdocml-$(VERSION).tar.gz: $(DOINSTALL)
+ mkdir -p .dist/mdocml/mdocml-$(VERSION)/
+ cp -f $(DOINSTALL) .dist/mdocml/mdocml-$(VERSION)/
+ ( cd .dist/mdocml/ && tar zcf ../../$@ mdocml-$(VERSION)/ )
+ rm -rf .dist/
+
+llib-llibmdoc.ln: $(MDOCLNS)
+ $(LINT) -Clibmdoc $(MDOCLNS)
+
+llib-llibman.ln: $(MANLNS)
+ $(LINT) -Clibman $(MANLNS)
+
+llib-llibmandoc.ln: $(MANDOCLNS)
+ $(LINT) -Clibmandoc $(MANDOCLNS)
+
+llib-llibroff.ln: $(ROFFLNS)
+ $(LINT) -Clibroff $(ROFFLNS)
+
+llib-lmandoc.ln: $(MAINLNS) llib-llibmdoc.ln llib-llibman.ln llib-llibmandoc.ln llib-llibroff.ln
+ $(LINT) -Cmandoc $(MAINLNS) llib-llibmdoc.ln llib-llibman.ln llib-llibmandoc.ln llib-llibroff.ln
+
+libmdoc.a: $(MDOCOBJS)
+ $(AR) rs $@ $(MDOCOBJS)
+
+libman.a: $(MANOBJS)
+ $(AR) rs $@ $(MANOBJS)
+
+libmandoc.a: $(MANDOCOBJS)
+ $(AR) rs $@ $(MANDOCOBJS)
+
+libroff.a: $(ROFFOBJS)
+ $(AR) rs $@ $(ROFFOBJS)
+
+mandoc: $(MAINOBJS) libroff.a libmdoc.a libman.a libmandoc.a
+ $(CC) $(CFLAGS) -o $@ $(MAINOBJS) libroff.a libmdoc.a libman.a libmandoc.a
+
+.sgml.html:
+ validate --warn $<
+ sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< > $@
+
+.1.1.txt .3.3.txt .7.7.txt:
+ ./mandoc -Tascii -Wall,stop $< | col -b > $@
+
+.1.1.sgml .3.3.sgml .7.7.sgml:
+ ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@
+
+.1.1.ps .3.3.ps .7.7.ps:
+ ./mandoc -Tps -Wall,stop $< > $@
+
+.1.1.xhtml .3.3.xhtml .7.7.xhtml:
+ ./mandoc -Txhtml -Wall,stop -Ostyle=style.css,man=%N.%S.xhtml,includes=%I.html $< > $@
+
+.1.1.pdf .3.3.pdf .7.7.pdf:
+ ./mandoc -Tpdf -Wall,stop $< > $@
+
+.tar.gz.md5:
+ md5 $< > $@
+
+.h.h.html:
+ highlight -I $< >$@
+
+config.h: config.h.pre config.h.post
+ rm -f config.log
+ ( cat config.h.pre; \
+ echo; \
+ if $(CC) $(CFLAGS) -Werror -c test-strlcat.c >> config.log 2>&1; then \
+ echo '#define HAVE_STRLCAT'; \
+ rm test-strlcat.o; \
+ fi; \
+ if $(CC) $(CFLAGS) -Werror -c test-strlcpy.c >> config.log 2>&1; then \
+ echo '#define HAVE_STRLCPY'; \
+ rm test-strlcpy.o; \
+ fi; \
+ echo; \
+ cat config.h.post \
+ ) > $@
View
5 contrib/mdocml/README.DRAGONFLY
@@ -0,0 +1,5 @@
+Original source is availale from:
+http://mdocml.bsd.lv/snapshots/mdocml.tar.gz
+
+This source is used in:
+ usr.bin/mandoc
View
11 usr.bin/mandoc/arch.c → contrib/mdocml/arch.c
@@ -1,6 +1,6 @@
-/* $Id: arch.c,v 1.6 2010/01/01 17:14:26 kristaps Exp $ */
+/* $Id: arch.c,v 1.8 2010/06/19 20:46:27 kristaps Exp $ */
/*
- * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
+ * Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -14,10 +14,15 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include "mandoc.h"
#include "libmdoc.h"
#define LINE(x, y) \
@@ -27,7 +32,7 @@ const char *
mdoc_a2arch(const char *p)
{
-#include "arch.in"
+#include "arch.in"
return(NULL);
}
View
8 usr.bin/mandoc/arch.in → contrib/mdocml/arch.in
@@ -1,6 +1,6 @@
-/* $Id: arch.in,v 1.7 2010/03/26 07:07:58 kristaps Exp $ */
+/* $Id: arch.in,v 1.10 2010/09/27 06:56:44 kristaps Exp $ */
/*
- * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
+ * Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -22,6 +22,8 @@
* formatted output.
*
* Be sure to escape strings.
+ *
+ * REMEMBER TO ADD NEW ARCHITECTURES TO MDOC.7!
*/
LINE("alpha", "Alpha")
@@ -40,6 +42,7 @@ LINE("loongson", "Loongson")
LINE("luna88k", "Luna88k")
LINE("mac68k", "Mac68k")
LINE("macppc", "MacPPC")
+LINE("mips64", "MIPS64")
LINE("mvme68k", "MVME68k")
LINE("mvme88k", "MVME88k")
LINE("mvmeppc", "MVMEPPC")
@@ -50,5 +53,4 @@ LINE("sparc", "SPARC")
LINE("sparc64", "SPARC64")
LINE("sun3", "Sun3")
LINE("vax", "VAX")
-LINE("x86_64", "x86_64")
LINE("zaurus", "Zaurus")
View
11 usr.bin/mandoc/att.c → contrib/mdocml/att.c
@@ -1,6 +1,6 @@
-/* $Id: att.c,v 1.6 2010/01/01 17:14:26 kristaps Exp $ */
+/* $Id: att.c,v 1.8 2010/06/19 20:46:27 kristaps Exp $ */
/*
- * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
+ * Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -14,10 +14,15 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include "mandoc.h"
#include "libmdoc.h"
#define LINE(x, y) \
@@ -27,7 +32,7 @@ const char *
mdoc_a2att(const char *p)
{
-#include "att.in"
+#include "att.in"
return(NULL);
}
View
4 usr.bin/mandoc/att.in → contrib/mdocml/att.in
@@ -1,6 +1,6 @@
-/* $Id: att.in,v 1.5 2009/06/10 20:18:43 kristaps Exp $ */
+/* $Id: att.in,v 1.6 2010/06/19 20:46:27 kristaps Exp $ */
/*
- * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
+ * Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
View
119 usr.bin/mandoc/chars.c → contrib/mdocml/chars.c
@@ -1,6 +1,6 @@
-/* $Id: chars.c,v 1.17 2010/03/23 13:25:01 kristaps Exp $ */
+/* $Id: chars.c,v 1.31 2011/01/02 10:10:57 kristaps Exp $ */
/*
- * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
+ * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -14,11 +14,16 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "mandoc.h"
#include "chars.h"
#define PRINT_HI 126
@@ -28,47 +33,43 @@ struct ln {
struct ln *next;
const char *code;
const char *ascii;
- const char *html;
- size_t codesz;
- size_t asciisz;
- size_t htmlsz;
+ int unicode;
int type;
#define CHARS_CHAR (1 << 0)
#define CHARS_STRING (1 << 1)
#define CHARS_BOTH (CHARS_CHAR | CHARS_STRING)
};
-#define LINES_MAX 369
+#define LINES_MAX 351
-#define CHAR(w, x, y, z, a, b) \
- { NULL, (w), (y), (a), (x), (z), (b), CHARS_CHAR },
-#define STRING(w, x, y, z, a, b) \
- { NULL, (w), (y), (a), (x), (z), (b), CHARS_STRING },
-#define BOTH(w, x, y, z, a, b) \
- { NULL, (w), (y), (a), (x), (z), (b), CHARS_BOTH },
+#define CHAR(in, ch, code) \
+ { NULL, (in), (ch), (code), CHARS_CHAR },
+#define STRING(in, ch, code) \
+ { NULL, (in), (ch), (code), CHARS_STRING },
+#define BOTH(in, ch, code) \
+ { NULL, (in), (ch), (code), CHARS_BOTH },
#define CHAR_TBL_START static struct ln lines[LINES_MAX] = {
#define CHAR_TBL_END };
#include "chars.in"
-struct tbl {
+struct ctab {
enum chars type;
struct ln **htab;
};
static inline int match(const struct ln *,
const char *, size_t, int);
-static const char *find(struct tbl *, const char *,
- size_t, size_t *, int);
+static const struct ln *find(struct ctab *, const char *, size_t, int);
void
chars_free(void *arg)
{
- struct tbl *tab;
+ struct ctab *tab;
- tab = (struct tbl *)arg;
+ tab = (struct ctab *)arg;
free(tab->htab);
free(tab);
@@ -78,7 +79,7 @@ chars_free(void *arg)
void *
chars_init(enum chars type)
{
- struct tbl *tab;
+ struct ctab *tab;
struct ln **htab;
struct ln *pp;
int i, hash;
@@ -90,16 +91,16 @@ chars_init(enum chars type)
* (they're in-line re-ordered during lookup).
*/
- tab = malloc(sizeof(struct tbl));
+ tab = malloc(sizeof(struct ctab));
if (NULL == tab) {
perror(NULL);
- exit(EXIT_FAILURE);
+ exit((int)MANDOCLEVEL_SYSERR);
}
htab = calloc(PRINT_HI - PRINT_LO + 1, sizeof(struct ln **));
if (NULL == htab) {
perror(NULL);
- exit(EXIT_FAILURE);
+ exit((int)MANDOCLEVEL_SYSERR);
}
for (i = 0; i < LINES_MAX; i++) {
@@ -121,31 +122,80 @@ chars_init(enum chars type)
}
+/*
+ * Special character to Unicode codepoint.
+ */
+int
+chars_spec2cp(void *arg, const char *p, size_t sz)
+{
+ const struct ln *ln;
+
+ ln = find((struct ctab *)arg, p, sz, CHARS_CHAR);
+ if (NULL == ln)
+ return(-1);
+ return(ln->unicode);
+}
+
+
+/*
+ * Reserved word to Unicode codepoint.
+ */
+int
+chars_res2cp(void *arg, const char *p, size_t sz)
+{
+ const struct ln *ln;
+
+ ln = find((struct ctab *)arg, p, sz, CHARS_STRING);
+ if (NULL == ln)
+ return(-1);
+ return(ln->unicode);
+}
+
+
+/*
+ * Special character to string array.
+ */
const char *
-chars_a2ascii(void *arg, const char *p, size_t sz, size_t *rsz)
+chars_spec2str(void *arg, const char *p, size_t sz, size_t *rsz)
{
+ const struct ln *ln;
+
+ ln = find((struct ctab *)arg, p, sz, CHARS_CHAR);
+ if (NULL == ln)
+ return(NULL);
- return(find((struct tbl *)arg, p, sz, rsz, CHARS_CHAR));
+ *rsz = strlen(ln->ascii);
+ return(ln->ascii);
}
+/*
+ * Reserved word to string array.
+ */
const char *
-chars_a2res(void *arg, const char *p, size_t sz, size_t *rsz)
+chars_res2str(void *arg, const char *p, size_t sz, size_t *rsz)
{
+ const struct ln *ln;
+
+ ln = find((struct ctab *)arg, p, sz, CHARS_STRING);
+ if (NULL == ln)
+ return(NULL);
- return(find((struct tbl *)arg, p, sz, rsz, CHARS_STRING));
+ *rsz = strlen(ln->ascii);
+ return(ln->ascii);
}
-static const char *
-find(struct tbl *tab, const char *p, size_t sz, size_t *rsz, int type)
+static const struct ln *
+find(struct ctab *tab, const char *p, size_t sz, int type)
{
struct ln *pp, *prev;
struct ln **htab;
int hash;
assert(p);
- assert(sz > 0);
+ if (0 == sz)
+ return(NULL);
if (p[0] < PRINT_LO || p[0] > PRINT_HI)
return(NULL);
@@ -174,12 +224,7 @@ find(struct tbl *tab, const char *p, size_t sz, size_t *rsz, int type)
htab[hash] = pp;
}
- if (CHARS_HTML == tab->type) {
- *rsz = pp->htmlsz;
- return(pp->html);
- }
- *rsz = pp->asciisz;
- return(pp->ascii);
+ return(pp);
}
return(NULL);
@@ -192,7 +237,7 @@ match(const struct ln *ln, const char *p, size_t sz, int type)
if ( ! (ln->type & type))
return(0);
- if (ln->codesz != sz)
+ if (strncmp(ln->code, p, sz))
return(0);
- return(0 == strncmp(ln->code, p, sz));
+ return('\0' == ln->code[(int)sz]);
}
View
10 usr.bin/mandoc/chars.h → contrib/mdocml/chars.h
@@ -1,6 +1,6 @@
-/* $Id: chars.h,v 1.1 2009/09/17 07:41:28 kristaps Exp $ */
+/* $Id: chars.h,v 1.6 2010/07/31 23:52:58 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
+ * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -25,8 +25,10 @@ enum chars {
};
void *chars_init(enum chars);
-const char *chars_a2ascii(void *, const char *, size_t, size_t *);
-const char *chars_a2res(void *, const char *, size_t, size_t *);
+const char *chars_spec2str(void *, const char *, size_t, size_t *);
+int chars_spec2cp(void *, const char *, size_t);
+const char *chars_res2str(void *, const char *, size_t, size_t *);
+int chars_res2cp(void *, const char *, size_t);
void chars_free(void *);
__END_DECLS
View
425 contrib/mdocml/chars.in
@@ -0,0 +1,425 @@
+/* $Id: chars.in,v 1.35 2010/09/15 13:10:30 kristaps Exp $ */
+/*
+ * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
+ *
+ * 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 AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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.
+ */
+
+/*
+ * The ASCII translation tables. STRING corresponds to predefined
+ * strings (cf. mdoc_samples.7 and tmac/mdoc/doc-nroff). CHAR
+ * corresponds to special characters (cf. groff_char.7). BOTH contains
+ * sequences that are equivalent in both STRING and CHAR.
+ *
+ * Either way, the left-hand side corresponds to the input sequence (\x,
+ * \(xx, \*(xx and so on) whose length is listed second element. The
+ * right-hand side is what's produced by the front-end, with the fourth
+ * element being its length.
+ *
+ * XXX - C-escape strings!
+ * XXX - update LINES_MAX if adding more!
+ */
+
+/* Non-breaking, non-collapsing space uses unit separator. */
+static const char ascii_nbrsp[2] = { ASCII_NBRSP, '\0' };
+
+CHAR_TBL_START
+
+/* Spacing. */
+CHAR("c", "", 0)
+CHAR("0", " ", 8194)
+CHAR(" ", ascii_nbrsp, 160)
+CHAR("~", ascii_nbrsp, 160)
+CHAR("%", "", 0)
+CHAR("&", "", 0)
+CHAR("^", "", 0)
+CHAR("|", "", 0)
+CHAR("}", "", 0)
+
+/* Accents. */
+CHAR("a\"", "\"", 779)
+CHAR("a-", "-", 175)
+CHAR("a.", ".", 729)
+CHAR("a^", "^", 770)
+BOTH("\'", "\'", 769)
+BOTH("aa", "\'", 769)
+BOTH("ga", "`", 768)
+BOTH("`", "`", 768)
+CHAR("ab", "`", 774)
+CHAR("ac", ",", 807)
+CHAR("ad", "\"", 776)
+CHAR("ah", "v", 711)
+CHAR("ao", "o", 730)
+CHAR("a~", "~", 771)
+CHAR("ho", ",", 808)
+CHAR("ha", "^", 94)
+CHAR("ti", "~", 126)
+
+/* Quotes. */
+CHAR("Bq", ",,", 8222)
+CHAR("bq", ",", 8218)
+BOTH("lq", "``", 8220)
+BOTH("rq", "\'\'", 8221)
+CHAR("oq", "`", 8216)
+CHAR("cq", "\'", 8217)
+CHAR("aq", "\'", 39)
+CHAR("dq", "\"", 34)
+CHAR("Fo", "<<", 171)
+CHAR("Fc", ">>", 187)
+CHAR("fo", "<", 8249)
+CHAR("fc", ">", 8250)
+
+/* Brackets. */
+CHAR("lB", "[", 91)
+CHAR("rB", "]", 93)
+CHAR("lC", "{", 123)
+CHAR("rC", "}", 125)
+CHAR("la", "<", 60)
+CHAR("ra", ">", 62)
+CHAR("bv", "|", 9130)
+CHAR("braceex", "|", 9130)
+CHAR("bracketlefttp", "|", 9121)
+CHAR("bracketleftbp", "|", 9123)
+CHAR("bracketleftex", "|", 9122)
+CHAR("bracketrighttp", "|", 9124)
+CHAR("bracketrightbp", "|", 9126)
+CHAR("bracketrightex", "|", 9125)
+CHAR("lt", ",-", 9127)
+CHAR("bracelefttp", ",-", 9127)
+CHAR("lk", "{", 9128)
+CHAR("braceleftmid", "{", 9128)
+CHAR("lb", ",-", 9129)
+CHAR("braceleftbp", "`-", 9129)
+CHAR("braceleftex", "|", 9130)
+CHAR("rt", "-.", 9131)
+CHAR("bracerighttp", "-.", 9131)
+CHAR("rk", "}", 9132)
+CHAR("bracerightmid", "}", 9132)
+CHAR("rb", "-\'", 9133)
+CHAR("bracerightbp", "-\'", 9133)
+CHAR("bracerightex", "|", 9130)
+CHAR("parenlefttp", "/", 9115)
+CHAR("parenleftbp", "\\", 9117)
+CHAR("parenleftex", "|", 9116)
+CHAR("parenrighttp", "\\", 9118)
+CHAR("parenrightbp", "/", 9120)
+CHAR("parenrightex", "|", 9119)
+
+/* Greek characters. */
+CHAR("*A", "A", 913)
+CHAR("*B", "B", 914)
+CHAR("*G", "|", 915)
+CHAR("*D", "/\\", 916)
+CHAR("*E", "E", 917)
+CHAR("*Z", "Z", 918)
+CHAR("*Y", "H", 919)
+CHAR("*H", "O", 920)
+CHAR("*I", "I", 921)
+CHAR("*K", "K", 922)
+CHAR("*L", "/\\", 923)
+CHAR("*M", "M", 924)
+CHAR("*N", "N", 925)
+CHAR("*C", "H", 926)
+CHAR("*O", "O", 927)
+CHAR("*P", "TT", 928)
+CHAR("*R", "P", 929)
+CHAR("*S", ">", 931)
+CHAR("*T", "T", 932)
+CHAR("*U", "Y", 933)
+CHAR("*F", "O_", 934)
+CHAR("*X", "X", 935)
+CHAR("*Q", "Y", 936)
+CHAR("*W", "O", 937)
+CHAR("*a", "a", 945)
+CHAR("*b", "B", 946)
+CHAR("*g", "y", 947)
+CHAR("*d", "d", 948)
+CHAR("*e", "e", 949)
+CHAR("*z", "C", 950)
+CHAR("*y", "n", 951)
+CHAR("*h", "0", 952)
+CHAR("*i", "i", 953)
+CHAR("*k", "k", 954)
+CHAR("*l", "\\", 955)
+CHAR("*m", "u", 956)
+CHAR("*n", "v", 957)
+CHAR("*c", "E", 958)
+CHAR("*o", "o", 959)
+CHAR("*p", "n", 960)
+CHAR("*r", "p", 961)
+CHAR("*s", "o", 963)
+CHAR("*t", "t", 964)
+CHAR("*u", "u", 965)
+CHAR("*f", "o", 981)
+CHAR("*x", "x", 967)
+CHAR("*q", "u", 968)
+CHAR("*w", "w", 969)
+CHAR("+h", "0", 977)
+CHAR("+f", "o", 966)
+CHAR("+p", "w", 982)
+CHAR("+e", "e", 1013)
+CHAR("ts", "s", 962)
+
+/* Accented letters. */
+CHAR(",C", "C", 199)
+CHAR(",c", "c", 231)
+CHAR("/L", "L", 321)
+CHAR("/O", "O", 216)
+CHAR("/l", "l", 322)
+CHAR("/o", "o", 248)
+CHAR("oA", "A", 197)
+CHAR("oa", "a", 229)
+CHAR(":A", "A", 196)
+CHAR(":E", "E", 203)
+CHAR(":I", "I", 207)
+CHAR(":O", "O", 214)
+CHAR(":U", "U", 220)
+CHAR(":a", "a", 228)
+CHAR(":e", "e", 235)
+CHAR(":i", "i", 239)
+CHAR(":o", "o", 245)
+CHAR(":u", "u", 252)
+CHAR(":y", "y", 255)
+CHAR("\'A", "A", 193)
+CHAR("\'E", "E", 201)
+CHAR("\'I", "I", 205)
+CHAR("\'O", "O", 211)
+CHAR("\'U", "U", 218)
+CHAR("\'a", "a", 225)
+CHAR("\'e", "e", 233)
+CHAR("\'i", "i", 237)
+CHAR("\'o", "o", 243)
+CHAR("\'u", "u", 250)
+CHAR("^A", "A", 194)
+CHAR("^E", "E", 202)
+CHAR("^I", "I", 206)
+CHAR("^O", "O", 212)
+CHAR("^U", "U", 219)
+CHAR("^a", "a", 226)
+CHAR("^e", "e", 234)
+CHAR("^i", "i", 238)
+CHAR("^o", "o", 244)
+CHAR("^u", "u", 251)
+CHAR("`A", "A", 192)
+CHAR("`E", "E", 200)
+CHAR("`I", "I", 204)
+CHAR("`O", "O", 210)
+CHAR("`U", "U", 217)
+CHAR("`a", "a", 224)
+CHAR("`e", "e", 232)
+CHAR("`i", "i", 236)
+CHAR("`o", "o", 242)
+CHAR("`u", "u", 249)
+CHAR("~A", "A", 195)
+CHAR("~N", "N", 209)
+CHAR("~O", "O", 213)
+CHAR("~a", "a", 227)
+CHAR("~n", "n", 241)
+CHAR("~o", "o", 245)
+
+/* Arrows and lines. */
+CHAR("<-", "<-", 8592)
+CHAR("->", "->", 8594)
+CHAR("<>", "<>", 8596)
+CHAR("da", "v", 8595)
+BOTH("ua", "^", 8593)
+BOTH("va", "^v", 8597)
+CHAR("lA", "<=", 8656)
+CHAR("rA", "=>", 8658)
+CHAR("hA", "<=>", 8660)
+CHAR("dA", "v", 8659)
+CHAR("uA", "^", 8657)
+CHAR("vA", "^=v", 8661)
+
+/* Logic. */
+CHAR("AN", "^", 8743)
+CHAR("OR", "v", 8744)
+CHAR("no", "~", 172)
+CHAR("tno", "~", 172)
+CHAR("te", "3", 8707)
+CHAR("fa", "V", 8704)
+CHAR("st", "-)", 8715)
+CHAR("tf", ".:.", 8756)
+CHAR("3d", ".:.", 8756)
+CHAR("or", "|", 124)
+
+/* Mathematicals. */
+CHAR("pl", "+", 43)
+CHAR("mi", "-", 8722)
+CHAR("-", "-", 45)
+CHAR("-+", "-+", 8723)
+CHAR("+-", "+-", 177)
+CHAR("t+-", "+-", 177)
+CHAR("pc", ".", 183)
+CHAR("md", ".", 8901)
+CHAR("mu", "x", 215)
+CHAR("tmu", "x", 215)
+CHAR("c*", "x", 8855)
+CHAR("c+", "+", 8853)
+CHAR("di", "-:-", 247)
+CHAR("tdi", "-:-", 247)
+CHAR("f/", "/", 8260)
+CHAR("**", "*", 8727)
+BOTH("<=", "<=", 8804)
+BOTH(">=", ">=", 8805)
+CHAR("<<", "<<", 8810)
+CHAR(">>", ">>", 8811)
+CHAR("eq", "=", 61)
+CHAR("!=", "!=", 8800)
+CHAR("==", "==", 8801)
+CHAR("ne", "!==", 8802)
+CHAR("=~", "=~", 8773)
+CHAR("-~", "-~", 8771)
+CHAR("ap", "~", 8764)
+CHAR("~~", "~~", 8776)
+CHAR("~=", "~=", 8780)
+CHAR("pt", "oc", 8733)
+CHAR("es", "{}", 8709)
+CHAR("mo", "E", 8712)
+CHAR("nm", "!E", 8713)
+CHAR("sb", "(=", 8834)
+CHAR("nb", "(!=", 8836)
+CHAR("sp", "=)", 8835)
+CHAR("nc", "!=)", 8837)
+CHAR("ib", "(=", 8838)
+CHAR("ip", "=)", 8839)
+CHAR("ca", "(^)", 8745)
+CHAR("cu", "U", 8746)
+CHAR("/_", "/_", 8736)
+CHAR("pp", "_|_", 8869)
+CHAR("is", "I", 8747)
+CHAR("integral", "I", 8747)
+CHAR("sum", "E", 8721)
+CHAR("product", "TT", 8719)
+CHAR("coproduct", "U", 8720)
+CHAR("gr", "V", 8711)
+CHAR("sr", "\\/", 8730)
+CHAR("sqrt", "\\/", 8730)
+CHAR("lc", "|~", 8968)
+CHAR("rc", "~|", 8969)
+CHAR("lf", "|_", 8970)
+CHAR("rf", "_|", 8971)
+CHAR("if", "oo", 8734)
+CHAR("Ah", "N", 8501)
+CHAR("Im", "I", 8465)
+CHAR("Re", "R", 8476)
+CHAR("pd", "a", 8706)
+CHAR("-h", "/h", 8463)
+
+/* Ligatures. */
+CHAR("ff", "ff", 64256)
+CHAR("fi", "fi", 64257)
+CHAR("fl", "fl", 64258)
+CHAR("Fi", "ffi", 64259)
+CHAR("Fl", "ffl", 64260)
+CHAR("AE", "AE", 198)
+CHAR("ae", "ae", 230)
+CHAR("OE", "OE", 338)
+CHAR("oe", "oe", 339)
+CHAR("ss", "ss", 223)
+CHAR("IJ", "IJ", 306)
+CHAR("ij", "ij", 307)
+
+/* Special letters. */
+CHAR("-D", "D", 208)
+CHAR("Sd", "o", 240)
+CHAR("TP", "b", 222)
+CHAR("Tp", "b", 254)
+CHAR(".i", "i", 305)
+CHAR(".j", "j", 567)
+
+/* Currency. */
+CHAR("Do", "$", 36)
+CHAR("ct", "c", 162)
+CHAR("Eu", "EUR", 8364)
+CHAR("eu", "EUR", 8364)
+CHAR("Ye", "Y", 165)
+CHAR("Po", "L", 163)
+CHAR("Cs", "x", 164)
+CHAR("Fn", "f", 402)
+
+/* Old style. */
+STRING("Am", "&", 38)
+STRING("Ba", "|", 124)
+STRING("Ge", ">=", 8805)
+STRING("Gt", ">", 62)
+STRING("If", "infinity", 0)
+STRING("Le", "<=", 8804)
+STRING("Lq", "``", 8220)
+STRING("Lt", "<", 60)
+STRING("Na", "NaN", 0)
+STRING("Ne", "!=", 8800)
+STRING("Pi", "pi", 960)
+STRING("Pm", "+-", 177)
+STRING("Rq", "\'\'", 8221)
+STRING("left-bracket", "[", 91)
+STRING("left-parenthesis", "(", 40)
+STRING("left-singlequote", "`", 8216)
+STRING("lp", "(", 40)
+STRING("q", "\"", 34)
+STRING("quote-left", "`", 8216)
+STRING("quote-right", "\'", 8217)
+STRING("R", "(R)", 174)
+STRING("right-bracket", "]", 93)
+STRING("right-parenthesis", ")", 41)
+STRING("right-singlequote", "\'", 8217)
+STRING("rp", ")", 41)
+STRING("Tm", "(Tm)", 8482)
+
+/* Lines. */
+CHAR("ba", "|", 124)
+CHAR("br", "|", 9474)
+CHAR("ul", "_", 95)
+CHAR("rl", "-", 8254)
+CHAR("bb", "|", 166)
+CHAR("sl", "/", 47)
+CHAR("rs", "\\", 92)
+
+/* Text markers. */
+CHAR("ci", "o", 9675)
+CHAR("bu", "o", 8226)
+CHAR("dd", "=", 8225)
+CHAR("dg", "-", 8224)
+CHAR("lz", "<>", 9674)
+CHAR("sq", "[]", 9633)
+CHAR("ps", "9|", 182)
+CHAR("sc", "S", 167)
+CHAR("lh", "<=", 9756)
+CHAR("rh", "=>", 9758)
+CHAR("at", "@", 64)
+CHAR("sh", "#", 35)
+CHAR("CR", "_|", 8629)
+CHAR("OK", "\\/", 10003)
+
+/* Legal symbols. */
+CHAR("co", "(C)", 169)
+CHAR("rg", "(R)", 174)
+CHAR("tm", "tm", 8482)
+
+/* Punctuation. */
+CHAR(".", ".", 46)
+CHAR("r!", "i", 161)
+CHAR("r?", "c", 191)
+CHAR("em", "--", 8212)
+CHAR("en", "-", 8211)
+CHAR("hy", "-", 8208)
+CHAR("e", "\\", 92)
+
+/* Units. */
+CHAR("de", "o", 176)
+CHAR("%0", "%o", 8240)
+CHAR("fm", "\'", 8242)
+CHAR("sd", "\"", 8243)
+CHAR("mc", "mu", 181)
+
+CHAR_TBL_END
View
95 contrib/mdocml/compat.c
@@ -0,0 +1,95 @@
+/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * 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 AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <string.h>
+
+int dummy; /* To prevent an empty object file */
+
+#ifndef HAVE_STRLCAT
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left). At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+ size_t dlen;
+
+ /* Find the end of dst and adjust bytes left but don't go past end */
+ while (n-- != 0 && *d != '\0')
+ d++;
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return(dlen + strlen(s));
+ while (*s != '\0') {
+ if (n != 1) {
+ *d++ = *s;
+ n--;
+ }
+ s++;
+ }
+ *d = '\0';
+
+ return(dlen + (s - src)); /* count does not include NUL */
+}
+#endif
+
+#ifndef HAVE_STRLCPY
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0) {
+ while (--n != 0) {
+ if ((*d++ = *s++) == '\0')
+ break;
+ }
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}
+#endif
View
25 contrib/mdocml/config.h.post
@@ -0,0 +1,25 @@
+#include <sys/types.h>
+
+#if !defined(__BEGIN_DECLS)
+# ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# else
+# define __BEGIN_DECLS
+# endif
+#endif
+#if !defined(__END_DECLS)
+# ifdef __cplusplus
+# define __END_DECLS }
+# else
+# define __END_DECLS
+# endif
+#endif
+
+#ifndef HAVE_STRLCAT
+extern size_t strlcat(char *, const char *, size_t);
+#endif
+#ifndef HAVE_STRLCPY
+extern size_t strlcpy(char *, const char *, size_t);
+#endif
+
+#endif /* MANDOC_CONFIG_H */
View
6 contrib/mdocml/config.h.pre
@@ -0,0 +1,6 @@
+#ifndef MANDOC_CONFIG_H
+#define MANDOC_CONFIG_H
+
+#if defined(__linux__) || defined(__MINT__)
+# define _GNU_SOURCE /* strptime(), getsubopt() */
+#endif
View
146 contrib/mdocml/example.style.css
@@ -0,0 +1,146 @@
+/* $Id: example.style.css,v 1.41 2011/01/05 13:00:11 kristaps Exp $ */
+
+/*
+ * This is an example style-sheet provided for mandoc(1) and the -Thtml
+ * or -Txhtml output mode.
+ *
+ * It mimics the appearance of the traditional cvsweb output.
+ *
+ * See mdoc(7) and man(7) for macro explanations.
+ */
+
+html { min-width: 580px; width: 580px; }
+body { font-family: monospace; }
+
+/* Preamble structure. */
+
+table.foot { width: 100%; } /* Document footer. */
+td.foot-date { width: 50%; } /* Document footer: date. */
+td.foot-os { width: 50%; text-align: right; } /* Document footer: OS/source. */
+table.head { width: 100%; } /* Document header. */
+td.head-ltitle { width: 10%; } /* Document header: left-title. */
+td.head-vol { width: 80%; text-align: center; } /* Document header: volume. */
+td.head-rtitle { width: 10%; text-align: right; } /* Document header: right-title. */
+
+/* Sections. */
+
+h1 { margin-bottom: 0px; font-size: medium; margin-left: -4ex; } /* Section header (Sh, SH). */
+h2 { margin-bottom: 0px; font-size: medium; margin-left: -2ex; } /* Sub-section header (Ss, SS). */
+div.section { margin-bottom: 2ex; margin-left: 4ex; } /* Sections (Sh, SH). */
+div.subsection { } /* Sub-sections (Ss, SS). */
+table.synopsis { } /* SYNOPSIS section table. */
+
+/* Vertical spacing. */
+
+p { } /* Paragraph: Pp, Lp. */
+blockquote { margin-top: 0px; margin-bottom: 0px; }
+table { margin-top: 0px; margin-bottom: 0px; }
+td { vertical-align: top; }
+
+/* General font modes. */
+
+i { } /* Italic: BI, IB, I, (implicit). */
+.emph { font-style: italic; font-weight: normal; } /* Emphasis: Em, Bl -emphasis. */
+b { } /* Bold: SB, BI, IB, BR, RB, B, (implicit). */
+.symb { font-style: normal; font-weight: bold; } /* Symbolic: Sy, Ms, Bf -symbolic. */
+small { } /* Small: SB, SM. */
+
+/* Block modes. */
+
+.display { } /* Top of all Bd, D1, Dl. */
+.list { } /* Top of all Bl. */
+
+/* Context-specific modes. */
+
+i.addr { font-weight: normal; } /* Address (Ad). */
+i.arg { font-weight: normal; } /* Command argument (Ar). */
+span.author { } /* Author name (An). */
+b.cmd { font-style: normal; } /* Command (Cm). */
+b.config { font-style: normal; } /* Config statement (Cd). */
+span.define { } /* Defines (Dv). */
+span.desc { } /* Nd. After em-dash. */
+b.diag { font-style: normal; } /* Diagnostic (Bl -diag). */
+span.env { } /* Environment variables (Ev). */
+span.errno { } /* Error string (Er). */
+i.farg { font-weight: normal; } /* Function argument (Fa, Fn). */
+i.file { font-weight: normal; } /* File (Pa). */
+b.flag { font-style: normal; } /* Flag (Fl, Cm). */
+b.fname { font-style: normal; } /* Function name (Fa, Fn, Rv). */
+i.ftype { font-weight: normal; } /* Function types (Ft, Fn). */
+b.includes { font-style: normal; } /* Header includes (In). */
+span.lib { } /* Library (Lb). */
+i.link-sec { font-weight: normal; } /* Section links (Sx). */
+code.lit { font-style: normal; font-weight: normal; } /* Literal: Dl, Li, Bf -literal, Bl -literal, Bl -unfilled. */
+b.macro { font-style: normal; } /* Macro-ish thing (Fd). */
+b.name { font-style: normal; } /* Name of utility (Nm). */
+span.opt { } /* Options (Op, Oo/Oc). */
+span.ref { } /* Citations (Rs). */
+span.ref-auth { } /* Reference author (%A). */
+i.ref-book { font-weight: normal; } /* Reference book (%B). */
+span.ref-city { } /* Reference city (%C). */
+span.ref-date { } /* Reference date (%D). */
+i.ref-issue { font-weight: normal; } /* Reference issuer/publisher (%I). */
+i.ref-jrnl { font-weight: normal; } /* Reference journal (%J). */
+span.ref-num { } /* Reference number (%N). */
+span.ref-opt { } /* Reference optionals (%O). */
+span.ref-page { } /* Reference page (%P). */
+span.ref-corp { } /* Reference corporate/foreign author (%Q). */
+span.ref-rep { } /* Reference report (%R). */
+span.ref-title { text-decoration: underline; } /* Reference title (%T). */
+span.ref-vol { } /* Reference volume (%V). */
+span.type { font-style: italic; font-weight: normal; } /* Variable types (Vt). */
+span.unix { } /* Unices (Ux, Ox, Nx, Fx, Bx, Bsx, Dx). */
+b.utility { font-style: normal; } /* Name of utility (Ex). */
+b.var { font-style: normal; } /* Variables (Rv). */
+
+a.link-ext { } /* Off-site link (Lk). */
+a.link-includes { } /* Include-file link (In). */
+a.link-mail { } /* Mailto links (Mt). */
+a.link-man { } /* Manual links (Xr). */
+a.link-ref { } /* Reference section links (%Q). */
+a.link-sec { } /* Section links (Sx). */
+
+/* Formatting for lists. See mdoc(7). */
+
+dl.list-diag { }
+dt.list-diag { }
+dd.list-diag { }
+
+dl.list-hang { }
+dt.list-hang { }
+dd.list-hang { }
+
+dl.list-inset { }
+dt.list-inset { }
+dd.list-inset { }
+
+dl.list-ohang { }
+dt.list-ohang { }
+dd.list-ohang { margin-left: 0em; }
+
+dl.list-tag { }
+dt.list-tag { }
+dd.list-tag { }
+
+table.list-col { }
+tr.list-col { }
+td.list-col { }
+
+ul.list-bul { list-style-type: disc; padding-left: 1em; }
+li.list-bul { }
+
+ul.list-dash { list-style-type: none; padding-left: 0em; }
+li.list-dash:before { content: "\2014 "; }
+
+ul.list-hyph { list-style-type: none; padding-left: 0em; }
+li.list-hyph:before { content: "\2013 "; }
+
+ul.list-item { list-style-type: none; padding-left: 0em; }
+li.list-item { }
+
+ol.list-enum { padding-left: 2em; }
+li.list-enum { }
+
+/* Table modes. See tbl(7). */
+
+table.tbl { }
View
BIN contrib/mdocml/external.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
285 usr.bin/mandoc/html.c → contrib/mdocml/html.c
@@ -1,6 +1,6 @@
-/* $Id: html.c,v 1.96 2010/02/17 19:48:33 kristaps Exp $ */
+/* $Id: html.c,v 1.124 2010/12/27 21:41:05 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
+ * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
@@ -25,13 +29,12 @@
#include <string.h>
#include <unistd.h>
+#include "mandoc.h"
#include "out.h"
#include "chars.h"
#include "html.h"
#include "main.h"
-#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
-
struct htmldata {
const char *name;
int flags;
@@ -50,49 +53,54 @@ static const struct htmldata htmltags[TAG_MAX] = {
{"h1", 0}, /* TAG_H1 */
{"h2", 0}, /* TAG_H2 */
{"span", 0}, /* TAG_SPAN */
- {"link", HTML_CLRLINE | HTML_NOSTACK}, /* TAG_LINK */
+ {"link", HTML_CLRLINE | HTML_NOSTACK | HTML_AUTOCLOSE}, /* TAG_LINK */
{"br", HTML_CLRLINE | HTML_NOSTACK | HTML_AUTOCLOSE}, /* TAG_BR */
{"a", 0}, /* TAG_A */
{"table", HTML_CLRLINE}, /* TAG_TABLE */
+ {"tbody", HTML_CLRLINE}, /* TAG_TBODY */
{"col", HTML_CLRLINE | HTML_NOSTACK | HTML_AUTOCLOSE}, /* TAG_COL */
{"tr", HTML_CLRLINE}, /* TAG_TR */
{"td", HTML_CLRLINE}, /* TAG_TD */
{"li", HTML_CLRLINE}, /* TAG_LI */
{"ul", HTML_CLRLINE}, /* TAG_UL */
{"ol", HTML_CLRLINE}, /* TAG_OL */
-};
-
-static const char *const htmlfonts[HTMLFONT_MAX] = {
- "roman",
- "bold",
- "italic"
+ {"dl", HTML_CLRLINE}, /* TAG_DL */
+ {"dt", HTML_CLRLINE}, /* TAG_DT */
+ {"dd", HTML_CLRLINE}, /* TAG_DD */
+ {"blockquote", HTML_CLRLINE}, /* TAG_BLOCKQUOTE */
+ {"p", HTML_CLRLINE | HTML_NOSTACK | HTML_AUTOCLOSE}, /* TAG_P */
+ {"pre", HTML_CLRLINE }, /* TAG_PRE */
+ {"b", 0 }, /* TAG_B */
+ {"i", 0 }, /* TAG_I */
+ {"code", 0 }, /* TAG_CODE */
+ {"small", 0 }, /* TAG_SMALL */
};
static const char *const htmlattrs[ATTR_MAX] = {
- "http-equiv",
- "content",
- "name",
- "rel",
- "href",
- "type",
- "media",
- "class",
- "style",
- "width",
- "valign",
- "target",
- "id",
- "summary",
+ "http-equiv", /* ATTR_HTTPEQUIV */
+ "content", /* ATTR_CONTENT */
+ "name", /* ATTR_NAME */
+ "rel", /* ATTR_REL */
+ "href", /* ATTR_HREF */
+ "type", /* ATTR_TYPE */
+ "media", /* ATTR_MEDIA */
+ "class", /* ATTR_CLASS */
+ "style", /* ATTR_STYLE */
+ "width", /* ATTR_WIDTH */
+ "id", /* ATTR_ID */
+ "summary", /* ATTR_SUMMARY */
+ "align", /* ATTR_ALIGN */
};
-static void print_spec(struct html *, const char *, size_t);
+static void print_spec(struct html *, enum roffdeco,
+ const char *, size_t);
static void print_res(struct html *, const char *, size_t);
static void print_ctag(struct html *, enum htmltag);
static void print_doctype(struct html *);
static void print_xmltype(struct html *);
static int print_encode(struct html *, const char *, int);
static void print_metaf(struct html *, enum roffdeco);
-static void print_attr(struct html *,
+static void print_attr(struct html *,
const char *, const char *);
static void *ml_alloc(char *, enum htmltype);
@@ -112,12 +120,11 @@ ml_alloc(char *outopts, enum htmltype type)
h = calloc(1, sizeof(struct html));
if (NULL == h) {
perror(NULL);
- exit(EXIT_FAILURE);
+ exit((int)MANDOCLEVEL_SYSERR);
}
h->type = type;
h->tags.head = NULL;
- h->ords.head = NULL;
h->symtab = chars_init(CHARS_HTML);
while (outopts && *outopts)
@@ -158,21 +165,15 @@ void
html_free(void *p)
{
struct tag *tag;
- struct ord *ord;
struct html *h;
h = (struct html *)p;
- while ((ord = h->ords.head) != NULL) {
- h->ords.head = ord->next;
- free(ord);
- }
-
while ((tag = h->tags.head) != NULL) {
- h->tags.head = tag->next;
+ h->tags.head = tag->next;
free(tag);
}
-
+
if (h->symtab)
chars_free(h->symtab);
@@ -212,49 +213,41 @@ print_gen_head(struct html *h)
static void
-print_spec(struct html *h, const char *p, size_t len)
+print_spec(struct html *h, enum roffdeco d, const char *p, size_t len)
{
+ int cp;
const char *rhs;
size_t sz;
- rhs = chars_a2ascii(h->symtab, p, len, &sz);
-
- if (NULL == rhs)
+ if ((cp = chars_spec2cp(h->symtab, p, len)) > 0) {
+ printf("&#%d;", cp);
+ return;
+ } else if (-1 == cp && DECO_SSPECIAL == d) {
+ fwrite(p, 1, len, stdout);
return;
- fwrite(rhs, 1, sz, stdout);
+ } else if (-1 == cp)
+ return;
+
+ if (NULL != (rhs = chars_spec2str(h->symtab, p, len, &sz)))
+ fwrite(rhs, 1, sz, stdout);
}
static void
print_res(struct html *h, const char *p, size_t len)
{
+ int cp;
const char *rhs;
size_t sz;
- rhs = chars_a2res(h->symtab, p, len, &sz);
-
- if (NULL == rhs)
+ if ((cp = chars_res2cp(h->symtab, p, len)) > 0) {
+ printf("&#%d;", cp);
+ return;
+ } else if (-1 == cp)
return;
- fwrite(rhs, 1, sz, stdout);
-}
-
-
-struct tag *
-print_ofont(struct html *h, enum htmlfont font)
-{
- struct htmlpair tag;
-
- h->metal = h->metac;
- h->metac = font;
-
- /* FIXME: DECO_ROMAN should just close out preexisting. */
-
- if (h->metaf && h->tags.head == h->metaf)
- print_tagq(h, h->metaf);
- PAIR_CLASS_INIT(&tag, htmlfonts[font]);
- h->metaf = print_otag(h, TAG_SPAN, 1, &tag);
- return(h->metaf);
+ if (NULL != (rhs = chars_res2str(h->symtab, p, len, &sz)))
+ fwrite(rhs, 1, sz, stdout);
}
@@ -281,7 +274,18 @@ print_metaf(struct html *h, enum roffdeco deco)
/* NOTREACHED */
}
- (void)print_ofont(h, font);
+ if (h->metaf) {
+ print_tagq(h, h->metaf);
+ h->metaf = NULL;
+ }
+
+ h->metal = h->metac;
+ h->metac = font;
+
+ if (HTMLFONT_NONE != font)
+ h->metaf = HTMLFONT_BOLD == font ?
+ print_otag(h, TAG_B, 0, NULL) :
+ print_otag(h, TAG_I, 0, NULL);
}
@@ -292,11 +296,12 @@ print_encode(struct html *h, const char *p, int norecurse)
int len, nospace;
const char *seq;
enum roffdeco deco;
+ static const char rejs[6] = { '\\', '<', '>', '&', ASCII_HYPH, '\0' };
nospace = 0;
for (; *p; p++) {
- sz = strcspn(p, "\\<>&");
+ sz = strcspn(p, rejs);
fwrite(p, 1, sz, stdout);
p += /* LINTED */
@@ -311,6 +316,15 @@ print_encode(struct html *h, const char *p, int norecurse)
} else if ('&' == *p) {
printf("&amp;");
continue;
+ } else if (ASCII_HYPH == *p) {
+ /*
+ * Note: "soft hyphens" aren't graphically
+ * displayed when not breaking the text; we want
+ * them to be displayed.
+ */
+ /*printf("&#173;");*/
+ putchar('-');
+ continue;
} else if ('\0' == *p)
break;
@@ -321,8 +335,10 @@ print_encode(struct html *h, const char *p, int norecurse)
case (DECO_RESERVED):
print_res(h, seq, sz);
break;
+ case (DECO_SSPECIAL):
+ /* FALLTHROUGH */
case (DECO_SPECIAL):
- print_spec(h, seq, sz);
+ print_spec(h, deco, seq, sz);
break;
case (DECO_PREVIOUS):
/* FALLTHROUGH */
@@ -359,7 +375,7 @@ print_attr(struct html *h, const char *key, const char *val)
struct tag *
-print_otag(struct html *h, enum htmltag tag,
+print_otag(struct html *h, enum htmltag tag,
int sz, const struct htmlpair *p)
{
int i;
@@ -371,7 +387,7 @@ print_otag(struct html *h, enum htmltag tag,
t = malloc(sizeof(struct tag));
if (NULL == t) {
perror(NULL);
- exit(EXIT_FAILURE);
+ exit((int)MANDOCLEVEL_SYSERR);
}
t->tag = tag;
t->next = h->tags.head;
@@ -380,8 +396,20 @@ print_otag(struct html *h, enum htmltag tag,
t = NULL;
if ( ! (HTML_NOSPACE & h->flags))
- if ( ! (HTML_CLRLINE & htmltags[tag].flags))
- putchar(' ');
+ if ( ! (HTML_CLRLINE & htmltags[tag].flags)) {
+ /* Manage keeps! */
+ if ( ! (HTML_KEEP & h->flags)) {
+ if (HTML_PREKEEP & h->flags)
+ h->flags |= HTML_KEEP;
+ putchar(' ');
+ } else
+ printf("&#160;");
+ }
+
+ if ( ! (h->flags & HTML_NONOSPACE))
+ h->flags &= ~HTML_NOSPACE;
+ else
+ h->flags |= HTML_NOSPACE;
/* Print out the tag name and attributes. */
@@ -411,19 +439,23 @@ print_otag(struct html *h, enum htmltag tag,
putchar('>');
h->flags |= HTML_NOSPACE;
+
+ if ((HTML_AUTOCLOSE | HTML_CLRLINE) & htmltags[tag].flags)
+ putchar('\n');
+
return(t);
}
static void
print_ctag(struct html *h, enum htmltag tag)
{
-
+
printf("</%s>", htmltags[tag].name);
if (HTML_CLRLINE & htmltags[tag].flags) {
h->flags |= HTML_NOSPACE;
putchar('\n');
- }
+ }
}
@@ -439,21 +471,9 @@ print_gen_decls(struct html *h)
static void
print_xmltype(struct html *h)
{
- const char *decl;
- switch (h->type) {
- case (HTML_XHTML_1_0_STRICT):
- decl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
- break;
- default:
- decl = NULL;
- break;
- }
-
- if (NULL == decl)
- return;
-
- printf("%s\n", decl);
+ if (HTML_XHTML_1_0_STRICT == h->type)
+ puts("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
}
@@ -477,17 +497,17 @@ print_doctype(struct html *h)
break;
}
- printf("<!DOCTYPE %s PUBLIC \"%s\" \"%s\">\n",
+ printf("<!DOCTYPE %s PUBLIC \"%s\" \"%s\">\n",
name, doctype, dtd);
}
void
-print_text(struct html *h, const char *p)
+print_text(struct html *h, const char *word)
{
- if (*p && 0 == *(p + 1))
- switch (*p) {
+ if (word[0] && '\0' == word[1])
+ switch (word[0]) {
case('.'):
/* FALLTHROUGH */
case(','):
@@ -503,29 +523,50 @@ print_text(struct html *h, const char *p)
case(')'):
/* FALLTHROUGH */
case(']'):
- /* FALLTHROUGH */
- case('}'):
if ( ! (HTML_IGNDELIM & h->flags))
h->flags |= HTML_NOSPACE;
break;
default:
break;
}
- if ( ! (h->flags & HTML_NOSPACE))
- putchar(' ');
+ if ( ! (HTML_NOSPACE & h->flags)) {
+ /* Manage keeps! */
+ if ( ! (HTML_KEEP & h->flags)) {
+ if (HTML_PREKEEP & h->flags)
+ h->flags |= HTML_KEEP;
+ putchar(' ');
+ } else
+ printf("&#160;");
+ }
- assert(p);
- if ( ! print_encode(h, p, 0))
- h->flags &= ~HTML_NOSPACE;
+ assert(NULL == h->metaf);
+ if (HTMLFONT_NONE != h->metac)
+ h->metaf = HTMLFONT_BOLD == h->metac ?
+ print_otag(h, TAG_B, 0, NULL) :
+ print_otag(h, TAG_I, 0, NULL);
+
+ assert(word);
+ if ( ! print_encode(h, word, 0))
+ if ( ! (h->flags & HTML_NONOSPACE))
+ h->flags &= ~HTML_NOSPACE;
- if (*p && 0 == *(p + 1))
- switch (*p) {
+ if (h->metaf) {
+ print_tagq(h, h->metaf);
+ h->metaf = NULL;
+ }
+
+ h->flags &= ~HTML_IGNDELIM;
+
+ /*
+ * Note that we don't process the pipe: the parser sees it as
+ * punctuation, but we don't in terms of typography.
+ */
+ if (word[0] && '\0' == word[1])
+ switch (word[0]) {
case('('):
/* FALLTHROUGH */
case('['):
- /* FALLTHROUGH */
- case('{'):
h->flags |= HTML_NOSPACE;
break;
default:
@@ -602,7 +643,7 @@ buffmt(struct html *h, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- (void)vsnprintf(h->buf + (int)h->buflen,
+ (void)vsnprintf(h->buf + (int)h->buflen,
BUFSIZ - h->buflen - 1, fmt, ap);
va_end(ap);
h->buflen = strlen(h->buf);
@@ -627,7 +668,7 @@ buffmt_includes(struct html *h, const char *name)
const char *p, *pp;
pp = h->base_includes;
-
+
while (NULL != (p = strchr(pp, '%'))) {
bufncat(h, pp, (size_t)(p - pp));
switch (*(p + 1)) {
@@ -646,13 +687,13 @@ buffmt_includes(struct html *h, const char *name)
void
-buffmt_man(struct html *h,
+buffmt_man(struct html *h,
const char *name, const char *sec)
{
const char *p, *pp;
pp = h->base_man;
-
+
/* LINTED */
while (NULL != (p = strchr(pp, '%'))) {
bufncat(h, pp, (size_t)(p - pp));
@@ -717,11 +758,11 @@ bufcat_su(struct html *h, const char *p, const struct roffsu *su)
break;
}
- if (su->pt)
- buffmt(h, "%s: %f%s;", p, v, u);
- else
- /* LINTED */
- buffmt(h, "%s: %d%s;", p, (int)v, u);
+ /*
+ * XXX: the CSS spec isn't clear as to which types accept
+ * integer or real numbers, so we just make them all decimals.
+ */
+ buffmt(h, "%s: %.2f%s;", p, v, u);