halibut-1.2/0000755000175000017500000000000013106256630010007 500000000000000halibut-1.2/Buildscr0000644000175000017500000000365313106256630011430 00000000000000# -*- sh -*- # Build script to build Halibut releases. module halibut ifnexist halibut/charset checkout charset halibut/charset set Version $(!builddate).$(vcsid) ifneq "$(RELEASE)" "" set Version $(RELEASE) # use perl to avoid inconsistent behaviour of echo '\v' in halibut do perl -e 'print "\n\\versionid Halibut version $$ARGV[0]\n"' $(Version) >> doc/manpage.but # Write out a version.h that contains the real version number. in halibut do echo '/* Generated by automated build script */' > version.h in halibut do echo '$#define VERSION "version $(Version)"' >> version.h set Rel ifneq "$(RELEASE)" "" set Rel RELEASE=$(RELEASE) set Basename halibut-$(Version) # Make the source archive. in halibut do ./release.sh $(Basename) $(Version) # Build a Windows binary of Halibut using clang-cl. in halibut with clangcl64 do make CC='clang --target=x86_64-pc-windows-msvc18.0.0 -D_CRT_SECURE_NO_WARNINGS' CC_LINK='lld-link -defaultlib:libcmt -out:$$@' EXE=.exe in halibut do mv build/halibut.exe . in halibut do rm -rf build delegate windows # Code-sign the Windows binary, if the local bob config provides # a script to do so. We assume here that the script accepts an -i # option to provide a 'more info' URL, and that it signs the file # in place. ifneq "$(winsigncode)" "" in halibut do $(winsigncode) -i http://www.chiark.greenend.org.uk/~sgtatham/halibut/ halibut.exe return halibut/halibut.exe enddelegate # Build a local binary of Halibut in order to build the docs. Make # sure to tag it with the supplied version number, so that the # release docs announce themselves as having been built with the # release Halibut (e.g. PDF's Producer property). in halibut do make $(Rel) # And now build the docs. in halibut/doc do make deliver halibut/*.tar.gz $@ deliver halibut/halibut.exe $@ deliver halibut/doc/halibut.pdf $@ deliver halibut/doc/halibut.txt $@ deliver halibut/doc/halibut.chm $@ deliver halibut/doc/*.html $@ halibut-1.2/INSTALL0000644000175000017500000000634413106256630010767 00000000000000Installation guide for Halibut ============================== This file is a guide to building and installing the documentation utility `Halibut' from its source archive. If you are reading this, then you have probably already unpacked the source archive somewhere. Building Halibut ---------------- If you have GNU make and gcc, you should simply be able to type `make'. The Makefile will generate a `build' subdirectory, and will put all the object files and binaries in there. In a release archive, the Makefile will also check the source files against a list of MD5 checksums, and if they match it will automatically add the correct version number to the build. This is _not_ a secure measure intended to enforce that only approved Halibut sources are ever built into a binary with a given version number; it is merely a sanity check against heavily modified copies _accidentally_ confusing users expecting standard versions of Halibut. Distribution maintainers are entirely at liberty, if they choose, to modify Halibut source files as appropriate for their distribution and then have the resulting binary call itself by the original version number. If you run `make VERSION=x.y', the resulting Halibut binary will call itself version x.y irrespective of the md5sum manifest. (You may also need to do this if your build system does not have the md5sum program.) Halibut unfortunately does not yet come with an autoconf-generated makefile, so if you do not have these utilities then you will have to do the build manually. Look in the master `Makefile' to find the list of source modules (they will be listed on the line starting `MODULES :=', and continued on lines starting `MODULES +='), compile those files with the C compiler of your choice, and link them together into a binary. In addition to the modules on that list, you will also need to compile `version.c', and if you wish your Halibut binary to identify itself with a version number then you will have to define the preprocessor symbol `VERSION' to the required version number string. On Unix this can be done with a command such as cc -c -DVERSION=\"0.9\" version.c Halibut's source files are intended to be almost entirely portable ANSI C. If they fail to compile and run correctly on your compiler, this might very well be considered a bug. Building the Halibut manual --------------------------- Once you have built Halibut itself, you might well want to build its manual. If you're using GNU make, you can do this just by changing into the `doc' subdirectory and typing `make'. (This relies on the Halibut binary you built in the previous step being present in the `build' subdirectory.) Failing that, you will need to read the Makefile and run a manual Halibut command, of the form halibut --text=halibut.txt --html blurb.but intro.but [...] index.but (The precise list of .but files is given at the top of doc/Makefile.) This will build plain text documentation in `halibut.txt', and a set of HTML files (*.html). It will also build a short man page `halibut.1', although this is by no means a replacement for the full manual. Installing Halibut ------------------ Halibut requires no additional data files. Simply install the binary, man page and full documentation in appropriate places for your system. halibut-1.2/LICENCE0000644000175000017500000000347613106256630010726 00000000000000Halibut is copyright (c) 1999-2017 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. halibut-1.2/Makefile0000644000175000017500000000551113106256630011371 00000000000000# Halibut master makefile # Currently depends on gcc, because: # - the dependency tracking uses -MD in order to avoid needing an # explicit `make depend' step # - the definition of CFLAGS includes the gcc-specific flag # `-Wall' # # Currently depends on GNU make, because: # - the Makefile uses GNU ifdef / ifndef commands and GNU make `%' # pattern rules # - we use .PHONY prefix=/usr/local exec_prefix=$(prefix) bindir=$(exec_prefix)/bin INSTALL=install -c .PHONY: all install clean spotless topclean release ifdef RELEASE ifndef VERSION VERSION := $(RELEASE) endif else CFLAGS += -g endif ifeq (x$(VERSION)y,xy) RELDIR := halibut else RELDIR := halibut-$(VERSION) endif # `make' from top level will build in directory `build' # `make BUILDDIR=foo' from top level will build in directory foo ifndef REALBUILD ifndef BUILDDIR ifdef TEST BUILDDIR := test else BUILDDIR := build endif endif all install: @test -d $(BUILDDIR) || mkdir $(BUILDDIR) @$(MAKE) -C $(BUILDDIR) -f ../Makefile $@ REALBUILD=yes spotless: topclean @test -d $(BUILDDIR) || mkdir $(BUILDDIR) @$(MAKE) -C $(BUILDDIR) -f ../Makefile spotless REALBUILD=yes clean: topclean @test -d $(BUILDDIR) || mkdir $(BUILDDIR) @$(MAKE) -C $(BUILDDIR) -f ../Makefile clean REALBUILD=yes # Remove Halibut output files in the source directory (may # have been created by running, for example, `build/halibut # inputs/test.but'). topclean: rm -f *.html output.* *.tar.gz # Makef a release archive. release: release.sh ./release.sh $(RELDIR) $(VERSION) else # The `real' makefile part. CFLAGS += -Wall -W -ansi -pedantic ifdef TEST CFLAGS += -DLOGALLOC LIBS += -lefence endif EXE =# all: halibut$(EXE) SRC := ../ ifeq ($(shell test -d $(SRC)charset && echo yes),yes) LIBCHARSET_SRCDIR = $(SRC)charset/ else LIBCHARSET_SRCDIR = $(SRC)../charset/ endif LIBCHARSET_OBJDIR = ./# LIBCHARSET_OBJPFX = cs-# LIBCHARSET_GENPFX = charset-# MD = -MD CFLAGS += -I$(LIBCHARSET_SRCDIR) -I$(LIBCHARSET_OBJDIR) include $(LIBCHARSET_SRCDIR)Makefile CC_LINK = $(CC) -o $@ MODULES := main malloc ustring error help licence version misc tree234 MODULES += input in_afm in_pf in_sfnt keywords contents index biblio MODULES += bk_text bk_html bk_whlp bk_man bk_info bk_paper bk_ps bk_pdf MODULES += winhelp winchm deflate lzx lz77 huffman psdata wcwidth OBJECTS := $(addsuffix .o,$(MODULES)) $(LIBCHARSET_OBJS) DEPS := $(addsuffix .d,$(MODULES)) halibut$(EXE): $(OBJECTS) $(CC_LINK) $(LFLAGS) $(OBJECTS) $(LIBS) %.o: $(SRC)%.c $(CC) $(CFLAGS) -MD -c $< version.o: FORCE $(CC) $(VDEF) -MD -c $(SRC)version.c spotless:: clean rm -f *.d clean:: rm -f *.o halibut core install: mkdir -p $(prefix) $(bindir) $(INSTALL) -m 755 halibut $(bindir)/halibut $(MAKE) -C ../doc install prefix="$(prefix)" INSTALL="$(INSTALL)" FORCE: # phony target to force version.o to be rebuilt every time -include $(DEPS) endif halibut-1.2/biblio.c0000644000175000017500000000466013106256630011341 00000000000000/* * 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) 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) { err_nosuchkw(¶->fpos, para->keyword); } else if (kw->text) { 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->breaks = FALSE; wd->alt = NULL; wd->next = NULL; wd->aux = 0; kw->text = wd; } para->kwtext = kw->text; } } } halibut-1.2/bk_html.c0000644000175000017500000026151013106256630011520 00000000000000/* * 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-