code:
# Process this file with autoconf to produce a configure script.
# $Id$
#
# Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
# 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
AC_INIT([GNU Texinfo], [6.3.90], [bug-texinfo@gnu.org])

dnl Must come before AM_INIT_AUTOMAKE.
AC_CONFIG_AUX_DIR([build-aux])
dnl tar-ustar because we have long filenames for some test files.
dnl parallel-tests as recommended by stefano.
AM_INIT_AUTOMAKE([1.14 dist-xz
                 info-in-builddir parallel-tests readme-alpha tar-ustar])

# Where to generate output; srcdir location.
AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS.
AC_CONFIG_SRCDIR([info/info.c])

# TexinfoXML DTD (./util/texinfo.dtd) version:
# manually set this to the next version number rather than
# $PACKAGE_VERSION, as soon as the DTD is modified, and perhaps put the
# file on the web, too.  Several reasons:
# 1. To avoid using a DTD from the Internet that wouldn't be in sync;
# 2. To avoid unnnecessary changes in XML output file headers, in
#    test results for instance.
# 3. It may be kept as is in case there were no change in the DTD
#    between releases.  This is rare, but has happened.
#
TEXINFO_DTD_VERSION=6.3dev
AC_SUBST([TEXINFO_DTD_VERSION])

# Conditional texi2html support.
AM_CONDITIONAL([TEXI2HTML],[false])

# Package date.
PACKAGE_DATE=`${SHELL} "$srcdir"/build-aux/mdate-sh "$srcdir"/configure.ac`
AC_SUBST([PACKAGE_DATE])

# We need Perl
AC_ARG_VAR([PERL], [The path to the 'perl' executable.])
AC_PATH_PROG([PERL], [perl])
if test -z "$PERL"; then
   AC_MSG_ERROR(
[perl not found; Texinfo requires Perl.
If you have perl installed somewhere not in PATH,
specify where it is using
  ./configure PERL=/path/to/perl
])
fi

# User variables for a Perl XS extension, which may be different, for
# example if the Perl interpreter being used was compiled with a
# different compiler.  Also in tp/Texinfo/Convert/XSParagraph/configure.ac.
AC_ARG_VAR([PERL_EXT_CFLAGS], [Compiler flags for a Perl extension])
AC_ARG_VAR([PERL_EXT_CPPFLAGS], [C preprocessor flags for a Perl extension])
AC_ARG_VAR([PERL_EXT_LDFLAGS], [Linker flags for a Perl extension])
AC_ARG_VAR([PERL_EXT_CC], [Compiler for a Perl extension])

AC_MSG_CHECKING([Perl version and Encode module])
if $PERL -e "use 5.007_003; use Encode;" > /dev/null 2>&1; then
  perl_version_requirement='yes'
else
  perl_version_requirement='no'
fi
AC_MSG_RESULT($perl_version_requirement)
if test z"$perl_version_requirement" = 'zno' ; then
  AC_MSG_ERROR([perl >= 5.7.3 with Encode required by Texinfo.])
fi

AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_PROG_AWK

# Checks for programs.
AC_PROG_CC

# Since we use gnulib: gl_EARLY must be called as soon as possible after
# the C compiler is checked.  The others could be later, but we just
# keep everything together.
gl_EARLY

# Rest of Gnulib.
gl_INIT

# help2man to generate man pages.
AM_MISSING_PROG(HELP2MAN, help2man)

AC_PROG_INSTALL
AC_PROG_MAKE_SET

AC_PROG_LN_S
AC_PROG_MKDIR_P

# gettext Makefiles may still need MKINSTALLDIRS.
MKINSTALLDIRS="\$(top_srcdir)/build-aux/install-sh -d"
AC_SUBST([MKINSTALLDIRS])

# check whether diff accepts the -u option (not on HP-UX).
AC_MSG_CHECKING(whether diff accepts -u)
diff_accepts_u_option=no
echo foo >conftest.dtx
echo foo | diff -u - conftest.dtx >/dev/null 2>&1
error_status_diff_u=$?
if test $error_status_diff_u = 0; then
  diff_accepts_u_option=yes
fi
AC_MSG_RESULT($diff_accepts_u_option)
rm -f conftest.dtx

DIFF_U_OPTION=
if test "z$diff_accepts_u_option" = 'zyes' ; then
  DIFF_U_OPTION=-u
fi
AC_SUBST([DIFF_U_OPTION])

# check whether diff accepts the -a option (only needed for GNU diff).
AC_MSG_CHECKING(whether diff accepts -a)
diff_accepts_a_option=no
echo foo >conftest.dtx
echo foo | diff -a - conftest.dtx >/dev/null 2>&1
error_status_diff_a=$?
if test $error_status_diff_a = 0; then
  diff_accepts_a_option=yes
fi
AC_MSG_RESULT($diff_accepts_a_option)
rm -f conftest.dtx

DIFF_A_OPTION=
if test "z$diff_accepts_a_option" = 'zyes' ; then
  DIFF_A_OPTION=-a
fi
AC_SUBST([DIFF_A_OPTION])

# Needed on sysV68 for sigblock, sigsetmask.  But check for it in libc first.
AC_CHECK_FUNC(sigblock, , [AC_CHECK_LIB(bsd, sigblock)])

# Checks for header files.
AC_HEADER_STAT
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h io.h limits.h pwd.h string.h strings.h \
  stropts.h termcap.h termio.h termios.h unistd.h \
  sys/fcntl.h sys/file.h sys/ioctl.h sys/stream.h \
  sys/time.h sys/ttold.h sys/wait.h)

# sys/ptem.h requires sys/stream.h for mblk_t on Solaris.
AC_CHECK_HEADERS([sys/ptem.h],,,
[#if HAVE_SYS_STREAM_H
#include <sys/stream.h>
#endif
])

AC_SYS_POSIX_TERMIOS

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_OFF_T
AC_TYPE_SIGNAL
AC_C_CONST
AC_STRUCT_TM

# Checks for function declarations.
AC_CHECK_DECLS([memchr, strcoll, strerror])

# Checks for library functions.
AC_FUNC_STRCOLL
AC_FUNC_VPRINTF
# in theory only pre-sysvr3 systems needed this and it's not likely
# that anyone compiling new texinfo still has such a thing? we'll see.
# AC_FUNC_SETVBUF_REVERSED
AC_CHECK_FUNCS(bzero getcwd memset setlocale setvbuf sigaction sigprocmask \
	       sigsetmask strchr posix_openpt)
AC_REPLACE_FUNCS(memcpy memmove strdup strerror)

# Used for Info tests
AM_CONDITIONAL([have_ptys], [test x$ac_cv_func_posix_openpt = xyes])

# We want to recognize djgpp to avoid the useless warning about no
# term library.
AC_CANONICAL_BUILD

# We need to run some of our own binaries, most notably makedoc, but as
# long as we have this process, we also use our own makeinfo and
# install-info.
#
# This means that if we are cross compiling, we have to configure the
# package twice: once with the native compiler (this is done in a
# subdirectory $native_tools), and once with the cross compiler.
# The former is invoked automatically here, with --host=$build.
# $native_tools is also added to SUBDIRS in the main Makefile.am,
# so that make compiles the native tools first.
#
if test "$cross_compiling" = no; then
  native_tools=
else
  native_tools=tools
  test -d "$native_tools" || mkdir "$native_tools"
  confdir=`(cd "$srcdir";pwd)`
  # Make sure the secondary configure won't fail with
  # "error: source directory already configured".
  rm -f config.status
  AC_MSG_NOTICE([[Doing configure of native tools (${build}).]])
  cd "$native_tools" || exit 1
  # Run secondary configure in alternate environment or
  # it gets the wrong CC etc.
  # env -i gives this build host configure a clean environment;
  # consequently, we have to re-initialize $PATH.
  env -i CC="$BUILD_CC" AR="$BUILD_AR" RANLIB="$BUILD_RANLIB" \
      PATH="$PATH" \
      tools_only=1 \
    ${confdir}/configure --build=${build} --host=${build} \
                         --disable-rpath --disable-nls
  cd .. || exit 1
  AC_MSG_NOTICE([[Continuing with main configure (${host}).]])
fi
AC_SUBST(native_tools)
AM_CONDITIONAL(TOOLS_ONLY, [[test "x$tools_only" = x1]])

# Some GNU/Linux systems (e.g., SuSE 4.3, 1996) don't have curses, but
# rather ncurses.  So we check for it.
TERMLIBS=
# Check for termlib before termcap because Solaris termcap needs libucb.
TERMLIB_VARIANTS="tinfo ncurses curses termlib termcap terminfo"
for termlib in ${TERMLIB_VARIANTS}; do
  AC_CHECK_LIB(${termlib}, tgetent,
     [TERMLIBS="${TERMLIBS} -l${termlib}"; break])
done
have_termlib=yes
# don't bother warning on djgpp and MinGW, they don't have a term library,
# and port each termcap-needing program separately according to the needs.
if test -z "$TERMLIBS" \
   && echo "$build" | grep -v djgpp | grep -v mingw >/dev/null; then
  AC_MSG_WARN([info needs a terminal library, one of: ${TERMLIB_VARIANTS}])
  have_termlib=no
fi

# Checks for variables.
# HP-UX 9 (at least) needs -lncurses which defines termcap variables PC etc.
AC_MSG_CHECKING(for library with termcap variables)
AC_CACHE_VAL(ac_cv_var_ospeed,
[oldLIBS=$LIBS
for trylib in $termlib ${TERMLIB_VARIANTS}; do
   if test "x$trylib" != "x$termlib"; then
     LIBS="$oldLIBS -l$termlib -l$trylib"
   else
     LIBS="$oldLIBS -l$termlib"
   fi
   AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[#ifdef HAVE_NCURSES_TERMCAP_H
#include <ncurses/termcap.h>
#else
#ifdef HAVE_TERMCAP_H
#include <termcap.h>
#else
#undef PC
char *BC;
char **UP;
char PC;
short ospeed;
#endif
#endif
/* Make sure all variables actually exist.  AIX 4.3 has ospeed but no BC.
   --Andreas Ley <andy@rz.uni-karlsruhe.de> 24 Aug 2000.  */
BC++;
UP++;
PC++;
return ospeed != 0;
]])], [ac_cv_var_ospeed=$trylib; break])
done
LIBS=$oldLIBS
])
AC_MSG_RESULT($ac_cv_var_ospeed)
if test -n "$ac_cv_var_ospeed" \
   && test "x$termlib" != "x$ac_cv_var_ospeed"; then
  TERMLIBS="${TERMLIBS} -l${ac_cv_var_ospeed}"
fi
AC_SUBST(TERMLIBS)#
AM_CONDITIONAL(HAVE_TERMLIBS, [[test "x$TERMLIBS" != x]])

# Do not use <ncurses/termcap.h> unless we're linking with ncurses.
# Must come after the termlib tests.
if test "x$termlib" = xncurses; then
  # Use AC_CHECK_HEADERS so the HAVE_*_H symbol gets defined.
  AC_CHECK_HEADERS(ncurses/termcap.h)
fi

# For teTeX and TeX Live.
AC_CANONICAL_HOST
AC_ARG_ENABLE([multiplatform],
  [AS_HELP_STRING([--enable-multiplatform],
     [put executables into bin/PLATFORM and libraries into lib/PLATFORM])])dnl
# if enable_multiplatform is set in the environment, use that.
if test "x$enable_multiplatform" = xyes; then
  test "x$bindir" = 'x${exec_prefix}/bin' && bindir="$bindir/$host"
  test "x$libdir" = 'x${exec_prefix}/lib' && libdir="$libdir/$host"
fi

# Taken from the example in
# http://www.gnu.org/software/automake/manual/html_node/Conditionals.html.
AC_ARG_ENABLE(install-warnings,
  [  --disable-install-warnings  omit make install warnings about TeX files],
  [case "${enableval}" in
     yes) install_warnings=true ;;
      no) install_warnings=false ;;
       *) AC_MSG_ERROR(bad value ${enableval} for --enable-install-warnings) ;;
   esac],
   [install_warnings=true])
AM_CONDITIONAL(INSTALL_WARNINGS,
   test x"$install_warnings" = xtrue || test x"$install_warnings" = xyes)

USE_EXTERNAL_EASTASIANWIDTH=no
AC_ARG_WITH([external-Unicode-EastAsianWidth],
   AC_HELP_STRING([--with-external-Unicode-EastAsianWidth],
      [use external Unicode-EastAsianWidth (default: no)]),
   [if test $withval = 'yes'; then
      USE_EXTERNAL_EASTASIANWIDTH=yes
   fi]
)

AC_SUBST([USE_EXTERNAL_EASTASIANWIDTH])

USE_EXTERNAL_UNIDECODE=no
AC_ARG_WITH([external-Text-Unidecode],
    AC_HELP_STRING([--with-external-Text-Unidecode],
           [use external Text::Unidecode (default: no)]),
   [if test $withval = 'yes'; then
      USE_EXTERNAL_UNIDECODE=yes
   fi]
)

AC_SUBST([USE_UNICODE])
AC_SUBST([USE_EXTERNAL_UNIDECODE])

# i18n support.  To update to a new version of gettext, run:
#   gettextize -f --po-dir=po --po-dir=po_document
# See http://gnu.org/s/gnulib/manual/html_node/gettextize-and-autopoint.html.
AM_GNU_GETTEXT_VERSION([0.19.8])
AM_GNU_GETTEXT([external])

USE_EXTERNAL_LIBINTL=no
AC_ARG_WITH([external-libintl-perl],
   AC_HELP_STRING([--with-external-libintl-perl],
      [use external libintl-perl (default: no)]),
   [if test $withval = 'yes'; then
      USE_EXTERNAL_LIBINTL=yes
   fi]
)

AC_SUBST([USE_EXTERNAL_LIBINTL])

AC_ARG_ENABLE([perl-xs],
    AC_HELP_STRING([--enable-perl-xs],
              [build Perl XS modules for speed (default: check)]),
    [ enable_xs=$enableval],
    [ enable_xs=check])

# Set xs_srcdir to the path from XSParagraph builddir to srcdir
case $srcdir in
  .)  # We are building in place.
    xs_srcdir=../../.. ;;
  [[\\/]]* | ?:[[\\/]]* )  # Absolute name.
    xs_srcdir=$srcdir/tp ;;
  *) # Relative name.
    xs_srcdir=../../../../$srcdir/tp ;;
esac

# Pass on all the options we were given to the subsidiary configure
# script.
# Don't use AC_CONFIG_SUBDIRS for this because it isn't done right away,
# and we need it for the check that follows.
# We use the _AC_OUTPUT_SUBDIRS internal autoconf macro
# (in /usr/share/autoconf/autoconf/status.m4) for this in order to
# pass on the configure command line correctly; for example, adjusting
# paths.  It is done in a subshell to be resilient against failure of the
# subsidiary configure script, which happens if the C compiler is found
# not to work.
#
save_subdirs=$subdirs
subdirs=tp/Texinfo/Convert/XSParagraph
( _AC_OUTPUT_SUBDIRS ) || enable_xs=no
subdirs=$save_subdirs

if test $enable_xs = check; then
  AC_MSG_CHECKING([whether we can build Perl extension (XS) modules])
  AC_MSG_RESULT([])
  enable_xs=no
  (cd tp/Texinfo/Convert/XSParagraph \
   && make clean \
   && make TestXS.la \
   && TEXINFO_XS=debug ; export TEXINFO_XS \
   && ${PERL} -I . \
              -I ${xs_srcdir} \
              -w ${xs_srcdir}/Texinfo/Convert/XSParagraph/fail.pl \
      | grep 'message from XS module') \
  && enable_xs=yes
  AC_MSG_CHECKING([whether we can build Perl extension (XS) modules])
  AC_MSG_RESULT([$enable_xs])
fi

AC_SUBST([enable_xs])

AM_CONDITIONAL([DISABLE_XS], [test "z$enable_xs" = zno])

if test $enable_xs = yes; then
  AC_CONFIG_SUBDIRS([tp/Texinfo/MiscXS])
fi

# Tests.
AC_CONFIG_FILES([install-info/tests/defs])
dnl We cannot enable the TeX-related tests, so don't waste time
dnl configuring them.  See contrib/nontests/README.
dnl AC_CONFIG_FILES([util/tests/defs])
dnl AC_CHECK_PROGS([HEVEA], [hevea], [])
dnl AC_CHECK_PROGS([TEX], [tex], [])

AC_CHECK_PROGS([PROVE], [prove], [])

tp_tests='no'
AC_ARG_ENABLE([tp-tests],
    AC_HELP_STRING([--enable-tp-tests],
        [run the parser and converters testsuite (default: detected)]),
    [if test $enableval = 'no'; then
       tp_tests='no'
     else
       tp_tests='yes'
     fi],
    [
     if test "z$PROVE" = 'z'; then
       tp_tests='no'
     elif $PERL -e "use 5.007_003; use Encode; use Test::More; use File::Basename; use File::Copy; use Data::Dumper; use Data::Compare; use Test::Deep; use Storable qw(dclone); use Getopt::Long qw(GetOptions);" > /dev/null 2>&1;
     then
       tp_tests='yes'
     else
       tp_tests='no'
     fi
    ])

AC_MSG_CHECKING([parser tests requirements])
AC_MSG_RESULT([$tp_tests])
AM_CONDITIONAL([TP_TESTS], [test "z$tp_tests" = 'zyes'])

build_perl_api_texi='no'
AC_ARG_ENABLE([perl-api-texi-build],
    AC_HELP_STRING([--enable-perl-api-texi-build],
        [build the perl api texinfo files (default: detected)]),
    [if test $enableval = 'no'; then
       build_perl_api_texi='no'
     else
       build_perl_api_texi='yes'
     fi],
    [
     if $PERL -e "use 5.007_003; use Encode; use Pod::Simple::PullParser;" > /dev/null 2>&1;
     then
       build_perl_api_texi='yes'
     else
       build_perl_api_texi='no'
     fi
    ])

AC_MSG_CHECKING([Perl Texinfo API texinfo documentation build requirements])
AC_MSG_RESULT([$build_perl_api_texi])
AM_CONDITIONAL([BUILD_PERL_API_TEXI], [test "z$build_perl_api_texi" = 'zyes'])

pod_simple_texinfo_tests='no'
AC_ARG_ENABLE([pod-simple-texinfo-tests],
    AC_HELP_STRING([--enable-pod-simple-texinfo-tests],
        [run the parser and converters testsuite (default: detected)]),
    [if test $enableval = 'no'; then
       pod_simple_texinfo_tests='no'
     else
       pod_simple_texinfo_tests='yes'
     fi],
    [
     if test "z$PROVE" = 'z' ; then
       pod_simple_texinfo_tests='no'
     elif $PERL -e "use 5.007_003; use Encode; use Test::More; use Pod::Simple::PullParser;" > /dev/null 2>&1;
     then
       pod_simple_texinfo_tests='yes'
     else
       pod_simple_texinfo_tests='no'
     fi
    ])

AC_MSG_CHECKING([Pod::Simple::Texinfo tests requirements])
AC_MSG_RESULT([$pod_simple_texinfo_tests])
AM_CONDITIONAL([POD_SIMPLE_TEXINFO_TESTS], [test "z$pod_simple_texinfo_tests" = 'zyes'])

host_is_windows=no
case "$host" in
   *-mingw32 | *-mingw64 | *-msdosdjgpp )  host_is_windows=yes ;;
esac
AM_CONDITIONAL([HOST_IS_WINDOWS], [test "x$host_is_windows" = "xyes"])

# The config files to generate.
AC_CONFIG_FILES([\
  Makefile
  doc/Makefile
  doc/tp_api/Makefile
  gnulib/lib/Makefile
  info/Makefile
  install-info/Makefile
  install-info/tests/Makefile
  man/Makefile
  po/Makefile.in
  po_document/Makefile.in
  util/Makefile
  texindex/Makefile
  tp/Makefile
  tp/Texinfo/ModulePath.pm
  tp/tests/Makefile
  tp/tests/many_input_files/Makefile
  tp/tests/sectioning/Makefile
  tp/tests/coverage/Makefile
  tp/tests/formatting/Makefile
  tp/tests/indices/Makefile
  tp/tests/contents/Makefile
  tp/tests/htmlxref/Makefile
  tp/tests/htmlxref-only_mono/Makefile
  tp/tests/htmlxref-only_split/Makefile
  tp/tests/nested_formats/Makefile
  tp/tests/layout/Makefile
  tp/tests/tex_html/Makefile
  tp/defs
  Pod-Simple-Texinfo/Makefile
])

AC_OUTPUT

# Summarize warnings to make them more visible.
if test $have_termlib = no; then
  AC_MSG_WARN([Could not find a terminal library among ${TERMLIB_VARIANTS}])
  AC_MSG_WARN([The programs from \`info' directory will not be built.])
fi

repo_name: mthl/texinfo

license: mit


code:
$Id$
texinfo/contrib/README

  Copyright 2013 Free Software Foundation, Inc.

  Copying and distribution of this file, with or without modification,
  are permitted in any medium without royalty provided the copyright
  notice and this notice are preserved.

The items here are for your amusement and/or hacking pleasure.
See comments and/or --help strings in each for their purpose(s).

They are all free software, but not officially part of Texinfo, and the
Texinfo maintainers don't support them (and generally have no knowledge
about them, just passing them on).

The texifont/ subdirectory was an attempt at implementing a generalized
font system, but it remains incomplete.  See the README there.

In contrast, the two txipsfonts-* files are attempts by Torsten Bronger
and Stephen Gildea, respectively, to use base PostScript fonts instead
of Computer Modern, in the simplest way.  (I could not find the right
version of the original texinfo.tex on which Torsten's file was based.)
Adapting one of these to actually be installable would doubtless be much
simpler (which is not to say simple) than finalizing texifont/, though
of course much less featureful.

The perldoc-all subdirectory is about making Texinfo out of the standard
Perl *.pod files.  The results are at
http://www.gnu.org/software/perl/manual.

path: contrib/README


code:
# -*- makefile -*-
#
# booklet.mak - making booklets from Texinfo.
#
# Copyright 2013 John Darrington.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# This makefile can be used to generate booklets from Texinfo sources.
# It reduces each page to A5 size and renders two pages per sheet onto
# A4 landscape.  The pages are ordered into a "quire" or "gathering".
# This means that you can print the result on a standard laser printer,
# fold in half and using simple stapler bind the result into a
# booklet.

# Targets are <foo>-{a4,a5}-book.{dvi,ps,pdf} where <foo>.texi is the texinfo
# source file.
# It is suitable for Texinfo documents up to approx. 70 pages.

# The *-a4-book targets produce A4 half area reduced pages.  The *-a5-book
# targets produce A5 full sized pages.  The *a5-book option will therefore
# have larger text, but will have a higher page count.  It may also have
# problems if the document has @display or @example environments with
# long lines.

# Example of use:
# 1. make -f Makebook manual-a4-book.ps
# 2. Print the result on a double sided laser printer.  Alternatively
#  if your laser printer does not support double sided printing, print the ODD
#  numbered sheets, retreive the result from the printer and thinking carefully
#  about the page orientation, shove them back into the paper tray.  Depending
#  on your printer, you may have to reverse the order of the sheets.  Then print
#  the EVEN numbered sheets.  I find gv usefull for this.
# 3. Fold the result along the short dimension.
# 4. Staple in place, using a long arm stapler.
# 5. Using a guillotine cut the pages such that their edges co-incide.
# 6. Sit back in an armchair and enjoy your reading.

# For those of you who live in countries which refuse to conform to ISO 216,
# you have a problem.

# End of instructions.

all:
	echo 'Usage: make -f Makebook <target>'

# Mutate the source, with appropriate headings, overriding anything that the
# author has thoughtlessly imposed.
# We want to specify the paper size, and double headings.  Anything else?
%-a4.texi: %.texi
	sed -e 's/@afivepaper/@afourpaper/' -e '/@end titlepage/a @headings double' $< > $@

%-a5.texi: %.texi
	sed -e 's/@afourpaper/@afivepaper/' -e '/@end titlepage/a @headings double' $< > $@

# Older versions of Texinfo break if the locale is non-english.
%.dvi: %.texi
	LC_ALL=C texi2dvi $< -o $@

# Reorder the dvi into the correct order for the quire.
%-sig.dvi: %.dvi
	dvibook	$< -o $@

# Render 2 pages per sheet, ensuring there is an appropriate "gutter"
%-a5-book.dvi: %-a5-sig.dvi
	dvitodvi  '2:0+1(148mm,0)' $< $@

%-a4-book.dvi: %-a4-sig.dvi
	dvitodvi  '2:700@0(-15mm,-5mm)+1(210mm,-5mm)' $< $@

# print the result in landscape orientation
%.ps: %.dvi
	dvips -t a4 -t landscape -t landscape $< -o $@

%.pdf: %.ps
	ps2pdf $< $@

.PHONY: clean
clean:
	$(RM) *-a[54].*


code:
/* === === === === === === === === === === === === === === === === ===

    This file: texinfo_bright_colors.css
    Version:   1.0
    Date:      September 13, 2010
    Author:    Jaakko Hollm@'en, e-mail: Jaakko.Hollmen@tkk.fi

    The purpose of this cascading style sheet (CSS) style file named
    "texinfo_bright_colors.css" is to introduce several bright and
    contrasting colors for the structural elements of an HTML file.
    The primary focus of the CSS style is to observe the sturucture
    of HTML files created with Texinfo documentation system, more
    specifically texi2html.

    This is NOT a presentation style but a visualization of the
    structure of an HTML file through coloring of the elements.
    The style file may turn out to be useful for both developers of the
    HTML outputting tools and the Texinfo documentation writers who
    are interested to observe the outputted HTML structure.

    The coloring has been achieved by associating a background-color
    to important HTML elements. Minimal formatting has been done,
    although the body font and the headers h1 to h5 have been given
    absolute sizes, and some expanded space has been introduced to
    horizontal rulers hr in order to make them more visible. There
    are margins around the document resembling a book-like presentation
    in the browser.

    This Cascading Style Sheet (CSS) confroms to the CSS standard,
    level 2.1. You can validate the correctness of your own
    creation or modification of the current CSS style at the Web
    address: http://jigsaw.w3.org/css-validator/ by one the three
    input methods available.

    If you edit your already produced HTML file generated by hand,
    change the section <style>...</style> with

    <link rel="stylesheet" href="./texinfo_bright_colors.css">

    and put the CSS file in the same directory, or simply by
    inclusion of the css file when compiling:

    texi2dvi --css-include=texinfo_bright_colors.css my_doc.texi

    Note: The output will be very "colorful", with very, very bright
          colors. You have been warned.

    --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---

    (c) Copyright, Jaakko Hollm@'en, Finland, Jaakko.Hollmen@tkk.fi
        September, 2010

    The current file "texinfo_bright_colors.css" is free software:
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software
    Foundation, either version 3 of the License, or (at your option)
    any later version.

    The current file "texinfo_bright_colors.css" is distributed in
    the hope that it will be useful, but WITHOUT ANY WARRANTY;
    without even the implied warranty of MERCHANTABILITY or FITNESS
    FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    more details.

    === === === === === === === === === === === === === === === === */

body {
margin: 30px 10% 30px 8%;
background-color: white;
font-family: serif;
font-size: 1.0em;
}

h1 {
font-size: 2.4em;
background-color: #FF0000;
}

h2 {
font-size: 2.0em;
background-color: #FF0066;
}

h3 {
font-size: 1.8em;
background-color: #FF00CC;
}

h4 {
font-size: 1.6em;
background-color: #FF33FF;
;
}

h5 {
font-size: 1.4em;
background-color: #FF99FF;
}

p {
background-color: #B0B0B0;
}

blockquote {
background-color: #FFCCFF;
}

div.shortcontents {
background-color: #FF9900;
}

div.contents {
background-color: #FF9900;
}

div.defun {
background-color: #FF9900;
}

div.float {
background-color: #FF9900;
}

div.footnote {
background-color: #FF9900;
}

div.node {
background-color: #FF9900;
}

ul {
background-color: #FF9900;
}

ol {
background-color: #CCFF33;
}

table {
background-color: #FFFF00;
}

tr {
background-color: #66FF00;
}

td {
background-color: #66CC00;
}

dl {
background-color: #00FF00;
}

dt {
background-color: #66CC00;
}

dd {
background-color: #00FFFF;
}

pre.display {
background-color: #33CCFF;
}

pre.smalldisplay {
background-color: #33CCFF;
}

pre.example {
background-color: #33CCFF;
}

pre.smallexample {
background-color: #33CCFF;
}

pre.format {
background-color: #33CCFF;
}

pre.smallformat {
background-color: #33CCFF;
}

pre.lisp {
background-color: #33CCFF;
}

pre.smalllisp {
background-color: #33CCFF;
}

pre.sp {
background-color: #33CCFF;
}

pre.verbatim {
background-color: #33CCFF;
}

code {
background-color: #00FF00;
}

hr {
background-color: #0000FF;
margin: 0.5em;
padding: 0.5em;
}


code:
/*
 * deref.c
 *
 * Make all texinfo references into the one argument form.
 *
 * Arnold Robbins
 * Written: December, 1991
 * Released: November, 1998
 *
 * Copyright 1991, 1998 Arnold David Robbins
 *
 * DEREF is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * DEREF is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * LIMITATIONS:
 *	One texinfo cross reference per line.
 *	Cross references may not cross newlines.
 *	Use of fgets for input (to be fixed).
 */

#include <stdio.h>
#include <ctype.h>
#include <errno.h>

/* for gcc on the 3B1, delete if this gives you grief */
extern int fclose(FILE *fp);
extern int fprintf(FILE *fp, const char *str, ...);
/* extern int sprintf(char *str, const char *fmt, ...); */
extern int fputs(char *buf, FILE *fp);

extern char *strerror(int errno);
extern char *strchr(char *cp, int ch);
extern int strncmp(const char *s1, const char *s2, int count);

extern int errno;

void process(FILE *fp);
void repair(char *line, char *ref, int toffset);

int Errs = 0;
char *Name = "stdin";
int Line = 0;
char *Me;

/* main --- handle arguments, global vars for errors */

int
main(int argc, char **argv)
{
	FILE *fp;

	Me = argv[0];

	if (argc == 1)
		process(stdin);
	else
		for (argc--, argv++; *argv != NULL; argc--, argv++) {
			if (argv[0][0] == '-' && argv[0][1] == '\0') {
				Name = "stdin";
				Line = 0;
				process(stdin);
			} else if ((fp = fopen(*argv, "r")) != NULL) {
				Name = *argv;
				Line = 0;
				process(fp);
				fclose(fp);
			} else {
				fprintf(stderr, "%s: can not open: %s\n",
					*argv, strerror(errno));
				Errs++;
			}
		}
	return Errs != 0;
}

/* isref --- decide if we've seen a texinfo cross reference */

int
isref(char *cp)
{
	if (strncmp(cp, "@ref{", 5) == 0)
		return 5;
	if (strncmp(cp, "@xref{", 6) == 0)
		return 6;
	if (strncmp(cp, "@pxref{", 7) == 0)
		return 7;
	return 0;
}

/* process --- read files, look for references, fix them up */

void
process(FILE *fp)
{
	char buf[BUFSIZ];
	char *cp;
	int count;

	while (fgets(buf, sizeof buf, fp) != NULL) {
		Line++;
		cp = strchr(buf, '@');
		if (cp == NULL) {
			fputs(buf, stdout);
			continue;
		}
		do {
			count = isref(cp);
			if (count == 0) {
				cp++;
				cp = strchr(cp, '@');
				if (cp == NULL) {
					fputs(buf, stdout);
					goto next;
				}
				continue;
			}
			/* got one */
			repair(buf, cp, count);
			break;
		} while (cp != NULL);
	next: ;
	}
}

/* repair --- turn all texinfo cross references into the one argument form */

void
repair(char *line, char *ref, int toffset)
{
	int braces = 1;		/* have seen first left brace */
	char *cp;

	ref += toffset;

	/* output line up to and including left brace in reference */
	for (cp = line; cp <= ref; cp++)
		putchar(*cp);

	/* output node name */
	for (; *cp && *cp != '}' && *cp != ',' && *cp != '\n'; cp++)
		putchar(*cp);

	if (*cp != '}')	{	/* could have been one arg xref */
		/* skip to matching right brace */
		for (; braces > 0; cp++) {
			switch (*cp) {
			case '@':
				cp++;	/* blindly skip next character */
				break;
			case '{':
				braces++;
				break;
			case '}':
				braces--;
				break;
			case '\n':
			case '\0':
				Errs++;
				fprintf(stderr,
					"%s: %s: %d: mismatched braces\n",
					Me, Name, Line);
				goto out;
			default:
				break;
			}
		}
	out:
		;
	}

	putchar('}');
	if (*cp == '}')
		cp++;

	/* now the rest of the line */
	for (; *cp; cp++)
		putchar(*cp);
	return;
}

/* strerror --- return error string, delete if in your library */

char *
strerror(int errno)
{
	static char buf[100];
	extern int sys_nerr;
	extern char *sys_errlist[];

	if (errno < sys_nerr && errno >= 0)
		return sys_errlist[errno];

	sprintf(buf, "unknown error %d", errno);
	return buf;
}


code:
#!/bin/sh
#fix-info-dir (GNU texinfo)
VERSION=1.1
#Copyright (C) 1998, 2003 Free Software Foundation, Inc.
#fix-info-dir comes with NO WARRANTY, to the extent permitted by law.
#You may redistribute copies of fix-info-dir
#under the terms of the GNU General Public License.
#For more information about these matters, see the files named COPYING."
#fix-info-dir was derived from update-info and gen-dir-node
# The skeleton file contains info topic names in the
# order they should appear in the output.  There are three special
# lines that alter the behavior: a line consisting of just "--" causes
# the next line to be echoed verbatim to the output.  A line
# containing just "%%" causes all the remaining filenames (wildcards
# allowed) in the rest of the file to be ignored.  A line containing
# just "!!" exits the script when reached (unless preceded by a line
# containing just "--").
#Author: Richard L. Hawes, rhawes@dmapub.dma.org.

# ###SECTION 1### Constants
set -h 2>/dev/null
# ENVIRONMENT
if test -z "$TMPDIR"; then
	TMPDIR="/usr/tmp"
fi
if test -z "$LINENO"; then
	LINENO="0"
fi

MENU_BEGIN='^\*\([ 	]\)\{1,\}Menu:'
MENU_ITEM='^\* ([^ 	]).*:([ 	])+\('
MENU_FILTER1='s/^\*\([ 	]\)\{1,\}/* /'
MENU_FILTER2='s/\([ 	]\)\{1,\}$//g'

TMP_FILE1="${TMPDIR}/fx${$}.info"
TMP_FILE2="${TMPDIR}/fy${$}.info"
TMP_FILE_LIST="$TMP_FILE1 $TMP_FILE2"

TRY_HELP_MSG="Try --help for more information"

# ###SECTION 100### main program
#variables set by options
CREATE_NODE=""
DEBUG=":"
MODE=""
#
Total="0"
Changed=""

while test "$*"; do
	case "$1" in
		-c|--create)    CREATE_NODE="y";;
		--debug)	set -eux; DEBUG="set>&2";;
		-d|--delete)	MODE="Detect_Invalid";;
		+d);;
		--version)
cat<<VersionEOF
fix-info-dir (GNU Texinfo) $VERSION
Copyright (C) 1998 Free Software Foundation, Inc.
fix-info-dir comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of fix-info-dir
under the terms of the GNU General Public License.
For more information about these matters, see the files named COPYING.
Author: Richard L. Hawes
VersionEOF
		exit;;

		--help)
cat<<HelpEndOfFile
Usage:	fix-info-dir  [OPTION]... [INFO_DIR/[DIR_FILE]] [SKELETON]

It detects and inserts missing menu items into the info dir file.
The info dir must be the current directory.

Options:
-c,	--create	create a new info node
-d,	--delete	delete invalid menu items (ignore missing menu items)
	--debug		print debug information to standard error path
	--help		print this help message and exit
	--version	print current version and exit
Backup of the info node has a '.old' suffix added.  This is a shell script.
Environment Variables: TMPDIR
Email bug reports to bug-texinfo@gnu.org.
HelpEndOfFile
		exit;;

		[-+]*)	echo "$0:$LINENO: \"$1\" is not a valid option">&2
			echo "$TRY_HELP_MSG">&2
			exit 2;;
		*) break;;
	esac
	shift
done

ORIGINAL_DIR=`pwd`

if test "$#" -gt "0"; then
	INFO_DIR="$1"
	shift
else
	INFO_DIR=$DEFAULT_INFO_DIR
fi

if test ! -d "${INFO_DIR}"; then
	DIR_FILE=`basename ${INFO_DIR}`;
	INFO_DIR=`dirname ${INFO_DIR}`;
else
	DIR_FILE="dir"
fi

cd "$INFO_DIR"||exit

if test "$CREATE_NODE"; then
	if test "$#" -gt "0"; then
		if test `expr $1 : /` = '1'; then
			SKELETON="$1"
		else
			SKELETON="$ORIGINAL_DIR/$1"
		fi
		if test ! -r "$SKELETON" && test -f "$SKELETON"; then
			echo "$0:$LINENO: $SKELETON is not readable">&2
			exit 2
		fi
		shift
	else
		SKELETON=/dev/null

	fi
else
	if test ! -f "$DIR_FILE"; then
		echo "$0:$LINENO: $DIR_FILE is irregular or nonexistant">&2
		exit 2
	elif test ! -r "$DIR_FILE"; then
		echo "$0:$LINENO: $DIR_FILE is not readable">&2
		exit 2
	elif test ! -w "$DIR_FILE"; then
		echo "$0:$LINENO: $DIR_FILE is not writeable">&2
		exit 2
	fi
fi

if test "$#" -gt "0"; then
	echo "$0:$LINENO: Too many parameters">&2
	echo "$TRY_HELP_MSG">&2
	exit 2
fi

if test -f "$DIR_FILE"; then
	cp "$DIR_FILE" "$DIR_FILE.old"
	echo "Backed up $DIR_FILE to $DIR_FILE.old."
fi

if test "$CREATE_NODE"; then
	if test "$MODE"; then
		echo "$0:$LINENO: ERROR: Illogical option combination: -d -c">&2
		echo "$TRY_HELP_MSG">&2
		exit 2
	fi
	echo "Creating new Info Node: `pwd`/$DIR_FILE"
	Changed="y"

{

	### output the dir header
	echo "-*- Text -*-"
	echo "This file was generated automatically by $0."
	echo "This version was generated on `date`"
	echo "by `whoami`@`hostname` for `pwd`"

	cat<<DIR_FILE_END_OF_FILE
This is the file .../info/$DIR_FILE, which contains the topmost node of the
Info hierarchy.  The first time you invoke Info you start off
looking at that node, which is ($DIR_FILE)Top.

File: $DIR_FILE       Node: Top       This is the top of the INFO tree

  This (the Directory node) gives a menu of major topics.
  Typing "q" exits, "?" lists all Info commands, "d" returns here,
  "h" gives a primer for first-timers,
  "mEmacs<Return>" visits the Emacs topic, etc.

  In Emacs, you can click mouse button 2 on a menu item or cross reference
  to select it.

* Menu: The list of major topics begins on the next line.

DIR_FILE_END_OF_FILE

### go through the list of files in the skeleton.  If an info file
### exists, grab the ENTRY information from it.  If an entry exists
### use it, otherwise create a minimal $DIR_FILE entry.

	# Read one line from the file.  This is so that we can echo lines with
	# whitespace and quoted characters in them.
	while read fileline; do
		# flag fancy features
		if test ! -z "$echoline"; then        # echo line
			echo "$fileline"
			echoline=""
			continue
		elif test "${fileline}" = "--"; then
			# echo the next line
			echoline="1"
			continue
		elif test "${fileline}" = "%%"; then
			# skip remaining files listed in skeleton file
			skip="1"
			continue
		elif test "${fileline}" = "!!"; then
			# quit now
			break
		fi

		# handle files if they exist
		for file in $fileline""; do
			fname=
			if test -z "$file"; then
				break
			fi
			# Find the file to operate upon.
			if test -r "$file"; then
				fname="$file"
			elif test -r "${file}.info"; then
				fname="${file}.info"
			elif test -r "${file}.gz"; then
				fname="${file}.gz"
			elif test -r "${file}.info.gz"; then
				fname="${file}.info.gz"
			else
				echo "$0:$LINENO: can't find info file for ${file}?">&2
				continue
			fi

			# if we found something and aren't skipping, do the entry
			if test "$skip"; then
				continue
			fi

			infoname=`echo $file|sed -e 's/.info$//'`
			entry=`zcat -f $fname|\
			sed -e '1,/START-INFO-DIR-ENTRY/d'\
			-e '/END-INFO-DIR-ENTRY/,$d'`
			if [ ! -z "${entry}" ]; then
				echo "${entry}"
			else
				echo "* ${infoname}: (${infoname})."
			fi
			Total=`expr "$Total" + "1"`
		done
	done
}>$DIR_FILE<$SKELETON
fi

trap ' eval "$DEBUG"; rm -f $TMP_FILE_LIST; exit ' 0
trap ' rm -f $TMP_FILE_LIST
	exit ' 1
trap ' rm -f $TMP_FILE_LIST
	echo "$0:$LINENO: received INT signal.">&2
	exit ' 2
trap ' rm -f $TMP_FILE_LIST
	echo "$0:$LINENO: received QUIT signal.">&2
	exit ' 3

sed -e "1,/$MENU_BEGIN/d" -e "$MENU_FILTER1" -e "$MENU_FILTER2"<$DIR_FILE\
|sed -n -e '/\* /{
s/).*$//g
s/\.gz$//
s/\.info$//
s/^.*(//p
}'|sort -u>$TMP_FILE1
ls -F|sed -e '/\/$/d' -e '/[-.][0-9]/d'\
	-e "/^$DIR_FILE\$/d" -e "/^$DIR_FILE.old\$/d"\
	-e 's/[*@]$//' -e 's/\.gz$//' -e 's/\.info$//'|sort>$TMP_FILE2

if test -z "$MODE"; then
	#Detect Missing
	DONE_MSG="total menu item(s) were inserted into `pwd`/$DIR_FILE"
	for Info_Name in `comm -13 $TMP_FILE1 $TMP_FILE2`; do
		if test -r "$Info_Name"; then
			Info_File="$Info_Name"
		elif test -r "${Info_Name}.info"; then
			Info_File="${Info_Name}.info"
		elif test -r "${Info_Name}.gz"; then
			Info_File="${Info_Name}.gz"
		elif test -r "${Info_Name}.info.gz"; then
			Info_File="${Info_Name}.info.gz"
		else
			echo "$0:$LINENO: can't find info file for ${Info_Name}?">&2
			continue
		fi
		Changed="y"
		if install-info $Info_File $DIR_FILE; then
			Total=`expr "$Total" + "1"`
		fi
	done
else
	# Detect Invalid
	DONE_MSG="total invalid menu item(s) were removed from `pwd`/$DIR_FILE"
	for Info_Name in `comm -23 $TMP_FILE1 $TMP_FILE2`; do
		Changed="y"
		if install-info --remove $Info_Name $DIR_FILE; then
			Total=`expr "$Total" + "1"`
		fi
	done
fi

# print summary
if test "$Changed"; then
	echo "$Total $DONE_MSG"
else
	echo "Nothing to do"
fi
rm -f $TMP_FILE_LIST
eval "$DEBUG"
exit 0

path: contrib/fix-info-dir


code:
#!/bin/sh
# Make links named `lcircle10' for all TFM and GF/PK files, if no
# lcircle10 files already exist.

# Don't override definition of prefix and/or libdir if they are
# already defined in the environment.
if test "z${prefix}" = "z" ; then
  prefix=/usr/local
else
  # prefix may contain references to other variables, thanks to make.
  eval prefix=\""${prefix}"\"
fi

if test "z${libdir}" = "z" ; then
  libdir="${prefix}/lib/tex"
else
  # libdir may contain references to other variables, thanks to make.
  eval libdir=\""${libdir}"\"
fi

texlibdir="${libdir}"
texfontdir="${texlibdir}/fonts"

# Directories for the different font formats, in case they're not all
# stored in one place.
textfmdir="${textfmdir-${texfontdir}}"
texpkdir="${texpkdir-${texfontdir}}"
texgfdir="${texgfdir-${texfontdir}}"

test "z${TMPDIR}" = "z" && TMPDIR="/tmp"

tempfile="${TMPDIR}/circ$$"
tempfile2="${TMPDIR}/circ2$$"

# EXIT SIGHUP SIGINT SIGQUIT SIGTERM
#trap 'rm -f "${tempfile}" "${tempfile2}"' 0 1 2 3 15

# Find all the fonts with names that include `circle'.
(cd "${texfontdir}"; find . -name '*circle*' -print > "${tempfile}")

# If they have lcircle10.tfm, assume everything is there, and quit.
if grep 'lcircle10\.tfm' "${tempfile}" > /dev/null 2>&1 ; then
  echo "Found lcircle10.tfm."
  exit 0
fi

# No TFM file for lcircle.  Make a link to circle10.tfm if it exists,
# and then make a link to the bitmap files.
grep 'circle10\.tfm' "${tempfile}" > "${tempfile2}" \
 || {
  echo "I can't find any circle fonts in ${texfontdir}.
If it isn't installed somewhere else, you need to get the Metafont sources
from somewhere, e.g., labrea.stanford.edu:pub/tex/latex/circle10.mf, and
run Metafont on them."
  exit 1
 }

# We have circle10.tfm.  (If we have it more than once, take the first
# one.)  Make the link.
tempfile2_line1="`sed -ne '1p;q' \"${tempfile2}\"`"
ln "${tempfile2_line1}" "${textfmdir}/lcircle10.tfm"
echo "Linked to ${tempfile2_line1}."

# Now make a link for the PK files, if any.
(cd "${texpkdir}"
 for f in `grep 'circle10.*pk' "${tempfile}"` ; do
    set - `echo "$f" \
            | sed -ne '/\//!s/^/.\//;s/\(.*\)\/\([^\/][^\/]*\)$/\1 \2/;p'`
    ln "$f" "${1}/l${2}"
    echo "Linked to $f."
 done
)

# And finally for the GF files.
(cd "${texgfdir}"
 for f in `grep 'circle10.*gf' "${tempfile}"` ; do
    set - `echo "$f" \
            | sed -ne '/\//!s/^/.\//;s/\(.*\)\/\([^\/][^\/]*\)$/\1 \2/;p'`
    ln "$f" "${1}/l${2}"
    echo "Linked to $f."
 done
)

# eof

path: contrib/fixfonts


code:
#! /usr/local/bin/gawk -f

# fixref.awk --- fix xrefs in texinfo documents
# Copyright 1991, 1998 Arnold David Robbins

# FIXREF is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# FIXREF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Updated: Jul 21  1992	--- change unknown
# Updated: Jul 18  1997 --- bug fix

# usage:		gawk -f fixref.awk input-file > output-file
# or if you have #!:	fixref.awk input-file > output-file

# Limitations:
#	1. no more than one cross reference on a line
#	2. cross references may not cross a newline

BEGIN	\
{
	# we make two passes over the file.  To do that we artificially
	# tweak the argument vector to do a variable assignment

	if (ARGC != 2) {
		printf("usage: %s texinfo-file\n", ARGV[0]) > "/dev/stderr"
		exit 1
	}
	ARGV[2] = "pass=2"
	ARGV[3] = ARGV[1]
	ARGC = 4

	# examine paragraphs
	RS = ""

	heading = "@(chapter|appendix|unnumbered|(appendix(sec|subsec|subsubsec))|section|subsection|subsubsection|unnumberedsec|heading|top)"

	pass = 1

	# put space between paragraphs on output
	ORS = "\n\n"
}

pass == 1 && NF == 0	{ next }

# pass == 1 && /@node/	\
# bug fix 7/18/96
pass == 1 && /^@node/	\
{
	lname = name = ""
	n = split($0, lines, "\n")
	for (i = 1; i <= n; i++) {
		if (lines[i] ~ ("^" heading)) {
			sub(heading, "", lines[i])
			sub(/^[ \t]*/, "", lines[i])
			lname = lines[i]
#			printf "long name is '%s'\n", lines[i]
		} else if (lines[i] ~ /@node/) {
			sub(/@node[ \t]*/, "", lines[i])
			sub(/[ \t]*,.*$/, "", lines[i])
			name = lines[i]
#			printf "node name is '%s'\n", lines[i]
		}
	}
	if (name && lname)
		names[name] = lname
	else if (lname)
		printf("node name for %s missing!\n", lname) > "/dev/stderr"
	else
		printf("long name for %s missing!\n", name) > "/dev/stderr"

	if (name ~ /:/)
		printf("node `%s' contains a `:'\n", name) > "/dev/stderr"

	if (lname) {
		if (lname ~ /:/)
			printf("name `%s' contains a `:'\n", lname) > "/dev/stderr"
		else if (lname ~ /,/) {
			printf("name `%s' contains a `,'\n", lname) > "/dev/stderr"
			gsub(/,/, " ", lname)
			names[name] = lname	# added 7/18/97
		}
	}
}

pass == 2 && /@(x|px)?ref{/	\
{
	# split the paragraph into lines
	# write them out one by one after fixing them
	n = split($0, lines, "\n")
	for (i = 1; i <= n; i++)
		if (lines[i] ~ /@(x|px)?ref{/) {
			res = updateref(lines[i])
			printf "%s\n", res
		} else
			printf "%s\n", lines[i]

	printf "\n"	# avoid ORS
	next
}

function updateref(orig,	refkind, line)
{
	line = orig	# work on a copy

	# find the beginning of the reference
	match(line, "@(x|px)?ref{")
	refkind = substr(line, RSTART, RLENGTH)

	# pull out just the node name
	sub(/.*ref{/, "", line)
	sub(/}.*$/, "", line)
	sub(/,.*/, "", line)

#	debugging
#	printf("found ref to node '%s'\n", line) > "/dev/stderr"

	# If the node name and the section name are the same
	# we don't want to bother doing this.

	if (! (line in names))	# sanity checking
		printf("no long name for %s\n", line) > "/dev/stderr"
	else if (names[line] != line && names[line] !~ /[:,]/) {
		# build up new ref
		newref = refkind line ", ," names[line] "}"
		pat = refkind line "[^}]*}"

		sub(pat, newref, orig)
	}

	return orig
}

pass == 2	{ print }


code:
eval '(exit $?0)' && eval 'exec perl -S "$0" ${1+"$@"}'
    & eval 'exec perl -S "$0" $argv:q'
    if 0;

## Copyright (c) 2002-2012 Simon Josefsson
##                    added -texinfo, -listfunc, -pkg-name
##                    man page revamp
##                    various improvements
## Copyright (c) 2001, 2002 Nikos Mavrogiannopoulos
##                    added -tex
## Copyright (c) 1998 Michael Zucchi

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# This will read a C source code file and scan for embedded comments
# in the style of gnome comments (+minor extensions - see below).

# usage:
# gdoc [ -docbook | -html | -text | -man | -tex | -texinfo | -listfunc ]
#      [ -sourceversion verno ] [ -include file | -includefuncprefix ]
#      [ -bugsto address ] [ -pkg-name packagename ]
#      [ -seeinfo infonode ] [ -copyright notice ] [ -verbatimcopying ]
#      [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile
#
#  Set output format using one of -docbook, -html, -text, -man, -tex,
#  -texinfo, or -listfunc.  Default is man.
#
#  -sourceversion
#       Version number for source code, e.g. '1.0.4'.  Used in 'man' headers.
#       Defaults to using current date.
#
#  -include FILE
#       For man pages, mention #include <FILE.h> in the synopsis.
#
#  -includefuncprefix
#       For man pages, mention a #include <FILE.h> in the synopsis.
#       The FILE derived from the function prefix.  For example, a
#       function gss_init_sec_context will generate an include
#       statement of #include <gss.h>.
#
#  -bugsto address
#       For man pages, include a section about reporting bugs and mention
#       the given e-mail address, e.g 'bug-libidn@gnu.org'.
#
#  -pkg-name packagename
#       For man pages when -bugsto is used, also include help URLs to the
#       the project's home page.  For example, "GNU Libidn".
#
#  -seeinfo infonode
#       For man pages, include a section that point to an info manual
#       for more information.
#
#  -copyright notice
#       For man pages, include a copyright section with the given
#       notice after a preamble.  Use, e.g., '2002, 2003 Simon Josefsson'.
#
#  -verbatimcopying
#       For man pages, and when the -copyright parameter is used,
#       add a licensing statement that say verbatim copying is permitted.
#
#  -function funcname
#	If set, then only generate documentation for the given function(s).  All
#	other functions are ignored.
#
#  c files - list of 'c' files to process
#
#  All output goes to stdout, with errors to stderr.

#
# format of comments.
# In the following table, (...)? signifies optional structure.
#                         (...)* signifies 0 or more structure elements
# /**
#  * function_name(:)? (- short description)?
# (* @parameterx: (description of parameter x)?)*
# (* a blank line)?
#  * (Description:)? (Description of function)?
#  * (Section header: (section description)? )*
#  (*)?*/
#
# So .. the trivial example would be:
#
# /**
#  * my_function
#  **/
#
# If the Description: header tag is ommitted, then there must be a blank line
# after the last parameter specification.
# e.g.
# /**
#  * my_function - does my stuff
#  * @my_arg: its mine damnit
#  *
#  * Does my stuff explained.
#  */
#
#  or, could also use:
# /**
#  * my_function - does my stuff
#  * @my_arg: its mine damnit
#  * Description: Does my stuff explained.
#  */
# etc.
#
# All descriptions can be multiline, apart from the short function description.
#
# All descriptive text is further processed, scanning for the following special
# patterns, which are highlighted appropriately.
#
# 'funcname()' - function
# '$ENVVAR' - environmental variable OBSOLETE (?)
# '#struct_name' - name of a structure
# '@parameter' - name of a parameter
# '%CONST' - name of a constant.

#
# Extensions for LaTeX:
#
# 1. the symbol '->' will be replaced with a rightarrow
# 2. x^y with ${x}^{y}$.
# 3. xxx\: with xxx:

use POSIX qw(strftime);

# match expressions used to find embedded type information
$type_constant = "\\\%(\\w+)";
$type_func = "(\\w+\\(\\))";
$type_param = "\\\@(\\w+)";
$type_struct = "\\\#(\\w+)";
$type_env = "(\\\$\\w+)";

# Output conversion substitutions.
#  One for each output format

# these work fairly well
%highlights_html = ( $type_constant, "\$1",
		     $type_func, "\$1",
		     $type_struct, "\$1",
		     $type_param, "<tt>\$1</tt>" );
$blankline_html = "
";

%highlights_texinfo = ( $type_constant, "\\\@code{\$1}",
			$type_func, "\\\@code{\$1}",
			$type_struct, "\\\@code{\$1}",
			$type_param, "\\\@code{\$1}" );
$blankline_texinfo = "";

%highlights_tex = ( $type_constant, "{\\\\it \$1}",
		     $type_func, "{\\\\bf \$1}",
		     $type_struct, "{\\\\it \$1}",
		     $type_param, "{\\\\bf \$1}" );
$blankline_tex = "\\\\";

# sgml, docbook format
%highlights_sgml = ( $type_constant, "<replaceable class=\"option\">\$1</replaceable>",
		     $type_func, "<function>\$1</function>",
		     $type_struct, "<structname>\$1</structname>",
		     $type_env, "<envar>\$1</envar>",
		     $type_param, "<parameter>\$1</parameter>" );
$blankline_sgml = "</para><para>\n";

# these are pretty rough
%highlights_man = ( $type_constant, "\\\\fB\$1\\\\fP",
		    $type_func, "\\\\fB\$1\\\\fP",
		    $type_struct, "\\\\fB\$1\\\\fP",
		    $type_param, "\\\\fI\$1\\\\fP" );
$blankline_man = "";

# text-mode
%highlights_text = ( $type_constant, "\$1",
		     $type_func, "\$1",
		     $type_struct, "\$1",
		     $type_param, "\$1" );
$blankline_text = "";

sub usage {
    print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man | -tex | -texinfo  -listfunc ]\n";
    print "         [ -sourceversion verno ] [ -include file | -includefuncprefix ]\n";
    print "         [ -bugsto address ] [ -seeinfo infonode ] [ -copyright notice]\n";
    print "         [ -verbatimcopying ] [ -pkg-name packagename ]\n";
    print "         [ -function funcname [ -function funcname ...] ]\n";
    print "         c source file(s) > outputfile\n";
    exit 1;
}

# read arguments
if ($#ARGV==-1) {
    usage();
}

$verbose = 0;
$output_mode = "man";
%highlights = %highlights_man;
$blankline = $blankline_man;
$modulename = "API Documentation";
$sourceversion = strftime "%Y-%m-%d", localtime;
$function_only = 0;
while ($ARGV[0] =~ m/^-(.*)/) {
    $cmd = shift @ARGV;
    if ($cmd eq "-html") {
	$output_mode = "html";
	%highlights = %highlights_html;
	$blankline = $blankline_html;
    } elsif ($cmd eq "-man") {
	$output_mode = "man";
	%highlights = %highlights_man;
	$blankline = $blankline_man;
    } elsif ($cmd eq "-tex") {
	$output_mode = "tex";
	%highlights = %highlights_tex;
	$blankline = $blankline_tex;
    } elsif ($cmd eq "-texinfo") {
	$output_mode = "texinfo";
	%highlights = %highlights_texinfo;
	$blankline = $blankline_texinfo;
    } elsif ($cmd eq "-text") {
	$output_mode = "text";
	%highlights = %highlights_text;
	$blankline = $blankline_text;
    } elsif ($cmd eq "-docbook") {
	$output_mode = "sgml";
	%highlights = %highlights_sgml;
	$blankline = $blankline_sgml;
    } elsif ($cmd eq "-listfunc") {
	$output_mode = "listfunc";
    } elsif ($cmd eq "-module") { # not needed for sgml, inherits from calling document
	$modulename = shift @ARGV;
    } elsif ($cmd eq "-sourceversion") {
	$sourceversion = shift @ARGV;
    } elsif ($cmd eq "-include") {
	$include = shift @ARGV;
    } elsif ($cmd eq "-includefuncprefix") {
	$includefuncprefix = 1;
    } elsif ($cmd eq "-bugsto") {
	$bugsto = shift @ARGV;
    } elsif ($cmd eq "-pkg-name") {
	$pkgname = shift @ARGV;
    } elsif ($cmd eq "-copyright") {
	$copyright = shift @ARGV;
    } elsif ($cmd eq "-verbatimcopying") {
	$verbatimcopying = 1;
    } elsif ($cmd eq "-seeinfo") {
	$seeinfo = shift @ARGV;
    } elsif ($cmd eq "-function") { # to only output specific functions
	$function_only = 1;
	$function = shift @ARGV;
	$function_table{$function} = 1;
    } elsif ($cmd eq "-v") {
	$verbose = 1;
    } elsif (($cmd eq "-h") || ($cmd eq "--help")) {
	usage();
    }
}

##
# dumps section contents to arrays/hashes intended for that purpose.
#
sub dump_section {
    my $name = shift @_;
    my $contents = join "\n", @_;

    if ($name =~ m/$type_constant/) {
	$name = $1;
#	print STDERR "constant section '$1' = '$contents'\n";
	$constants{$name} = $contents;
    } elsif ($name =~ m/$type_param/) {
#	print STDERR "parameter def '$1' = '$contents'\n";
	$name = $1;
	$parameters{$name} = $contents;
    } else {
#	print STDERR "other section '$name' = '$contents'\n";
	$sections{$name} = $contents;
	push @sectionlist, $name;
    }
}

##
# output function
#
# parameters, a hash.
#  function => "function name"
#  parameterlist => @list of parameters
#  parameters => %parameter descriptions
#  sectionlist => @list of sections
#  sections => %descriont descriptions
#

sub repstr {
    $pattern = shift;
    $repl = shift;
    $match1 = shift;
    $match2 = shift;
    $match3 = shift;
    $match4 = shift;

    $output = $repl;
    $output =~ s,\$1,$match1,g;
    $output =~ s,\$2,$match2,g;
    $output =~ s,\$3,$match3,g;
    $output =~ s,\$4,$match4,g;

    eval "\$return = qq/$output/";

#    print "pattern $pattern matched 1=$match1 2=$match2 3=$match3 4=$match4 replace $repl yielded $output interpolated $return\n";

    $return;
}

sub just_highlight {
    my $contents = join "\n", @_;
    my $line;
    my $ret = "";

    foreach $pattern (keys %highlights) {
#	print "scanning pattern $pattern ($highlights{$pattern})\n";
	$contents =~ s:$pattern:repstr($pattern, $highlights{$pattern}, $1, $2, $3, $4):gse;
    }
    foreach $line (split "\n", $contents) {
	if ($line eq ""){
	    $ret = $ret . $lineprefix . $blankline;
	} else {
	    $ret = $ret . $lineprefix . $line;
	}
	$ret = $ret . "\n";
    }

    return $ret;
}

sub output_highlight {
    print (just_highlight (@_));
}

# output in texinfo
sub output_texinfo {
    my %args = %{$_[0]};
    my ($parameter, $section);
    my $count;

    print "\@subheading ".$args{'function'}."\n";
    print "\@anchor{".$args{'function'}."}\n";
    print "\@deftypefun {" . $args{'functiontype'} . "} ";
    print "{".$args{'function'}."} ";
    print "(";
    $count = 0;
    foreach $parameter (@{$args{'parameterlist'}}) {
	print $args{'parametertypes'}{$parameter}." \@var{".$parameter."}";
	if ($count != $#{$args{'parameterlist'}}) {
	    $count++;
	    print ", ";
	}
    }
    print ")\n";
    foreach $parameter (@{$args{'parameterlist'}}) {
	if ($args{'parameters'}{$parameter}) {
	    print "\@var{".$parameter."}: ";
	    output_highlight($args{'parameters'}{$parameter});
	    print "\n";
	}
    }
    foreach $section (@{$args{'sectionlist'}}) {
	print "\n\@strong{$section:} " if $section ne $section_default;
	$args{'sections'}{$section} =~ s:([{}]):\@\1:gs;
	output_highlight($args{'sections'}{$section});
    }
    print "\@end deftypefun\n\n";
}

# output in html
sub output_html {
    my %args = %{$_[0]};
    my ($parameter, $section);
    my $count;
    print "\n\n&nbsp
Function
\n";

    print "".$args{'functiontype'}."\n";
    print "".$args{'function'}."\n";
    print "(";
    $count = 0;
    foreach $parameter (@{$args{'parameterlist'}}) {
	print "".$args{'parametertypes'}{$parameter}." ".$parameter."\n";
	if ($count != $#{$args{'parameterlist'}}) {
	    $count++;
	    print ", ";
	}
    }
    print ")\n";

    print "
Arguments
\n";
    print "
\n";
    foreach $parameter (@{$args{'parameterlist'}}) {
	print "
".$args{'parametertypes'}{$parameter}." ".$parameter."\n";
	print "
";
	output_highlight($args{'parameters'}{$parameter});
    }
    print "
\n";
    foreach $section (@{$args{'sectionlist'}}) {
	print "
$section
\n";
	print "
\n";
	output_highlight($args{'sections'}{$section});
	print "
\n";
    }
    print "
\n";
}

# output in tex
sub output_tex {
    my %args = %{$_[0]};
    my ($parameter, $section);
    my $count;
    my $func = $args{'function'};
    my $param;
    my $param2;
    my $sec;
    my $check;
    my $type;

    $func =~ s/_/\\_/g;

    print "\n\n\\subsection{". $func . "}\n\\label{" . $args{'function'} . "}\n";

    $type = $args{'functiontype'};
    $type =~ s/_/\\_/g;

    print "{\\it ".$type."}\n";
    print "{\\bf ".$func."}\n";
    print "(";
    $count = 0;
    foreach $parameter (@{$args{'parameterlist'}}) {
        $param = $args{'parametertypes'}{$parameter};
        $param2 = $parameter;
	$param =~ s/_/\\_/g;
        $param2 =~ s/_/\\_/g;

	print "{\\it ".$param."} {\\bf ".$param2."}";
	if ($count != $#{$args{'parameterlist'}}) {
	    $count++;
	    print ", ";
	}
    }
    print ")\n";

    print "\n{\\large{Arguments}}\n";

    print "\\begin{itemize}\n";
    $check=0;
    foreach $parameter (@{$args{'parameterlist'}}) {
        $param1 = $args{'parametertypes'}{$parameter};
        $param1 =~ s/_/\\_/g;
        $param2 = $parameter;
	$param2 =~ s/_/\\_/g;

	$check = 1;
	print "\\item {\\it ".$param1."} {\\bf ".$param2."}: \n";
#	print "\n";

	$param3 = $args{'parameters'}{$parameter};
	$param3 =~ s/#([a-zA-Z\_]+)/{\\it \1}/g;

	$out = just_highlight($param3);
	$out =~ s/_/\\_/g;
	print $out;
    }
    if ($check==0) {
	print "\\item void\n";
    }
    print "\\end{itemize}\n";

    foreach $section (@{$args{'sectionlist'}}) {
	$sec = $section;
	$sec =~ s/_/\\_/g;
	$sec =~ s/#([a-zA-Z\_]+)/{\\it \1}/g;

	print "\n{\\large{$sec}}\\\\\n";
	print "\\begin{rmfamily}\n";

	$sec = $args{'sections'}{$section};
	$sec =~ s/\\:/:/g;
	$sec =~ s/#([a-zA-Z\_]+)/{\\it \1}/g;
	$sec =~ s/->/\$\\rightarrow\$/g;
	$sec =~ s/([0-9]+)\^([0-9]+)/\$\{\1\}\^\{\2\}\$/g;

	$out = just_highlight($sec);
	$out =~ s/_/\\_/g;

	print $out;
	print "\\end{rmfamily}\n";
    }
    print "\n";
}

# output in sgml DocBook
sub output_sgml {
    my %args = %{$_[0]};
    my ($parameter, $section);
    my $count;
    my $id;

    $id = $args{'module'}."-".$args{'function'};
    $id =~ s/[^A-Za-z0-9]/-/g;

    print "<refentry>\n";
    print "<refmeta>\n";
    print "<refentrytitle><phrase id=\"$id\">".$args{'function'}."</phrase></refentrytitle>\n";
    print "</refmeta>\n";
    print "<refnamediv>\n";
    print " <refname>".$args{'function'}."</refname>\n";
    print " <refpurpose>\n";
    print "  ".$args{'purpose'}."\n";
    print " </refpurpose>\n";
    print "</refnamediv>\n";

    print "<refsynopsisdiv>\n";
    print " <title>Synopsis</title>\n";
    print "  <funcsynopsis>\n";
    print "   <funcdef>".$args{'functiontype'}." ";
    print "<function>".$args{'function'}." ";
    print "</function></funcdef>\n";

#    print "<refsect1>\n";
#    print " <title>Synopsis</title>\n";
#    print "  <funcsynopsis>\n";
#    print "   <funcdef>".$args{'functiontype'}." ";
#    print "<function>".$args{'function'}." ";
#    print "</function></funcdef>\n";

    $count = 0;
    if ($#{$args{'parameterlist'}} >= 0) {
	foreach $parameter (@{$args{'parameterlist'}}) {
	    print "   <paramdef>".$args{'parametertypes'}{$parameter};
	    print " <parameter>$parameter</parameter></paramdef>\n";
	}
    } else {
	print "  <void>\n";
    }
    print "  </funcsynopsis>\n";
    print "</refsynopsisdiv>\n";
#    print "</refsect1>\n";

    # print parameters
    print "<refsect1>\n <title>Arguments</title>\n";
#    print "<para>\nArguments\n";
    if ($#{$args{'parameterlist'}} >= 0) {
	print " <variablelist>\n";
	foreach $parameter (@{$args{'parameterlist'}}) {
	    print "  <varlistentry>\n   <term><parameter>$parameter</parameter></term>\n";
	    print "   <listitem>\n    <para>\n";
	    $lineprefix="     ";
	    output_highlight($args{'parameters'}{$parameter});
	    print "    </para>\n   </listitem>\n  </varlistentry>\n";
	}
	print " </variablelist>\n";
    } else {
	print " <para>\n  None\n </para>\n";
    }
    print "</refsect1>\n";

    # print out each section
    $lineprefix="   ";
    foreach $section (@{$args{'sectionlist'}}) {
	print "<refsect1>\n <title>$section</title>\n <para>\n";
#	print "<para>\n$section\n";
	if ($section =~ m/EXAMPLE/i) {
	    print "<example><para>\n";
	}
	output_highlight($args{'sections'}{$section});
#	print "</para>";
	if ($section =~ m/EXAMPLE/i) {
	    print "</para></example>\n";
	}
	print " </para>\n</refsect1>\n";
    }

    print "\n\n";
}

##
# output in man
sub output_man {
    my %args = %{$_[0]};
    my ($parameter, $section);
    my $count;

    print ".\\\" DO NOT MODIFY THIS FILE!  It was generated by gdoc.\n";
    print ".TH \"$args{'function'}\" 3 \"$args{'sourceversion'}\" \"". $args{'module'} . "\" \"". $args{'module'} . "\"\n";

    print ".SH NAME\n";

    print $args{'function'};
    if ($args{'purpose'}) {
	print " \\- " . $args{'purpose'} . "\n";
    } else {
	print " \\- API function\n";
    }

    print ".SH SYNOPSIS\n";
    print ".B #include <". $args{'include'} . ">\n"
	if $args{'include'};
    print ".B #include <". lc((split /_/, $args{'function'})[0]) . ".h>\n"
	if $args{'includefuncprefix'};
    print ".sp\n";
    print ".BI \"".$args{'functiontype'}." ".$args{'function'}."(";
    $count = 0;
    foreach $parameter (@{$args{'parameterlist'}}) {
	print $args{'parametertypes'}{$parameter}." \" ".$parameter." \"";
	if ($count != $#{$args{'parameterlist'}}) {
	    $count++;
	    print ", ";
	}
    }
    print ");\"\n";

    print ".SH ARGUMENTS\n";
    foreach $parameter (@{$args{'parameterlist'}}) {
	print ".IP \"".$args{'parametertypes'}{$parameter}." ".$parameter."\" 12\n";
	$param = $args{'parameters'}{$parameter};
	$param =~ s/-/\\-/g;
	output_highlight($param);
    }
    foreach $section (@{$args{'sectionlist'}}) {
	print ".SH \"" . uc($section) . "\"\n";
	$sec = $args{'sections'}{$section};
	$sec =~ s/-/\\-/g;
	output_highlight($sec);
    }

    if ($args{'bugsto'}) {
	print ".SH \"REPORTING BUGS\"\n";
	print "Report bugs to <". $args{'bugsto'} . ">.\n";
	if ($args{'pkgname'}) {
	    print $args{'pkgname'} . " home page: " .
		"http://www.gnu.org/software/" . $args{'module'} . "/\n";
	}
	print "General help using GNU software: http://www.gnu.org/gethelp/\n";
    }

    if ($args{'copyright'}) {
	print ".SH COPYRIGHT\n";
	print "Copyright \\(co ". $args{'copyright'} . ".\n";
	if ($args{'verbatimcopying'}) {
	    print ".br\n";
	    print "Copying and distribution of this file, with or without modification,\n";
	    print "are permitted in any medium without royalty provided the copyright\n";
	    print "notice and this notice are preserved.\n";
	}
    }

    if ($args{'seeinfo'}) {
	print ".SH \"SEE ALSO\"\n";
	print "The full documentation for\n";
	print ".B " . $args{'module'} . "\n";
	print "is maintained as a Texinfo manual.  If the\n";
	print ".B info\n";
	print "and\n";
	print ".B " . $args{'module'} . "\n";
	print "programs are properly installed at your site, the command\n";
	print ".IP\n";
	print ".B info " . $args{'seeinfo'} . "\n";
	print ".PP\n";
	print "should give you access to the complete manual.\n";
    }
}

sub output_listfunc {
    my %args = %{$_[0]};
    print $args{'function'} . "\n";
}

##
# output in text
sub output_text {
    my %args = %{$_[0]};
    my ($parameter, $section);

    print "Function = ".$args{'function'}."\n";
    print "  return type: ".$args{'functiontype'}."\n\n";
    foreach $parameter (@{$args{'parameterlist'}}) {
	print " ".$args{'parametertypes'}{$parameter}." ".$parameter."\n";
	print "    -> ".$args{'parameters'}{$parameter}."\n";
    }
    foreach $section (@{$args{'sectionlist'}}) {
	print " $section:\n";
	print "    -> ";
	output_highlight($args{'sections'}{$section});
    }
}

##
# generic output function - calls the right one based
# on current output mode.
sub output_function {
#    output_html(@_);
    eval "output_".$output_mode."(\@_);";
}

##
# takes a function prototype and spits out all the details
# stored in the global arrays/hsahes.
sub dump_function {
    my $prototype = shift @_;

    if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ ||
	$prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ ||
	$prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ ||
	$prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ ||
	$prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/)  {
	$return_type = $1;
	$function_name = $2;
	$args = $3;

#	print STDERR "ARGS = '$args'\n";

	foreach $arg (split ',', $args) {
	    # strip leading/trailing spaces
	    $arg =~ s/^\s*//;
	    $arg =~ s/\s*$//;
#	    print STDERR "SCAN ARG: '$arg'\n";
	    @args = split('\s', $arg);

#	    print STDERR " -> @args\n";
	    $param = pop @args;
#	    print STDERR " -> @args\n";
	    if ($param =~ m/^(\*+)(.*)/) {
		$param = $2;
		push @args, $1;
	    }
	    if ($param =~ m/^(.*)(\[\])$/) {
		$param = $1;
		push @args, $2;
	    }
#	    print STDERR " :> @args\n";
	    $type = join " ", @args;

	    if ($parameters{$param} eq "" && $param != "void") {
		$parameters{$param} = "-- undescribed --";
		print STDERR "warning: $lineno: Function parameter '$param' not described in '$function_name'\n";
	    }

	    push @parameterlist, $param;
	    $parametertypes{$param} = $type;

#	    print STDERR "param = '$param', type = '$type'\n";
	}
    } else {
	print STDERR "warning: $lineno: Cannot understand prototype: '$prototype'\n" if (!($prototype  =~ m,GSASL_VALID_MECHANISM_CHARACTERS,));
	return;
    }

    if ($function_only==0 || defined($function_table{$function_name})) {
	output_function({'function' => $function_name,
			 'module' => $modulename,
			 'sourceversion' => $sourceversion,
			 'include' => $include,
			 'includefuncprefix' => $includefuncprefix,
			 'bugsto' => $bugsto,
			 'pkgname' => $pkgname,
			 'copyright' => $copyright,
			 'verbatimcopying' => $verbatimcopying,
			 'seeinfo' => $seeinfo,
			 'functiontype' => $return_type,
			 'parameterlist' => \@parameterlist,
			 'parameters' => \%parameters,
			 'parametertypes' => \%parametertypes,
			 'sectionlist' => \@sectionlist,
			 'sections' => \%sections,
			 'purpose' => $function_purpose
			 });
    }
}

######################################################################
# main
# states
# 0 - normal code
# 1 - looking for function name
# 2 - scanning field start.
# 3 - scanning prototype.
$state = 0;
$section = "";

$doc_special = "\@\%\$\#";

$doc_start = "^/\\*\\*\$";
$doc_end = "\\*/";
$doc_com = "\\s*\\*\\s*";
$doc_func = $doc_com."(\\w+):?";
$doc_sect = $doc_com."([".$doc_special."[:upper:]][\\w ]+):\\s*(.*)";
$doc_content = $doc_com."(.*)";

%constants = ();
%parameters = ();
@parameterlist = ();
%sections = ();
@sectionlist = ();

$contents = "";
$section_default = "Description";	# default section
$section = $section_default;

$lineno = 0;
foreach $file (@ARGV) {
    if (!open(IN,"<$file")) {
	print STDERR "Error: Cannot open file $file\n";
	next;
    }
    while (<IN>) {
	$lineno++;

	if ($state == 0) {
	    if (/$doc_start/o) {
		$state = 1;		# next line is always the function name
	    }
	} elsif ($state == 1) {	# this line is the function name (always)
	    if (/$doc_func/o) {
		$function = $1;
		$state = 2;
		if (/-\s*(.*)/) {
		    $function_purpose = $1;
		} else {
		    $function_purpose = "";
		}
		if ($verbose) {
		    print STDERR "Info($lineno): Scanning doc for $function\n";
		}
	    } else {
		print STDERR "warning: $lineno: Cannot understand $_ on line $lineno",
		" - I thought it was a doc line\n";
		$state = 0;
	    }
	} elsif ($state == 2) {	# look for head: lines, and include content
	    if (/$doc_sect/o) {
		$newsection = $1;
		$newcontents = $2;

		if ($contents ne "") {
		    dump_section($section, $contents);
		    $section = $section_default;
		}

		$contents = $newcontents;
		if ($contents ne "") {
		    $contents .= "\n";
		}
		$section = $newsection;
	    } elsif (/$doc_end/) {

		if ($contents ne "") {
		    dump_section($section, $contents);
		    $section = $section_default;
		    $contents = "";
		}

#	    print STDERR "end of doc comment, looking for prototype\n";
		$prototype = "";
		$state = 3;
	    } elsif (/$doc_content/) {
		# miguel-style comment kludge, look for blank lines after
		# @parameter line to signify start of description
		if ($1 eq "" && $section =~ m/^@/) {
		    dump_section($section, $contents);
		    $section = $section_default;
		    $contents = "";
		} else {
		    $contents .= $1."\n";
		}
	    } else {
		# i dont know - bad line?  ignore.
		print STDERR "warning: $lineno: Bad line: $_";
	    }
	} elsif ($state == 3) {	# scanning for function { (end of prototype)
	    if (m#\s*/\*\s+MACDOC\s*#io) {
	      # do nothing
	    }
	    elsif (/([^\{]*)/) {
		$prototype .= $1;
	    }
	    if (/\{/) {
		$prototype =~ s@/\*.*?\*/@@gos;	# strip comments.
		$prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
		$prototype =~ s@^ +@@gos; # strip leading spaces
		dump_function($prototype);

		$function = "";
		%constants = ();
		%parameters = ();
		%parametertypes = ();
		@parameterlist = ();
		%sections = ();
		@sectionlist = ();
		$prototype = "";

		$state = 0;
	    }
	}
    }
}

path: contrib/gdoc


code:
#!/bin/sh
# Generate the top-level Info node, given a directory of Info files
# and (optionally) a skeleton file.  The output will be suitable for a
# top-level dir file.  The skeleton file contains info topic names in the
# order they should appear in the output.  There are three special
# lines that alter the behavior: a line consisting of just "--" causes
# the next line to be echoed verbatim to the output.  A line
# containing just "%%" causes all the remaining filenames (wildcards
# allowed) in the rest of the file to be ignored.  A line containing
# just "!!" exits the script when reached (unless preceded by a line
# containing just "--").  Once the script reaches the end of the
# skeleton file, it goes through the remaining files in the directory
# in order, putting their entries at the end.  The script will use the
# ENTRY information in each info file if it exists.  Otherwise it will
# make a minimal entry.

# sent by Jeffrey Osier <jeffrey@cygnus.com>, who thinks it came from
# zoo@winternet.com (david d `zoo' zuhn)

# modified 7 April 1995 by Joe Harrington <jh@tecate.gsfc.nasa.gov> to
# take special flags

INFODIR=$1
if [ $# = 2 ] ; then
  SKELETON=$2
else
  SKELETON=/dev/null
fi

skip=

if [ $# -gt 2 ] ; then
  echo usage: $0 info-directory [ skeleton-file ] 1>&2
  exit 1
elif [ -z "${INFODIR}" ] ; then
  INFODIR="%%DEFAULT_INFO_DIR%%"
else
  true
fi

if [ ! -d ${INFODIR} ] ; then
  echo "$0: first argument must specify a directory"
  exit 1
fi

### output the dir header
echo "-*- Text -*-"
echo "This file was generated automatically by $0."
echo "This version was generated on `date`"
echo "by `whoami`@`hostname` for `(cd ${INFODIR}; pwd)`"

cat << moobler
\$Id: gen-dir-node,v 1.1 2013-01-02 01:00:25 karl Exp $
This is the file .../info/dir, which contains the topmost node of the
Info hierarchy.  The first time you invoke Info you start off
looking at that node, which is (dir)Top.

File: dir	Node: Top	This is the top of the INFO tree

  This (the Directory node) gives a menu of major topics.
  Typing "q" exits, "?" lists all Info commands, "d" returns here,
  "h" gives a primer for first-timers,
  "mEmacs<Return>" visits the Emacs topic, etc.

  In Emacs, you can click mouse button 2 on a menu item or cross reference
  to select it.

* Menu: The list of major topics begins on the next line.

moobler

### go through the list of files in the skeleton.  If an info file
### exists, grab the ENTRY information from it.  If an entry exists
### use it, otherwise create a minimal dir entry.
###
### Then remove that file from the list of existing files.  If any
### additional files remain (ones that don't have a skeleton entry),
### then generate entries for those in the same way, putting the info for
### those at the end....

infofiles=`(cd ${INFODIR}; /bin/ls | grep -v '\-[0-9]*$' | egrep -v '^dir$|^dir\.info$|^dir\.orig$')`

# echoing gets clobbered by backquotes; we do it the hard way...
lines=`wc $SKELETON | awk '{print $1}'`
line=1
while [ $lines -ge $line ] ; do
  # Read one line from the file.  This is so that we can echo lines with
  # whitespace and quoted characters in them.
  fileline=`awk NR==$line $SKELETON`

  # flag fancy features
  if [ ! -z "$echoline" ] ; then	# echo line
    echo "$fileline"
    fileline=
    echoline=
  elif [ "${fileline}" = "--" ] ; then	# should we echo the next line?
    echoline=1
  elif [ "${fileline}" = "%%" ] ; then	# eliminate remaining files from dir?
    skip=1
  elif [ "${fileline}" = "!!" ] ; then	# quit now
    exit 0
  fi

  # handle files if they exist
  for file in $fileline"" ; do	# expand wildcards ("" handles blank lines)

    fname=

    if [ -z "$echoline" ] && [ ! -z "$file" ] ; then
      # Find the file to operate upon.  Check both possible names.
      infoname=`echo $file | sed 's/\.info$//'`
      noext=
      ext=
      if [ -f ${INFODIR}/$infoname ] ; then
        noext=$infoname
      fi
      if [ -f ${INFODIR}/${infoname}.info ] ; then
        ext=${infoname}.info
      fi

      # If it exists with both names take what was said in the file.
      if [ ! -z "$ext" ] && [ ! -z "$noext" ]; then
        fname=$file
        warn="### Warning: $ext and $noext both exist!  Using ${file}. ###"
      elif [ ! -z "${noext}${ext}" ]; then
        # just take the name if it exists only once
        fname=${noext}${ext}
      fi

      # if we found something and aren't skipping, do the entry
      if [ ! -z "$fname" ] ; then
        if [ -z "$skip" ] ; then

          if [ ! -z "$warn" ] ; then	# issue any warning
	    echo $warn
	    warn=
          fi

          entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' \
		     -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/$fname`
          if [ ! -z "${entry}" ] ; then
            echo "${entry}"
          else
            echo "* ${infoname}: (${infoname})."
          fi
        fi

        # remove the name from the directory listing
	infofiles=`echo "" ${infofiles} "" | sed -e "s/ ${fname} / /" -e "s/  / /g"`

      fi

    fi

  done

  line=`expr $line + 1`
done

if [ -z "${infofiles}" ] ; then
  exit 0
elif [ $lines -gt 0 ]; then
  echo
fi

# Sort remaining files by INFO-DIR-SECTION.
prevsect=
filesectdata=`(cd ${INFODIR}; fgrep INFO-DIR-SECTION /dev/null ${infofiles} | \
	      fgrep -v 'INFO-DIR-SECTION Miscellaneous' | \
	      sort -t: -k2 -k1 | tr ' ' '_')`
for sectdata in ${filesectdata}; do
  file=`echo ${sectdata} | cut -d: -f1`
  section=`sed -n -e 's/^INFO-DIR-SECTION //p' ${INFODIR}/${file}`
  infofiles=`echo "" ${infofiles} "" | sed -e "s/ ${file} / /" -e "s/  / /g"`

  if [ "${prevsect}" != "${section}" ] ; then
    if [ ! -z "${prevsect}" ] ; then
      echo ""
    fi
    echo "${section}"
    prevsect="${section}"
  fi

  infoname=`echo $file | sed 's/\.info$//'`
  entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' \
	-e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/${file}`
  if [ ! -z "${entry}" ] ; then
    echo "${entry}"
  elif [ ! -d "${INFODIR}/${file}" ] ; then
    echo "* ${infoname}: (${infoname})."
  fi
done

# Process miscellaneous files.
for file in ${infofiles}; do
  if [ ! -z "${prevsect}" ] ; then
    echo ""
    echo "Miscellaneous"
    prevsect=""
  fi

  infoname=`echo $file | sed 's/\.info$//'`
  entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' \
	-e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/${file}`

  if [ ! -z "${entry}" ] ; then
    echo "${entry}"
  elif [ ! -d "${INFODIR}/${file}" ] ; then
    echo "* ${infoname}: (${infoname})."
  fi
done

path: contrib/gen-dir-node


code:
#!/usr/local/bin/perl -w
# infosrch does a regex search on an info manual.
# By Harry Putnam <reader@newsguy.com>.

($myscript = $0) =~ s:^.*/::;
$six = '';

if($ARGV[0] eq "help"){
   &usage;
   exit;
}
if($ARGV[0] eq "-e"){
   shift;
   $six = "true";
}
if(!$ARGV[1]){
   &usage;
   exit;
}

$target = shift;
$regex  = shift;

$shell_proc  =  "info --output - --subnodes 2>/dev/null $target";

open(SHELL_PROC," $shell_proc|");
while(<SHELL_PROC>){
  chomp;
  push @lines,$_;
}
close(SHELL_PROC);
$cnt = 0;
for(@lines){
   if(/$regex/ && !$six){
      print "$target\n   $lines[($cnt-1)]\n<$cnt> $lines[$cnt]\n   $lines[($cnt+1)]\n";
      print "-- \n";
   }elsif(/$regex/ && $six){
        print "$target\n";
        if($lines[($cnt-6)]){
           print "    $lines[($cnt-6)]\n";
        }
        if($lines[($cnt-5)]){
           print "    $lines[($cnt-5)]\n";
        }
        if($lines[($cnt-4)]){
           print "    $lines[($cnt-4)]\n";
        }
        if($lines[($cnt-3)]){
           print "    $lines[($cnt-3)]\n";
        }
        if($lines[($cnt-2)]){
           print "    $lines[($cnt-2)]\n";
        }
        if($lines[($cnt-1)]){
           print "    $lines[($cnt-1)]\n";
        }
        if($lines[$cnt]){
           print "$cnt $lines[$cnt]\n";
        }
        if($lines[($cnt+1)]){
           print "    $lines[($cnt+1)]\n";
        }
        if($lines[($cnt+2)]){
           print "    $lines[($cnt+2)]\n";
        }
        if($lines[($cnt+3)]){
           print "    $lines[($cnt+3)]\n";
        }
        if($lines[($cnt+4)]){
           print "    $lines[($cnt+4)]\n";
        }
        if($lines[($cnt+5)]){
           print "    $lines[($cnt+5)]\n";
        }
        if($lines[($cnt+6)]){
           print "    $lines[($cnt+6)]\n";
        }
        print "-- \n";
     }
     $cnt++;
}

sub usage {
  print <<EOM;

Purpose: Extract full text from info node and search it by regex
Usage: $myscript [-e] TARGET REGEX

Where TARGET is an info node such as `emacs', `bash' etc, and
REGEX is what you want to find in it.

The -e flag is not required but if used then 6 lines preceding and six
lines following any hits will be printed.  The default (with no -e flag)
is to print one line before and after.

The output has the line number prepended to the line containing the
actual regex.

Info command used:
  info --output - --subnodes 2>/dev/null TARGET

EOM
}

path: contrib/infosrch


code:
#!/usr/bin/env perl
# javaprop2texiflag.pl --- -*- coding: utf-8 -*-
# Copyright 2012 Vincent Belaïche
#
# Author: Vincent Belaïche <vincentb1@users.sourceforge.net>
# Version: $Id: javaprop2texiflag.pl,v 1.2 2012/09/02 11:17:29 vincentb1 Exp $
# Keywords:
# X-URL: http://www.jpicedt.org/
#
# Ce logiciel est régi par la licence CeCILL soumise au droit français et respectant les principes de
# diffusion des logiciels libres. Vous pouvez utiliser, modifier et/ou redistribuer ce programme sous les
# conditions de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA sur le site
# "http://www.cecill.info".
#
# En contrepartie de l'accessibilité au code source et des droits de copie, de modification et de
# redistribution accordés par cette licence, il n'est offert aux utilisateurs qu'une garantie limitée.  Pour
# les mêmes raisons, seule une responsabilité restreinte pèse sur l'auteur du programme, le titulaire des
# droits patrimoniaux et les concédants successifs.
#
# A cet égard l'attention de l'utilisateur est attirée sur les risques associés au chargement, à
# l'utilisation, à la modification et/ou au développement et à la reproduction du logiciel par l'utilisateur
# étant donné sa spécificité de logiciel libre, qui peut le rendre complexe à manipuler et qui le réserve donc
# à des développeurs et des professionnels avertis possédant des connaissances informatiques approfondies.
# Les utilisateurs sont donc invités à charger et tester l'adéquation du logiciel à leurs besoins dans des
# conditions permettant d'assurer la sécurité de leurs systèmes et ou de leurs données et, plus généralement,
# à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
#
# Le fait que vous puissiez accéder à cet en-tête signifie que vous avez pris connaissance de la licence
# CeCILL, et que vous en avez accepté les termes.
#
## Commentary:

#

## Installation:

## Code:
use strict;
use warnings;
use feature qw(say unicode_strings);
use PerlIO;

my $version='$Id: javaprop2texiflag.pl,v 1.2 2012/09/02 11:17:29 vincentb1 Exp $';
my $linenb = 0;
my $inputfile;
my $verbose;

sub usage
{
	my $retval = shift;
	print "Usage:
	javaprop2texiflag.pl ARGUMENTS LIST

-h, --header ARG    : Add a header ARG to the produced output
-p, --prefix ARG    : Set prefix to ARG, prefix is empty by default
-i, --input  ARG    : Set input to ARG, otherwise it is STDIN
-i, --output ARG    : Set output to ARG, otherwise it is STDIN
-c, --showcomments  : Translate comments into the output
-e, --showemptylines: Translate empty lines into the output
-v, --verbose       : Output some message when done
--version           : show version and exit
--help              : show this message and exit
";
	exit $retval;
}

#
#
sub  jp2texif_unescape
{
	$_ = shift();
	s!\\(n(?{"\n"})|r(?{"\r"})|f(?{"\f"})|t(?{"\t"})|u([0-9A-F]{4})(?{chr hex $2})|(.)(?{$3}))!$^R!g;
	return $_;
}

sub jp2texif_encode
{
	$_ = shift;
	s!(([\@\{\}])(?{'@'."$2"})|\n(?{'@*'}))!$^R!g;
	# Texinfo-fier les espaces de tête pour les rendre significatifs
	if(/\A([ \t]+)(.*)\Z/)
	{
		my $spaceprefix    = $1;
		my $remainder = $2;
		$spaceprefix =~ s!(.)!\@$1!g;
		$_ = $spaceprefix . $remainder;
	}
	# Texinfo-fier les espaces de queue pour les rendre significatifs
	if(/(.+?)([ \t]+)\Z/)
	{
		my $spacepostfix   = $2;
		my $remainder = $1;
		$spacepostfix =~ s!(.)!\@$1!g;
		$_ = $remainder . $spacepostfix;
	}
	return $_
}

my @header = ();
my $prefix         = "";
my $outputfile;
my $showcomments;
my $showemptylines;

my $i = 0;
while($i < @ARGV){
	if($i + 1 < @ARGV)
	{
		if($ARGV[$i] =~ /\A-(i|-input)\Z/)
		{
			$inputfile = $ARGV[$i+1];
			$i = $i +2;
		}
		elsif($ARGV[$i] =~ /\A-(o|-output)\Z/)
		{
			$outputfile = $ARGV[$i+1];
			$i = $i +2;
		}
		elsif($ARGV[$i] =~ /\A-(p|-prefix)\Z/)
		{
			$prefix = $ARGV[$i+1];
			$i = $i +2;
		}
		elsif($ARGV[$i] =~ /\A-(h|-header)\Z/)
		{
			$header[++$#header] = \$ARGV[$i+1];
			$i = $i +2;
		}
		else
		{
			goto ONE_ARG;
		}
	}
	else
	{
	  ONE_ARG:
		{
			if($ARGV[$i] =~ /\A-(c|-showcomments)\Z/)
			{
				$showcomments = 1;
				$i ++;
			}
			elsif($ARGV[$i] =~ /\A-(e|-showemptylines)\Z/)
			{
				$showemptylines = 1;
				$i ++;
			}
			elsif($ARGV[$i] =~ /\A-(v|-verbose)\Z/)
			{
				$verbose = 1;
				$i ++;
			}
			elsif($ARGV[$i] eq "--version")
			{
				print "Version of javaprop2texiflag.pl = $version\n";
				exit 0;
			}
			elsif($ARGV[$i] eq "--help")
			{
				usage(0);
				exit;
			}
			else
			{
				print "Invalid remaining arguments: @ARGV[$i .. $#ARGV]\n";
				usage(-1);
			}
		}
	}
}

my $in;
if($inputfile)
{
	open($in,  "< :encoding(ISO-8859-1)", $inputfile)  or die "Can't open $inputfile $!";
}
else
{
	$in = \*STDIN;
}
my $out;
if($outputfile)
{
	open($out, "> :encoding(UTF-8)", $outputfile) or die "Can't open $outputfile $!";
}
else
{
	$out = \*STDOUT;
}
select $out;

my $line;
if(@header)
{
	foreach(@header){
		say '@c ', $$_;
	}
}

my $folded_line = 0;
my $flagnb      = 0;

my $propname;
my $propval;
my $nextpropval;

LINE: while(<$in>){
	$line = $_ ;
	$linenb++ ;
	if($line =~ /\A(\s*)[#!](.*)\Z/)
	{
		if($showcomments)
		{
			say "$1" , '@c ' , "$2";
		}
		next LINE;
	}
	elsif($line =~ /\A\s*\Z/)
	{
		if($showemptylines)
		{
			say "\n";
		}
		next LINE;
	}
	elsif($line =~ /\A(\s*(.*))\Z/)
	{
		if($folded_line == 0)
		{
			if($line =~ /\A\s*((?:[a-zA-Z0-9_\.-]|\\[nr=:])+)\s*[=:](.*)\Z/)
			{
				$propname = $1;
				$propval = $2;
				if($propval =~ m!(\\+)$! && (length($1) & 1) == 1)
				{
					# nombre impair de contre-obliques en fin de ligne, c'est un repliement
					$folded_line = 1;
					$propval =~ s!.$!!;
					$propval = jp2texif_unescape($propval);

				}
				else
				{
					say "\@set $prefix$propname " , jp2texif_encode( jp2texif_unescape($propval));
					$flagnb ++;
				}
			}
			else
			{
				die "$inputfile:$linenb: Invalid line = $line";
			}
		}
		elsif($folded_line == 1)
		{
			$nextpropval = $2;
			if($nextpropval =~ m!(\\+)$! && (length($1) & 1) == 1)
			{
				# nombre impair de contre-obliques en fin de ligne, on reste en repliement
				$nextpropval =~ s!.$!!;
				$propval = $propval . jp2texif_unescape($nextpropval);
			}
			else
			{
				# le repliement est fini
				$folded_line = 0;
				$propval = $propval . jp2texif_unescape($nextpropval);
				say "\@set $prefix$propname " , jp2texif_encode($propval);
				$flagnb ++;
			}

		}
	    else
		{
			die "$inputfile:$linenb: javaprop2texiflag INTERNAL BUG";
		}

		next LINE;
	}
	else
	{
		die "$inputfile:$linenb: Invalid line = $line";
	}
}

if($verbose)
{
	if($inputfile)
	{
		$inputfile = "file \`$inputfile\'";
	}
	else
	{
		$inputfile = "standard input";
	}
	print STDOUT "\nDone: javaprop2texiflag is finished,\n\tinput was $inputfile,\n\t$linenb lines were processed,\n\t$flagnb flags were produced.\n";
}


code:
# Makefile.am for texinfo/util/tests.
#
# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


code:
$Id$
texinfo/contrib/nontests/README

  Copyright 2015, 2016 Free Software Foundation, Inc.

  Copying and distribution of this file, with or without modification,
  are permitted in any medium without royalty provided the copyright
  notice and this notice are preserved.

These tests were for the util directory.

Perhaps some day we will actually make these work.  We can't just invoke
them unconditionally, since people may or may not have working TeX
installations.  And even checking whether it is working or not is not
simple.

The txitextest script compares old and new results of running manuals
through texinfo.tex.  The texinfo.tex developer(s) run this from cron
nightly as an imperfect check against errors and/or reversions creeping
in.

path: contrib/nontests/README


code:
#!/bin/sh
# Copyright 2012 Free Software Foundation, Inc.
#
# This file is part of GNU Texinfo.
#
# GNU Texinfo is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
# GNU Texinfo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# This is a basic test of whether the Texinfo support in automake works.
# Both texi2dvi and makeinfo.  Since it requires automake, we don't want
# to enable it by default or anything.

set -x; set -e; set -u

mkdir foo.dir
cd foo.dir

mkdir sub

cat > configure.ac <<'END'
AC_INIT([try-texinfo], [1.0])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
END

cat > Makefile.am <<'END'
all-local: pdf dvi ps info
info_TEXINFOS = sub/foobarbaz.texi
END

cat > sub/foobarbaz.texi <<'END'
\input texinfo
@setfilename foobarbaz.info
@settitle Zardoz
@node Top
Foo Bar.
@bye
END

autoreconf -vi
grep ' -o.*foobarbaz\.texi' Makefile.in # Sanity check.
./configure
make
test -f sub/foobarbaz.info
test -f sub/foobarbaz.dvi
test -f sub/foobarbaz.ps
test -f sub/foobarbaz.pdf
make distcheck


code:
#! /bin/sh
# Copyright (C) 2006, 2007  Free Software Foundation, Inc.
#
# This file is part of GNU Texinfo.
#
# GNU Texinfo is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
# GNU Texinfo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

required='hevea'

. ./defs || exit 1

set -e

create_input_tex <<EOF
\cite{texinfo.doc}
\bibliographystyle{plain}
\bibliography{sample}
EOF

cat >sample.bib <<EOF
@misc{texinfo.doc,
  title =	 "{GNU Texinfo}: The {GNU} documentation format",
  author =	 "Robert J. Chassell and Richard M. Stallman",
  year =	 "1988"
}
EOF

# check HTML|INFO|TEXT|DVI|PDF
# ----------------------------
check ()
{
  out=$1
  # Testing the local build mode.
  TEXI2DVI_pass --$out --batch --tidy input.tex
  # There should only be the DVI and the TEXI file.
  assert_files input.$out input.tex sample.bib input.t2d
  cp input.$out /tmp/foo
  rm input.$out
}

# Currently we don't use bibtex with hevea.  This is to be fixed.
for out in dvi pdf # html info text
do
  check $out
done