Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/mdocml/dist Merge mdocml 1.12.3.
details: https://anonhg.NetBSD.org/src/rev/9de00a9d348e
branches: trunk
changeset: 792507:9de00a9d348e
user: joerg <joerg%NetBSD.org@localhost>
date: Sun Jan 05 19:27:20 2014 +0000
description:
Merge mdocml 1.12.3.
diffstat:
external/bsd/mdocml/dist/apropos_db.c | 876 -------------------------------
external/bsd/mdocml/dist/apropos_db.h | 73 --
external/bsd/mdocml/dist/arch.in | 5 +-
external/bsd/mdocml/dist/catman.8 | 111 ---
external/bsd/mdocml/dist/catman.c | 511 ------------------
external/bsd/mdocml/dist/compat_fgetln.c | 2 +-
external/bsd/mdocml/dist/lib.in | 21 +-
external/bsd/mdocml/dist/libmandoc.h | 29 +-
external/bsd/mdocml/dist/man_term.c | 245 +++++--
external/bsd/mdocml/dist/mandoc.h | 42 +-
external/bsd/mdocml/dist/mandocdb.h | 62 --
external/bsd/mdocml/dist/mdoc_argv.c | 119 +--
external/bsd/mdocml/dist/mdoc_term.c | 314 +++++-----
external/bsd/mdocml/dist/mdoc_validate.c | 384 +++++++++---
external/bsd/mdocml/dist/msec.in | 2 +-
external/bsd/mdocml/dist/read.c | 163 +++--
external/bsd/mdocml/dist/roff.c | 704 ++++++++++++++----------
external/bsd/mdocml/dist/st.in | 26 +-
external/bsd/mdocml/dist/tbl.c | 38 +-
external/bsd/mdocml/dist/tbl_data.c | 12 +-
external/bsd/mdocml/dist/tbl_layout.c | 154 +----
external/bsd/mdocml/dist/tbl_opts.c | 2 +-
external/bsd/mdocml/dist/whatis.1 | 190 ------
23 files changed, 1307 insertions(+), 2778 deletions(-)
diffs (truncated from 6663 to 300 lines):
diff -r d4a8bf49c25e -r 9de00a9d348e external/bsd/mdocml/dist/apropos_db.c
--- a/external/bsd/mdocml/dist/apropos_db.c Sun Jan 05 19:26:44 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,876 +0,0 @@
-/* $Vendor-Id: apropos_db.c,v 1.31 2012/03/24 01:46:25 kristaps Exp $ */
-/*
- * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps%bsd.lv@localhost>
- * Copyright (c) 2011 Ingo Schwarze <schwarze%openbsd.org@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 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 <assert.h>
-#include <fcntl.h>
-#include <regex.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#if defined(__linux__)
-# include <endian.h>
-# include <db_185.h>
-#elif defined(__APPLE__)
-# include <libkern/OSByteOrder.h>
-# include <db.h>
-#else
-# include <db.h>
-#endif
-
-#include "mandocdb.h"
-#include "apropos_db.h"
-#include "mandoc.h"
-
-#define RESFREE(_x) \
- do { \
- free((_x)->file); \
- free((_x)->cat); \
- free((_x)->title); \
- free((_x)->arch); \
- free((_x)->desc); \
- free((_x)->matches); \
- } while (/*CONSTCOND*/0)
-
-struct expr {
- int regex; /* is regex? */
- int index; /* index in match array */
- uint64_t mask; /* type-mask */
- int and; /* is rhs of logical AND? */
- char *v; /* search value */
- regex_t re; /* compiled re, if regex */
- struct expr *next; /* next in sequence */
- struct expr *subexpr;
-};
-
-struct type {
- uint64_t mask;
- const char *name;
-};
-
-struct rectree {
- struct res *node; /* record array for dir tree */
- int len; /* length of record array */
-};
-
-static const struct type types[] = {
- { TYPE_An, "An" },
- { TYPE_Ar, "Ar" },
- { TYPE_At, "At" },
- { TYPE_Bsx, "Bsx" },
- { TYPE_Bx, "Bx" },
- { TYPE_Cd, "Cd" },
- { TYPE_Cm, "Cm" },
- { TYPE_Dv, "Dv" },
- { TYPE_Dx, "Dx" },
- { TYPE_Em, "Em" },
- { TYPE_Er, "Er" },
- { TYPE_Ev, "Ev" },
- { TYPE_Fa, "Fa" },
- { TYPE_Fl, "Fl" },
- { TYPE_Fn, "Fn" },
- { TYPE_Fn, "Fo" },
- { TYPE_Ft, "Ft" },
- { TYPE_Fx, "Fx" },
- { TYPE_Ic, "Ic" },
- { TYPE_In, "In" },
- { TYPE_Lb, "Lb" },
- { TYPE_Li, "Li" },
- { TYPE_Lk, "Lk" },
- { TYPE_Ms, "Ms" },
- { TYPE_Mt, "Mt" },
- { TYPE_Nd, "Nd" },
- { TYPE_Nm, "Nm" },
- { TYPE_Nx, "Nx" },
- { TYPE_Ox, "Ox" },
- { TYPE_Pa, "Pa" },
- { TYPE_Rs, "Rs" },
- { TYPE_Sh, "Sh" },
- { TYPE_Ss, "Ss" },
- { TYPE_St, "St" },
- { TYPE_Sy, "Sy" },
- { TYPE_Tn, "Tn" },
- { TYPE_Va, "Va" },
- { TYPE_Va, "Vt" },
- { TYPE_Xr, "Xr" },
- { UINT64_MAX, "any" },
- { 0, NULL }
-};
-
-static DB *btree_open(void);
-static int btree_read(const DBT *, const DBT *,
- const struct mchars *,
- uint64_t *, recno_t *, char **);
-static int expreval(const struct expr *, int *);
-static void exprexec(const struct expr *,
- const char *, uint64_t, struct res *);
-static int exprmark(const struct expr *,
- const char *, uint64_t, int *);
-static struct expr *exprexpr(int, char *[], int *, int *, size_t *);
-static struct expr *exprterm(char *, int);
-static DB *index_open(void);
-static int index_read(const DBT *, const DBT *, int,
- const struct mchars *, struct res *);
-static void norm_string(const char *,
- const struct mchars *, char **);
-static size_t norm_utf8(unsigned int, char[7]);
-static int single_search(struct rectree *, const struct opts *,
- const struct expr *, size_t terms,
- struct mchars *, int);
-
-/*
- * Open the keyword mandoc-db database.
- */
-static DB *
-btree_open(void)
-{
- BTREEINFO info;
- DB *db;
-
- memset(&info, 0, sizeof(BTREEINFO));
- info.lorder = 4321;
- info.flags = R_DUP;
-
- db = dbopen(MANDOC_DB, O_RDONLY, 0, DB_BTREE, &info);
- if (NULL != db)
- return(db);
-
- return(NULL);
-}
-
-/*
- * Read a keyword from the database and normalise it.
- * Return 0 if the database is insane, else 1.
- */
-static int
-btree_read(const DBT *k, const DBT *v, const struct mchars *mc,
- uint64_t *mask, recno_t *rec, char **buf)
-{
- uint64_t vbuf[2];
-
- /* Are our sizes sane? */
- if (k->size < 2 || sizeof(vbuf) != v->size)
- return(0);
-
- /* Is our string nil-terminated? */
- if ('\0' != ((const char *)k->data)[(int)k->size - 1])
- return(0);
-
- norm_string((const char *)k->data, mc, buf);
- memcpy(vbuf, v->data, v->size);
- *mask = betoh64(vbuf[0]);
- *rec = betoh64(vbuf[1]);
- return(1);
-}
-
-/*
- * Take a Unicode codepoint and produce its UTF-8 encoding.
- * This isn't the best way to do this, but it works.
- * The magic numbers are from the UTF-8 packaging.
- * They're not as scary as they seem: read the UTF-8 spec for details.
- */
-static size_t
-norm_utf8(unsigned int cp, char out[7])
-{
- int rc;
-
- rc = 0;
-
- if (cp <= 0x0000007F) {
- rc = 1;
- out[0] = (char)cp;
- } else if (cp <= 0x000007FF) {
- rc = 2;
- out[0] = (cp >> 6 & 31) | 192;
- out[1] = (cp & 63) | 128;
- } else if (cp <= 0x0000FFFF) {
- rc = 3;
- out[0] = (cp >> 12 & 15) | 224;
- out[1] = (cp >> 6 & 63) | 128;
- out[2] = (cp & 63) | 128;
- } else if (cp <= 0x001FFFFF) {
- rc = 4;
- out[0] = (cp >> 18 & 7) | 240;
- out[1] = (cp >> 12 & 63) | 128;
- out[2] = (cp >> 6 & 63) | 128;
- out[3] = (cp & 63) | 128;
- } else if (cp <= 0x03FFFFFF) {
- rc = 5;
- out[0] = (cp >> 24 & 3) | 248;
- out[1] = (cp >> 18 & 63) | 128;
- out[2] = (cp >> 12 & 63) | 128;
- out[3] = (cp >> 6 & 63) | 128;
- out[4] = (cp & 63) | 128;
- } else if (cp <= 0x7FFFFFFF) {
- rc = 6;
- out[0] = (cp >> 30 & 1) | 252;
- out[1] = (cp >> 24 & 63) | 128;
- out[2] = (cp >> 18 & 63) | 128;
- out[3] = (cp >> 12 & 63) | 128;
- out[4] = (cp >> 6 & 63) | 128;
- out[5] = (cp & 63) | 128;
- } else
- return(0);
-
- out[rc] = '\0';
- return((size_t)rc);
-}
-
-/*
- * Normalise strings from the index and database.
- * These strings are escaped as defined by mandoc_char(7) along with
- * other goop in mandoc.h (e.g., soft hyphens).
- * This function normalises these into a nice UTF-8 string.
- * Returns 0 if the database is fucked.
- */
-static void
-norm_string(const char *val, const struct mchars *mc, char **buf)
-{
- size_t sz, bsz;
- char utfbuf[7];
- const char *seq, *cpp;
- int len, u, pos;
- enum mandoc_esc esc;
- static const char res[] = { '\\', '\t',
- ASCII_NBRSP, ASCII_HYPH, '\0' };
-
- /* Pre-allocate by the length of the input */
-
- bsz = strlen(val) + 1;
- *buf = mandoc_realloc(*buf, bsz);
- pos = 0;
-
- while ('\0' != *val) {
- /*
- * Halt on the first escape sequence.
- * This also halts on the end of string, in which case
- * we just copy, fallthrough, and exit the loop.
- */
- if ((sz = strcspn(val, res)) > 0) {
- memcpy(&(*buf)[pos], val, sz);
- pos += (int)sz;
- val += (int)sz;
- }
-
- if (ASCII_HYPH == *val) {
- (*buf)[pos++] = '-';
- val++;
- continue;
- } else if ('\t' == *val || ASCII_NBRSP == *val) {
- (*buf)[pos++] = ' ';
- val++;
- continue;
- } else if ('\\' != *val)
- break;
-
- /* Read past the slash. */
-
- val++;
- u = 0;
-
- /*
- * Parse the escape sequence and see if it's a
- * predefined character or special character.
- */
-
- esc = mandoc_escape(&val, &seq, &len);
Home |
Main Index |
Thread Index |
Old Index