Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/public-domain/sqlite/sqlite2mdoc From: https://gith...
details: https://anonhg.NetBSD.org/src/rev/efdd0ab8c807
branches: trunk
changeset: 344453:efdd0ab8c807
user: christos <christos%NetBSD.org@localhost>
date: Wed Mar 30 21:30:20 2016 +0000
description:
From: https://github.com/kristapsdz/sqlite2mdoc
diffstat:
external/public-domain/sqlite/sqlite2mdoc/LICENSE.md | 14 +
external/public-domain/sqlite/sqlite2mdoc/Makefile | 22 +
external/public-domain/sqlite/sqlite2mdoc/README.md | 35 +
external/public-domain/sqlite/sqlite2mdoc/main.c | 1574 +++++++++++++++
external/public-domain/sqlite/sqlite2mdoc/sqlite2mdoc.1 | 129 +
5 files changed, 1774 insertions(+), 0 deletions(-)
diffs (truncated from 1794 to 300 lines):
diff -r 893462e6aa71 -r efdd0ab8c807 external/public-domain/sqlite/sqlite2mdoc/LICENSE.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/public-domain/sqlite/sqlite2mdoc/LICENSE.md Wed Mar 30 21:30:20 2016 +0000
@@ -0,0 +1,14 @@
+Copyright (c) 2012--2016, Kristaps Dzonsons <kristaps%bsd.lv@localhost>
+
+Permission to use, copy, modify, and/or 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.
+
diff -r 893462e6aa71 -r efdd0ab8c807 external/public-domain/sqlite/sqlite2mdoc/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/public-domain/sqlite/sqlite2mdoc/Makefile Wed Mar 30 21:30:20 2016 +0000
@@ -0,0 +1,22 @@
+# If you're on Linux, un-comment the following.
+#LDADD = -lbsd
+
+#####################################################################
+# You probably don't want to change anything beneath here.
+#####################################################################
+
+CFLAGS += -g -W -Wall
+PREFIX = /usr/local
+
+sqlite2mdoc: main.o
+ $(CC) -o $@ main.o $(LDADD)
+
+install:
+ mkdir -p $(DESTDIR)$(PREFIX)/bin
+ mkdir -p $(DESTDIR)$(PREFIX)/man/man1
+ install -m 0755 sqlite2mdoc $(DESTDIR)$(PREFIX)/bin
+ install -m 0444 sqlite2mdoc.1 $(DESTDIR)$(PREFIX)/man/man1
+
+clean:
+ rm -f sqlite2mdoc main.o
+ rm -rf sqlite2mdoc.dSYM
diff -r 893462e6aa71 -r efdd0ab8c807 external/public-domain/sqlite/sqlite2mdoc/README.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/public-domain/sqlite/sqlite2mdoc/README.md Wed Mar 30 21:30:20 2016 +0000
@@ -0,0 +1,35 @@
+## Synopsis
+
+This utility accepts an [SQLite](https://www.sqlite.org) header file
+`sqlite.h` and produces a set of decently well-formed
+[mdoc(7)](http://man.openbsd.org/OpenBSD-current/man7/mdoc.7) files
+documenting the C API.
+These will be roughly equivalent to the [C-language Interface
+Specification for SQLite](https://www.sqlite.org/c3ref/intro.html).
+
+You can also use it for any file(s) using the documentation standards of
+SQLite.
+See the [sqlite2mdoc.1](sqlite2mdoc.1) manpage for syntax details.
+
+This [GitHub](https://www.github.com) repository is a read-only mirror
+of the project's CVS repository.
+
+## Installation
+
+Simply run `make`: this utility isn't meant for installation, but for
+integration into your SQLite deployment phase.
+You can run `make install`, however, if you plan on using it for other
+documentation.
+There are no compile-time or run-time dependencies unless you're on
+Linux, in which case you'll need
+[libbsd](https://libbsd.freedesktop.org).
+You'll also need to uncomment the `LDADD` line in the
+[Makefile](Makefile), in this case.
+
+
+This software has been used on OpenBSD, Mac OS X, and Linux machines.
+
+## License
+
+All sources use the ISC (like OpenBSD) license.
+See the [LICENSE.md](LICENSE.md) file for details.
diff -r 893462e6aa71 -r efdd0ab8c807 external/public-domain/sqlite/sqlite2mdoc/main.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/public-domain/sqlite/sqlite2mdoc/main.c Wed Mar 30 21:30:20 2016 +0000
@@ -0,0 +1,1574 @@
+/* $Id: main.c,v 1.1 2016/03/30 21:30:20 christos Exp $ */
+/*
+ * Copyright (c) 2016 Kristaps Dzonsons <kristaps%bsd.lv@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifdef __linux__
+#define _GNU_SOURCE
+#endif
+#include <sys/queue.h>
+
+#include <assert.h>
+#include <ctype.h>
+#include <err.h>
+#include <getopt.h>
+#include <search.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef __linux__
+#include <bsd/stdio.h>
+#include <bsd/stdlib.h>
+#include <bsd/string.h>
+#endif
+
+/*
+ * Phase of parsing input file.
+ */
+enum phase {
+ PHASE_INIT = 0, /* waiting to encounter definition */
+ PHASE_KEYS, /* have definition, now keywords */
+ PHASE_DESC, /* have keywords, now description */
+ PHASE_SEEALSO,
+ PHASE_DECL /* have description, now declarations */
+};
+
+/*
+ * What kind of declaration (preliminary analysis).
+ */
+enum decltype {
+ DECLTYPE_CPP, /* pre-processor */
+ DECLTYPE_C, /* semicolon-closed non-preprocessor */
+ DECLTYPE_NEITHER /* non-preprocessor, no semicolon */
+};
+
+/*
+ * In variables and function declarations, we toss these.
+ */
+enum preproc {
+ PREPROC_SQLITE_API,
+ PREPROC_SQLITE_DEPRECATED,
+ PREPROC_SQLITE_EXPERIMENTAL,
+ PREPROC_SQLITE_EXTERN,
+ PREPROC__MAX
+};
+
+/*
+ * HTML tags that we recognise.
+ */
+enum tag {
+ TAG_B_CLOSE,
+ TAG_B_OPEN,
+ TAG_BLOCK_CLOSE,
+ TAG_BLOCK_OPEN,
+ TAG_DD_CLOSE,
+ TAG_DD_OPEN,
+ TAG_DL_CLOSE,
+ TAG_DL_OPEN,
+ TAG_DT_CLOSE,
+ TAG_DT_OPEN,
+ TAG_H3_CLOSE,
+ TAG_H3_OPEN,
+ TAG_LI_CLOSE,
+ TAG_LI_OPEN,
+ TAG_OL_CLOSE,
+ TAG_OL_OPEN,
+ TAG_PRE_CLOSE,
+ TAG_PRE_OPEN,
+ TAG_UL_CLOSE,
+ TAG_UL_OPEN,
+ TAG__MAX
+};
+
+TAILQ_HEAD(defnq, defn);
+TAILQ_HEAD(declq, decl);
+
+/*
+ * A declaration of type DECLTYPE_CPP or DECLTYPE_C.
+ * These need not be unique (if ifdef'd).
+ */
+struct decl {
+ enum decltype type; /* type of declaration */
+ char *text; /* text */
+ size_t textsz; /* strlen(text) */
+ TAILQ_ENTRY(decl) entries;
+};
+
+/*
+ * A definition is basically the manpage contents.
+ */
+struct defn {
+ char *name; /* really Nd */
+ TAILQ_ENTRY(defn) entries;
+ char *desc; /* long description */
+ size_t descsz; /* strlen(desc) */
+ struct declq dcqhead; /* declarations */
+ int multiline; /* used when parsing */
+ int instruct; /* used when parsing */
+ const char *fn; /* parsed from file */
+ size_t ln; /* parsed at line */
+ int postprocessed; /* good for emission? */
+ char *dt; /* manpage title */
+ char **nms; /* manpage names */
+ size_t nmsz; /* number of names */
+ char *fname; /* manpage filename */
+ char *keybuf; /* raw keywords */
+ size_t keybufsz; /* length of "keysbuf" */
+ char *seealso; /* see also tags */
+ size_t seealsosz; /* length of seealso */
+ char **xrs; /* parsed "see also" references */
+ size_t xrsz; /* number of references */
+ char **keys; /* parsed keywords */
+ size_t keysz; /* number of keywords */
+};
+
+/*
+ * Entire parse routine.
+ */
+struct parse {
+ enum phase phase; /* phase of parse */
+ size_t ln; /* line number */
+ const char *fn; /* open file */
+ struct defnq dqhead; /* definitions */
+};
+
+/*
+ * How to handle HTML tags we find in the text.
+ */
+struct taginfo {
+ const char *html; /* HTML to key on */
+ const char *mdoc; /* generate mdoc(7) */
+ unsigned int flags;
+#define TAGINFO_NOBR 0x01 /* follow w/space, not newline */
+#define TAGINFO_NOOP 0x02 /* just strip out */
+#define TAGINFO_NOSP 0x04 /* follow w/o space or newline */
+#define TAGINFO_INLINE 0x08 /* inline block (notused) */
+};
+
+static const struct taginfo tags[TAG__MAX] = {
+ { "</b>", "\\fP", TAGINFO_INLINE }, /* TAG_B_CLOSE */
+ { "<b>", "\\fB", TAGINFO_INLINE }, /* TAG_B_OPEN */
+ { "</blockquote>", ".Ed\n.Pp", 0 }, /* TAG_BLOCK_CLOSE */
+ { "<blockquote>", ".Bd -ragged", 0 }, /* TAG_BLOCK_OPEN */
+ { "</dd>", "", TAGINFO_NOOP }, /* TAG_DD_CLOSE */
+ { "<dd>", "", TAGINFO_NOOP }, /* TAG_DD_OPEN */
+ { "</dl>", ".El\n.Pp", 0 }, /* TAG_DL_CLOSE */
+ { "<dl>", ".Bl -tag -width Ds", 0 }, /* TAG_DL_OPEN */
+ { "</dt>", "", TAGINFO_NOBR | TAGINFO_NOSP}, /* TAG_DT_CLOSE */
+ { "<dt>", ".It", TAGINFO_NOBR }, /* TAG_DT_OPEN */
+ { "</h3>", "", TAGINFO_NOBR | TAGINFO_NOSP}, /* TAG_H3_CLOSE */
+ { "<h3>", ".Ss", TAGINFO_NOBR }, /* TAG_H3_OPEN */
+ { "</li>", "", TAGINFO_NOOP }, /* TAG_LI_CLOSE */
+ { "<li>", ".It", 0 }, /* TAG_LI_OPEN */
+ { "</ol>", ".El\n.Pp", 0 }, /* TAG_OL_CLOSE */
+ { "<ol>", ".Bl -enum", 0 }, /* TAG_OL_OPEN */
+ { "</pre>", ".Ed\n.Pp", 0 }, /* TAG_PRE_CLOSE */
+ { "<pre>", ".Bd -literal", 0 }, /* TAG_PRE_OPEN */
+ { "</ul>", ".El\n.Pp", 0 }, /* TAG_UL_CLOSE */
+ { "<ul>", ".Bl -bullet", 0 }, /* TAG_UL_OPEN */
+};
+
+static const char *const preprocs[TAG__MAX] = {
+ "SQLITE_API", /* PREPROC_SQLITE_API */
+ "SQLITE_DEPRECATED", /* PREPROC_SQLITE_DEPRECATED */
+ "SQLITE_EXPERIMENTAL", /* PREPROC_SQLITE_EXPERIMENTAL */
+ "SQLITE_EXTERN", /* PREPROC_SQLITE_EXTERN */
+};
+
+/* Verbose reporting. */
+static int verbose;
+/* Don't output any files: use stdout. */
+static int nofile;
+
+static void
+decl_function_add(struct parse *p, char **etext,
+ size_t *etextsz, const char *cp, size_t len)
+{
+
+ if (' ' != (*etext)[*etextsz - 1]) {
+ *etext = realloc(*etext, *etextsz + 2);
+ if (NULL == *etext)
+ err(EXIT_FAILURE, "%s:%zu: "
+ "realloc", p->fn, p->ln);
+ (*etextsz)++;
+ strlcat(*etext, " ", *etextsz + 1);
+ }
+ *etext = realloc(*etext, *etextsz + len + 1);
+ if (NULL == *etext)
+ err(EXIT_FAILURE, "%s:%zu: realloc", p->fn, p->ln);
+ memcpy(*etext + *etextsz, cp, len);
+ *etextsz += len;
+ (*etext)[*etextsz] = '\0';
+}
Home |
Main Index |
Thread Index |
Old Index