mirror of
https://github.com/darlinghq/darling-groff.git
synced 2024-11-23 11:59:53 +00:00
Add generated shell and perl scripts
This commit is contained in:
parent
f5132dadf2
commit
32ca18a8b8
6566
gen/usr/bin/afmtodit
Executable file
6566
gen/usr/bin/afmtodit
Executable file
File diff suppressed because it is too large
Load Diff
91
gen/usr/bin/eqn2graph
Executable file
91
gen/usr/bin/eqn2graph
Executable file
@ -0,0 +1,91 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# eqn2graph -- compile EQN equation descriptions to bitmap images
|
||||
#
|
||||
# by Eric S. Raymond <esr@thyrsus.com>, July 2002
|
||||
#
|
||||
# In Unixland, the magic is in knowing what to string together...
|
||||
#
|
||||
# Take an eqn equation on stdin, emit cropped bitmap on stdout.
|
||||
# The pic markup should *not* be wrapped in .EQ/.EN, this script will do that.
|
||||
# A -U option on the command line enables gpic/groff "unsafe" mode.
|
||||
# A -format FOO option changes the image output format to any format
|
||||
# supported by convert(1). All other options are passed to convert(1).
|
||||
# The default format is PNG.
|
||||
#
|
||||
# This is separate from pic2graph because pic processing has some weird
|
||||
# clipping effect on the output, mangling equations that are very wide
|
||||
# or deep. Besides, this tool can supply its own delimiters.
|
||||
#
|
||||
|
||||
# Requires the groff suite and the ImageMagick tools. Both are open source.
|
||||
# This code is released to the public domain.
|
||||
#
|
||||
# Here are the assumptions behind the option processing:
|
||||
#
|
||||
# 1. None of the options of eqn(1) are relevant.
|
||||
#
|
||||
# 2. Only the -U option of groff(1) is relevant.
|
||||
#
|
||||
# 3. Many options of convert(1) are potentially relevant, (especially
|
||||
# -density, -interlace, -transparency, -border, and -comment).
|
||||
#
|
||||
# Thus, we pass -U to groff(1), and everything else to convert(1).
|
||||
#
|
||||
# $Id: eqn2graph.sh,v 1.5 2005/05/18 07:03:06 wl Exp $
|
||||
#
|
||||
groff_opts=""
|
||||
convert_opts=""
|
||||
format="png"
|
||||
|
||||
while [ "$1" ]
|
||||
do
|
||||
case $1 in
|
||||
-unsafe)
|
||||
groff_opts="-U";;
|
||||
-format)
|
||||
format=$2
|
||||
shift;;
|
||||
-v | --version)
|
||||
echo "GNU eqn2graph (groff) version 1.19.2"
|
||||
exit 0;;
|
||||
--help)
|
||||
echo "usage: eqn2graph [ option ...] < in > out"
|
||||
exit 0;;
|
||||
*)
|
||||
convert_opts="$convert_opts $1";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# create temporary directory
|
||||
tmp=
|
||||
for d in "$GROFF_TMPDIR" "$TMPDIR" "$TMP" "$TEMP" /tmp; do
|
||||
test -z "$d" && continue
|
||||
|
||||
tmp=`(umask 077 && mktemp -d -q "$d/eqn2graph-XXXXXX") 2> /dev/null` \
|
||||
&& test -n "$tmp" && test -d "$tmp" \
|
||||
&& break
|
||||
|
||||
tmp=$d/eqn2graph$$-$RANDOM
|
||||
(umask 077 && mkdir $tmp) 2> /dev/null && break
|
||||
done;
|
||||
if test -z "$tmp"; then
|
||||
echo "$0: cannot create temporary directory" >&2
|
||||
{ (exit 1); exit 1; }
|
||||
fi
|
||||
|
||||
trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 2 15
|
||||
|
||||
# Here goes:
|
||||
# 1. Add .EQ/.EN.
|
||||
# 2. Process through eqn(1) to emit troff markup.
|
||||
# 3. Process through groff(1) to emit Postscript.
|
||||
# 4. Use convert(1) to crop the Postscript and turn it into a bitmap.
|
||||
read equation
|
||||
(echo ".EQ"; echo 'delim $$'; echo ".EN"; echo '$'"$equation"'$') | \
|
||||
groff -e $groff_opts -Tps -P-pletter > $tmp/eqn2graph.ps \
|
||||
&& convert -trim -crop 0x0 $convert_opts $tmp/eqn2graph.ps $tmp/eqn2graph.$format \
|
||||
&& cat $tmp/eqn2graph.$format
|
||||
|
||||
# End
|
346
gen/usr/bin/gdiffmk
Executable file
346
gen/usr/bin/gdiffmk
Executable file
@ -0,0 +1,346 @@
|
||||
#! /bin/sh
|
||||
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
||||
# Written by Mike Bianchi <MBianchi@Foveal.com <mailto:MBianchi@Foveal.com>>
|
||||
|
||||
# This file is part of the gdiffmk utility, which is part of groff.
|
||||
|
||||
# groff 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 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# groff 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 groff; see the files COPYING and LICENSE in the top
|
||||
# directory of the groff source. If not, write to the Free Software
|
||||
# Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
# This file is part of GNU gdiffmk.
|
||||
|
||||
|
||||
cmd=$( basename $0 )
|
||||
|
||||
function Usage {
|
||||
if test "$#" -gt 0
|
||||
then
|
||||
echo >&2 "${cmd}: $@"
|
||||
fi
|
||||
echo >&2 "\
|
||||
|
||||
Usage: ${cmd} [ OPTIONS ] FILE1 FILE2 [ OUTPUT ]
|
||||
Place difference marks into the new version of a groff/nroff/troff document.
|
||||
FILE1 and FILE2 are compared, using \`diff', and FILE2 is output with
|
||||
groff \`.mc' requests added to indicate how it is different from FILE1.
|
||||
|
||||
FILE1 Previous version of the groff file. \`-' means standard input.
|
||||
FILE2 Current version of the groff file. \`-' means standard input.
|
||||
Either FILE1 or FILE2 can be standard input, but not both.
|
||||
OUTPUT Copy of FILE2 with \`.mc' commands added.
|
||||
\`-' means standard output (the default).
|
||||
|
||||
OPTIONS:
|
||||
-a ADDMARK Mark for added groff source lines. Default: \`+'.
|
||||
-c CHANGEMARK Mark for changed groff source lines. Default: \`|'.
|
||||
-d DELETEMARK Mark for deleted groff source lines. Default: \`*'.
|
||||
|
||||
-D Show the deleted portions from changed and deleted text.
|
||||
Default delimiting marks: \`[[' .... \`]]'.
|
||||
-B By default, the deleted texts marked by the \`-D' option end
|
||||
with an added troff \`.br' command. This option prevents
|
||||
the added \`.br'.
|
||||
-M MARK1 MARK2 Change the delimiting marks for the \`-D' option.
|
||||
|
||||
-x DIFFCMD Use a different diff(1) command;
|
||||
one that accepts the \`-Dname' option, such as GNU diff.
|
||||
--version Print version information on the standard output and exit.
|
||||
--help Print this message on the standard error.
|
||||
"
|
||||
exit 255
|
||||
}
|
||||
|
||||
|
||||
function Exit {
|
||||
exitcode=$1
|
||||
shift
|
||||
for arg
|
||||
do
|
||||
echo >&2 "${cmd}: $1"
|
||||
shift
|
||||
done
|
||||
exit ${exitcode}
|
||||
}
|
||||
|
||||
# Usage: FileRead exit_code filename
|
||||
#
|
||||
# Check for existence and readability of given file name.
|
||||
# If not found or not readable, print message and exit with EXIT_CODE.
|
||||
function FileRead {
|
||||
case "$2" in
|
||||
-)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
if test ! -e "$2"
|
||||
then
|
||||
Exit $1 "File \`$2' not found."
|
||||
fi
|
||||
if test ! -r "$2"
|
||||
then
|
||||
Exit $1 "File \`$2' not readable."
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Usage: FileCreate exit_code filename
|
||||
#
|
||||
# Create the given filename if it doesn't exist.
|
||||
# If unable to create or write, print message and exit with EXIT_CODE.
|
||||
function FileCreate {
|
||||
case "$2" in
|
||||
-)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
if ! touch "$2" 2>/dev/null
|
||||
then
|
||||
if test ! -e "$2"
|
||||
then
|
||||
Exit $1 "File \`$2' not created; " \
|
||||
"Cannot write directory \`$( dirname "$2" )'."
|
||||
fi
|
||||
Exit $1 "File \`$2' not writeable."
|
||||
fi
|
||||
}
|
||||
|
||||
function WouldClobber {
|
||||
case "$2" in
|
||||
-)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
if test "$1" -ef "$3"
|
||||
then
|
||||
Exit 3 \
|
||||
"The $2 and OUTPUT arguments both point to the same file," \
|
||||
"\`$1', and it would be overwritten."
|
||||
fi
|
||||
}
|
||||
|
||||
ADDMARK='+'
|
||||
CHANGEMARK='|'
|
||||
DELETEMARK='*'
|
||||
MARK1='[['
|
||||
MARK2=']]'
|
||||
|
||||
function RequiresArgument {
|
||||
# Process flags that take either concatenated or
|
||||
# separated values.
|
||||
case "$1" in
|
||||
-??*)
|
||||
expr "$1" : '-.\(.*\)'
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if test "$#" -lt 2
|
||||
then
|
||||
Exit 255 "Option \`$1' requires a value."
|
||||
fi
|
||||
|
||||
echo "$2"
|
||||
return 0
|
||||
}
|
||||
|
||||
badoption=
|
||||
DIFFCMD=diff
|
||||
D_option=
|
||||
br=.br
|
||||
for OPTION
|
||||
do
|
||||
case "${OPTION}" in
|
||||
-a*)
|
||||
ADDMARK=$( RequiresArgument "${OPTION}" $2 ) &&
|
||||
shift
|
||||
;;
|
||||
-c*)
|
||||
CHANGEMARK=$( RequiresArgument "${OPTION}" $2 ) &&
|
||||
shift
|
||||
;;
|
||||
-d*)
|
||||
DELETEMARK=$( RequiresArgument "${OPTION}" $2 ) &&
|
||||
shift
|
||||
;;
|
||||
-D )
|
||||
D_option=D_option
|
||||
;;
|
||||
-M* )
|
||||
MARK1=$( RequiresArgument "${OPTION}" $2 ) &&
|
||||
shift
|
||||
if [ $# -lt 2 ]
|
||||
then
|
||||
Usage "Option \`-M' is missing the MARK2 value."
|
||||
fi
|
||||
MARK2=$2
|
||||
shift
|
||||
;;
|
||||
-B )
|
||||
br=.
|
||||
;;
|
||||
-x* )
|
||||
DIFFCMD=$( RequiresArgument "${OPTION}" $2 ) &&
|
||||
shift
|
||||
;;
|
||||
--version)
|
||||
echo "GNU ${cmd} (groff) version 1.19.2"
|
||||
exit 0
|
||||
;;
|
||||
--help)
|
||||
Usage
|
||||
;;
|
||||
--)
|
||||
# What follows -- are file arguments
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-)
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
badoption="${cmd}: invalid option \`$1'"
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
${DIFFCMD} -Dx /dev/null /dev/null >/dev/null 2>&1 ||
|
||||
Usage "The \`${DIFFCMD}' program does not accept" \
|
||||
"the required \`-Dname' option.
|
||||
Use GNU diff instead. See the \`-x DIFFCMD' option."
|
||||
|
||||
if test -n "${badoption}"
|
||||
then
|
||||
Usage "${badoption}"
|
||||
fi
|
||||
|
||||
if test "$#" -lt 2 -o "$#" -gt 3
|
||||
then
|
||||
Usage "Incorrect number of arguments."
|
||||
fi
|
||||
|
||||
if test "1$1" = 1- -a "2$2" = 2-
|
||||
then
|
||||
Usage "Both FILE1 and FILE2 are \`-'."
|
||||
fi
|
||||
|
||||
FILE1=$1
|
||||
FILE2=$2
|
||||
|
||||
FileRead 1 "${FILE1}"
|
||||
FileRead 2 "${FILE2}"
|
||||
|
||||
if test "$#" = 3
|
||||
then
|
||||
case "$3" in
|
||||
-)
|
||||
# output goes to standard output
|
||||
;;
|
||||
*)
|
||||
# output goes to a file
|
||||
WouldClobber "${FILE1}" FILE1 "$3"
|
||||
WouldClobber "${FILE2}" FILE2 "$3"
|
||||
|
||||
FileCreate 3 "$3"
|
||||
exec >$3
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# To make a very unlikely label even more unlikely ...
|
||||
label=__diffmk_$$__
|
||||
|
||||
sed_script='
|
||||
/^#ifdef '"${label}"'/,/^#endif \/\* '"${label}"'/ {
|
||||
/^#ifdef '"${label}"'/ s/.*/.mc '"${ADDMARK}"'/
|
||||
/^#endif \/\* '"${label}"'/ s/.*/.mc/
|
||||
p
|
||||
d
|
||||
}
|
||||
/^#ifndef '"${label}"'/,/^#endif \/\* [!not ]*'"${label}"'/ {
|
||||
/^#else \/\* '"${label}"'/,/^#endif \/\* '"${label}"'/ {
|
||||
/^#else \/\* '"${label}"'/ s/.*/.mc '"${CHANGEMARK}"'/
|
||||
/^#endif \/\* '"${label}"'/ s/.*/.mc/
|
||||
p
|
||||
d
|
||||
}
|
||||
/^#endif \/\* \(not\|!\) '"${label}"'/ {
|
||||
s/.*/.mc '"${DELETEMARK}"'/p
|
||||
a\
|
||||
.mc
|
||||
}
|
||||
d
|
||||
}
|
||||
p
|
||||
'
|
||||
|
||||
if [ ${D_option} ]
|
||||
then
|
||||
sed_script='
|
||||
/^#ifdef '"${label}"'/,/^#endif \/\* '"${label}"'/ {
|
||||
/^#ifdef '"${label}"'/ s/.*/.mc '"${ADDMARK}"'/
|
||||
/^#endif \/\* '"${label}"'/ s/.*/.mc/
|
||||
p
|
||||
d
|
||||
}
|
||||
/^#ifndef '"${label}"'/,/^#endif \/\* [!not ]*'"${label}"'/ {
|
||||
/^#ifndef '"${label}"'/ {
|
||||
i\
|
||||
'"${MARK1}"'
|
||||
d
|
||||
}
|
||||
/^#else \/\* '"${label}"'/ ! {
|
||||
/^#endif \/\* [!not ]*'"${label}"'/ ! {
|
||||
p
|
||||
d
|
||||
}
|
||||
}
|
||||
/^#else \/\* '"${label}"'/,/^#endif \/\* '"${label}"'/ {
|
||||
/^#else \/\* '"${label}"'/ {
|
||||
i\
|
||||
'"${MARK2}"'\
|
||||
'"${br}"'
|
||||
s/.*/.mc '"${CHANGEMARK}"'/
|
||||
a\
|
||||
.mc '"${CHANGEMARK}"'
|
||||
d
|
||||
}
|
||||
/^#endif \/\* '"${label}"'/ s/.*/.mc/
|
||||
p
|
||||
d
|
||||
}
|
||||
/^#endif \/\* \(not\|!\) '"${label}"'/ {
|
||||
i\
|
||||
'"${MARK2}"'\
|
||||
'"${br}"'
|
||||
s/.*/.mc '"${DELETEMARK}"'/p
|
||||
a\
|
||||
.mc
|
||||
}
|
||||
d
|
||||
}
|
||||
p
|
||||
'
|
||||
fi
|
||||
|
||||
diff -D"${label}" -- ${FILE1} ${FILE2} |
|
||||
sed -n "${sed_script}"
|
||||
|
||||
# EOF
|
85
gen/usr/bin/grap2graph
Executable file
85
gen/usr/bin/grap2graph
Executable file
@ -0,0 +1,85 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# grap2graph -- compile graph description descriptions to bitmap images
|
||||
#
|
||||
# by Eric S. Raymond <esr@thyrsus.com>, May 2003
|
||||
#
|
||||
# In Unixland, the magic is in knowing what to string together...
|
||||
#
|
||||
# Take grap description on stdin, emit cropped bitmap on stdout.
|
||||
# The pic markup should *not* be wrapped in .G1/.G2, this script will do that.
|
||||
# A -U option on the command line enables gpic/groff "unsafe" mode.
|
||||
# A -format FOO option changes the image output format to any format
|
||||
# supported by convert(1). All other options are passed to convert(1).
|
||||
# The default format is PNG.
|
||||
#
|
||||
|
||||
# Requires the groff suite and the ImageMagick tools. Both are open source.
|
||||
# This code is released to the public domain.
|
||||
#
|
||||
# Here are the assumptions behind the option processing:
|
||||
#
|
||||
# 1. None of the options of grap(1) are relevant.
|
||||
#
|
||||
# 2. Only the -U option of groff(1) is relevant.
|
||||
#
|
||||
# 3. Many options of convert(1) are potentially relevant, (especially
|
||||
# -density, -interlace, -transparency, -border, and -comment).
|
||||
#
|
||||
# Thus, we pass -U to groff(1), and everything else to convert(1).
|
||||
#
|
||||
# $Id: grap2graph.sh,v 1.4 2005/05/18 07:03:06 wl Exp $
|
||||
#
|
||||
groff_opts=""
|
||||
convert_opts=""
|
||||
format="png"
|
||||
|
||||
while [ "$1" ]
|
||||
do
|
||||
case $1 in
|
||||
-unsafe)
|
||||
groff_opts="-U";;
|
||||
-format)
|
||||
format=$2
|
||||
shift;;
|
||||
-v | --version)
|
||||
echo "GNU grap2graph (groff) version 1.19.2"
|
||||
exit 0;;
|
||||
--help)
|
||||
echo "usage: grap2graph [ option ...] < in > out"
|
||||
exit 0;;
|
||||
*)
|
||||
convert_opts="$convert_opts $1";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# create temporary directory
|
||||
tmp=
|
||||
for d in "$GROFF_TMPDIR" "$TMPDIR" "$TMP" "$TEMP" /tmp; do
|
||||
test -z "$d" && continue
|
||||
|
||||
tmp=`(umask 077 && mktemp -d -q "$d/grap2graph-XXXXXX") 2> /dev/null` \
|
||||
&& test -n "$tmp" && test -d "$tmp" \
|
||||
&& break
|
||||
|
||||
tmp=$d/grap2graph$$-$RANDOM
|
||||
(umask 077 && mkdir $tmp) 2> /dev/null && break
|
||||
done;
|
||||
if test -z "$tmp"; then
|
||||
echo "$0: cannot create temporary directory" >&2
|
||||
{ (exit 1); exit 1; }
|
||||
fi
|
||||
|
||||
trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 2 15
|
||||
|
||||
# Here goes:
|
||||
# 1. Add .G1/.G2.
|
||||
# 2. Process through grap(1) to emit pic markup.
|
||||
# 3. Process through groff(1) with pic preprocessing to emit Postscript.
|
||||
# 4. Use convert(1) to crop the Postscript and turn it into a bitmap.
|
||||
(echo ".G1"; cat; echo ".G2") | grap | groff -p $groff_opts -Tps -P-pletter | \
|
||||
convert -trim -crop 0x0 $convert_opts - $tmp/grap2graph.$format \
|
||||
&& cat $tmp/grap2graph.$format
|
||||
|
||||
# End
|
299
gen/usr/bin/groffer
Executable file
299
gen/usr/bin/groffer
Executable file
@ -0,0 +1,299 @@
|
||||
#! /bin/sh
|
||||
|
||||
# groffer - display groff files
|
||||
|
||||
# Source file position: <groff-source>/contrib/groffer/groffer.sh
|
||||
|
||||
# Copyright (C) 2001,2002,2003,2004,2005
|
||||
# Free Software Foundation, Inc.
|
||||
# Written by Bernd Warken
|
||||
|
||||
# This file is part of `groffer', which is part of `groff' version
|
||||
# 1.19.2. See $_GROFF_VERSION.
|
||||
|
||||
# `groff' 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 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# `groff' 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 `groff'; see the files COPYING and LICENSE in the top
|
||||
# directory of the `groff' source. If not, write to the Free Software
|
||||
# Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301,
|
||||
# USA.
|
||||
|
||||
########################################################################
|
||||
|
||||
_PROGRAM_VERSION='0.9.22';
|
||||
_LAST_UPDATE='22 August 2005';
|
||||
|
||||
export _PROGRAM_VERSION;
|
||||
export _LAST_UPDATE;
|
||||
|
||||
export GROFFER_OPT; # option environment for groffer
|
||||
|
||||
export _CONF_FILE_ETC; # configuration file in /etc
|
||||
export _CONF_FILE_HOME; # configuration file in $HOME
|
||||
export _CONF_FILES; # configuration files
|
||||
_CONF_FILE_ETC='/etc/groff/groffer.conf';
|
||||
_CONF_FILE_HOME="${HOME}/.groff/groffer.conf";
|
||||
_CONF_FILES="${_CONF_FILE_ETC} ${_CONF_FILE_HOME}";
|
||||
|
||||
# characters
|
||||
|
||||
export _AT;
|
||||
export _SP;
|
||||
export _SQ;
|
||||
export _TAB;
|
||||
|
||||
_AT='@';
|
||||
_SP=' ';
|
||||
_SQ="'";
|
||||
_TAB=' ';
|
||||
|
||||
export _ERROR;
|
||||
_ERROR='7'; # for syntax errors; no `-1' in `ash'
|
||||
|
||||
# @...@ constructs
|
||||
|
||||
export _GROFF_VERSION
|
||||
_GROFF_VERSION='1.19.2';
|
||||
if test _1.19.2_ = _${_AT}VERSION${_AT}_
|
||||
then
|
||||
_GROFF_VERSION='1.19.2';
|
||||
fi;
|
||||
|
||||
export _AT_BINDIR_AT;
|
||||
export _AT_G_AT;
|
||||
export _AT_LIBDIR_AT;
|
||||
export _GROFFER_LIBDIR;
|
||||
if test _/usr/local/bin_ = _${_AT}BINDIR${_AT}_
|
||||
then
|
||||
# script before `make'
|
||||
_AT_BINDIR_AT='.';
|
||||
_AT_G_AT='';
|
||||
_AT_LIBDIR_AT='';
|
||||
_GROFFER_LIBDIR='.';
|
||||
else
|
||||
_AT_BINDIR_AT='/usr/local/bin';
|
||||
_AT_G_AT='';
|
||||
_AT_LIBDIR_AT='/usr/local/lib';
|
||||
_GROFFER_LIBDIR="${_AT_LIBDIR_AT}"'/groff/groffer';
|
||||
fi;
|
||||
|
||||
export _GROFFER_SH; # file name of this shell script
|
||||
case "$0" in
|
||||
*groffer*)
|
||||
_GROFFER_SH="$0";
|
||||
# was: _GROFFER_SH="${_AT_BINDIR_AT}/groffer";
|
||||
;;
|
||||
*)
|
||||
echo 'The groffer script should be started directly.' >&2
|
||||
exit 1;
|
||||
;;
|
||||
esac;
|
||||
|
||||
export _GROFFER2_SH; # file name of the script that follows up
|
||||
_GROFFER2_SH="${_GROFFER_LIBDIR}"/groffer2.sh;
|
||||
|
||||
export _NULL_DEV;
|
||||
if test -c /dev/null
|
||||
then
|
||||
_NULL_DEV="/dev/null";
|
||||
else
|
||||
_NULL_DEV="NUL";
|
||||
fi;
|
||||
|
||||
|
||||
# Test of the `$()' construct.
|
||||
if test _"$(echo "$(echo 'test')")"_ \
|
||||
!= _test_
|
||||
then
|
||||
echo 'The "$()" construct did not work.' >&2;
|
||||
exit "${_ERROR}";
|
||||
fi;
|
||||
|
||||
# Test of sed program
|
||||
if test _"$(echo red | sed -e 's/r/s/')"_ != _sed_
|
||||
then
|
||||
echo 'The sed program did not work.' >&2;
|
||||
exit "${_ERROR}";
|
||||
fi;
|
||||
|
||||
|
||||
########################### configuration
|
||||
|
||||
# read and transform the configuration files, execute the arising commands
|
||||
for f in "${_CONF_FILE_HOME}" "${_CONF_FILE_ETC}"
|
||||
do
|
||||
if test -f "$f"
|
||||
then
|
||||
o=""; # $o means groffer option
|
||||
# use "" quotes because of ksh and posh
|
||||
eval "$(cat "$f" | sed -n -e '
|
||||
# Ignore comments
|
||||
/^['"${_SP}${_TAB}"']*#/d
|
||||
# Delete leading and final space
|
||||
s/^['"${_SP}${_TAB}"']*//
|
||||
s/['"${_SP}${_TAB}"']*$//
|
||||
# Print all shell commands
|
||||
/^[^-]/p
|
||||
# Replace empty arguments
|
||||
s/^\(-[^ ]*\)=$/o="${o} \1 '"${_SQ}${_SQ}"'"/p
|
||||
# Replace division between option and argument by single space
|
||||
s/[='"${_SP}${_TAB}"']['"${_SP}${_TAB}"']*/'"${_SP}"'/
|
||||
# Handle lines without spaces
|
||||
s/^\(-[^'"${_SP}"']*\)$/o="${o} \1"/p
|
||||
# Print options that have their argument encircled with single quotes
|
||||
/^-[^ ]* '"${_SQ}"'.*'"${_SQ}"'$/s/^.*$/o="${o} &"/p
|
||||
# Replace encircled double quotes by single quotes and print the result
|
||||
s/^\(-[^ ]*\) "\(.*\)"$/o="${o} \1 '"${_SQ}"'\2'"${_SQ}"'"/p
|
||||
# Encircle the remaining arguments with single quotes
|
||||
s/^\(-[^ ]*\) \(.*\)$/o="${o} \1 '"${_SQ}"'\2'"${_SQ}"'"/p
|
||||
')"
|
||||
if test _"${o}"_ != __
|
||||
then
|
||||
if test _"{GROFFER_OPT}"_ = __
|
||||
then
|
||||
GROFFER_OPT="${o}";
|
||||
else
|
||||
GROFFER_OPT="${o} ${GROFFER_OPT}";
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
done;
|
||||
|
||||
# integrate $GROFFER_OPT into the command line; it isn't needed any more
|
||||
if test _"${GROFFER_OPT}"_ != __
|
||||
then
|
||||
eval set x "${GROFFER_OPT}" '"$@"';
|
||||
shift;
|
||||
GROFFER_OPT='';
|
||||
fi;
|
||||
|
||||
|
||||
########################### Determine the shell
|
||||
|
||||
export _SHELL;
|
||||
|
||||
# use "``" instead of "$()" for using the case ")" construct
|
||||
# do not use "" quotes because of ksh
|
||||
_SHELL=`
|
||||
# $x means list.
|
||||
# $s means shell.
|
||||
# The command line arguments are taken over.
|
||||
# Shifting herein does not have an effect outside.
|
||||
export x;
|
||||
case " $*" in
|
||||
*\ --sh*) # abbreviation for --shell
|
||||
x='';
|
||||
s='';
|
||||
# determine all --shell arguments, store them in $x in reverse order
|
||||
while test $# != 0
|
||||
do
|
||||
case "$1" in
|
||||
--shell|--sh|--she|--shel)
|
||||
if test "$#" -ge 2
|
||||
then
|
||||
s="$2";
|
||||
shift;
|
||||
fi;
|
||||
;;
|
||||
--shell=*|--sh=*|--she=*|--shel=*)
|
||||
# delete up to first "=" character
|
||||
s="$(echo x"$1" | sed -e 's/^x[^=]*=//')";
|
||||
;;
|
||||
*)
|
||||
shift;
|
||||
continue;
|
||||
esac;
|
||||
if test _"${x}"_ = __
|
||||
then
|
||||
x="'${s}'";
|
||||
else
|
||||
x="'${s}' ${x}";
|
||||
fi;
|
||||
shift;
|
||||
done;
|
||||
|
||||
# from all possible shells in $x determine the first being a shell
|
||||
# or being empty
|
||||
s="$(
|
||||
# "" quotes because of posh
|
||||
eval set x "${x}";
|
||||
shift;
|
||||
if test $# != 0
|
||||
then
|
||||
for i
|
||||
do
|
||||
if test _"$i"_ = __
|
||||
then
|
||||
# use the empty argument as the default shell
|
||||
echo empty;
|
||||
break;
|
||||
else
|
||||
# test $i on being a shell program;
|
||||
# use this kind of quoting for posh
|
||||
if test _"$(eval "$i -c 'echo ok'" 2>${_NULL_DEV})"_ = _ok_ >&2
|
||||
then
|
||||
# shell found
|
||||
cat <<EOF
|
||||
${i}
|
||||
EOF
|
||||
break;
|
||||
else
|
||||
# if not being a shell go on searching
|
||||
continue;
|
||||
fi;
|
||||
fi;
|
||||
done;
|
||||
fi;
|
||||
)";
|
||||
if test _"${s}"_ != __
|
||||
then
|
||||
cat <<EOF
|
||||
${s}
|
||||
EOF
|
||||
fi;
|
||||
;;
|
||||
esac;
|
||||
`
|
||||
|
||||
########################### test fast shells for automatic run
|
||||
|
||||
if test _"${_SHELL}"_ = __
|
||||
then
|
||||
for s in ksh ash dash pdksh zsh posh
|
||||
do
|
||||
if test _"$(eval "$s -c 'echo ok'" 2>${_NULL_DEV})"_ = _ok_ >&2
|
||||
then
|
||||
_SHELL="$s";
|
||||
break;
|
||||
fi;
|
||||
done;
|
||||
fi;
|
||||
|
||||
|
||||
########################### start groffer2.sh
|
||||
|
||||
if test _"${_SHELL}"_ = _empty_
|
||||
then
|
||||
_SHELL='';
|
||||
fi;
|
||||
|
||||
if test _"${_SHELL}"_ = __
|
||||
then
|
||||
# no shell found, so start groffer2.sh normally
|
||||
eval exec "'${_GROFFER2_SH}'" '"$@"';
|
||||
exit;
|
||||
else
|
||||
# start groffer2.sh with the found $_SHELL
|
||||
# do not quote $_SHELL to allow arguments
|
||||
eval exec "${_SHELL} '${_GROFFER2_SH}'" '"$@"';
|
||||
exit;
|
||||
fi;
|
112
gen/usr/bin/grog
Executable file
112
gen/usr/bin/grog
Executable file
@ -0,0 +1,112 @@
|
||||
#! /bin/sh
|
||||
# grog -- guess options for groff command
|
||||
# Like doctype in Kernighan & Pike, Unix Programming Environment, pp 306-8.
|
||||
|
||||
soelim=soelim
|
||||
|
||||
opts=
|
||||
sp="([ ]|$)"
|
||||
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
--)
|
||||
shift; break;;
|
||||
-)
|
||||
break;;
|
||||
-C)
|
||||
sp=; opts="$opts -C"; shift; break;;
|
||||
-v | --version)
|
||||
echo "GNU grog (groff) version 1.19.2"
|
||||
exit 0;;
|
||||
--help)
|
||||
echo "usage: grog [ option ...] [files...]"
|
||||
exit 0;;
|
||||
-*)
|
||||
opts="$opts $arg"; shift;;
|
||||
*)
|
||||
break;;
|
||||
esac
|
||||
done
|
||||
|
||||
egrep -h "^\.(\[|\])|((P|PS|[PLI]P|[pnil]p|sh|Dd|Tp|Dp|De|Cx|Cl|Oo|.* Oo|Oc|.* Oc|TS|EQ|TH|SH|so|\[|R1|GS|G1|PH|SA)$sp)" $* \
|
||||
| sed -e '/^\.so/s/^.*$/.SO_START\
|
||||
&\
|
||||
.SO_END/' \
|
||||
| $soelim \
|
||||
| egrep '^\.(P|PS|[PLI]P|[pnil]p|sh|Dd|Tp|Dp|De|Cx|Cl|Oo|.* Oo|Oc|.* Oc|TS|EQ|TH|SH|\[|\]|R1|GS|G1|PH|SA|SO_START|SO_END)' \
|
||||
| awk '
|
||||
/^\.SO_START$/ { so = 1 }
|
||||
/^\.SO_END$/ { so = 0 }
|
||||
/^\.TS/ { tbl++; if (so > 0) soelim++ }
|
||||
/^\.PS([ 0-9.<].*)?$/ { pic++; if (so > 0) soelim++ }
|
||||
/^\.EQ/ { eqn++; if (so > 0) soelim++ }
|
||||
/^\.R1/ { refer++; if (so > 0) soelim++ }
|
||||
/^\.\[/ {refer_start++; if (so > 0) soelim++ }
|
||||
/^\.\]/ {refer_end++; if (so > 0) soelim++ }
|
||||
/^\.GS/ { grn++; if (so > 0) soelim++ }
|
||||
/^\.G1/ { grap++; pic++; if (so > 0) soelim++ }
|
||||
/^\.TH/ { TH++ }
|
||||
/^\.[PLI]P/ { PP++ }
|
||||
/^\.P$/ { P++ }
|
||||
/^\.SH/ { SH++ }
|
||||
/^\.(PH|SA)/ { mm++ }
|
||||
/^\.([pnil]p|sh)/ { me++ }
|
||||
/^\.Dd/ { mdoc++ }
|
||||
/^\.(Tp|Dp|De|Cx|Cl)/ { mdoc_old++ }
|
||||
/^\.(O[oc]|.* O[oc]( |$))/ {
|
||||
sub(/\\\".*/, "")
|
||||
gsub(/\"[^\"]*\"/, "")
|
||||
sub(/\".*/, "")
|
||||
sub(/^\.Oo/, " Oo ")
|
||||
sub(/^\.Oc/, " Oc ")
|
||||
sub(/ Oo$/, " Oo ")
|
||||
sub(/ Oc$/, " Oc ")
|
||||
while (/ Oo /) {
|
||||
sub(/ Oo /, " ")
|
||||
Oo++
|
||||
}
|
||||
while (/ Oc /) {
|
||||
sub(/ Oc /, " ")
|
||||
Oo--
|
||||
}
|
||||
}
|
||||
/^\.(PRINTSTYLE|START)/ { mom++ }
|
||||
|
||||
END {
|
||||
if (files ~ /^-/)
|
||||
files = "-- " files
|
||||
printf "groff"
|
||||
refer = refer || (refer_start && refer_end)
|
||||
if (pic > 0 || tbl > 0 || grn > 0 || grap > 0 || eqn > 0 || refer > 0) {
|
||||
printf " -"
|
||||
if (soelim > 0) printf "s"
|
||||
if (refer > 0) printf "R"
|
||||
if (grn > 0) printf "g"
|
||||
if (grap > 0) printf "G"
|
||||
if (pic > 0) printf "p"
|
||||
if (tbl > 0) printf "t"
|
||||
if (eqn > 0) printf "e"
|
||||
}
|
||||
if (me > 0)
|
||||
printf " -me"
|
||||
else if (SH > 0 && TH > 0)
|
||||
printf " -man"
|
||||
else if (mom > 0)
|
||||
printf " -mom"
|
||||
else if (PP > 0)
|
||||
printf " -ms"
|
||||
else if (P > 0 || mm > 0)
|
||||
printf " -mm"
|
||||
else if (mdoc > 0) {
|
||||
if (mdoc_old > 0 || Oo > 0)
|
||||
printf " -mdoc-old"
|
||||
else
|
||||
printf " -mdoc"
|
||||
}
|
||||
if (opts != "")
|
||||
printf "%s", opts
|
||||
if (files != "")
|
||||
printf " %s", files
|
||||
print ""
|
||||
}' "opts=$opts" "files=$*" -
|
137
gen/usr/bin/mmroff
Executable file
137
gen/usr/bin/mmroff
Executable file
@ -0,0 +1,137 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
use strict;
|
||||
# runs groff in safe mode, that seems to be the default
|
||||
# installation now. That means that I have to fix all nice
|
||||
# features outside groff. Sigh.
|
||||
# I do agree however that the previous way opened a whole bunch
|
||||
# of security holes.
|
||||
|
||||
my $no_exec;
|
||||
# check for -x and remove it
|
||||
if (grep(/^-x$/, @ARGV)) {
|
||||
$no_exec++;
|
||||
@ARGV = grep(!/^-x$/, @ARGV);
|
||||
}
|
||||
|
||||
# mmroff should always have -mm, but not twice
|
||||
@ARGV = grep(!/^-mm$/, @ARGV);
|
||||
my $check_macro = "groff -rRef=1 -z -mm @ARGV";
|
||||
my $run_macro = "groff -mm @ARGV";
|
||||
|
||||
my (%cur, $rfilename, $max_height, $imacro, $max_width, @out, @indi);
|
||||
open(MACRO, "$check_macro 2>&1 |") || die "run $check_macro:$!";
|
||||
while(<MACRO>) {
|
||||
if (m#^\.\\" Rfilename: (\S+)#) {
|
||||
# remove all directories just to be more secure
|
||||
($rfilename = $1) =~ s#.*/##;
|
||||
next;
|
||||
}
|
||||
if (m#^\.\\" Imacro: (\S+)#) {
|
||||
# remove all directories just to be more secure
|
||||
($imacro = $1) =~ s#.*/##;
|
||||
next;
|
||||
}
|
||||
if (m#^\.\\" Index: (\S+)#) {
|
||||
# remove all directories just to be more secure
|
||||
my $f;
|
||||
($f = $1) =~ s#.*/##;
|
||||
&print_index($f, \@indi, $imacro);
|
||||
@indi = ();
|
||||
$imacro = '';
|
||||
next;
|
||||
}
|
||||
my $x;
|
||||
if (($x) = m#^\.\\" IND (.+)#) {
|
||||
$x =~ s#\\##g;
|
||||
my @x = split(/\t/, $x);
|
||||
grep(s/\s+$//, @x);
|
||||
push(@indi, join("\t", @x));
|
||||
next;
|
||||
}
|
||||
if (m#^\.\\" PIC id (\d+)#) {
|
||||
%cur = ('id', $1);
|
||||
next;
|
||||
}
|
||||
if (m#^\.\\" PIC file (\S+)#) {
|
||||
&psbb($1);
|
||||
&ps_calc($1);
|
||||
next;
|
||||
}
|
||||
if (m#^\.\\" PIC (\w+)\s+(\S+)#) {
|
||||
eval "\$cur{'$1'} = '$2'";
|
||||
next;
|
||||
}
|
||||
s#\\ \\ $##;
|
||||
push(@out, $_);
|
||||
}
|
||||
close(MACRO);
|
||||
|
||||
|
||||
if ($rfilename) {
|
||||
push(@out, ".nr pict*max-height $max_height\n") if defined $max_height;
|
||||
push(@out, ".nr pict*max-width $max_width\n") if defined $max_width;
|
||||
|
||||
open(OUT, ">$rfilename") || "create $rfilename:$!";
|
||||
print OUT '.\" references', "\n";
|
||||
my $i;
|
||||
for $i (@out) {
|
||||
print OUT $i;
|
||||
}
|
||||
close(OUT);
|
||||
}
|
||||
|
||||
exit 0 if $no_exec;
|
||||
exit system($run_macro);
|
||||
|
||||
sub print_index {
|
||||
my ($f, $ind, $macro) = @_;
|
||||
|
||||
open(OUT, ">$f") || "create $f:$!";
|
||||
my $i;
|
||||
for $i (sort @$ind) {
|
||||
if ($macro) {
|
||||
$i = '.'.$macro.' "'.join('" "', split(/\t/, $i)).'"';
|
||||
}
|
||||
print OUT "$i\n";
|
||||
}
|
||||
close(OUT);
|
||||
}
|
||||
|
||||
sub ps_calc {
|
||||
my ($f) = @_;
|
||||
|
||||
my $w = abs($cur{'llx'}-$cur{'urx'});
|
||||
my $h = abs($cur{'lly'}-$cur{'ury'});
|
||||
$max_width = $w if $w > $max_width;
|
||||
$max_height = $h if $h > $max_height;
|
||||
|
||||
my $id = $cur{'id'};
|
||||
push(@out, ".ds pict*file!$id $f\n");
|
||||
push(@out, ".ds pict*id!$f $id\n");
|
||||
push(@out, ".nr pict*llx!$id $cur{'llx'}\n");
|
||||
push(@out, ".nr pict*lly!$id $cur{'lly'}\n");
|
||||
push(@out, ".nr pict*urx!$id $cur{'urx'}\n");
|
||||
push(@out, ".nr pict*ury!$id $cur{'ury'}\n");
|
||||
push(@out, ".nr pict*w!$id $w\n");
|
||||
push(@out, ".nr pict*h!$id $h\n");
|
||||
}
|
||||
|
||||
|
||||
sub psbb {
|
||||
my ($f) = @_;
|
||||
|
||||
unless (open(IN, $f)) {
|
||||
print STDERR "Warning: Postscript file $f:$!";
|
||||
next;
|
||||
}
|
||||
while(<IN>) {
|
||||
if (/^%%BoundingBox:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/) {
|
||||
$cur{'llx'} = $1;
|
||||
$cur{'lly'} = $2;
|
||||
$cur{'urx'} = $3;
|
||||
$cur{'ury'} = $4;
|
||||
}
|
||||
}
|
||||
close(IN);
|
||||
}
|
10
gen/usr/bin/neqn
Executable file
10
gen/usr/bin/neqn
Executable file
@ -0,0 +1,10 @@
|
||||
#! /bin/sh
|
||||
# Provision of this shell script should not be taken to imply that use of
|
||||
# GNU eqn with groff -Tascii|-Tlatin1|-Tutf8|-Tcp1047 is supported.
|
||||
|
||||
GROFF_RUNTIME="${GROFF_BIN_PATH=/usr/local/bin}:"
|
||||
PATH="$GROFF_RUNTIME$PATH"
|
||||
export PATH
|
||||
exec eqn -Tascii ${1+"$@"}
|
||||
|
||||
# eof
|
101
gen/usr/bin/pic2graph
Executable file
101
gen/usr/bin/pic2graph
Executable file
@ -0,0 +1,101 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# pic2graph -- compile PIC image descriptions to bitmap images
|
||||
#
|
||||
# by Eric S. Raymond <esr@thyrsus.com>, July 2002
|
||||
|
||||
# In Unixland, the magic is in knowing what to string together...
|
||||
#
|
||||
# Take a pic/eqn diagram on stdin, emit cropped bitmap on stdout.
|
||||
# The pic markup should *not* be wrapped in .PS/.PE, this script will do that.
|
||||
# An -unsafe option on the command line enables gpic/groff "unsafe" mode.
|
||||
# A -format FOO option changes the image output format to any format
|
||||
# supported by convert(1). An -eqn option changes the eqn delimiters.
|
||||
# All other options are passed to convert(1). The default format in PNG.
|
||||
#
|
||||
# Requires the groff suite and the ImageMagick tools. Both are open source.
|
||||
# This code is released to the public domain.
|
||||
#
|
||||
# Here are the assumptions behind the option processing:
|
||||
#
|
||||
# 1. Only the -U option of gpic(1) is relevant. -C doesn't matter because
|
||||
# we're generating our own .PS/.PE, -[ntcz] are irrelevant because we're
|
||||
# generating Postscript.
|
||||
#
|
||||
# 2. Ditto for groff(1), though it's a longer and more tedious demonstration.
|
||||
#
|
||||
# 3. Many options of convert(1) are potentially relevant (especially
|
||||
# -density, -interlace, -transparency, -border, and -comment).
|
||||
#
|
||||
# Thus, we pass -U to gpic and groff, and everything else to convert(1).
|
||||
#
|
||||
# We don't have complete option coverage on eqn because this is primarily
|
||||
# intended as a pic translator; we can live with eqn defaults.
|
||||
#
|
||||
# $Id: pic2graph.sh,v 1.7 2005/05/18 07:03:07 wl Exp $
|
||||
#
|
||||
groffpic_opts=""
|
||||
gs_opts=""
|
||||
convert_opts=""
|
||||
format="png"
|
||||
eqndelim='$$'
|
||||
|
||||
while [ "$1" ]
|
||||
do
|
||||
case $1 in
|
||||
-unsafe)
|
||||
groffpic_opts="-U";;
|
||||
-format)
|
||||
format=$2
|
||||
shift;;
|
||||
-eqn)
|
||||
eqndelim=$2
|
||||
shift;;
|
||||
-v | --version)
|
||||
echo "GNU pic2graph (groff) version 1.19.2"
|
||||
exit 0;;
|
||||
--help)
|
||||
echo "usage: pic2graph [ option ...] < in > out"
|
||||
exit 0;;
|
||||
*)
|
||||
convert_opts="$convert_opts $1";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "$eqndelim" ]
|
||||
then
|
||||
eqndelim="delim $eqndelim"
|
||||
fi
|
||||
|
||||
# create temporary directory
|
||||
tmp=
|
||||
for d in "$GROFF_TMPDIR" "$TMPDIR" "$TMP" "$TEMP" /tmp; do
|
||||
test -z "$d" && continue
|
||||
|
||||
tmp=`(umask 077 && mktemp -d -q "$d/pic2graph-XXXXXX") 2> /dev/null` \
|
||||
&& test -n "$tmp" && test -d "$tmp" \
|
||||
&& break
|
||||
|
||||
tmp=$d/pic2graph$$-$RANDOM
|
||||
(umask 077 && mkdir $tmp) 2> /dev/null \
|
||||
&& break
|
||||
done;
|
||||
if test -z "$tmp"; then
|
||||
echo "$0: cannot create temporary directory" >&2
|
||||
{ (exit 1); exit 1; }
|
||||
fi
|
||||
|
||||
trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 2 15
|
||||
|
||||
# Here goes:
|
||||
# 1. Wrap the input in dummy .PS/PE macros (and add possibly null .EQ/.EN)
|
||||
# 2. Process through eqn and pic to emit troff markup.
|
||||
# 3. Process through groff to emit Postscript.
|
||||
# 4. Use convert(1) to crop the PostScript and turn it into a bitmap.
|
||||
(echo ".EQ"; echo $eqndelim; echo ".EN"; echo ".PS"; cat; echo ".PE") | \
|
||||
groff -e -p $groffpic_opts -Tps -P-pletter > $tmp/pic2graph.ps \
|
||||
&& convert -trim -crop 0x0 $convert_opts $tmp/pic2graph.ps $tmp/pic2graph.$format \
|
||||
&& cat $tmp/pic2graph.$format
|
||||
|
||||
# End
|
Loading…
Reference in New Issue
Block a user