Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Converted discount to 'fake submodule'

  • Loading branch information...
commit e144b9a4a43870c3a651eb91c6e672b62c3d9376 1 parent 7085215
@vdh vdh authored
Showing with 13,948 additions and 4 deletions.
  1. +0 −3  .gitmodules
  2. +0 −1  discount
  3. +47 −0 discount/COPYRIGHT
  4. +33 −0 discount/CREDITS
  5. +61 −0 discount/Csio.c
  6. +41 −0 discount/INSTALL
  7. +116 −0 discount/Makefile.in
  8. +40 −0 discount/Plan9/README
  9. +169 −0 discount/Plan9/markdown.1
  10. +332 −0 discount/Plan9/markdown.2
  11. +543 −0 discount/Plan9/markdown.6
  12. +37 −0 discount/Plan9/mkfile
  13. +16 −0 discount/README
  14. +1 −0  discount/VERSION
  15. +111 −0 discount/amalloc.c
  16. +29 −0 discount/amalloc.h
  17. +43 −0 discount/basename.c
  18. +1,660 −0 discount/configure.inc
  19. +141 −0 discount/configure.sh
  20. +85 −0 discount/css.c
  21. +77 −0 discount/cstring.h
  22. +49 −0 discount/docheader.c
  23. +152 −0 discount/dumptree.c
  24. +188 −0 discount/emmatch.c
  25. +83 −0 discount/flags.c
  26. +1,643 −0 discount/generate.c
  27. +24 −0 discount/html5.c
  28. +235 −0 discount/main.c
  29. +34 −0 discount/makepage.1
  30. +27 −0 discount/makepage.c
  31. +164 −0 discount/markdown.1
  32. +136 −0 discount/markdown.3
  33. +1,020 −0 discount/markdown.7
  34. +1,219 −0 discount/markdown.c
  35. +169 −0 discount/markdown.h
  36. +71 −0 discount/mkd-callbacks.3
  37. +190 −0 discount/mkd-extensions.7
  38. +182 −0 discount/mkd-functions.3
  39. +41 −0 discount/mkd-line.3
  40. +52 −0 discount/mkd2html.1
  41. +185 −0 discount/mkd2html.c
  42. +344 −0 discount/mkdio.c
  43. +100 −0 discount/mkdio.h.in
  44. +157 −0 discount/resource.c
  45. +47 −0 discount/setup.c
  46. +123 −0 discount/tags.c
  47. +19 −0 discount/tags.h
  48. +27 −0 discount/tests/autolink.t
  49. +27 −0 discount/tests/automatic.t
  50. +16 −0 discount/tests/backslash.t
  51. +17 −0 discount/tests/callbacks.t
  52. +13 −0 discount/tests/chrome.text
  53. +35 −0 discount/tests/code.t
  54. +29 −0 discount/tests/compat.t
  55. +31 −0 discount/tests/crash.t
  56. +49 −0 discount/tests/div.t
  57. +96 −0 discount/tests/dl.t
  58. +9 −0 discount/tests/embedlinks.text
  59. +19 −0 discount/tests/emphasis.t
  60. +33 −0 discount/tests/flow.t
  61. +16 −0 discount/tests/footnotes.t
  62. +77 −0 discount/tests/functions.sh
  63. +26 −0 discount/tests/header.t
  64. +141 −0 discount/tests/html.t
  65. +17 −0 discount/tests/html5.t
  66. +14 −0 discount/tests/links.text
  67. +130 −0 discount/tests/linkylinky.t
  68. +21 −0 discount/tests/linkypix.t
  69. +155 −0 discount/tests/list.t
  70. +38 −0 discount/tests/list3deep.t
  71. +12 −0 discount/tests/misc.t
  72. +44 −0 discount/tests/pandoc.t
  73. +19 −0 discount/tests/para.t
  74. +12 −0 discount/tests/paranoia.t
  75. +77 −0 discount/tests/peculiarities.t
  76. +20 −0 discount/tests/pseudo.t
  77. +27 −0 discount/tests/reddit.t
  78. +14 −0 discount/tests/reparse.t
  79. +91 −0 discount/tests/schiraldi.t
  80. +24 −0 discount/tests/smarty.t
  81. +29 −0 discount/tests/snakepit.t
  82. +15 −0 discount/tests/strikethrough.t
  83. +34 −0 discount/tests/style.t
  84. +17 −0 discount/tests/superscript.t
  85. +897 −0 discount/tests/syntax.text
  86. +167 −0 discount/tests/tables.t
  87. +48 −0 discount/tests/tabstop.t
  88. +35 −0 discount/tests/toc.t
  89. +18 −0 discount/tests/xml.t
  90. +142 −0 discount/theme.1
  91. +609 −0 discount/theme.c
  92. +101 −0 discount/toc.c
  93. +11 −0 discount/tools/checkbits.sh
  94. +38 −0 discount/tools/cols.c
  95. +23 −0 discount/tools/echo.c
  96. +22 −0 discount/version.c.in
  97. +82 −0 discount/xml.c
  98. +48 −0 discount/xmlpage.c
View
3  .gitmodules
@@ -1,3 +0,0 @@
-[submodule "discount"]
- path = discount
- url = git://github.com/Orc/discount.git
1  discount
@@ -1 +0,0 @@
-Subproject commit 566ee12c947302c37e227284741ab2c03d26e8e2
View
47 discount/COPYRIGHT
@@ -0,0 +1,47 @@
+->Copyright (C) 2007 David Loren Parsons.
+All rights reserved.<-
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation files
+(the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicence, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution, and in the same place and form as other
+ copyright, license and disclaimer information.
+
+ 3. The end-user documentation included with the redistribution, if
+ any, must include the following acknowledgment:
+
+ This product includes software developed by
+ David Loren Parsons <http://www.pell.portland.or.us/~orc>
+
+ in the same place and form as other third-party acknowledgments.
+ Alternately, this acknowledgment may appear in the software
+ itself, in the same form and location as other such third-party
+ acknowledgments.
+
+ 4. Except as contained in this notice, the name of David Loren
+ Parsons shall not be used in advertising or otherwise to promote
+ the sale, use or other dealings in this Software without prior
+ written authorization from David Loren Parsons.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL DAVID LOREN PARSONS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
View
33 discount/CREDITS
@@ -0,0 +1,33 @@
+Discount is primarily my work, but it has only reached the point
+where it is via contributions, critiques, and bug reports from a
+host of other people, some of which are listed before. If your
+name isn't on this list, please remind me
+ -david parsons (orc@pell.chi.il.us)
+
+
+Josh Wood -- Plan9 support.
+Mike Schiraldi -- Reddit style automatic links, MANY MANY MANY
+ bug reports about boundary conditions and
+ places where I didn't get it right.
+Jjgod Jiang -- Table of contents support.
+Petite Abeille -- Many bug reports about places where I didn't
+ get it right.
+Tim Channon -- inspiration for the `mkd_xhtmlpage()` function
+Christian Herenz-- Many bug reports regarding my implementation of
+ `[]()` and `![]()`
+A.S.Bradbury -- Portability bug reports for 64 bit systems.
+Joyent -- Loan of a solaris box so I could get discount
+ working under solaris.
+Ryan Tomayko -- Portability requests (and the rdiscount ruby
+ binding.)
+yidabu -- feedback on the documentation, bug reports
+ against utf-8 support.
+Pierre Joye -- bug reports, php discount binding.
+Masayoshi Sekimura- perl discount binding.
+Jeremy Hinegardner- bug reports about list handling.
+Andrew White -- bug reports about the format of generated urls.
+Steve Huff -- bug reports about Makefile portability (for Fink)
+Ignacio Burgue?o-- bug reports about `>%class%`
+Henrik Nyh -- bug reports about embedded html handling.
+
+
View
61 discount/Csio.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include "cstring.h"
+#include "markdown.h"
+#include "amalloc.h"
+
+
+/* putc() into a cstring
+ */
+void
+Csputc(int c, Cstring *iot)
+{
+ EXPAND(*iot) = c;
+}
+
+
+/* printf() into a cstring
+ */
+int
+Csprintf(Cstring *iot, char *fmt, ...)
+{
+ va_list ptr;
+ int siz=100;
+
+ do {
+ RESERVE(*iot, siz);
+ va_start(ptr, fmt);
+ siz = vsnprintf(T(*iot)+S(*iot), ALLOCATED(*iot)-S(*iot), fmt, ptr);
+ va_end(ptr);
+ } while ( siz > (ALLOCATED(*iot)-S(*iot)) );
+
+ S(*iot) += siz;
+ return siz;
+}
+
+
+/* write() into a cstring
+ */
+int
+Cswrite(Cstring *iot, char *bfr, int size)
+{
+ RESERVE(*iot, size);
+ memcpy(T(*iot)+S(*iot), bfr, size);
+ S(*iot) += size;
+ return size;
+}
+
+
+/* reparse() into a cstring
+ */
+void
+Csreparse(Cstring *iot, char *buf, int size, int flags)
+{
+ MMIOT f;
+ ___mkd_initmmiot(&f, 0);
+ ___mkd_reparse(buf, size, 0, &f);
+ ___mkd_emblock(&f);
+ SUFFIX(*iot, T(f.out), S(f.out));
+ ___mkd_freemmiot(&f, 0);
+}
View
41 discount/INSTALL
@@ -0,0 +1,41 @@
+
+ HOW TO BUILD AND INSTALL DISCOUNT
+
+1) Unpacking the distribution
+
+The DISCOUNT sources are distributed in tarballs. After extracting from
+the tarball, you should end up with all the source and build files in the
+directory
+ discount-(version)
+
+2) Installing the distribution
+
+DISCOUNT uses configure.sh to set itself up for compilation. To run
+configure, just do ``./configure.sh'' and it will check your system for
+build dependencies and build makefiles for you. If configure.sh finishes
+without complaint, you can then do a ``make'' to compile everything and a
+``make install'' to install the binaries.
+
+Configure.sh has a few options that can be set:
+
+--src=DIR where the source lives (.)
+--prefix=DIR where to install the final product (/usr/local)
+--execdir=DIR where to put executables (prefix/bin)
+--sbindir=DIR where to put static executables (prefix/sbin)
+--confdir=DIR where to put configuration information (/etc)
+--libdir=DIR where to put libraries (prefix/lib)
+--libexecdir=DIR where to put private executables
+--mandir=DIR where to put manpages
+--enable-dl-tag Use the DL tag extension
+--enable-pandoc-header Use pandoc-style header blocks
+--enable-superscript A^B expands to A<sup>B</sup>
+--enable-amalloc Use a debugging memory allocator (to detect leaks)
+--relaxed-emphasis Don't treat _ in the middle of a word as emphasis
+--with-tabstops=N Set tabstops to N characters (default is 4)
+
+3) Installing sample programs and manpages
+
+The standard ``make install'' rule just installs the binaries. If you
+want to install the sample programs, they are installed with
+``make install.samples''; to install manpages, ``make install.man''.
+A shortcut to install everything is ``make install.everything''
View
116 discount/Makefile.in
@@ -0,0 +1,116 @@
+CC=@CC@ -I. -L.
+CFLAGS=@CFLAGS@
+AR=@AR@
+RANLIB=@RANLIB@
+
+BINDIR=@exedir@
+MANDIR=@mandir@
+LIBDIR=@libdir@
+INCDIR=@prefix@/include
+
+PGMS=markdown
+SAMPLE_PGMS=mkd2html makepage
+@THEME@SAMPLE_PGMS+= theme
+MKDLIB=libmarkdown
+OBJS=mkdio.o markdown.o dumptree.o generate.o \
+ resource.o docheader.o version.o toc.o css.o \
+ xml.o Csio.o xmlpage.o basename.o emmatch.o \
+ setup.o tags.o html5.o flags.o @AMALLOC@
+
+MAN3PAGES=mkd-callbacks.3 mkd-functions.3 markdown.3 mkd-line.3
+
+all: $(PGMS) $(SAMPLE_PGMS)
+
+install: $(PGMS)
+ @INSTALL_PROGRAM@ $(PGMS) $(DESTDIR)/$(BINDIR)
+ ./librarian.sh install libmarkdown VERSION $(DESTDIR)/$(LIBDIR)
+ @INSTALL_DATA@ mkdio.h $(DESTDIR)/$(INCDIR)
+
+install.everything: install install.samples install.man
+
+install.samples: $(SAMPLE_PGMS) install
+ @INSTALL_PROGRAM@ $(SAMPLE_PGMS) $(DESTDIR)/$(BINDIR)
+ @INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man1
+ @INSTALL_DATA@ theme.1 makepage.1 mkd2html.1 $(DESTDIR)/$(MANDIR)/man1
+
+install.man:
+ @INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man3
+ @INSTALL_DATA@ $(MAN3PAGES) $(DESTDIR)/$(MANDIR)/man3
+ for x in mkd_line mkd_generateline; do \
+ ( echo '.\"' ; echo ".so man3/mkd-line.3" ) > $(DESTDIR)/$(MANDIR)/man3/$$x.3;\
+ done
+ for x in mkd_in mkd_string; do \
+ ( echo '.\"' ; echo ".so man3/markdown.3" ) > $(DESTDIR)/$(MANDIR)/man3/$$x.3;\
+ done
+ for x in mkd_compile mkd_css mkd_generatecss mkd_generatehtml mkd_cleanup mkd_doc_title mkd_doc_author mkd_doc_date; do \
+ ( echo '.\"' ; echo ".so man3/mkd-functions.3" ) > $(DESTDIR)/$(MANDIR)/man3/$$x.3; \
+ done
+ @INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man7
+ @INSTALL_DATA@ markdown.7 mkd-extensions.7 $(DESTDIR)/$(MANDIR)/man7
+ @INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man1
+ @INSTALL_DATA@ markdown.1 $(DESTDIR)/$(MANDIR)/man1
+
+install.everything: install install.man
+
+version.o: version.c VERSION
+ $(CC) -DVERSION=\"`cat VERSION`\" -c version.c
+
+markdown: main.o $(MKDLIB)
+ $(CC) $(CFLAGS) -o markdown main.o -lmarkdown @LIBS@
+
+# example programs
+@THEME@theme: theme.o $(MKDLIB) mkdio.h
+@THEME@ $(CC) -o theme theme.o -lmarkdown @LIBS@
+
+
+mkd2html: mkd2html.o $(MKDLIB) mkdio.h
+ $(CC) -o mkd2html mkd2html.o -lmarkdown @LIBS@
+
+makepage: makepage.c $(MKDLIB) mkdio.h
+ $(CC) -o makepage makepage.c -lmarkdown @LIBS@
+
+main.o: main.c mkdio.h config.h
+ $(CC) -I. -c main.c
+
+$(MKDLIB): $(OBJS)
+ ./librarian.sh make $(MKDLIB) VERSION $(OBJS)
+
+verify: echo tools/checkbits.sh
+ @./echo -n "headers ... "; tools/checkbits.sh && echo "GOOD"
+
+test: $(PGMS) echo cols verify
+ @for x in tests/*.t; do \
+ @LD_LIBRARY_PATH@=`pwd` sh $$x || exit 1; \
+ done
+
+cols: tools/cols.c config.h
+ $(CC) -o cols tools/cols.c
+echo: tools/echo.c config.h
+ $(CC) -o echo tools/echo.c
+
+clean:
+ rm -f $(PGMS) $(SAMPLE_PGMS) *.o
+ rm -f $(MKDLIB) `./librarian.sh files $(MKDLIB) VERSION`
+
+distclean spotless: clean
+ rm -f @GENERATED_FILES@ @CONFIGURE_FILES@
+
+Csio.o: Csio.c cstring.h amalloc.h config.h markdown.h
+amalloc.o: amalloc.c
+basename.o: basename.c config.h cstring.h amalloc.h markdown.h
+css.o: css.c config.h cstring.h amalloc.h markdown.h
+docheader.o: docheader.c config.h cstring.h amalloc.h markdown.h
+dumptree.o: dumptree.c markdown.h cstring.h amalloc.h config.h
+emmatch.o: emmatch.c config.h cstring.h amalloc.h markdown.h
+generate.o: generate.c config.h cstring.h amalloc.h markdown.h
+main.o: main.c config.h amalloc.h
+makepage.o: makepage.c
+markdown.o: markdown.c config.h cstring.h amalloc.h markdown.h
+mkd2html.o: mkd2html.c config.h mkdio.h cstring.h amalloc.h
+mkdio.o: mkdio.c config.h cstring.h amalloc.h markdown.h
+resource.o: resource.c config.h cstring.h amalloc.h markdown.h
+theme.o: theme.c config.h mkdio.h cstring.h amalloc.h
+toc.o: toc.c config.h cstring.h amalloc.h markdown.h
+version.o: version.c config.h
+xml.o: xml.c config.h cstring.h amalloc.h markdown.h
+xmlpage.o: xmlpage.c config.h cstring.h amalloc.h markdown.h
View
40 discount/Plan9/README
@@ -0,0 +1,40 @@
+% Discount on Plan 9
+% Josh Wood
+% 2009-06-12
+
+# *Discount* Markdown compiler on Plan 9
+
+## Build
+
+ % CONFIG='--enable-all-features' mk config
+ % mk install
+ % markdown -V
+ markdown: discount X.Y.Z DL_TAG HEADER DEBUG SUPERSCRIPT RELAXED DIV
+
+`--enable-all-features` may be replaced by zero or more of:
+
+ --enable-dl-tag Use the DL tag extension
+ --enable-pandoc-header Use pandoc-style header blocks
+ --enable-superscript A^B becomes A<sup>B</sup>
+ --enable-amalloc Enable memory allocation debugging
+ --relaxed-emphasis underscores aren't special in the middle of words
+ --with-tabstops=N Set tabstops to N characters (default is 4)
+ --enable-div Enable >%id% divisions
+ --enable-alpha-list Enable (a)/(b)/(c) lists
+ --enable-all-features Turn on all stable optional features
+
+## Notes
+
+The supplied mkfile merely drives Discount's own configure script and
+then APE's *psh* environment to build the Discount source, then copies
+the result(s) to locations appropriate for system-wide use on Plan 9.
+There are a few other *mk*(1) targets:
+
+`install.libs`: Discount includes a C library and header.
+Installation is optional. Plan 9 binaries are statically linked.
+
+`install.man`: Add manual pages for markdown(1) and (6).
+
+`install.progs`: Extra programs. *makepage* writes complete XHTML
+documents, rather than fragments. *mkd2html* is similar, but produces
+HTML.
View
169 discount/Plan9/markdown.1
@@ -0,0 +1,169 @@
+.TH MARKDOWN 1
+.SH NAME
+markdown \- convert Markdown text to HTML
+.SH SYNOPSIS
+.B markdown
+[
+.B -dTV
+]
+[
+.BI -b " url-base
+]
+[
+.BI -F " bitmap
+]
+[
+.BI -f " flags
+]
+[
+.BI -o " ofile
+]
+[
+.BI -s " text
+]
+[
+.BI -t " text
+]
+[
+.I file
+]
+.SH DESCRIPTION
+The
+.I markdown
+utility reads the
+.IR Markdown (6)-formatted
+.I file
+(or standard input) and writes its
+.SM HTML
+fragment representation on standard output.
+.PP
+The options are:
+.TF dfdoptions
+.TP
+.BI -b " url-base
+Links in source begining with
+.B /
+will be prefixed with
+.I url-base
+in the output.
+.TP
+.B -d
+Instead of printing an
+.SM HTML
+fragment, print a parse tree.
+.TP
+.BI -F " bitmap
+Set translation flags.
+.I Bitmap
+is a bit map of the various configuration options described in
+.IR markdown (2).
+.TP
+.BI -f " flags
+Set or clear various translation
+.IR flags ,
+described below.
+.I Flags
+are in a comma-delimited list, with an optional
+.B +
+(set) prefix on each flag.
+.TP
+.BI -o " ofile
+Write the generated
+.SM HTML
+to
+.IR ofile .
+.TP
+.BI -s " text
+Use the
+.IR markdown (2)
+function to format the
+.I text
+on standard input.
+.TP
+.B -T
+Under
+.B -f
+.BR toc ,
+print the table of contents as an unordered list before the usual
+.SM HTML
+output.
+.TP
+.BI -t " text
+Use
+.IR mkd_text
+(in
+.IR markdown (2))
+to format
+.I text
+instead of processing standard input with
+.IR markdown .
+.TP
+.B -V
+Show version number and configuration. If the version includes the string
+.BR DL_TAG ,
+.I markdown
+was configured with definition list support. If the version includes the string
+.BR HEADER ,
+.I markdown
+was configured to support pandoc header blocks.
+.PD
+.SS TRANSLATION FLAGS
+The translation flags understood by
+.B -f
+are:
+.TF \ noheader
+.TP
+.B noimage
+Don't allow image tags.
+.TP
+.B nolinks
+Don't allow links.
+.TP
+.B nohtml
+Don't allow any embedded HTML.
+.TP
+.B cdata
+Generate valid XML output.
+.TP
+.B noheader
+Do not process pandoc headers.
+.TP
+.B notables
+Do not process the syntax extension for tables.
+.TP
+.B tabstops
+Use Markdown-standard 4-space tabstops.
+.TP
+.B strict
+Disable superscript and relaxed emphasis.
+.TP
+.B relax
+Enable superscript and relaxed emphasis (the default).
+.TP
+.B toc
+Enable table of contents support, generated from headings (in
+.IR markdown (6))
+in the source.
+.TP
+.B 1.0
+Revert to Markdown 1.0 compatibility.
+.PD
+.PP
+For example,
+.B -f nolinks,quot
+tells
+.I markdown
+not to allow
+.B <a>
+tags, and to expand double quotes.
+.SH SOURCE
+.B /sys/src/cmd/discount
+.SH SEE ALSO
+.IR markdown (2),
+.IR markdown (6)
+.PP
+http://daringfireball.net/projects/markdown/,
+``Markdown''.
+.SH DIAGNOSTICS
+.I Markdown
+exits 0 on success and >0 if an error occurs.
View
332 discount/Plan9/markdown.2
@@ -0,0 +1,332 @@
+.TH MARKDOWN 2
+.SH NAME
+mkd_in, mkd_string, markdown, mkd_compile, mkd_css, mkd_generatecss,
+mkd_document, mkd_generatehtml, mkd_xhtmlpage, mkd_toc, mkd_generatetoc,
+mkd_cleanup, mkd_doc_title, mkd_doc_author, mkd_doc_date, mkd_line,
+mkd_generateline \- convert Markdown text to HTML
+.SH SYNOPSIS
+.ta \w'MMIOT* 'u
+.B #include <mkdio.h>
+.PP
+.B
+MMIOT* mkd_in(FILE *input, int flags)
+.PP
+.B
+MMIOT* mkd_string(char *buf, int size, int flags)
+.PP
+.B
+int markdown(MMIOT *doc, FILE *output, int flags)
+.PP
+.B
+int mkd_compile(MMIOT *document, int flags)
+.PP
+.B
+int mkd_css(MMIOT *document, char **doc)
+.PP
+.B
+int mkd_generatecss(MMIOT *document, FILE *output)
+.PP
+.B
+int mkd_document(MMIOT *document, char **doc)
+.PP
+.B
+int mkd_generatehtml(MMIOT *document, FILE *output)
+.PP
+.B
+int mkd_xhtmlpage(MMIOT *document, int flags, FILE *output)
+.PP
+.B
+int mkd_toc(MMIOT *document, char **doc)
+.PP
+.B
+int mkd_generatetoc(MMIOT *document, FILE *output)
+.PP
+.B
+void mkd_cleanup(MMIOT*);
+.PP
+.B
+char* mkd_doc_title(MMIOT*)
+.PP
+.B
+char* mkd_doc_author(MMIOT*)
+.PP
+.B
+char* mkd_doc_date(MMIOT*)
+.PP
+.B
+int mkd_line(char *string, int size, char **doc, int flags)
+.PP
+.B
+int mkd_generateline(char *string, int size, FILE *output, int flags)
+.PD
+.PP
+.SH DESCRIPTION
+These functions convert
+.IR Markdown (6)
+text into
+.SM HTML
+markup.
+.PP
+.I Mkd_in
+reads the text referenced by pointer to
+.B FILE
+.I input
+and returns a pointer to an
+.B MMIOT
+structure of the form expected by
+.I markdown
+and the other converters.
+.I Mkd_string
+accepts one
+.I string
+and returns a pointer to
+.BR MMIOT .
+.PP
+After such preparation,
+.I markdown
+converts
+.I doc
+and writes the result to
+.IR output ,
+while
+.I mkd_compile
+transforms
+.I document
+in-place.
+.PP
+One or more of the following
+.I flags
+(combined with
+.BR OR )
+control
+.IR markdown 's
+processing of
+.IR doc :
+.TF MKD_NOIMAGE
+.TP
+.B MKD_NOIMAGE
+Do not process
+.B ![]
+and remove
+.B <img>
+tags from the output.
+.TP
+.B MKD_NOLINKS
+Do not process
+.B []
+and remove
+.B <a>
+tags from the output.
+.TP
+.B MKD_NOPANTS
+Suppress Smartypants-style replacement of quotes, dashes, or ellipses.
+.TP
+.B MKD_STRICT
+Disable superscript and relaxed emphasis processing if configured; otherwise a no-op.
+.TP
+.B MKD_TAGTEXT
+Process as inside an
+.SM HTML
+tag: no
+.BR <em> ,
+no
+.BR <bold> ,
+no
+.SM HTML
+or
+.B []
+expansion.
+.TP
+.B MKD_NO_EXT
+Don't process pseudo-protocols (in
+.IR markdown (6)).
+.TP
+.B MKD_CDATA
+Generate code for
+.SM XML
+.B ![CDATA[...]]
+element.
+.TP
+.B MKD_NOHEADER
+Don't process Pandoc-style headers.
+.TP
+.B MKD_TABSTOP
+When reading documents, expand tabs to 4 spaces, overriding any compile-time configuration.
+.TP
+.B MKD_TOC
+Label headings for use with the
+.I mkd_generatetoc
+and
+.I mkd_toc
+functions.
+.TP
+.B MKD_1_COMPAT
+MarkdownTest_1.0 compatibility. Trim trailing spaces from first line of code blocks and disable implicit reference links (in
+.IR markdown (6)).
+.TP
+.B MKD_AUTOLINK
+Greedy
+.SM URL
+generation. When set, any
+.SM URL
+is converted to a hyperlink, even those not encased in
+.BR <> .
+.TP
+.B MKD_SAFELINK
+Don't make hyperlinks from
+.B [][]
+links that have unknown
+.SM URL
+protocol types.
+.TP
+.B MKD_NOTABLES
+Do not process the syntax extension for tables (in
+.IR markdown (6)).
+.TP
+.B MKD_EMBED
+All of
+.BR MKD_NOLINKS ,
+.BR MKD_NOIMAGE ,
+and
+.BR MKD_TAGTEXT .
+.PD
+.PP
+This implementation supports
+Pandoc-style
+headers and inline
+.SM CSS
+.B <style>
+blocks, but
+.I markdown
+does not access the data provided by these extensions.
+The following functions do, and allow other manipulations.
+.PP
+Given a pointer to
+.B MMIOT
+prepared by
+.I mkd_in
+or
+.IR mkd_string ,
+.I mkd_compile
+compiles the
+.I document
+into
+.BR <style> ,
+Pandoc, and
+.SM HTML
+sections. It accepts the
+.I flags
+described for
+.IR markdown ,
+above.
+.PP
+Once compiled, the document particulars can be read and written:
+.PP
+.I Mkd_css
+allocates a string and populates it with any
+.B <style>
+sections from the document.
+.I Mkd_generatecss
+writes any
+.B <style>
+sections to
+.IR output .
+.PP
+.I Mkd_document
+points
+.I doc
+to the
+.B MMIOT
+.IR document ,
+returning
+.IR document 's
+size.
+.PP
+.I Mkd_generatehtml
+writes the rest of the
+.I document
+to the
+.IR output .
+.PP
+.IR Mkd_doc_title ,
+.IR mkd_doc_author ,
+and
+.I mkd_doc_date
+read the contents of any Pandoc header.
+.PP
+.I Mkd_xhtmlpage
+writes an
+.SM XHTML
+page representation of the document.
+It accepts the
+.I flags
+described for
+.IR markdown ,
+above.
+.PP
+.I Mkd_toc
+.IR malloc s
+a buffer into which it writes an outline, in the form of a
+.B <ul>
+element populated with
+.BR <li> s
+each containing a link to successive headings in the
+.IR document .
+It returns the size of that string.
+.I Mkd_generatetoc
+is similar,
+but writes the outline to the
+.I output
+referenced by a pointer to
+.BR FILE .
+.PP
+.I Mkd_cleanup
+deletes a processed
+.BR MMIOT .
+.PP
+The last two functions convert a single line of markdown source, for example a page title or a signature.
+.I Mkd_line
+allocates a buffer into which it writes an
+.SM HTML
+fragment representation of the
+.IR string .
+.I Mkd_generateline
+writes the result to
+.IR output .
+.SH SOURCE
+.B /sys/src/cmd/discount
+.SH SEE ALSO
+.IR markdown (1),
+.IR markdown (6)
+.SH DIAGNOSTICS
+The
+.I mkd_in
+and
+.I mkd_string
+functions return a pointer to
+.B MMIOT
+on success, null on failure.
+.IR Markdown ,
+.IR mkd_compile ,
+.IR mkd_style ,
+and
+.I mkd_generatehtml
+return
+.B 0
+on success,
+.B -1
+otherwise.
+.SH BUGS
+Error handling is minimal at best.
+.PP
+The
+.B MMIOT
+created by
+.I mkd_string
+is deleted by the
+.I markdown
+function.
+.PP
+This is an
+.SM APE
+library.
View
543 discount/Plan9/markdown.6
@@ -0,0 +1,543 @@
+.TH MARKDOWN 6
+.SH NAME
+Markdown \- text formatting syntax
+.SH DESCRIPTION
+Markdown
+is a text markup syntax for machine conversion to
+the more complex
+.SM HTML
+or
+.SM XHTML
+markup languages.
+It is intended to be easy to read and to write, with
+emphasis on readability.
+A Markdown-formatted document should be publishable as-is,
+in plain text, without the formatting distracting the reader.
+.PP
+The biggest source of inspiration for Markdown's
+syntax is the format of plain text email. The markup is comprised entirely
+of punctuation characters, chosen so as to look like what they mean.
+Asterisks around a word look like
+.IR *emphasis* .
+Markdown lists look like lists. Even
+blockquotes look like quoted passages of text, assuming the reader has
+used email.
+.PP
+.SS Block Elements
+.TF W
+.PD
+.TP
+Paragraphs and Line Breaks
+A paragraph is one or more consecutive lines of text, separated
+by one or more blank lines. (A blank line is any line that looks like a
+blank line -- a line containing nothing but spaces or tabs is considered
+blank.) Normal paragraphs should not be indented with spaces or tabs.
+.IP
+Lines may be freely broken for readability; Markdown
+does not translate source line breaks to
+.B <br />
+tags. To request generation of
+.B <br />
+in the output, end a line with two or more spaces, then a newline.
+.TP
+Headings
+Headings can be marked in two ways, called
+.I setext
+and
+.IR atx .
+.IP
+Setext-style headings are
+``underlined'' using equal signs (for first-level
+headings) and dashes (for second-level headings).
+.IP
+Atx-style headings use 1-6 hash characters at the start of the line,
+corresponding to
+.SM HTML
+.BR <h^(1-6)^> .
+Optional closing hashes may follow
+the heading text.
+.TP
+Blockquotes
+Lines beginning with
+.B >
+are output in blockquotes.
+Blockquotes can be nested
+by multiple levels of
+.BR >> .
+Blockquotes can contain other Markdown elements, including
+headings, lists, and code blocks.
+.TP
+Lists
+Markdown supports ordered (numbered) and unordered (bulleted) lists.
+List markers typically start at the left margin, but may be indented by
+up to three spaces.
+List markers must be followed by one or more spaces
+or a tab, then the list item text.
+A newline terminates each list item.
+.IP
+Unordered lists use asterisks, pluses, and hyphens interchangeably as
+list markers.
+.IP
+Ordered lists use integers followed by periods as list markers.
+The order of the integers is not interpreted,
+but the list should begin with
+.BR 1 .
+.IP
+If list items are separated by blank lines, Markdown will wrap each list
+item in
+.B <p>
+tags in the
+.SM HTML
+output.
+.IP
+List items may consist of multiple paragraphs.
+Each subsequent
+paragraph within a list item must be indented by either 4 spaces
+or one tab.
+To put a blockquote within a list item, the blockquote's
+.B >
+marker needs to be indented.
+To put a code block within a list item, the code block needs
+to be indented
+.I twice
+-- 8 spaces or two tabs.
+.TP
+Code Blocks
+To produce a code block, indent every line of the
+block by at least 4 spaces or 1 tab.
+A code block continues until it reaches a line that is not indented.
+.IP
+Rather than forming normal paragraphs, the lines
+of a code block are interpreted literally.
+Regular Markdown syntax is not processed within code blocks.
+Markdown wraps a code block in both
+.B <pre>
+and
+.B <code>
+tags.
+One level of indentation -- 4
+spaces or 1 tab -- is removed from each line of the code block in
+the output.
+.TP
+Horizontal Rules
+Produce a horizontal rule tag
+.RB ( <hr\ /> )
+by placing three or
+more hyphens, asterisks, or underscores on a line by themselves.
+.SS Span Elements
+.TF W
+.PD
+.TP
+Links
+Markdown supports two styles of links:
+.I inline
+and
+.IR reference .
+In both styles, the link text is delimited by square brackets
+.RB ( [] ).
+To create an inline link, use a set of regular parentheses immediately
+after the link text's closing square bracket.
+Inside the parentheses,
+put the link URL, along with an optional
+title for the link surrounded in double quotes.
+For example:
+.IP
+.EX
+ An [example](http://example.com/ "Title") inline link.
+.EE
+.IP
+Reference-style links use a second set of square brackets, inside
+which you place a label of your choosing to identify the link:
+.IP
+.EX
+ An [example][id] reference-style link.
+.EE
+.IP
+The label is then assigned a value on its own line, anywhere in the document:
+.IP
+.EX
+ [id]: http://example.com/ "Optional Title"
+.EE
+.IP
+Link label names may consist of letters, numbers, spaces, and
+punctuation.
+Labels are not case sensitive.
+An empty label bracket
+set after a reference-style link implies the link label is equivalent to
+the link text.
+A URL value can then be assigned to the link by referencing
+the link text as the label name.
+.TP
+Emphasis
+Markdown treats asterisks
+.RB ( * )
+and underscores
+.RB ( _ )
+as indicators of emphasis.
+Text surrounded with single asterisks or underscores
+will be wrapped with an
+.SM HTML
+.B <em>
+tag.
+Double asterisks or underscores generate an
+.SM HTML
+.B <strong>
+tag.
+.TP
+Code
+To indicate a span of code, wrap it with backtick quotes
+.RB ( ` ).
+Unlike a code block, a code span indicates code within a
+normal paragraph.
+To include a literal backtick character within a code span, you can use
+multiple backticks as the opening and closing delimiters:
+.IP
+.EX
+ ``There is a literal backtick (`) here.``
+.EE
+.TP
+Images
+Markdown image syntax is intended to resemble that
+for links, allowing for two styles, once again
+.I inline
+and
+.IR reference .
+The syntax is as for each respective style of link, described above, but
+prefixed with an exclamation mark character
+.RB ( ! ).
+Inline image syntax looks like this:
+.IP
+.EX
+ ![Alt text](/path/to/img.jpg "Optional title")
+.EE
+.IP
+That is:
+An exclamation mark;
+followed by a set of square brackets containing the `alt'
+attribute text for the image;
+followed by a set of parentheses containing the URL or path to
+the image, and an optional `title' attribute enclosed in double
+or single quotes.
+.IP
+Reference-style image syntax looks like this:
+.IP
+.EX
+ ![Alt text][id]
+.EE
+.IP
+Where
+.I id
+is a label used as for reference-style URL links, described above.
+.SS Convenience
+.TF W
+.PD
+.TP
+Automatic Links
+There is a shortcut style for creating ``automatic''
+links for URLs and email addresses.
+Surround the URL
+or address with angle brackets.
+.TP
+Backslash Escapes
+Use backslash escapes to generate literal
+characters which would otherwise have special meaning in Markdown's
+formatting syntax.
+.TP
+Inline HTML
+For markup that is not covered by Markdown's
+syntax, simply use the
+.SM HTML
+directly.
+The only restrictions are that block-level
+.SM HTML
+elements --
+.BR <div> ,
+.BR <table> ,
+.BR <pre> ,
+.BR <p> ,
+etc. -- must be separated from surrounding
+content by blank lines, and the start and end tags of the block should
+not be indented with tabs or spaces. Markdown formatting syntax is
+not processed within block-level
+.SM HTML
+tags.
+.IP
+Span-level
+.SM HTML
+tags -- e.g.
+.BR <span> ,
+.BR <cite> ,
+or
+.B <del>
+-- can be
+used anywhere in a Markdown
+paragraph, list item, or heading.
+It is permitted to use
+.SM HTML
+tags instead of Markdown formatting; e.g.
+.SM HTML
+.B <a>
+or
+.B <img>
+tags instead of Markdown's
+link or image syntax.
+Unlike block-level
+.SM HTML
+tags, Markdown
+syntax
+.I is
+processed within the elements of span-level tags.
+.TP
+Automatic Special Character Escapes
+To be displayed literally in a user agent, the characters
+.B <
+and
+.B &
+must appear as escaped entities in
+.SM HTML
+source, e.g.
+.B &lt;
+and
+.BR &amp; .
+Markdown
+allows natural use of these characters, taking care of
+the necessary escaping.
+The ampersand part of a directly-used
+.SM HTML
+entity remains unchanged; otherwise it will be translated
+into
+.BR &amp; .
+Inside code spans and blocks, angle brackets and
+ampersands are always encoded automatically.
+This makes it easy to use Markdown to write about
+.SM HTML
+code.
+.PP
+.SS Smarty Pants
+The
+.IR markdown (1)
+utility transforms a few plain text symbols into their typographically-fancier
+.SM HTML
+entity equivalents.
+These are extensions to the standard Markdown syntax.
+.TF W
+.PD
+.TP
+Punctuation
+Input single- and double-quotes are transformed
+into ``curly'' quote entities in the output (e.g.,
+.B 'text'
+becomes
+.BR &lsquo;text&rsquo; ).
+Input double-dashes
+.RB ( -- )
+and triple-dashes become en- and em-dashes, respectively,
+while a series of three dots
+.RB ( ... )
+in the input becomes an ellipsis entity
+.RB ( &hellip; )
+in the
+.SM HTML
+output.
+.TP
+Symbols
+Three other transformations replace the common plain-text shorthands
+.BR (c) ,
+.BR (r) ,
+and
+.BR (tm)
+from the input with their respective
+.SM HTML
+entities. (As in
+.B (c)
+becoming
+.BR &copy; ,
+the Copyright symbol entity.)
+.TP
+Fractions
+A small set of plain-text shorthands for fractions is recognized.
+.B 1/4
+becomes
+.BR &frac14; ,
+for example. These fraction notations are replaced with their
+.SM HTML
+entity equivalents:
+.BR 1/4 ,
+.BR 1/2 ,
+.BR 3/4 .
+.B 1/4th
+and
+.B 3/4ths
+are replaced with their entity and the indicated ordinal suffix letters.
+.PP
+Like the basic Markdown syntax, none of the ``Smarty Pants'' extensions are processed
+inside code blocks or spans.
+.PP
+.SS Discount Extensions
+.IR Markdown (1)
+recognizes some extensions to the Markdown format,
+many of them adopted or adapted from other Markdown
+interpreters or document formatting systems.
+.TF W
+.PD
+.TP
+Pandoc Headers
+If
+.I markdown
+was configured with
+.BR --enable-pandoc-header ,
+the markdown source can have a 3-line Pandoc header in the format of
+.IP
+.EX
+% Title
+% Author
+% Date
+.EE
+.IP
+whose data is available to the
+.IR mkd_doc_title ,
+.IR mkd_doc_author ,
+and
+.I mkd_doc_date
+(in
+.IR markdown (2))
+functions.
+.TP
+Embedded Stylesheets
+Stylesheets may be defined and modified in a
+.B <style>
+block. A style block is parsed like any other block-level
+.SM HTML;
+.B <style>
+starting on column 1, raw
+.SM HTML
+(or, in this case,
+.SM CSS \)
+following it, and either ending with a
+.B </style>
+at the end of the line or at the beginning of a subsequent line.
+.IP
+Style blocks apply to the entire document regardless of where they are defined.
+.TP
+Image Dimensions
+Image specification has been extended with an argument describing image dimensions:
+.BI = height x width.
+For an image 400 pixels high and 300 wide, the new syntax is:
+.IP
+.EX
+ ![Alt text](/path/to/image.jpg =400x300 "Title")
+.EE
+.TP
+Pseudo-Protocols
+Pseudo-protocols that may replace the common
+.B http:
+or
+.B mailto:
+have been added to the link syntax described above.
+.IP
+.BR abbr :
+Text following is used as the
+.B title
+attribute of an
+.B abbr
+tag wrapping the link text. So
+.B [LT](abbr:Link Text)
+gives
+.B <abbr title="Link Text">LT</abbr>.
+.IP
+.BR id :
+The link text is marked up and written to the output, wrapped with
+.B <a id=text following>
+and
+.BR </a> .
+.IP
+.BR class :
+ The link text is marked up and written to the output, wrapped with
+.B <span class=text following>
+and
+.BR </span> .
+.IP
+.BR raw :
+Text following is written to the output with no further processing.
+The link text is discarded.
+.TP
+Alphabetic Lists
+If
+.I markdown
+was configured with
+.BR --enable-alpha-list ,
+.IP
+.EX
+a. this
+b. is
+c. an alphabetic
+d. list
+.EE
+.IP
+yields an
+.SM HTML
+.B ol
+ordered list.
+.TP
+Definition Lists
+If configured with
+.BR --enable-dl-tag ,
+markup for definition lists is enabled. A definition list item is defined as
+.IP
+.EX
+=term=
+ definition
+.EE
+.TP
+Tables
+Tables are specified with a pipe
+.RB ( | )
+and dash
+.RB ( - )
+marking. The markdown text
+.IP
+.EX
+header0|header1
+-------|-------
+ textA|textB
+ textC|textD
+.EE
+.IP
+will produce an
+.SM HTML
+.B table
+of two columns and three rows.
+A header row is designated by ``underlining'' with dashes.
+Declare a column's alignment by affixing a colon
+.RB ( : )
+to the left or right end of the dashes underlining its header.
+In the output, this
+yields the corresponding value for the
+.B align
+attribute on each
+.B td
+cell in the column.
+A colon at both ends of a column's header dashes indicates center alignment.
+.TP
+Relaxed Emphasis
+If configured with
+.BR --relaxed-emphasis ,
+the rules for emphasis are changed so that a single
+.B _
+will not count as an emphasis character in the middle of a word.
+This is useful for documenting some code where
+.B _
+appears frequently, and would normally require a backslash escape.
+.PD
+.SH SEE ALSO
+.IR markdown (1),
+.IR markdown (2)
+.PP
+http://daringfireball.net/projects/markdown/syntax/,
+``Markdown: Syntax''.
+.PP
+http://daringfireball.net/projects/smartypants/,
+``Smarty Pants''.
+.PP
+http://michelf.com/projects/php-markdown/extra/#table,
+``PHP Markdown Extra: Tables''.
View
37 discount/Plan9/mkfile
@@ -0,0 +1,37 @@
+BIN=/$objtype/bin
+CC='cc -D_BSD_EXTENSION -D_C99_SNPRINTF_EXTENSION'
+
+markdown:
+ ape/psh -c 'cd .. && make'
+
+none:V: markdown
+
+test: markdown
+ ape/psh -c 'cd ..&& make test'
+
+install: markdown
+ cp ../markdown $BIN/markdown
+
+install.progs: install
+ cp ../makepage $BIN/makepage
+ cp ../mkd2html $BIN/mkd2html
+
+install.libs: install
+ cp ../mkdio.h /sys/include/ape/mkdio.h
+ cp ../libmarkdown.a /$objtype/lib/ape/libmarkdown.a
+
+install.man: install
+ cp markdown.1 /sys/man/1/markdown
+ cp markdown.2 /sys/man/2/markdown
+ cp markdown.6 /sys/man/6/markdown
+
+installall:V: install.libs install.man install.progs
+
+config:
+ ape/psh -c 'cd .. && ./configure.sh $CONFIG'
+
+clean:
+ ape/psh -c 'cd .. && make clean'
+
+nuke:
+ ape/psh -c 'cd .. && make distclean'
View
16 discount/README
@@ -0,0 +1,16 @@
+DISCOUNT is a implementation of John Gruber's Markdown markup
+language. It implements, as far as I can tell, all of the
+language as described in
+<http://daringfireball.net/projects/markdown/syntax>
+and passes the Markdown test suite at
+<http://daringfireball.net/projects/downloads/MarkdownTest_1.0.zip>
+
+DISCOUNT is free software written by David Parsons <orc@pell.chi.il.us>;
+it is released under a BSD-style license that allows you to do
+as you wish with it as long as you don't attempt to claim it as
+your own work.
+
+Most of the programs included in the DISCOUNT distribution have
+manual pages describing how they work.
+
+The file INSTALL describes how to build and install discount
View
1  discount/VERSION
@@ -0,0 +1 @@
+2.0.5
View
111 discount/amalloc.c
@@ -0,0 +1,111 @@
+/*
+ * debugging malloc()/realloc()/calloc()/free() that attempts
+ * to keep track of just what's been allocated today.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define MAGIC 0x1f2e3d4c
+
+struct alist { int magic, size; struct alist *next, *last; };
+
+static struct alist list = { 0, 0, 0, 0 };
+
+static int mallocs=0;
+static int reallocs=0;
+static int frees=0;
+
+void *
+acalloc(int size, int count)
+{
+ struct alist *ret = calloc(size + sizeof(struct alist), count);
+
+ if ( ret ) {
+ ret->magic = MAGIC;
+ ret->size = size * count;
+ if ( list.next ) {
+ ret->next = list.next;
+ ret->last = &list;
+ ret->next->last = ret;
+ list.next = ret;
+ }
+ else {
+ ret->last = ret->next = &list;
+ list.next = list.last = ret;
+ }
+ ++mallocs;
+ return ret+1;
+ }
+ return 0;
+}
+
+
+void*
+amalloc(int size)
+{
+ return acalloc(size,1);
+}
+
+
+void
+afree(void *ptr)
+{
+ struct alist *p2 = ((struct alist*)ptr)-1;
+
+ if ( p2->magic == MAGIC ) {
+ p2->last->next = p2->next;
+ p2->next->last = p2->last;
+ ++frees;
+ free(p2);
+ }
+ else
+ free(ptr);
+}
+
+
+void *
+arealloc(void *ptr, int size)
+{
+ struct alist *p2 = ((struct alist*)ptr)-1;
+ struct alist save;
+
+ if ( p2->magic == MAGIC ) {
+ save.next = p2->next;
+ save.last = p2->last;
+ p2 = realloc(p2, sizeof(*p2) + size);
+
+ if ( p2 ) {
+ p2->size = size;
+ p2->next->last = p2;
+ p2->last->next = p2;
+ ++reallocs;
+ return p2+1;
+ }
+ else {
+ save.next->last = save.last;
+ save.last->next = save.next;
+ return 0;
+ }
+ }
+ return realloc(ptr, size);
+}
+
+
+void
+adump()
+{
+ struct alist *p;
+
+
+ for ( p = list.next; p && (p != &list); p = p->next ) {
+ fprintf(stderr, "allocated: %d byte%s\n", p->size, (p->size==1) ? "" : "s");
+ fprintf(stderr, " [%.*s]\n", p->size, (char*)(p+1));
+ }
+
+ if ( getenv("AMALLOC_STATISTICS") ) {
+ fprintf(stderr, "%d malloc%s\n", mallocs, (mallocs==1)?"":"s");
+ fprintf(stderr, "%d realloc%s\n", reallocs, (reallocs==1)?"":"s");
+ fprintf(stderr, "%d free%s\n", frees, (frees==1)?"":"s");
+ }
+}
View
29 discount/amalloc.h
@@ -0,0 +1,29 @@
+/*
+ * debugging malloc()/realloc()/calloc()/free() that attempts
+ * to keep track of just what's been allocated today.
+ */
+#ifndef AMALLOC_D
+#define AMALLOC_D
+
+#include "config.h"
+
+#ifdef USE_AMALLOC
+
+extern void *amalloc(int);
+extern void *acalloc(int,int);
+extern void *arealloc(void*,int);
+extern void afree(void*);
+extern void adump();
+
+#define malloc amalloc
+#define calloc acalloc
+#define realloc arealloc
+#define free afree
+
+#else
+
+#define adump() (void)1
+
+#endif
+
+#endif/*AMALLOC_D*/
View
43 discount/basename.c
@@ -0,0 +1,43 @@
+/*
+ * mkdio -- markdown front end input functions
+ *
+ * Copyright (C) 2007 David L Parsons.
+ * The redistribution terms are provided in the COPYRIGHT file that must
+ * be distributed with this source code.
+ */
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "mkdio.h"
+#include "cstring.h"
+#include "amalloc.h"
+
+static char *
+e_basename(const char *string, const int size, void *context)
+{
+ char *ret;
+ char *base = (char*)context;
+
+ if ( base && string && (*string == '/') && (ret=malloc(strlen(base)+size+2)) ) {
+ strcpy(ret, base);
+ strncat(ret, string, size);
+ return ret;
+ }
+ return 0;
+}
+
+static void
+e_free(char *string, void *context)
+{
+ if ( string ) free(string);
+}
+
+void
+mkd_basename(MMIOT *document, char *base)
+{
+ mkd_e_url(document, e_basename);
+ mkd_e_data(document, base);
+ mkd_e_free(document, e_free);
+}
View
1,660 discount/configure.inc
@@ -0,0 +1,1660 @@
+# @(#) configure.inc 1.42@(#)
+# Copyright (c) 1999-2007 David Parsons. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. My name may not be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY DAVID PARSONS ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
+# PARSONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+
+#
+# this preamble code is executed when this file is sourced and it picks
+# interesting things off the command line.
+#
+ac_default_path="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
+
+ac_standard="--src=DIR where the source lives (.)
+--prefix=DIR where to install the final product (/usr/local)
+--execdir=DIR where to put executables (prefix/bin)
+--sbindir=DIR where to put static executables (prefix/sbin)
+--confdir=DIR where to put configuration information (/etc)
+--libdir=DIR where to put libraries (prefix/lib)
+--libexecdir=DIR where to put private executables
+--mandir=DIR where to put manpages"
+
+__fail=exit
+
+if dirname B/A 2>/dev/null >/dev/null; then
+__ac_dirname() {
+ dirname "$1"
+}
+else
+__ac_dirname() {
+ echo "$1" | sed -e 's:/[^/]*$::'
+}
+fi
+
+ac_progname=$0
+ac_configure_command=
+Q=\'
+for x in "$@"; do
+ ac_configure_command="$ac_configure_command $Q$x$Q"
+done
+# ac_configure_command="$*"
+
+__d=`__ac_dirname "$ac_progname"`
+if [ "$__d" = "$ac_progname" ]; then
+ AC_SRCDIR=`pwd`
+else
+ AC_SRCDIR=`cd $__d;pwd`
+fi
+
+__ac_dir() {
+ if test -d "$1"; then
+ (cd "$1";pwd)
+ else
+ echo "$1";
+ fi
+}
+
+#
+# echo w/o newline
+#
+echononl()
+{
+ ${ac_echo:-echo} "${@}$ac_echo_nonl"
+}
+
+#
+# log something to the terminal and to a logfile.
+#
+LOG () {
+ echo "$@"
+ echo "$@" 1>&5
+}
+
+#
+# log something to the terminal without a newline, and to a logfile with
+# a newline
+#
+LOGN () {
+ echononl "$@" 1>&5
+ echo "$@"
+}
+
+#
+# log something to the terminal
+#
+TLOG () {
+ echo "$@" 1>&5
+}
+
+#
+# log something to the terminal, no newline
+#
+TLOGN () {
+ echononl "$@" 1>&5
+}
+
+
+#
+# AC_CONTINUE tells configure not to bomb if something fails, but to
+# continue blithely along
+#
+AC_CONTINUE () {
+ __fail="return"
+}
+
+
+#
+# generate a .o file from sources
+#
+__MAKEDOTO() {
+ AC_PROG_CC
+
+ if $AC_CC -c -o /tmp/doto$$.o "$@" $AC_LIBS 2>/tmp/doto$$.err; then
+ rm -f /tmp/doto$$.o /tmp/doto$$.err
+ TLOG " (found)"
+ return 0
+ fi
+ rm -f /tmp/doto$$.o
+ TLOG " (not found)"
+ echo "test failed: command was $AC_CC -c -o /tmp/doto$$.o" "$@" $AC_LIBS
+ echo "output:"
+ cat /tmp/doto$$.err
+ rm -f /tmp/doto$$.err
+ echo "offending sources:"
+ for x in "$@"; do
+ echo "$x:"
+ cat $x
+ done
+ return 1
+}
+
+
+#
+# Emulate gnu autoconf's AC_CHECK_HEADERS() function
+#
+AC_CHECK_HEADERS () {
+
+ echo "/* AC_CHECK_HEADERS */" > /tmp/ngc$$.c
+ for hdr in $*; do
+ echo "#include <$hdr>" >> /tmp/ngc$$.c
+ done
+ echo "main() { }" >> /tmp/ngc$$.c
+
+ LOGN "looking for header $hdr"
+
+ if __MAKEDOTO /tmp/ngc$$.c; then
+ AC_DEFINE 'HAVE_'`echo $hdr | $AC_UPPERCASE | tr './' '_'` 1
+ rc=0
+ else
+ rc=1
+ fi
+ rm -f /tmp/ngc$$.c
+ return $rc
+}
+
+
+#
+# emulate GNU autoconf's AC_CHECK_FUNCS function
+#
+AC_CHECK_FUNCS () {
+ AC_PROG_CC
+
+ B=`echo "$1" | sed -e 's/(.*)//'`
+
+ case "$B" in
+ "$1") F="$1()" ;;
+ *) F="$1" ;;
+ esac
+
+ shift
+ rm -f /tmp/ngc$$.c
+
+ while [ "$1" ]; do
+ echo "#include <$1>" >> /tmp/ngc$$.c
+ shift
+ done
+
+ cat >> /tmp/ngc$$.c << EOF
+main()
+{
+
+ $F;
+}
+EOF
+
+ LOGN "looking for the $B function"
+
+ if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $LIBS; then
+ AC_DEFINE `echo ${2:-HAVE_$B} | $AC_UPPERCASE` 1
+ TLOG " (found)"
+ rc=0
+ else
+ echo "offending command was:"
+ cat /tmp/ngc$$.c
+ echo "$AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $LIBS"
+ TLOG " (not found)"
+ rc=1
+ fi
+ rm -f /tmp/ngc$$.c /tmp/ngc$$
+ return $rc
+}
+
+
+#
+# check to see if some structure exists
+#
+# usage: AC_CHECK_STRUCT structure {include ...}
+#
+AC_CHECK_STRUCT () {
+ struct=$1
+ shift
+
+ rm -f /tmp/ngc$$.c
+
+ for include in $*; do
+ echo "#include <$include>" >> /tmp/ngc$$.c
+ done
+
+ cat >> /tmp/ngc$$.c << EOF
+main()
+{
+ struct $struct foo;
+}
+EOF
+
+ LOGN "looking for struct $struct"
+
+ if __MAKEDOTO /tmp/ngc$$.c; then
+ AC_DEFINE HAVE_STRUCT_`echo ${struct} | $AC_UPPERCASE`
+ rc=0
+ else
+ rc=1
+ fi
+ rm -f /tmp/ngc$$.c
+ return $rc
+}
+
+
+#
+# check to see if some type exists
+#
+# usage: AC_CHECK_TYPE type {include ...}
+#
+AC_CHECK_TYPE () {
+ type=$1
+ shift
+
+ rm -f /tmp/ngc$$.c
+
+ for include in $*; do
+ echo "#include <$include>" >> /tmp/ngc$$.c
+ done
+
+ cat >> /tmp/ngc$$.c << EOF
+main()
+{
+ $type foo;
+}
+EOF
+
+ LOGN "looking for $type type"
+
+ if __MAKEDOTO /tmp/ngc$$.c; then
+ AC_DEFINE HAVE_TYPE_`echo ${type} | $AC_UPPERCASE`
+ rc=0
+ else
+ rc=1
+ fi
+ rm -f /tmp/ngc$$.c
+ return $rc
+}
+
+
+#
+# check to see if some structure contains a field
+#
+# usage: AC_CHECK_FIELD structure field {include ...}
+#
+AC_CHECK_FIELD () {
+
+ struct=$1
+ field=$2
+ shift 2
+
+ rm -f /tmp/ngc$$.c
+
+ for include in $*;do
+ echo "#include <$include>" >> /tmp/ngc$$.c
+ done
+
+ cat >> /tmp/ngc$$.c << EOF
+main()
+{
+ struct $struct foo;
+
+ foo.$field;
+}
+EOF
+
+ LOGN "checking that struct $struct has a $field field"
+
+ if __MAKEDOTO /tmp/ngc$$.c; then
+ AC_DEFINE HAVE_`echo ${struct}_$field | $AC_UPPERCASE`
+ rc=0
+ else
+ rc=1
+ fi
+ rm -f /tmp/ngc$$.c
+ return $rc
+}
+
+
+#
+# check that the C compiler works
+#
+AC_PROG_CC () {
+ test "$AC_CC" && return 0
+
+ cat > /tmp/ngc$$.c << \EOF
+#include <stdio.h>
+main()
+{
+ puts("hello, sailor");
+}
+EOF
+
+ TLOGN "checking the C compiler"
+
+ unset AC_CFLAGS AC_LDFLAGS
+
+ if [ "$CC" ] ; then
+ AC_CC="$CC"
+ elif [ "$WITH_PATH" ]; then
+ AC_CC=`acLookFor cc`
+ elif [ "`acLookFor cc`" ]; then
+ # don't specify the full path if the user is looking in their $PATH
+ # for a C compiler.
+ AC_CC=cc
+ fi
+
+ # finally check for POSIX c89
+ test "$AC_CC" || AC_CC=`acLookFor c89`
+
+ if [ ! "$AC_CC" ]; then
+ TLOG " (no C compiler found)"
+ $__fail 1
+ fi
+ echo "checking out the C compiler"
+
+ $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c
+ status=$?
+
+ TLOGN " ($AC_CC)"
+ if [ $status -eq 0 ]; then
+ if $AC_CC -v 2>&1 | grep 'gcc version' >/dev/null; then
+ TLOG " oh ick, it looks like gcc"
+ IS_BROKEN_CC=T
+ else
+ TLOG " ok"
+ fi
+
+ # check that the CFLAGS and LDFLAGS aren't bogus
+
+ unset AC_CFLAGS AC_LDFLAGS
+
+ if [ "$CFLAGS" ]; then
+ test "$CFLAGS" && echo "validating CFLAGS=${CFLAGS}"
+ if $AC_CC $CFLAGS -o /tmp/ngc$$.o /tmp/ngc$$.c ; then
+ AC_CFLAGS=${CFLAGS:-"-g"}
+ test "$CFLAGS" && echo "CFLAGS=\"${CFLAGS}\" are okay"
+ elif [ "$CFLAGS" ]; then
+ echo "ignoring bogus CFLAGS=\"${CFLAGS}\""
+ fi
+ else
+ AC_CFLAGS=-g
+ fi
+ if [ "$LDFLAGS" ]; then
+ test "$LDFLAGS" && echo "validating LDFLAGS=${LDFLAGS}"
+ if $AC_CC $LDFLAGS -o /tmp/ngc$$ /tmp/ngc$$.o; then
+ AC_LDFLAGS=${LDFLAGS:-"-g"}
+ test "$LDFLAGS" && TLOG "LDFLAGS=\"${LDFLAGS}\" are okay"
+ elif [ "$LDFLAGS" ]; then
+ TLOG "ignoring bogus LDFLAGS=\"${LDFLAGS}\""
+ fi
+ else
+ AC_LDFLAGS=${CFLAGS:-"-g"}
+ fi
+ else
+ AC_FAIL " does not compile code properly"
+ fi
+
+ AC_SUB 'CC' "$AC_CC"
+
+ rm -f /tmp/ngc$$ /tmp/ngc$$.c /tmp/ngc$$.o
+
+ return $status
+}
+
+
+#
+# acLookFor actually looks for a program, without setting anything.
+#
+acLookFor () {
+ path=${AC_PATH:-$ac_default_path}
+ case "X$1" in
+ X-[rx]) __mode=$1
+ shift
+ ;;
+ *) __mode=-x
+ ;;
+ esac
+ oldifs="$IFS"
+ for program in $*; do
+ IFS=":"
+ for x in $path; do
+ if [ $__mode $x/$program -a -f $x/$program ]; then
+ echo $x/$program
+ break 2
+ fi
+ done
+ done
+ IFS="$oldifs"
+ unset __mode
+}
+
+
+#
+# check that a program exists and set its path
+#
+MF_PATH_INCLUDE () {
+ SYM=$1; shift
+
+ case X$1 in
+ X-[rx]) __mode=$1
+ shift
+ ;;
+ *) unset __mode
+ ;;
+ esac
+
+ TLOGN "looking for $1"
+
+ DEST=`acLookFor $__mode $*`
+
+ __sym=`echo "$SYM" | $AC_UPPERCASE`
+ if [ "$DEST" ]; then
+ TLOG " ($DEST)"
+ echo "$1 is $DEST"
+ AC_MAK $SYM
+ AC_DEFINE PATH_$__sym \""$DEST"\"
+ AC_SUB $__sym "$DEST"
+ eval CF_$SYM=$DEST
+ return 0
+ else
+ #AC_SUB $__sym ''
+ echo "$1 is not found"
+ TLOG " (not found)"
+ return 1
+ fi
+}
+
+#
+# AC_INIT starts the ball rolling
+#
+# After AC_INIT, fd's 1 and 2 point to config.log
+# and fd 5 points to what used to be fd 1
+#
+AC_INIT () {
+ __config_files="config.cmd config.sub config.h config.mak config.log"
+ rm -f $__config_files
+ __cwd=`pwd`
+ exec 5>&1 1>$__cwd/config.log 2>&1
+ AC_CONFIGURE_FOR=__AC_`echo $1 | sed -e 's/\..$//' | $AC_UPPERCASE | tr ' ' '_'`_D
+
+ # check to see whether to use echo -n or echo ...\c
+ #
+ echo -n hello > $$
+ echo world >> $$
+ if grep "helloworld" $$ >/dev/null; then
+ ac_echo="echo -n"
+ echo "[echo -n] works"
+ else
+ ac_echo="echo"
+ echo 'hello\c' > $$
+ echo 'world' >> $$
+ if grep "helloworld" $$ >/dev/null; then
+ ac_echo_nonl='\c'
+ echo "[echo ...\\c] works"
+ fi
+ fi
+ rm -f $$
+
+ LOG "Configuring for [$1]"
+
+ cat > $__cwd/config.h << EOF
+/*
+ * configuration for $1${2:+" ($2)"}, generated `date`
+ * by ${LOGNAME:-`whoami`}@`hostname`
+ */
+#ifndef $AC_CONFIGURE_FOR
+#define $AC_CONFIGURE_FOR 1
+
+
+EOF
+
+ unset __share
+ if [ -d $AC_PREFIX/share/man ]; then
+ for t in 1 2 3 4 5 6 7 8 9; do
+ if [ -d $AC_PREFIX/share/man/man$t ]; then
+ __share=/share
+ elif [ -d $AC_PREFIX/share/man/cat$t ]; then
+ __share=/share
+ fi
+ done
+ else
+ __share=
+ fi
+
+ if [ -d $AC_PREFIX/libexec ]; then
+ __libexec=libexec
+ else
+ __libexec=lib
+ fi
+
+
+ AC_PREFIX=${AC_PREFIX:-/usr/local}
+ AC_EXECDIR=${AC_EXECDIR:-$AC_PREFIX/bin}
+ AC_SBINDIR=${AC_SBINDIR:-$AC_PREFIX/sbin}
+ AC_LIBDIR=${AC_LIBDIR:-$AC_PREFIX/lib}
+ AC_MANDIR=${AC_MANDIR:-$AC_PREFIX$__share/man}
+ AC_LIBEXEC=${AC_LIBEXEC:-$AC_PREFIX/$__libexec}
+ AC_CONFDIR=${AC_CONFDIR:-/etc}
+
+ AC_PATH=${WITH_PATH:-$PATH}
+ AC_PROG_CPP
+ AC_PROG_INSTALL
+
+ ac_os=`uname -s`
+ _os=`echo $ac_os | $AC_UPPERCASE | sed -e 's/[^A-Z0-9_].*$//'`
+ AC_DEFINE OS_$_os 1
+ eval OS_${_os}=1
+ unset _os
+}
+
+
+#
+# AC_LIBRARY checks to see if a given library exists and contains the
+# given function.
+# usage: AC_LIBRARY function library [alternate ...]
+#
+AC_LIBRARY() {
+ SRC=$1
+ shift
+
+ __acllibs=
+ __aclhdrs=
+
+ for x in "$@"; do
+ case X"$x" in
+ X-l*) __acllibs="$__acllibs $x" ;;
+ *) __aclhdrs="$__aclhdrs $x" ;;
+ esac
+ done
+
+ # first see if the function can be found in any of the
+ # current libraries
+ AC_QUIET AC_CHECK_FUNCS $SRC $__aclhdrs && return 0
+
+ # then search through the list of libraries
+ __libs="$LIBS"
+ for x in $__acllibs; do
+ LIBS="$__libs $x"
+ if AC_QUIET AC_CHECK_FUNCS $SRC $__aclhdrs; then
+ AC_LIBS="$AC_LIBS $x"
+ return 0
+ fi
+ done
+ return 1
+}
+
+
+#
+# AC_PROG_LEX checks to see if LEX exists, and if it's lex or flex.
+#
+AC_PROG_LEX() {
+ TLOGN "looking for lex "
+
+ DEST=`acLookFor lex`
+ if [ "$DEST" ]; then
+ AC_MAK LEX
+ AC_DEFINE PATH_LEX \"$DEST\"
+ AC_SUB 'LEX' "$DEST"
+ echo "lex is $DEST"
+ else
+ DEST=`acLookFor flex`
+ if [ "$DEST" ]; then
+ AC_MAK FLEX
+ AC_DEFINE 'LEX' \"$DEST\"
+ AC_SUB 'LEX', "$DEST"
+ echo "lex is $DEST"
+ else
+ AC_SUB LEX ''
+ echo "neither lex or flex found"
+ TLOG " (not found)"
+ return 1
+ fi
+ fi
+
+ if AC_LIBRARY yywrap -ll -lfl; then
+ TLOG "($DEST)"
+ return 0
+ fi
+ TLOG "(no lex library found)"
+ return 1
+}
+
+
+#
+# AC_PROG_YACC checks to see if YACC exists, and if it's bison or
+# not.
+#
+AC_PROG_YACC () {
+
+ TLOGN "looking for yacc "
+
+ DEST=`acLookFor yacc`
+ if [ "$DEST" ]; then
+ AC_MAK YACC
+ AC_DEFINE PATH_YACC \"$DEST\"
+ AC_SUB 'YACC' "$DEST"
+ TLOG "($DEST)"
+ echo "yacc is $DEST"
+ else
+ DEST=`acLookFor bison`
+ if [ "$DEST" ]; then
+ AC_MAK BISON
+ AC_DEFINE 'YACC' \"$DEST\"
+ AC_SUB 'YACC' "$DEST -y"
+ echo "yacc is $DEST -y"
+ TLOG "($DEST -y)"
+ else
+ AC_SUB 'YACC' ''
+ echo "neither yacc or bison found"
+ TLOG " (not found)"
+ return 1
+ fi
+ fi
+ return 0
+}
+
+
+#
+# AC_PROG looks for a program
+#
+AC_PROG () {
+ PN=`basename $1 | $AC_UPPERCASE | tr -dc $AC_UPPER_PAT`
+
+ if set | grep -v PROG_$PN >/dev/null; then
+ TLOGN "looking for $1"
+ DEST=`acLookFor $1`
+ if [ "$DEST" ]; then
+ eval PROG_$PN="$DEST"
+ AC_SUB $PN $DEST
+ TLOG " ($DEST)"
+ return 0
+ fi
+ AC_SUB $PN true
+ TLOG " (not found)"
+ return 1
+ fi
+}
+
+
+#
+# AC_PROG_LN_S checks to see if ln exists, and, if so, if ln -s works
+#
+AC_PROG_LN_S () {
+ test "$AC_FIND_PROG" || AC_PROG_FIND
+
+ test "$AC_FIND_PROG" || return 1
+
+ TLOGN "looking for \"ln -s\""
+ DEST=`acLookFor ln`
+
+ if [ "$DEST" ]; then
+ rm -f /tmp/b$$
+ $DEST -s /tmp/a$$ /tmp/b$$
+ if [ "`$AC_FIND_PROG /tmp/b$$ -type l -print`" ]; then
+ TLOG " ($DEST)"
+ echo "$DEST exists, and ln -s works"
+ PROG_LN_S="$DEST -s"
+ AC_SUB 'LN_S' "$DEST -s"
+ rm -f /tmp/b$$
+ else
+ AC_SUB 'LN_S' ''
+ TLOG " ($DEST exists, but -s does not seem to work)"
+ echo "$DEST exists, but ln -s doesn't seem to work"
+ rm -f /tmp/b$$
+ return 1
+ fi
+ else
+ AC_SUB 'LN_S' ''
+ echo "ln not found"
+ TLOG " (not found)"
+ return 1
+ fi
+}
+
+
+#
+# AC_PROG_FIND looks for the find program and sets the FIND environment
+# variable
+#
+AC_PROG_FIND () {
+ if test -z "$AC_FIND_PROG"; then
+ MF_PATH_INCLUDE FIND find
+ rc=$?
+ AC_FIND_PROG=$DEST
+ return $rc
+ fi
+ return 0
+}
+
+
+#
+# AC_PROG_AWK looks for the awk program and sets the AWK environment
+# variable
+#
+AC_PROG_AWK () {
+ if test -z "$AC_AWK_PROG"; then
+ MF_PATH_INCLUDE AWK awk
+ rc=$?
+ AC_AWK_PROG=$DEST
+ return $rc
+ fi
+ return 0
+}
+
+
+#
+# AC_PROG_SED looks for the sed program and sets the SED environment
+# variable
+#
+AC_PROG_SED () {
+ if test -z "$AC_SED_PROG"; then
+ MF_PATH_INCLUDE SED sed
+ rc=$?
+ AC_SED_PROG=$DEST
+ return $rc
+ fi
+ return 0
+}
+
+
+#
+# AC_HEADER_SYS_WAIT looks for sys/wait.h
+#
+AC_HEADER_SYS_WAIT () {
+ AC_CHECK_HEADERS sys/wait.h || return 1
+}
+
+#
+# AC_TYPE_PID_T checks to see if the pid_t type exists
+#
+AC_TYPE_PID_T () {
+
+ AC_CHECK_TYPE pid_t sys/types.h
+ return $?
+}
+
+
+#
+# AC_C_CONST checks to see if the compiler supports the const keyword
+#
+AC_C_CONST () {
+ cat > /tmp/pd$$.c << EOF
+const char me=1;
+EOF
+ LOGN "checking for \"const\" keyword"
+
+ if __MAKEDOTO /tmp/pd$$.c; then
+ rc=0
+ else
+ AC_DEFINE 'const' '/**/'
+ rc=1
+ fi
+ rm -f /tmp/pd$$.c
+ return $rc
+}
+
+
+#
+# AC_C_VOLATILE checks to see if the compiler supports the volatile keyword
+#
+AC_C_VOLATILE () {
+ cat > /tmp/pd$$.c << EOF
+f() { volatile char me=1; }
+EOF
+ LOGN "checking for \"volatile\" keyword"
+
+ if __MAKEDOTO /tmp/pd$$.c; then
+ rc=0
+ else
+ AC_DEFINE 'volatile' '/**/'
+ rc=1
+ fi
+ rm -f /tmp/pd$$.c
+ return $rc
+}
+
+
+#
+# AC_SCALAR_TYPES checks to see if the compiler can generate 2 and 4 byte ints.
+#
+AC_SCALAR_TYPES () {
+ cat > /tmp/pd$$.c << EOF
+#include <stdio.h>
+#include <string.h>
+
+int pound_define = 1;
+
+void
+say(char *w, char *v)
+{
+ printf(pound_define ? "#define %s %s\n"
+ : "s:@%s@:%s:g\n", w, v);
+}
+
+void
+main(argc, argv)
+char **argv;
+{
+ unsigned long v_long;
+ unsigned int v_int;
+ unsigned short v_short;
+
+ if ( argc > 1 && strcmp(argv[1], "sub") == 0 )
+ pound_define = 0;
+
+ if (sizeof v_long == 4)
+ say("DWORD", "unsigned long");
+ else if (sizeof v_int == 4)
+ say("DWORD", "unsigned int");
+ else
+ exit(1);
+
+ if (sizeof v_int == 2)
+ say("WORD", "unsigned int");
+ else if (sizeof v_short == 2)
+ say("WORD", "unsigned short");
+ else
+ exit(2);
+ say("BYTE", "unsigned char");
+ exit(0);
+}
+EOF
+ rc=1
+ LOGN "defining WORD & DWORD scalar types"
+ if $AC_CC /tmp/pd$$.c -o /tmp/pd$$; then
+ while [ "$1" ]; do
+ case "$1" in
+ sub)if /tmp/pd$$ sub >> $__cwd/config.sub; then
+ rc=0
+ fi;;
+ *) if /tmp/pd$$ >> $__cwd/config.h; then
+ rc=0
+ fi ;;
+ esac
+ shift
+ done
+ if [ "$rc" != 0 ]; then