Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 nbibtex (0.9.18-13) unstable; urgency=medium
 .
   * secure upstream homepage and uscan URLs
   * remove nonworking bib2html executable script (closes: #683663)
Author: Barak A. Pearlmutter <bap@debian.org>
Bug-Debian: https://bugs.debian.org/683663

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2019-07-19

--- nbibtex-0.9.18.orig/INSTALL
+++ nbibtex-0.9.18/INSTALL
@@ -1,6 +1,8 @@
 If you're lucky enough to be able to use a Debian package,
 go to http://www.eecs.harvard.edu/~nr/nbibtex and follow the 
 directions for getting nbibtex.
+(Or "apt-get install nbibtex" as it may already be available from your
+distribution.)
 
 Otherwise, to build NbibTeX requires a C compiler and Lua version 5.0.
 Needing Lua means needing the right -I and -l options to your compiler.
@@ -10,5 +12,5 @@ script by hand.  Maybe it does something
 By default, the script installs into /usr/local.
 
 Options to ./configure include
-  --debian      configure as for Debian, including installation into /usr
   --compatible  make the 'plainnat' style exactly compatible with BibTeX
+  --help        show a list of configuration options
--- nbibtex-0.9.18.orig/Makefile.in
+++ nbibtex-0.9.18/Makefile.in
@@ -1,24 +1,53 @@
+
+bindir=$(prefix)/bin
+datarootdir=$(prefix)/share
+datadir=$(datarootdir)
+datasubdir=$(datadir)/nbibtex
+
+VERSION=$(shell cat VERSION)
+
 OBJS=nbib.o nbibtex.o boyer-moore.o
+CPPDEFS=-DSHARE='"${datasubdir}"'
+
+all: nbibtex
+all: nbib.pdf
 
 nbibtex: $(OBJS)
-	$(CC) -o nbibtex $(OBJS) $(LDFLAGS) 
 
 install: nbibtex
-	for i in $(SHARE) $(BIN) $(MAN1); do [ -d $$i ] || install -d $$i; done
-	install -m644 bibtex.lua natbib.nbs $(SHARE)
-	install -m644 nbibtex.1 nbibfind.1 $(MAN1)
-	install -m755 nbibtex $(BIN)
-	rm -f $(BIN)/nbibfind
-	ln $(BIN)/nbibtex $(BIN)/nbibfind
+	for i in $(datasubdir) $(bindir) $(mandir)/man1; do install -d $(DESTDIR)$$i; done
+	install -m644 bibtex.lua natbib.nbs $(DESTDIR)$(datasubdir)/
+	install -m644 nbibtex.1 nbibfind.1 $(DESTDIR)$(mandir)/man1/
+	install -m755 nbibtex $(DESTDIR)$(bindir)/
+	ln --force $(DESTDIR)$(bindir)/nbibtex $(DESTDIR)$(bindir)/nbibfind
 
 uninstall: 
-	rm $(SHARE)/bibtex.lua $(SHARE)/natbib.nbs
-	rm $(MAN1)/nbibtex.1 $(MAN1)/nbibfind.1
-	rm $(BIN)/nbibtex $(BIN)/nbibfind
-	rmdir $(SHARE)
+	rm $(DESTDIR)$(datasubdir)/bibtex.lua $(DESTDIR)$(datasubdir)/natbib.nbs
+	rm $(DESTDIR)$(mandir)/man1/nbibtex.1 $(DESTDIR)$(mandir)/man1/nbibfind.1
+	rm $(DESTDIR)$(bindir)/nbibtex $(DESTDIR)$(bindir)/nbibfind
+	rmdir $(DESTDIR)$(datasubdir)
 
 clean:
-	rm -f $(OBJS)
+	rm -f $(OBJS) nbibtex
 
 distclean: clean
-	rm -f nbibtex
+	rm -f Makefile bibtex.lua natbib.nbs nbibtex.1
+	rm -f nbib.c nbibtex.c nbib.tex nbib.pdf
+
+.PHONY: all install uninstall clean distclean
+
+nbib.c nbibtex.c: nbib.nw
+	notangle -R$@ -L nbib.nw | sed 's/<VERSION>/$(VERSION)/' > $@
+
+nbib.tex: nbib.nw
+	noweave nbib.nw | tail -n +2 | sed 's/<VERSION>/$(VERSION)/' > $@
+
+## latexmk f = fixedpoint latex f
+
+nbib.pdf: nbib.tex
+	latexmk --pdf $<
+
+## NOTES
+
+# Makefile bibtex.lua natbib.nbs nbibtex.1: Makefile.in bibtex.lua.in natbib.nbs.in nbibtex.1.in
+# 	./configure
--- /dev/null
+++ nbibtex-0.9.18/VERSION
@@ -0,0 +1 @@
+0.9.18
--- /dev/null
+++ nbibtex-0.9.18/bib2html
@@ -0,0 +1,21 @@
+#!/usr/bin/env lua5.1
+-- -*- mode: lua -*-
+
+local function eprintf(...) return io.stderr:write(string.format(...)) end
+
+require 'bibtex'
+require 'nbib-html'
+
+bst = bibtex.style 'html'
+
+if table.getn(arg) ~= 1 then
+  eprintf('Usage: %s bibname', arg[0])
+  os.exit(1)
+end
+
+local bib = arg[1]
+
+local pre, cs = bibtex.all_entries(arg[1], bst.macros())
+bibtex.do_crossrefs(cs)
+bst.emit(io.stdout, pre, cs)
+
--- nbibtex-0.9.18.orig/configure
+++ nbibtex-0.9.18/configure
@@ -1,32 +1,40 @@
 #!/bin/sh
 
-DESTDIR=
-PREFIX=usr/local
-debian=
+prefix=/usr/local
+mandir="\$(datarootdir)/man"
 plain_compatible=false
+if [ -z "${ignore_unknown_options}" ]; then ignore_unknown_options=false; fi
 
 while [ $# -gt 0 ]
 do
-  case $1 in
-    --help)
-       cat 1>&2 <<EOF
+    case $1 in
+	--help)
+	    cat 1>&2 <<EOF
 Usage: $0 [options]
 
 Options:
   --help         This message
-  --debian       Configure to build debian package
   --compat[ible] Bibliography style 'plainnat' identical to standard
-  --prefix==     Set installation prefix [default $PREFIX]
+  --prefix=/DIR  Set installation prefix [default $prefix]
+  --mandir=/DIR  Man page installation prefix, [default $mandir]
+  --ignore-unknown-options (or set environment ignore_unknown_options=true)
 EOF
-      exit 0
-      ;;
-   --prefix=*) PREFIX="`echo $2 | sed 's/.*=//'`" ; shift ; shift ;;
-   --debian) debian=1 ; PREFIX=usr ; shift ;;
-   --compat|--compatible) plain_compatible=true ; shift ;;
-   *) echo "Usage: $0 -- help"; exit 1 ;;
-  esac
+	    exit 0
+	    ;;
+	--prefix=*) prefix="$(echo $1 | sed 's/.*=//')" ; shift ;;
+	--mandir=*) mandir="$(echo $1 | sed 's/.*=//')" ; shift ;;
+	--compat|--compatible) plain_compatible=true ; shift ;;
+	--ignore-unknown-options) ignore_unknown_options=true ; shift ;;
+	*) if ${ignore_unknown_options}; then
+	       echo "warning: Unknown option $1"
+	       shift
+	   else
+	       echo "error: Unknown option $1"
+	       echo "Usage: $0 --help"; exit 1
+	   fi ;;
+    esac
 done
-      
+
 ######################################################################33
 #
 # search for lua
@@ -34,18 +42,18 @@ done
 CF=
 LF=
 
-if [ -x "`which pkg-config 2>/dev/null`" ]; then
+if [ -x "$(which pkg-config 2>/dev/null)" ]; then
 
-  CF="`pkg-config --cflags lua5.1`"
-  LF="`pkg-config --libs   lua5.1`"
+    CF="$(pkg-config --cflags lua5.1)"
+    LF="$(pkg-config --libs   lua5.1)"
 
-  if [ -z "$CF" ]; then
-    echo "Don't know how to find include files for Lua 5.1"; exit 1
-  fi
-
-  if [ -z "$LF" ]; then
-    echo "Don't know how to find libraries for Lua 5.1"; exit 1
-  fi
+    if [ -z "$CF" ]; then
+	echo "Don't know how to find include files for Lua 5.1"; exit 1
+    fi
+
+    if [ -z "$LF" ]; then
+	echo "Don't know how to find libraries for Lua 5.1"; exit 1
+    fi
 
 fi
 
@@ -59,88 +67,72 @@ lua40=
 lua50=
 
 if [ -z "$CF" ]; then
-  for i in $LUAI; do
-    if [ -r $i/lua.h ] && grep 'LUA_VERSION.* 5\.1' $i/lua.h > /dev/null; then
-      CF="-I$i"
-      break
-    elif [ -r $i/lua.h ] && grep 'LUA_VERSION.* 5\.0' $i/lua.h > /dev/null; then
-      lua50=true
-    elif [ -r $i/lua.h ] && grep 'LUA_VERSION.* 4\.0' $i/lua.h > /dev/null; then
-      lua40=true
-    fi
-  done
+    for i in $LUAI; do
+	if [ -r $i/lua.h ] && grep 'LUA_VERSION.* 5\.1' $i/lua.h > /dev/null; then
+	    CF="-I$i"
+	    break
+	elif [ -r $i/lua.h ] && grep 'LUA_VERSION.* 5\.0' $i/lua.h > /dev/null; then
+	    lua50=true
+	elif [ -r $i/lua.h ] && grep 'LUA_VERSION.* 4\.0' $i/lua.h > /dev/null; then
+	    lua40=true
+	fi
+    done
 fi
 
 if [ -z "$LF" ]; then
-  L1=
-  for i in $LIBS; do
-    if [ -r $i/liblua5.1.so ]; then
-      LF="-L$i"
-      L1="-lliblua5.1"
-      break
-    fi
-  done
-  if [ -z "$L1" ]; then
+    L1=
     for i in $LIBS; do
-      if [ -r $i/liblua.so ]; then
-        if [ "x$LF" != "x-L$i" ]; then LF="$LF -L$i"; fi
-        L1="-lliblua"
-        break
-      fi
+	if [ -r $i/liblua5.1.so ]; then
+	    LF="-L$i"
+	    L1="-lliblua5.1"
+	    break
+	fi
     done
-  fi
-  if [ -n "$L1" ]; then
-    LF="$LF $L1"
-  else
-    LF=
-  fi
+    if [ -z "$L1" ]; then
+	for i in $LIBS; do
+	    if [ -r $i/liblua.so ]; then
+		if [ "x$LF" != "x-L$i" ]; then LF="$LF -L$i"; fi
+		L1="-lliblua"
+		break
+	    fi
+	done
+    fi
+    if [ -n "$L1" ]; then
+	LF="$LF $L1"
+    else
+	LF=
+    fi
 fi
 
 if [ -z "$CF" ]; then
-  echo "Don't know how to find include files for Lua 5.0"; exit 1
+    echo "Don't know how to find include files for Lua 5.0"; exit 1
 fi
 
 if [ -z "$LF" ]; then
-  echo "Don't know how to find libraries for Lua 5.0"
-  if [ -n "$lua40" ]; then echo "(I did find an include file for Lua 4.0)"; fi
-  if [ -n "$lua40" ]; then echo "(I did find an include file for Lua 4.0)"; fi
-  if [ -n "$lua51" ]; then echo "(I did find an include file for Lua 5.1, but nbibtex requires Lua 5.0)"; fi
-  exit 1
+    echo "Don't know how to find libraries for Lua 5.0"
+    if [ -n "$lua40" ]; then echo "(I did find an include file for Lua 4.0)"; fi
+    if [ -n "$lua40" ]; then echo "(I did find an include file for Lua 4.0)"; fi
+    if [ -n "$lua51" ]; then echo "(I did find an include file for Lua 5.1, but nbibtex requires Lua 5.0)"; fi
+    exit 1
 fi
 
 echo "Lua: OK"
 
 ################################################################
 
-if [ -z "$debian" ]; then
-  setdest="DESTDIR=$DESTDIR"
-else
-  setdest=
-fi
-
-dollar='$'
-
-cat <<EOF > Makefile
-$setdest
-SHARE=$dollar(DESTDIR)/$PREFIX/share/nbibtex
-BIN=$dollar(DESTDIR)/$PREFIX/bin
-MAN1=$dollar(DESTDIR)/$PREFIX/share/man/man1
+cat <<EOF - Makefile.in > Makefile
+prefix=${prefix}
+mandir=${mandir}
+CPPFLAGS+=$CF \$(CPPDEFS)
+LOADLIBES=$LF
 EOF
 
-cat <<EOF >> Makefile
-CFLAGS=$CF -DSHARE='"$dollar(SHARE)"'
-LDFLAGS=$LF
-
-EOF
-
-cat Makefile.in >> Makefile
-
 cat <<EOF - bibtex.lua.in > bibtex.lua
 local config = { nbs = "$SHARE" }
 EOF
 
 if [ $plain_compatible = false ]; then
-  compatibility='Two of these styles\
+    compatibility='Two of these styles\
 .RB ( abbrvnat \
 and\
 .BR unsrtnat )\
@@ -152,7 +144,7 @@ the Chicago Manual of Style. \
 A compatible version is available as style \
 .BR plainnatc .'
 else
-  compatibility='These styles \
+    compatibility='These styles \
 .RB ( plainnat , \
 .BR abbrvnat , \
 and \
@@ -165,12 +157,11 @@ is available as style \
 fi
 
 
-sed -e "s@<NBSDIR>@$DESTDIR/$PREFIX/share/nbibtex@g" \
+sed -e "s@<NBSDIR>@$prefix/share/nbibtex@g" \
     -e "s@<compatibility>@$compatibility@" \
-  < nbibtex.1.in > nbibtex.1
+    < nbibtex.1.in > nbibtex.1
 
 
 cat <<EOF - natbib.nbs.in > natbib.nbs
 local plain_compatible = $plain_compatible
 EOF
-
--- nbibtex-0.9.18.orig/fun.tex
+++ nbibtex-0.9.18/fun.tex
@@ -12,7 +12,7 @@
 This history is intended not so much to capture functional programming
 as it is to test my replacement for Bib{\TeX}.
 The idea is that you change the
-\verb+\bibliography+ command to use your own bibliography,
+\texttt{\textbackslash bibliography} command to use your own bibliography,
 try my \texttt{nbibtex}, and see how many papers it picks up
 correctly.
 To get all~23 references, I~had to combine the bibliographies of four
--- nbibtex-0.9.18.orig/nbib.nw
+++ nbibtex-0.9.18/nbib.nw
@@ -3,7 +3,7 @@
 \documentclass{article}
 \usepackage{fullpage}
 \usepackage{noweb,url}
-\usepackage[hypertex]{hyperref}
+\usepackage{hyperref}
 \noweboptions{smallcode}
 
 \def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
@@ -236,25 +236,25 @@ Success or failure is nonzero or zero bu
 <<function prototypes>>=
 typedef int bool;
 @
-Function [[getline]] refills the buffer with a new line (and updates
+Function [[get_line]] refills the buffer with a new line (and updates
 [[line_num]]), returning failure on end of file.
 <<function prototypes>>=
-static bool getline(Bibreader rdr);
+static bool get_line(Bibreader rdr);
 @ 
 Several scanning functions come in two flavors,
 which depend on what happends at the end of a line:
-the [[_getline]] flavor refills the buffer and keeps scanning;
+the [[_get_line]] flavor refills the buffer and keeps scanning;
 the normal flavor fails.
 Here are some functions that scan for combinations of particular
 characters, whitespace, and nonwhite characters.
 <<function prototypes>>=
 static bool upto1(Bibreader rdr, char c);
-static bool upto1_getline(Bibreader rdr, char c);
+static bool upto1_get_line(Bibreader rdr, char c);
 static void upto_white_or_1(Bibreader rdr, char c);
 static void upto_white_or_2(Bibreader rdr, char c1, char c2);
 static void upto_white_or_3(Bibreader rdr, char c1, char c2, char c3);
 static bool upto_nonwhite(Bibreader rdr);
-static bool upto_nonwhite_getline(Bibreader rdr);
+static bool upto_nonwhite_get_line(Bibreader rdr);
 @ Because there is always whitespace at the end of a line, the
 [[upto_white_*]] flavor cannot fail.
 @
@@ -365,7 +365,7 @@ If no entry remains, the function return
 <<function definitions>>=
 #undef ready_tok
 #define ready_tok(RDR) do { \
-  if (!upto_nonwhite_getline(RDR)) \
+  if (!upto_nonwhite_get_line(RDR)) \
     LERR("Unexpected end of file"); \
   } while(0)
 
@@ -403,7 +403,7 @@ static int get_bib_command_or_entry_and_
 }
 @ 
 <<scan [[rdr]] up to and past the next [[@]] sign and skip white space (or return 0)>>=
-if (!upto1_getline(rdr, '@'))
+if (!upto1_get_line(rdr, '@'))
   return 0;  /* no more entries; return nil */
 assert(*rdr->cur == '@');
 rdr->cur++;   /* skip the @ sign */
@@ -509,7 +509,7 @@ the error handling for [[ready_tok]] nee
 <<Procedures and functions for input scanning>>=
 #undef ready_tok
 #define ready_tok(RDR) do { \
-  if (!upto_nonwhite_getline(RDR)) \
+  if (!upto_nonwhite_get_line(RDR)) \
     LERRB("Unexpected end of file"); \
   } while(0)
 @ 
@@ -697,9 +697,9 @@ static bool upto1(Bibreader rdr, char c)
 Scan the reader up to the character requested or end of file;
 fails if not found.
 <<function definitions>>=
-static int upto1_getline(Bibreader rdr, char c) {
+static int upto1_get_line(Bibreader rdr, char c) {
   while (!upto1(rdr, c))
-    if (!getline(rdr))
+    if (!get_line(rdr))
       return 0;
   return 1;
 }
@@ -755,16 +755,16 @@ static bool upto_nonwhite(Bibreader rdr)
 Scan past whitespace up to end of file if needed;
 returns true iff nonwhite character found.
 <<function definitions>>=
-static int upto_nonwhite_getline(Bibreader rdr) {
+static int upto_nonwhite_get_line(Bibreader rdr) {
   while (!upto_nonwhite(rdr))
-    if (!getline(rdr))
+    if (!get_line(rdr))
       return 0;
   return 1;
 }
 @ 
 \subsubsection{Actual input}
 <<function definitions>>=
-static bool getline(Bibreader rdr) {
+static bool get_line(Bibreader rdr) {
   char *result;
   unsigned char *buf = rdr->buf;
   int n;
@@ -1219,8 +1219,9 @@ listed in the [[nonids]] string.
 @ 
 \subsection{Main function for the nbib commands}
 
-This code will is the standalone main function for all the nbib commands.
-\nextchunklabel{c-main}
+\label{c-main}
+
+This code is the standalone main function for all the nbib commands.
 <<nbibtex.c>>=
 #include <stdlib.h>
 #include <stdio.h>
@@ -1238,8 +1239,8 @@ int main (int argc, char *argv[]) {
   static const char* files[] = { SHARE "/bibtex.lua",  SHARE "/natbib.nbs" };
 
   #define OPEN(N) lua_pushcfunction(L, luaopen_ ## N); lua_call(L, 0, 0)
-  OPEN(base); OPEN(table); OPEN(io); OPEN(package); OPEN(string); OPEN(bibtex);
-  OPEN(boyer_moore);
+  OPEN(base); OPEN(io); OPEN(os); OPEN(package); OPEN(string); OPEN(table); 
+  OPEN(bibtex); OPEN(boyer_moore); 
 
   for (i = 0; i < sizeof(files)/sizeof(files[0]); i++) {
     if (luaL_dofile(L, files[i])) {
@@ -1310,7 +1311,7 @@ How we get the C~code depends on how
 \begin{itemize}
 \item
 In the distribution, \texttt{bibtex.lua} is loaded by the C~code in
-chunk~\subpageref{c-main}, which defines the [[bibtex]] module.
+Section~\ref{c-main}, which defines the [[bibtex]] module.
 \item
 For standalone testing purposes, \texttt{bibtex.lua} can be loaded
 directly into an 
--- nbibtex-0.9.18.orig/nbibfind.1
+++ nbibtex-0.9.18/nbibfind.1
@@ -89,7 +89,7 @@ is found in the field named by
 .I key
 may also be
 .BR "[type]" ,
-which matches agains the type of the entry,
+which matches against the type of the entry,
 or
 .BR "*" ,
 which looks for 
--- nbibtex-0.9.18.orig/nbibtex.1.in
+++ nbibtex-0.9.18/nbibtex.1.in
@@ -67,7 +67,7 @@ A
 .I bibname
 without a slash (/) character means the same thing it would mean
 in a \\bibliographystyle command: it is looked up according to the
-.rules of \*(OB.
+rules of \*(OB.
 A
 .I bibname with
 a slash character is taken to be the absolute or relative pathname 
@@ -207,7 +207,7 @@ is found in the field named by
 .I key
 may also be
 .BR "[type]" ,
-which matches agains the type of the entry,
+which matches against the type of the entry,
 or
 .BR "*" ,
 which looks for 
