From 7b358424ebad9349421acd533c2fa1cbf6cf3e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 28 Dec 2016 16:52:56 +0100 Subject: Initial import of xtrkcad version 1:4.0.2-2 --- app/tools/halibut/CMakeLists.txt | 32 + app/tools/halibut/LICENCE | 36 + app/tools/halibut/README | 36 + app/tools/halibut/biblio.c | 105 + app/tools/halibut/bk_html.c | 2791 ++++++ app/tools/halibut/bk_paper.c | 2789 ++++++ app/tools/halibut/charset/CMakeLists.txt | 38 + app/tools/halibut/charset/LICENCE | 22 + app/tools/halibut/charset/README | 37 + app/tools/halibut/charset/big5enc.c | 93 + app/tools/halibut/charset/big5set.c | 4045 +++++++++ app/tools/halibut/charset/charset.h | 229 + app/tools/halibut/charset/cns11643.c | 13104 +++++++++++++++++++++++++++++ app/tools/halibut/charset/cp949.c | 94 + app/tools/halibut/charset/cstable.c | 120 + app/tools/halibut/charset/enum.c | 28 + app/tools/halibut/charset/euc.c | 272 + app/tools/halibut/charset/fromucs.c | 82 + app/tools/halibut/charset/gb2312.c | 2089 +++++ app/tools/halibut/charset/hz.c | 142 + app/tools/halibut/charset/internal.h | 126 + app/tools/halibut/charset/iso2022.c | 1385 +++ app/tools/halibut/charset/iso2022s.c | 544 ++ app/tools/halibut/charset/istate.c | 3 + app/tools/halibut/charset/jisx0208.c | 2021 +++++ app/tools/halibut/charset/jisx0212.c | 1919 +++++ app/tools/halibut/charset/ksx1001.c | 5261 ++++++++++++ app/tools/halibut/charset/locale.c | 93 + app/tools/halibut/charset/localenc.c | 174 + app/tools/halibut/charset/macenc.c | 169 + app/tools/halibut/charset/mimeenc.c | 333 + app/tools/halibut/charset/sbcs.c | 72 + app/tools/halibut/charset/sbcsdat.c | 4485 ++++++++++ app/tools/halibut/charset/sbcsdat.h | 75 + app/tools/halibut/charset/shiftjis.c | 128 + app/tools/halibut/charset/slookup.c | 29 + app/tools/halibut/charset/superset.c | 65 + app/tools/halibut/charset/test.c | 72 + app/tools/halibut/charset/toucs.c | 87 + app/tools/halibut/charset/utf16.c | 217 + app/tools/halibut/charset/utf7.c | 295 + app/tools/halibut/charset/utf8.c | 907 ++ app/tools/halibut/charset/xenc.c | 95 + app/tools/halibut/contents.c | 244 + app/tools/halibut/deflate.c | 2781 ++++++ app/tools/halibut/deflate.h | 168 + app/tools/halibut/error.c | 378 + app/tools/halibut/halibut.h | 548 ++ app/tools/halibut/help.c | 56 + app/tools/halibut/in_afm.c | 276 + app/tools/halibut/in_pf.c | 450 + app/tools/halibut/index.c | 270 + app/tools/halibut/input.c | 1644 ++++ app/tools/halibut/keywords.c | 154 + app/tools/halibut/licence.c | 51 + app/tools/halibut/main.c | 473 ++ app/tools/halibut/malloc.c | 149 + app/tools/halibut/misc.c | 580 ++ app/tools/halibut/paper.h | 405 + app/tools/halibut/psdata.c | 4523 ++++++++++ app/tools/halibut/tree234.c | 2197 +++++ app/tools/halibut/tree234.h | 202 + app/tools/halibut/ustring.c | 486 ++ app/tools/halibut/version | 1 + app/tools/halibut/version.c | 13 + app/tools/halibut/wcwidth.c | 184 + 66 files changed, 60972 insertions(+) create mode 100644 app/tools/halibut/CMakeLists.txt create mode 100644 app/tools/halibut/LICENCE create mode 100644 app/tools/halibut/README create mode 100644 app/tools/halibut/biblio.c create mode 100644 app/tools/halibut/bk_html.c create mode 100644 app/tools/halibut/bk_paper.c create mode 100644 app/tools/halibut/charset/CMakeLists.txt create mode 100644 app/tools/halibut/charset/LICENCE create mode 100644 app/tools/halibut/charset/README create mode 100644 app/tools/halibut/charset/big5enc.c create mode 100644 app/tools/halibut/charset/big5set.c create mode 100644 app/tools/halibut/charset/charset.h create mode 100644 app/tools/halibut/charset/cns11643.c create mode 100644 app/tools/halibut/charset/cp949.c create mode 100644 app/tools/halibut/charset/cstable.c create mode 100644 app/tools/halibut/charset/enum.c create mode 100644 app/tools/halibut/charset/euc.c create mode 100644 app/tools/halibut/charset/fromucs.c create mode 100644 app/tools/halibut/charset/gb2312.c create mode 100644 app/tools/halibut/charset/hz.c create mode 100644 app/tools/halibut/charset/internal.h create mode 100644 app/tools/halibut/charset/iso2022.c create mode 100644 app/tools/halibut/charset/iso2022s.c create mode 100644 app/tools/halibut/charset/istate.c create mode 100644 app/tools/halibut/charset/jisx0208.c create mode 100644 app/tools/halibut/charset/jisx0212.c create mode 100644 app/tools/halibut/charset/ksx1001.c create mode 100644 app/tools/halibut/charset/locale.c create mode 100644 app/tools/halibut/charset/localenc.c create mode 100644 app/tools/halibut/charset/macenc.c create mode 100644 app/tools/halibut/charset/mimeenc.c create mode 100644 app/tools/halibut/charset/sbcs.c create mode 100644 app/tools/halibut/charset/sbcsdat.c create mode 100644 app/tools/halibut/charset/sbcsdat.h create mode 100644 app/tools/halibut/charset/shiftjis.c create mode 100644 app/tools/halibut/charset/slookup.c create mode 100644 app/tools/halibut/charset/superset.c create mode 100644 app/tools/halibut/charset/test.c create mode 100644 app/tools/halibut/charset/toucs.c create mode 100644 app/tools/halibut/charset/utf16.c create mode 100644 app/tools/halibut/charset/utf7.c create mode 100644 app/tools/halibut/charset/utf8.c create mode 100644 app/tools/halibut/charset/xenc.c create mode 100644 app/tools/halibut/contents.c create mode 100644 app/tools/halibut/deflate.c create mode 100644 app/tools/halibut/deflate.h create mode 100644 app/tools/halibut/error.c create mode 100644 app/tools/halibut/halibut.h create mode 100644 app/tools/halibut/help.c create mode 100644 app/tools/halibut/in_afm.c create mode 100644 app/tools/halibut/in_pf.c create mode 100644 app/tools/halibut/index.c create mode 100644 app/tools/halibut/input.c create mode 100644 app/tools/halibut/keywords.c create mode 100644 app/tools/halibut/licence.c create mode 100644 app/tools/halibut/main.c create mode 100644 app/tools/halibut/malloc.c create mode 100644 app/tools/halibut/misc.c create mode 100644 app/tools/halibut/paper.h create mode 100644 app/tools/halibut/psdata.c create mode 100644 app/tools/halibut/tree234.c create mode 100644 app/tools/halibut/tree234.h create mode 100644 app/tools/halibut/ustring.c create mode 100644 app/tools/halibut/version create mode 100644 app/tools/halibut/version.c create mode 100644 app/tools/halibut/wcwidth.c (limited to 'app/tools/halibut') diff --git a/app/tools/halibut/CMakeLists.txt b/app/tools/halibut/CMakeLists.txt new file mode 100644 index 0000000..ec7d74b --- /dev/null +++ b/app/tools/halibut/CMakeLists.txt @@ -0,0 +1,32 @@ +SET(SOURCES + biblio.c + bk_html.c + contents.c + deflate.c + error.c + halibut.h + help.c + index.c + input.c + in_pf.c + in_afm.c + psdata.c + bk_paper.c + keywords.c + licence.c + main.c + malloc.c + misc.c + tree234.c + tree234.h + ustring.c + version.c + wcwidth.c + ) + +INCLUDE_DIRECTORIES(charset) +ADD_EXECUTABLE(halibut ${SOURCES}) +TARGET_LINK_LIBRARIES(halibut xtrkcad-charset) + +ADD_SUBDIRECTORY(charset) + diff --git a/app/tools/halibut/LICENCE b/app/tools/halibut/LICENCE new file mode 100644 index 0000000..972c0df --- /dev/null +++ b/app/tools/halibut/LICENCE @@ -0,0 +1,36 @@ +Halibut is copyright (c) 1999-2007 Simon Tatham. + +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, sublicense, 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: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Halibut contains font metrics derived from the "Font Metrics for PDF +Core 14 Fonts", which carry the following copyright notice and licence: + + Copyright (c) 1985, 1987, 1989, 1990, 1991, 1992, 1993, 1997 + Adobe Systems Incorporated. All Rights Reserved. + + This file and the 14 PostScript(R) AFM files it accompanies may be + used, copied, and distributed for any purpose and without charge, + with or without modification, provided that all copyright notices + are retained; that the AFM files are not distributed without this + file; that all modifications to this file or any of the AFM files + are prominently noted in the modified file(s); and that this + paragraph is not modified. Adobe Systems has no responsibility or + obligation to support the use of the AFM files. diff --git a/app/tools/halibut/README b/app/tools/halibut/README new file mode 100644 index 0000000..b602834 --- /dev/null +++ b/app/tools/halibut/README @@ -0,0 +1,36 @@ +HALIBUT Readme +============== + +This version of Halibut has been adapted to the needs of the XTrkCad +Project. It is based on version 1 of Halibut. + +The original version is available at: + +http://www.chiark.greenend.org.uk/~sgtatham/halibut/ + +This site also has the full documentation. + +XTrkCad Modifications +--------------------- + +The following changes have been made: + +1. Backends - only the HTML backend is included + +2. \f: Emphasize more + This formating instruction is similar to the \e. It is usually rendered + as bold on HTML + + Example: Here is some \f{bold text}. + + Nesting of \e and \f is unsupported. + +3 \G: Include graphic + This instruction is used to include bitmaps into the document. Note that + there are no checks for presence of the file nor whether its a valid + graphics format. + + \G just takes the filename as a parameter. + + Example: Include a bitmap here \G{png.d/bitmap.png}. + diff --git a/app/tools/halibut/biblio.c b/app/tools/halibut/biblio.c new file mode 100644 index 0000000..7ce163d --- /dev/null +++ b/app/tools/halibut/biblio.c @@ -0,0 +1,105 @@ +/* + * biblio.c: process the bibliography + */ + +#include +#include "halibut.h" + +static wchar_t *gentext(int num) { + wchar_t text[22]; + wchar_t *p = text + lenof(text); + *--p = L'\0'; + *--p = L']'; + while (num != 0) { + assert(p > text); + *--p = L"0123456789"[num % 10]; + num /= 10; + } + assert(p > text); + *--p = L'['; + return ustrdup(p); +} + +static void cite_biblio(keywordlist *kl, wchar_t *key, filepos fpos) { + keyword *kw = kw_lookup(kl, key); + if (!kw) + error(err_nosuchkw, &fpos, key); + else { + /* + * We've found a \k reference. If it's a + * bibliography entry ... + */ + if (kw->para->type == para_Biblio) { + /* + * ... then mark the paragraph as cited. + */ + kw->para->type = para_BiblioCited; + } + } +} + +/* + * Make a pass through the source form, generating citation formats + * for bibliography entries and also marking which bibliography + * entries are actually cited (or \nocite-ed). + */ + +void gen_citations(paragraph *source, keywordlist *kl) { + paragraph *para; + int bibnum = 0; + + for (para = source; para; para = para->next) { + word *ptr; + + /* + * \BR and \nocite paragraphs get special processing here. + */ + if (para->type == para_BR) { + keyword *kw = kw_lookup(kl, para->keyword); + if (!kw) { + error(err_nosuchkw, ¶->fpos, para->keyword); + } else if (kw->text) { + error(err_multiBR, ¶->fpos, para->keyword); + } else { + kw->text = dup_word_list(para->words); + } + } else if (para->type == para_NoCite) { + wchar_t *wp = para->keyword; + while (*wp) { + cite_biblio(kl, wp, para->fpos); + wp = uadv(wp); + } + } + + /* + * Scan for keyword references. + */ + for (ptr = para->words; ptr; ptr = ptr->next) { + if (ptr->type == word_UpperXref || + ptr->type == word_LowerXref) + cite_biblio(kl, ptr->text, ptr->fpos); + } + } + + /* + * We're now almost done; all that remains is to scan through + * the cited bibliography entries and invent default citation + * texts for the ones that don't already have explicitly + * provided \BR text. + */ + for (para = source; para; para = para->next) { + if (para->type == para_BiblioCited) { + keyword *kw = kw_lookup(kl, para->keyword); + assert(kw != NULL); + if (!kw->text) { + word *wd = smalloc(sizeof(word)); + wd->text = gentext(++bibnum); + wd->type = word_Normal; + wd->alt = NULL; + wd->next = NULL; + kw->text = wd; + } + para->kwtext = kw->text; + } + } +} diff --git a/app/tools/halibut/bk_html.c b/app/tools/halibut/bk_html.c new file mode 100644 index 0000000..8b5443b --- /dev/null +++ b/app/tools/halibut/bk_html.c @@ -0,0 +1,2791 @@ +/* + * HTML backend for Halibut + */ + +/* + * TODO: + * + * - I'm never entirely convinced that having a fragment link to + * come in at the start of the real text in the file is + * sensible. Perhaps for the topmost section in the file, no + * fragment should be used? (Though it should probably still be + * _there_ even if unused.) + * + * - In HHK index mode: subsidiary hhk entries (as in replacing + * `foo, bar' with `foo\n\tbar') can be done by embedding + * sub-