summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwlemb <wlemb>2000-02-29 10:35:50 +0000
committerwlemb <wlemb>2000-02-29 10:35:50 +0000
commit1e67c0310dafbfca9ed201c1653960c910a22059 (patch)
tree872526e0fa9b8501f1567bb1c3800058f76bf77b
parentefb0d77a34c0b94cbb627c877f2e3e5dffdc4ded (diff)
downloadgroff-1e67c0310dafbfca9ed201c1653960c910a22059.tar.gz
Adding GNU getopt to the groff distribution.
* src/include/getopt.h, src/libs/libgroff/{getopt.c,getopt1.c}: New files. * src/include/Makefile.sub, src/libs/libgroff/Makefile.sub: Update. * aclocal.a4: Remove GROFF_GETOPT function. * configure.in, Makefile.in, PROBLEMS: Update. * src/include/lib.h: Replace getopt tests with getopt.h. * src/devices/grolbp/lpb.cc: Remove inclusion of getopt.h. * doc/groff.texinfo: Further checking/updating. Adding more index entries. * src/devices/grolbp/grolbp.man: Added a comment line at the beginning of the file (similar to shell scripts) which indicates that `tbl' should be used as a preprocessor.
-rw-r--r--ChangeLog19
-rw-r--r--Makefile.in2
-rw-r--r--PROBLEMS7
-rw-r--r--aclocal.m417
-rwxr-xr-xconfigure200
-rwxr-xr-xconfigure.in1
-rw-r--r--doc/groff.texinfo718
-rw-r--r--src/devices/grolbp/grolbp.man8
-rw-r--r--src/devices/grolbp/lbp.cc1
-rw-r--r--src/include/Makefile.sub19
-rw-r--r--src/include/getopt.h133
-rw-r--r--src/include/lib.h20
-rw-r--r--src/libs/libgroff/Makefile.sub14
-rw-r--r--src/libs/libgroff/getopt.c1052
-rw-r--r--src/libs/libgroff/getopt1.c190
15 files changed, 1916 insertions, 485 deletions
diff --git a/ChangeLog b/ChangeLog
index 484c1858..b73025aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,27 @@
+2000-02-29 Werner LEMBERG <wl@gnu.org>
+
+ Adding GNU getopt to the groff distribution.
+
+ * src/include/getopt.h, src/libs/libgroff/{getopt.c,getopt1.c}:
+ New files.
+ * src/include/Makefile.sub, src/libs/libgroff/Makefile.sub: Update.
+ * aclocal.a4: Remove GROFF_GETOPT function.
+ * configure.in, Makefile.in, PROBLEMS: Update.
+ * src/include/lib.h: Replace getopt tests with getopt.h.
+ * src/devices/grolbp/lpb.cc: Remove inclusion of getopt.h.
+
+ * doc/groff.texinfo: Further checking/updating. Adding more index
+ entries.
+
2000-02-28 Werner LEMBERG <wl@gnu.org>
* doc/groff.texinfo: Further checking/updating. Adding more index
entries.
+ * src/devices/grolbp/grolbp.man: Added a comment line at the
+ beginning of the file (similar to shell scripts) which indicates
+ that `tbl' should be used as a preprocessor.
+
2000-02-27 Blake McBride <blake@florida-software.com>
Adapting groff to MS Visual C++ 6.0 compiler (tested with
diff --git a/Makefile.in b/Makefile.in
index c17f5380..1544d568 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -162,8 +162,6 @@ man7dir=$(manroot)/man$(man7ext)
# -DHAVE_STDLIB_H if you have <stdlib.h>
# -DHAVE_RENAME if you have rename()
# -DHAVE_MKSTEMP if you have mkstemp()
-# -DSTDLIB_H_DECLARES_GETOPT if your C++ <stdlib.h> declares getopt()
-# -DUNISTD_H_DECLARES_GETOPT if your C++ <unistd.h> declares getopt()
# -DSTDLIB_H_DECLARES_PUTENV if your C++ <stdlib.h> declares putenv()
# -DSTDIO_H_DECLARES_POPEN if your C++ <stdio.h> declares popen()
# -DSTDIO_H_DECLARES_PCLOSE if your C++ <stdio.h> declares pclose()
diff --git a/PROBLEMS b/PROBLEMS
index 299e23ae..59e9c0eb 100644
--- a/PROBLEMS
+++ b/PROBLEMS
@@ -48,10 +48,9 @@ should be declared as `const char *'; the first argument to fread
should be declared as `void *'; the first argument to fwrite should be
declared as `const void *'; malloc should be declared to return `void
*'; in <alloca.h>, the declaration `extern "C" { void
-*__builtin_alloca(int); }' should be added; declarations of getopt(),
-optarg, optind and opterr should be added to <stdlib.h>; in
-<sys/signal.h> the return type and the second argument type of
-signal() should be changed to be `void (*)(int)'.
+*__builtin_alloca(int); }' should be added; in <sys/signal.h> the
+return type and the second argument type of signal() should be
+changed to be `void (*)(int)'.
You can either change them in place, or copy them to some other
directory and include that directory with a -I option.
diff --git a/aclocal.m4 b/aclocal.m4
index 1a278c2b..692891f1 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -103,23 +103,6 @@ AC_MSG_RESULT(no))
AC_LANG_RESTORE])dnl
dnl
dnl
-AC_DEFUN(GROFF_GETOPT,
-[AC_LANG_SAVE
-AC_LANG_CPLUSPLUS
-AC_MSG_CHECKING([declaration of getopt in stdlib.h])
-AC_TRY_COMPILE([#include <stdlib.h>
-extern "C" { void getopt(int); }],,
-AC_MSG_RESULT(no),
-AC_MSG_RESULT(yes);AC_DEFINE(STDLIB_H_DECLARES_GETOPT))
-AC_MSG_CHECKING([declaration of getopt in unistd.h])
-AC_TRY_COMPILE([#include <sys/types.h>
-#include <unistd.h>
-extern "C" { void getopt(int); }],,
-AC_MSG_RESULT(no),
-AC_MSG_RESULT(yes);AC_DEFINE(UNISTD_H_DECLARES_GETOPT))
-AC_LANG_RESTORE])dnl
-dnl
-dnl
AC_DEFUN(GROFF_PUTENV,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
diff --git a/configure b/configure
index ee511476..4c85d4eb 100755
--- a/configure
+++ b/configure
@@ -1531,74 +1531,10 @@ ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cxx_cross
-echo $ac_n "checking declaration of getopt in stdlib.h""... $ac_c" 1>&6
-echo "configure:1536: checking declaration of getopt in stdlib.h" >&5
-cat > conftest.$ac_ext <<EOF
-#line 1538 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-extern "C" { void getopt(int); }
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:1546: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- echo "$ac_t""no" 1>&6
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- echo "$ac_t""yes" 1>&6;cat >> confdefs.h <<\EOF
-#define STDLIB_H_DECLARES_GETOPT 1
-EOF
-
-fi
-rm -f conftest*
-echo $ac_n "checking declaration of getopt in unistd.h""... $ac_c" 1>&6
-echo "configure:1560: checking declaration of getopt in unistd.h" >&5
-cat > conftest.$ac_ext <<EOF
-#line 1562 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <unistd.h>
-extern "C" { void getopt(int); }
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:1571: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- echo "$ac_t""no" 1>&6
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- echo "$ac_t""yes" 1>&6;cat >> confdefs.h <<\EOF
-#define UNISTD_H_DECLARES_GETOPT 1
-EOF
-
-fi
-rm -f conftest*
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-
-ac_ext=C
-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cxx_cross
-
echo $ac_n "checking declaration of putenv""... $ac_c" 1>&6
-echo "configure:1600: checking declaration of putenv" >&5
+echo "configure:1536: checking declaration of putenv" >&5
cat > conftest.$ac_ext <<EOF
-#line 1602 "configure"
+#line 1538 "configure"
#include "confdefs.h"
#include <stdlib.h>
extern "C" { void putenv(int); }
@@ -1606,7 +1542,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:1610: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1546: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""no" 1>&6
else
@@ -1635,9 +1571,9 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking declaration of popen""... $ac_c" 1>&6
-echo "configure:1639: checking declaration of popen" >&5
+echo "configure:1575: checking declaration of popen" >&5
cat > conftest.$ac_ext <<EOF
-#line 1641 "configure"
+#line 1577 "configure"
#include "confdefs.h"
#include <stdio.h>
extern "C" { void popen(int); }
@@ -1645,7 +1581,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:1649: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1585: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""no" 1>&6
else
@@ -1674,9 +1610,9 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking declaration of pclose""... $ac_c" 1>&6
-echo "configure:1678: checking declaration of pclose" >&5
+echo "configure:1614: checking declaration of pclose" >&5
cat > conftest.$ac_ext <<EOF
-#line 1680 "configure"
+#line 1616 "configure"
#include "confdefs.h"
#include <stdio.h>
extern "C" { void pclose(int); }
@@ -1684,7 +1620,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:1688: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1624: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""no" 1>&6
else
@@ -1713,9 +1649,9 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking for sys_nerr in <errno.h> or <stdio.h>""... $ac_c" 1>&6
-echo "configure:1717: checking for sys_nerr in <errno.h> or <stdio.h>" >&5
+echo "configure:1653: checking for sys_nerr in <errno.h> or <stdio.h>" >&5
cat > conftest.$ac_ext <<EOF
-#line 1719 "configure"
+#line 1655 "configure"
#include "confdefs.h"
#include <errno.h>
#include <stdio.h>
@@ -1723,7 +1659,7 @@ int main() {
int k; k = sys_nerr;
; return 0; }
EOF
-if { (eval echo configure:1727: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1663: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6;cat >> confdefs.h <<\EOF
#define HAVE_SYS_NERR 1
@@ -1752,9 +1688,9 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking for sys_errlist in <errno.h> or <stdio.h>""... $ac_c" 1>&6
-echo "configure:1756: checking for sys_errlist in <errno.h> or <stdio.h>" >&5
+echo "configure:1692: checking for sys_errlist in <errno.h> or <stdio.h>" >&5
cat > conftest.$ac_ext <<EOF
-#line 1758 "configure"
+#line 1694 "configure"
#include "confdefs.h"
#include <errno.h>
#include <stdio.h>
@@ -1762,7 +1698,7 @@ int main() {
int k; k = (int)sys_errlist[0];
; return 0; }
EOF
-if { (eval echo configure:1766: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1702: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6;cat >> confdefs.h <<\EOF
#define HAVE_SYS_ERRLIST 1
@@ -1791,9 +1727,9 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking declaration of hypot""... $ac_c" 1>&6
-echo "configure:1795: checking declaration of hypot" >&5
+echo "configure:1731: checking declaration of hypot" >&5
cat > conftest.$ac_ext <<EOF
-#line 1797 "configure"
+#line 1733 "configure"
#include "confdefs.h"
#include <math.h>
extern "C" { double hypot(double,double); }
@@ -1801,7 +1737,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:1805: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1741: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""no" 1>&6
else
@@ -1830,16 +1766,16 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking C++ <osfcn.h>""... $ac_c" 1>&6
-echo "configure:1834: checking C++ <osfcn.h>" >&5
+echo "configure:1770: checking C++ <osfcn.h>" >&5
cat > conftest.$ac_ext <<EOF
-#line 1836 "configure"
+#line 1772 "configure"
#include "confdefs.h"
#include <osfcn.h>
int main() {
read(0, 0, 0); open(0, 0);
; return 0; }
EOF
-if { (eval echo configure:1843: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1779: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6;cat >> confdefs.h <<\EOF
#define HAVE_CC_OSFCN_H 1
@@ -1868,16 +1804,16 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking C++ <limits.h>""... $ac_c" 1>&6
-echo "configure:1872: checking C++ <limits.h>" >&5
+echo "configure:1808: checking C++ <limits.h>" >&5
cat > conftest.$ac_ext <<EOF
-#line 1874 "configure"
+#line 1810 "configure"
#include "confdefs.h"
#include <limits.h>
int main() {
int x = INT_MIN; int y = INT_MAX; int z = UCHAR_MAX;
; return 0; }
EOF
-if { (eval echo configure:1881: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1817: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6;cat >> confdefs.h <<\EOF
#define HAVE_CC_LIMITS_H 1
@@ -1906,16 +1842,16 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking for declaration of time_t""... $ac_c" 1>&6
-echo "configure:1910: checking for declaration of time_t" >&5
+echo "configure:1846: checking for declaration of time_t" >&5
cat > conftest.$ac_ext <<EOF
-#line 1912 "configure"
+#line 1848 "configure"
#include "confdefs.h"
#include <time.h>
int main() {
time_t t = time(0); struct tm *p = localtime(&t);
; return 0; }
EOF
-if { (eval echo configure:1919: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1855: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6
else
@@ -1936,12 +1872,12 @@ ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$a
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1940: checking return type of signal handlers" >&5
+echo "configure:1876: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1945 "configure"
+#line 1881 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -1958,7 +1894,7 @@ int main() {
int i;
; return 0; }
EOF
-if { (eval echo configure:1962: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1898: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -1977,16 +1913,16 @@ EOF
echo $ac_n "checking struct exception""... $ac_c" 1>&6
-echo "configure:1981: checking struct exception" >&5
+echo "configure:1917: checking struct exception" >&5
cat > conftest.$ac_ext <<EOF
-#line 1983 "configure"
+#line 1919 "configure"
#include "confdefs.h"
#include <math.h>
int main() {
struct exception e;
; return 0; }
EOF
-if { (eval echo configure:1990: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1926: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6;cat >> confdefs.h <<\EOF
#define HAVE_STRUCT_EXCEPTION 1
@@ -2000,7 +1936,7 @@ else
fi
rm -f conftest*
echo $ac_n "checking for sin in -lm""... $ac_c" 1>&6
-echo "configure:2004: checking for sin in -lm" >&5
+echo "configure:1940: checking for sin in -lm" >&5
ac_lib_var=`echo m'_'sin | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2008,7 +1944,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lm $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2012 "configure"
+#line 1948 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -2019,7 +1955,7 @@ int main() {
sin()
; return 0; }
EOF
-if { (eval echo configure:2023: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2045,17 +1981,17 @@ for ac_hdr in unistd.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2049: checking for $ac_hdr" >&5
+echo "configure:1985: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2054 "configure"
+#line 1990 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2059: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1995: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2084,12 +2020,12 @@ done
for ac_func in getpagesize
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2088: checking for $ac_func" >&5
+echo "configure:2024: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2093 "configure"
+#line 2029 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2112,7 +2048,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2116: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2137,7 +2073,7 @@ fi
done
echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:2141: checking for working mmap" >&5
+echo "configure:2077: checking for working mmap" >&5
if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2145,7 +2081,7 @@ else
ac_cv_func_mmap_fixed_mapped=no
else
cat > conftest.$ac_ext <<EOF
-#line 2149 "configure"
+#line 2085 "configure"
#include "confdefs.h"
/* Thanks to Mike Haertel and Jim Avera for this test.
@@ -2285,7 +2221,7 @@ main()
}
EOF
-if { (eval echo configure:2289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_mmap_fixed_mapped=yes
else
@@ -2312,12 +2248,12 @@ LIBS="$LIBS -lc $LIBM"
for ac_func in fmod strtol getcwd strerror putenv
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2316: checking for $ac_func" >&5
+echo "configure:2252: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2321 "configure"
+#line 2257 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2340,7 +2276,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2344: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2280: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2370,12 +2306,12 @@ LIBS="$saved_libs"
for ac_func in rename mkstemp strcasecmp
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2374: checking for $ac_func" >&5
+echo "configure:2310: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2379 "configure"
+#line 2315 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2398,7 +2334,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2338: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2423,12 +2359,12 @@ fi
done
echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6
-echo "configure:2427: checking for sys_siglist declaration in signal.h or unistd.h" >&5
+echo "configure:2363: checking for sys_siglist declaration in signal.h or unistd.h" >&5
if eval "test \"`echo '$''{'ac_cv_decl_sys_siglist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2432 "configure"
+#line 2368 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -2440,7 +2376,7 @@ int main() {
char *msg = *(sys_siglist + 1);
; return 0; }
EOF
-if { (eval echo configure:2444: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2380: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_decl_sys_siglist=yes
else
@@ -2469,16 +2405,16 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking whether ANSI array delete syntax supported""... $ac_c" 1>&6
-echo "configure:2473: checking whether ANSI array delete syntax supported" >&5
+echo "configure:2409: checking whether ANSI array delete syntax supported" >&5
cat > conftest.$ac_ext <<EOF
-#line 2475 "configure"
+#line 2411 "configure"
#include "confdefs.h"
int main() {
char *p = new char[5]; delete [] p;
; return 0; }
EOF
-if { (eval echo configure:2482: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2418: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6
else
@@ -2507,16 +2443,16 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking traditional preprocessor""... $ac_c" 1>&6
-echo "configure:2511: checking traditional preprocessor" >&5
+echo "configure:2447: checking traditional preprocessor" >&5
cat > conftest.$ac_ext <<EOF
-#line 2513 "configure"
+#line 2449 "configure"
#include "confdefs.h"
#define name2(a,b) a/**/b
int main() {
int name2(foo,bar);
; return 0; }
EOF
-if { (eval echo configure:2520: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2456: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6;cat >> confdefs.h <<\EOF
#define TRADITIONAL_CPP 1
@@ -2537,12 +2473,12 @@ ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$a
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking w_coredump""... $ac_c" 1>&6
-echo "configure:2541: checking w_coredump" >&5
+echo "configure:2477: checking w_coredump" >&5
if test "$cross_compiling" = yes; then
echo "$ac_t""no" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2546 "configure"
+#line 2482 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/wait.h>
@@ -2557,7 +2493,7 @@ main()
#endif
}
EOF
-if { (eval echo configure:2561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2497: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
echo "$ac_t""yes" 1>&6;cat >> confdefs.h <<\EOF
#define WCOREFLAG 0200
@@ -2573,12 +2509,12 @@ rm -fr conftest*
fi
echo $ac_n "checking default value for grops -b option""... $ac_c" 1>&6
-echo "configure:2577: checking default value for grops -b option" >&5
+echo "configure:2513: checking default value for grops -b option" >&5
test -n "${BROKEN_SPOOLER_FLAGS}" || BROKEN_SPOOLER_FLAGS=7
echo "$ac_t""$BROKEN_SPOOLER_FLAGS" 1>&6
echo $ac_n "checking default paper size""... $ac_c" 1>&6
-echo "configure:2582: checking default paper size" >&5
+echo "configure:2518: checking default paper size" >&5
if test -z "$PAGE"; then
descfile=
if test -r $prefix/share/groff/font/devps/DESC; then
@@ -2613,7 +2549,7 @@ test -n "$PAGE" || PAGE=letter
echo "$ac_t""$PAGE" 1>&6
echo $ac_n "checking for existing troff installation""... $ac_c" 1>&6
-echo "configure:2617: checking for existing troff installation" >&5
+echo "configure:2553: checking for existing troff installation" >&5
if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
echo "$ac_t""yes" 1>&6
g=g
@@ -2624,7 +2560,7 @@ fi
echo $ac_n "checking for prefix of system macro packages""... $ac_c" 1>&6
-echo "configure:2628: checking for prefix of system macro packages" >&5
+echo "configure:2564: checking for prefix of system macro packages" >&5
sys_tmac_prefix=
sys_tmac_file_prefix=
for d in /usr/share/lib/tmac /usr/lib/tmac; do
@@ -2644,7 +2580,7 @@ echo "$ac_t""$sys_tmac_prefix" 1>&6
tmac_wrap=
echo $ac_n "checking which system macro packages should be made available""... $ac_c" 1>&6
-echo "configure:2648: checking which system macro packages should be made available" >&5
+echo "configure:2584: checking which system macro packages should be made available" >&5
if test "x$sys_tmac_file_prefix" = "xtmac."; then
for f in $sys_tmac_prefix*; do
suff=`echo $f | sed -e "s;$sys_tmac_prefix;;"`
diff --git a/configure.in b/configure.in
index bf9a3f0f..74498966 100755
--- a/configure.in
+++ b/configure.in
@@ -19,7 +19,6 @@ dnl checks for headers
AC_CHECK_HEADERS(unistd.h dirent.h limits.h sys/dir.h stdlib.h)
GROFF_ISC_SYSV3
GROFF_POSIX
-GROFF_GETOPT
GROFF_PUTENV
GROFF_POPEN
GROFF_PCLOSE
diff --git a/doc/groff.texinfo b/doc/groff.texinfo
index 495111a2..e83e9b40 100644
--- a/doc/groff.texinfo
+++ b/doc/groff.texinfo
@@ -977,17 +977,17 @@ For PostScript printers and previewers.
@item dvi
For @TeX{} dvi format.
@item X75
-For a 75dpi X11 previewer.
+For a 75@dmn{dpi} X11 previewer.
@item X100
-For a 100dpi X11 previewer.
+For a 100@dmn{dpi} X11 previewer.
@item @sc{ascii}
For typewriter-like devices.
@item latin1
-For typewriter-like devices using the ISO@w{ }Latin@w{-}1 (ISO@w{
-}8859@w{-}1) character set.
+For typewriter-like devices using the @w{ISO Latin-1} (@w{ISO 8859-1})
+character set.
@item utf8
-For typewriter-like devices using the Unicode (ISO@w{ }10646) character
-set with UTF@w{-}8 encoding.
+For typewriter-like devices which use the Unicode (@w{ISO 10646})
+character set with @w{UTF-8} encoding.
@item lj4
For an HP LaserJet4-compatible (or other PCL5-compatible) printer.
@item html
@@ -3050,7 +3050,6 @@ These dimensions are:
@cindex margin, left
@cindex page offset
@cindex offset, page
-@findex po
@vindex .o
@dfn{Page offset}--This is the leftmost position of text on the final
output, defining the @dfn{left margin}. It can be adjusted with the
@@ -3061,7 +3060,6 @@ may not do what you expect.
@item in
@cindex indentation
@cindex line indentation
-@findex in
@vindex .i
@dfn{Indentation}--This is the distance from the left margin where text
will be printed. This can be adjusted with the @code{in} request, and
@@ -3079,7 +3077,6 @@ applies to the current output line.
@cindex length of line
@vindex .l
@vindex .ll
-@findex ll
@dfn{Line length}--This is the distance from the left margin to right
margin. This can be adjusted with the @code{ll} request, and the
current setting can be found in the built-in number register @code{.l}
@@ -3196,7 +3193,7 @@ is not a single @dfn{orphan} line left at the bottom of a page. The
@code{ne} request will ensure that there is a certain distance,
specified by the first argument, before the next page is triggered
(@pxref{Traps}, for further information). The default unit for
-@code{ne} is @code{v} and the default argument is@w{ }1v.
+@code{ne} is @code{v} and the default argument is@w{ }1@dmn{v}.
For example, to make sure that no fewer than 2@w{ }lines get orphaned,
you can do the following before each paragraph:
@@ -3214,8 +3211,8 @@ text
amount of vertical space. If the desired amount of space exists before
the next trap (bottom page boundary), the space will be output
immediately. If there is not enough space, it is stored for later
-output via the @code{os} request. The default argument is@w{ }1v and
-the default unit is @code{v}.
+output via the @code{os} request. The default argument is@w{ }1@dmn{v}
+and the default unit is @code{v}.
@node Fonts, Sizes, Page Control, Programming Tutorial
@@ -3228,7 +3225,7 @@ the default unit is @code{v}.
text. There are two ways to do this, via the @code{ft} request and the
@code{\f} escape.
-Fonts are generaly specified as upper-case strings, which are usually
+Fonts are generally specified as upper-case strings, which are usually
1@w{ }to 4 characters representing an abreviation or acronym of the font
name.
@@ -3315,15 +3312,27 @@ correction}, but this term isn't used.
@c (f to (f.
@findex ftr
+@findex ft
+@findex ul
+@findex bd
+@findex \f
+@findex cs
+@findex tkf
+@findex special
+@findex fspecial
+@findex fp
+@findex code
The @code{ftr} request will translate fonts; its syntax is
@example
.ftr @var{F} @var{G}
@end example
+
+@noindent
which translates font@w{ }@var{F} to font@w{ }@var{G}. Whenever a font
named @var{F} is referred to in a @code{\f} escape sequence, or in the
-@code{ft}, @var{ul}, @var{bd}, @var{cs}, @var{tkf}, @var{special},
-@var{fspecial}, @var{fp}, or @var{sty} requests, font@w{ }@var{G} will
+@code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf}, @code{special},
+@code{fspecial}, @code{fp}, or @code{code} requests, font@w{ }@var{G} will
be used. If @var{G} is missing, or equal to @var{F} then font@w{
}@var{F} will not be translated.
@@ -3393,7 +3402,7 @@ say no more!
@end example
@noindent
-Nnote that after these font changes have taken place the original font
+Note that after these font changes have taken place the original font
is restored.
@vindex .f
@@ -3502,12 +3511,12 @@ property)
lines can be broken before the character (initially no characters have
this property)
@item 4
-lines can be broken after the character (initially characters
+lines can be broken after the character (initially the characters
@samp{-\(hy\(em} have this property)
@item 8
@cindex overlapping characters
@cindex characters, overlapping
-the character overlaps horizontally (initially characters
+the character overlaps horizontally (initially the characters
@samp{\(ul\(rn\(ru} have this property)
@item 16
the character overlaps vertically (initially character @samp{\(br} has
@@ -3520,7 +3529,7 @@ this property will be treated as the end of a sentence if followed by a
newline or two spaces; in other words the character is @dfn{transparent}
for the purposes of end of sentence recognition---this is the same as
having a zero space factor in @TeX{} (initially characters
-@samp{"')]*\(dg\(rq} have this property)
+@samp{"')]*\(dg\(rq} have this property).
@end table
@findex char
@@ -3728,26 +3737,30 @@ and the text begins. Any of the following forms are valid:
@table @code
@item \s@var{n}
-Set the point size to @var{n}@w{ }points. @var{n} must be exactly one
-digit.
+Set the point size to @var{n}@w{ }points. @var{n}@w{ }must be either 0
+or in the range 4 to@w{ }39.
@itemx \s+@var{n}
@itemx \s-@var{n}
-Increase resp.@: decrease the point size by @var{n}@w{ }points. @var{n}
-must be exactly one digit.
+Increase resp.@: decrease the point size by @var{n}@w{ }points.
+@var{n}@w{ }must be exactly one digit.
@item \s(@var{nn}
Set the point size to @var{nn}@w{ }points. @var{nn} must be exactly two
digits.
@item \s+(@var{nn}
@itemx \s-(@var{nn}
+@itemx \s(+@var{nn}
+@itemx \s(-@var{nn}
Increase resp.@: decrease the point size by @var{nn}@w{ }points.
@var{nn} must be exactly two digits.
-@item \s[+@var{nnn}]
-@itemx \s[-@var{nnn}]
-@itemx \s+[@var{nnn}]
-@itemx \s-[@var{nnn}]
+@end table
+
+@xref{Fractional Type Sizes}, for yet another syntactical form of using
+the @code{\s} escape.
Some devices may only have certain permissible sizes, in which case
-groff will round to the nearest permissible size.
+@code{gtroff} will round to the nearest permissible size.
+
+@c XXX example
@example
... .sz macro example?? ...
@@ -3762,60 +3775,73 @@ groff will round to the nearest permissible size.
@cindex unit, @code{s}
@cindex @code{z} unit
@cindex unit, @code{z}
+@findex ps
+@findex cs
+@findex tkf
+@findex \H
+@findex \s
A @dfn{scaled point} is equal to 1/@var{sizescale} points, where
-@var{sizescale} is specified in the @file{DESC} file (1 by default.)
+@var{sizescale} is specified in the @file{DESC} file (1@w{ }by default.)
There is a new scale indicator @samp{z} which has the effect of
multiplying by @var{sizescale}. Requests and escape sequences in
-troff interpret arguments that represent a pointsize as being in units
-of scaled points, but they evaluate each such argument using a default
-scale indicator of @samp{z}. Arguments treated in this way are the
-argument to the @code{ps} request, the third argument to the @code{cs}
-request, the second and fourth arguments to the @code{tkf} request,
-the argument to the @code{\H} escape sequence, and those variants of
-the @code{\s} escape sequence that take a numeric expression as their
-argument.
-
-For example, suppose @var{sizescale} is 1000; then a scaled point will be
-equivalent to a millipoint; the request @samp{.ps 10.25} is equivalent to
-@samp{.ps 10.25z} and so sets the pointsize to 10250 scaled points, which is
-equal to 10.25 points.
-
-The number register @code{\n(.s} returns the pointsize in points as
-decimal fraction. There is also a new number register @code{\n[.ps]}
-that returns the pointsize in scaled points.
-
-It would make no sense to use the @samp{z} scale indicator in a
-numeric expression whose default scale indicator was neither @samp{u}
-nor @samp{z}, and so troff disallows this. Similarily it would make
+@code{gtroff} interpret arguments that represent a pointsize as being in
+units of scaled points, but they evaluate each such argument using a
+default scale indicator of @samp{z}. Arguments treated in this way are
+the argument to the @code{ps} request, the third argument to the
+@code{cs} request, the second and fourth arguments to the @code{tkf}
+request, the argument to the @code{\H} escape sequence, and those
+variants of the @code{\s} escape sequence that take a numeric expression
+as their argument (see below).
+
+For example, suppose @var{sizescale} is@w{ }1000; then a scaled point
+will be equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
+equivalent to @w{@samp{.ps 10.25z}} and thus sets the pointsize to 10250
+scaled points, which is equal to 10.25@w{ }points.
+
+It would make no sense to use the @samp{z} scale indicator in a numeric
+expression whose default scale indicator was neither @samp{u} nor
+@samp{z}, and so @code{gtroff} disallows this. Similarily it would make
no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
numeric expression whose default scale indicator was @samp{z}, and so
-troff disallows this as well.
+@code{gtroff} disallows this as well.
There is also new scale indicator @samp{s} which multiplies by the
-number of units in a scaled point. So, for example, @samp{\n[.ps]s}
-is equal to 1m. Be sure not to confuse the @samp{s} and @samp{z}
+number of units in a scaled point. So, for example, @samp{\n[.ps]s} is
+equal to @samp{1m}. Be sure not to confuse the @samp{s} and @samp{z}
scale indicators.
-@code{\s'+@var{n}'}
-@code{\s'-@var{n}'}
-@code{\s+'@var{n}'}
-@code{\s-'@var{n}'}
-Set the point size to @var{n} scaled points; @var{n} is a numeric
-expression with a default scale indicator of @samp{z}.
-
-@code{\n[.ps]}
-The current pointsize in scaled points.
-
-@code{\n[.psr]}
-The last-requested pointsize in scaled points.
-
-@code{\n[.sr]}
-The last requested pointsize in points as a decimal fraction. This is a
-string-valued register.
+@vindex .s
+@vindex .ps
+The number register @code{.s} returns the pointsize in points as decimal
+fraction. There is also a new number register @code{.ps} that returns
+the pointsize in scaled points.
+
+@vindex .psr
+@vindex .sr
+The last-requested pointsize in scaled points is contained in the
+@code{.psr} number register. The last requested pointsize in points as
+a decimal fraction can be found in @code{.psr}. This is a string-valued
+register.
+@table @code
+@item \s[@var{n}]
+@itemx \s'@var{n}'
+Set the point size to @var{n} scaled points; @var{n}@w{ }is a numeric
+expression with a default scale indicator of @samp{z}.
+@item \s[+@var{n}]
+@itemx \s[-@var{n}]
+@itemx \s+[@var{n}]
+@itemx \s-[@var{n}]
+@itemx \s'+@var{n}'
+@itemx \s'-@var{n}'
+@itemx \s+'@var{n}'
+@itemx \s-'@var{n}'
+Increases resp.@: decreases the point size by @var{n} scaled points;
+@var{n} is a numeric expression with a default scale indicator of
+@samp{z}.
+@end table
-@c distribute these through the text
-@xref{Font Files}
+@xref{Font Files}.
@node Strings, Conditionals and Loops, Sizes, Programming Tutorial
@@ -3823,51 +3849,54 @@ string-valued register.
@cindex strings
@findex ds
-Groff has string variables, which are entirely for user convenience
-(i.e.@: there are no built-in strings). They are defined via the
-@code{ds} request.
+@code{gtroff} has string variables, which are entirely for user
+convenience (i.e.@: there are no built-in strings). They are defined
+via the @code{ds} request.
@example
.ds UX \s-1UNIX\s0\u\s-3tm\s0\d
@end example
@findex \*
+@cindex string interpolation
+@cindex string expansion
+@cindex interpolation of strings
+@cindex expansion of strings
They are interpolated, or expanded in-place, via the @code{\*} escape:
@example
The \*(UX Operating System
@end example
-Will produce:
-
-@example
-The UNIXtm Operating System
-@end example
-
-If the string named by the @code{\*} does not exist, the escape will
-be replaced by nothing.
+If the string named by the @code{\*} does not exist, the escape will be
+replaced by nothing.
@cindex comments, with @code{ds}
-NOTE: Unlike other requests the third argument takes up the entire
-line including trailing spaces. This means that comments on a line
-with such a request can introduce unwanted space into a string.
+@strong{Caution:} Unlike other requests, the second argument to the
+@code{ds} request takes up the entire line including trailing spaces.
+This means that comments on a line with such a request can introduce
+unwanted space into a string.
@example
-.ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" trademark of you-know-who
+.ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
@end example
-Instead you should either put the comment on another line or
-have the comment escape adjacent with the end of the string.
+@noindent
+Instead you should either put the comment on another line or have the
+comment escape adjacent with the end of the string.
@example
-.ds UX \s-1UNIX\s0\u\s-3tm\s0\d\" trademark of you-know-who
+.ds UX \s-1UNIX\s0\u\s-3tm\s0\d\" UNIX trademark
@end example
-If you need leading space you can start the string with a double
-quote. No trailing quote is needed, in fact any trailing quote is
-included in your string.
+@cindex trailing quotes
+@cindex quotes, trailing
+@cindex leading spaces with @code{ds}
+@cindex spaces with @code{ds}
+If you need leading space you can start the string with a double quote.
+No trailing quote is needed; in fact, any trailing quote is included in
+your string.
-@cindex canibalism
@example
.ds sign " Yours in a white wine sauce,
@end example
@@ -3875,18 +3904,22 @@ included in your string.
@findex as
@cindex appending to strings
@cindex strings, appending
-You can also append onto a string with the @code{as} request.
-It works the same as the @code{ds} request except that it appends the
-second argument onto the string named by the first argument.
+You can also append onto a string with the @code{as} request. It works
+similar to the @code{ds} request except that it appends the second
+argument onto the string named by the first argument.
@example
.as sign " with shallots, onions and garlic,
@end example
-@findex \@key{ret}
+@findex \@key{RET}
+@cindex multiline strings
+@cindex strings, multiline
+@cindex newline character, escaping
+@cindex escaping newline characters
Strings are not limited to a sigle line of text. A string can span
-several lines by escaping the newlines with a backslash. The
-resulting string will be stored @emph{without} the newlines.
+several lines by escaping the newlines with a backslash. The resulting
+string will be stored @emph{without} the newlines.
@example
.ds foo lots and lots \
@@ -3896,37 +3929,57 @@ next several lines
@findex substring
@cindex substrings
-@code{.substring xx n1 [n2]}
-Replace the string in register@w{ }xx with the substring defined by the
-indices n1 and@w{ }n2. The first character in the string has index one.
-If n2 is omitted, it is taken to be equal to the string's length. If
-the index value n1 or n2 is negative or zero, it will be counted from
-the end of the string, going backwards: The last character has index@w{
-}0, the character before the last character has index@w{ }-1, etc.
+Rudimentary string maipulation routines are given with the
+@code{substring} and @code{length} requests. The former has the
+following syntax:
+
+@example
+.substring @var{xx} @var{n1} [@var{n2}]
+@end example
+
+@noindent
+It replaces the string in register@w{ }@var{xx} with the substring
+defined by the indices @var{n1} and@w{ }@var{n2}. The first character
+in the string has index one. If @var{n2} is omitted, it is taken to be
+equal to the string's length. If the index value @var{n1} or @var{n2}
+is negative or zero, it will be counted from the end of the string,
+going backwards: The last character has index@w{ }0, the character
+before the last character has index@w{ }-1, etc.
@findex length
@cindex length of a string
@cindex string, length of
-@code{.length xx string}
-Compute the length of string and return it in the number register@w{ }xx
-(which is not necessarily defined before).
+Here the syntax of the @code{length} request:
+
+@example
+.length @var{xx} @var{string}
+@end example
+
+@noindent
+It computes the length of @var{string} and returns it in the number
+register@w{ }@var{xx} (which is not necessarily defined before).
@findex rn
@code{rn}
+@c XXX
+
@findex rm
@code{rm}
+@c XXX
+
@findex als
@code{als}
+@c XXX
+
@findex chop
@code{chop}
-@c distribute these through the text
-@xref{Identifiers}
-@c distribute these through the text
-@xref{Comments}
+@c XXX
+
+@xref{Identifiers}, and @ref{Comments}.
@node Conditionals and Loops, Writing Macros, Strings, Programming Tutorial
@@ -3942,25 +3995,27 @@ available:
@table @code
@item e
@itemx o
-True if the current page is even or odd numbered (respectively)
+True if the current page is even or odd numbered (respectively).
@item n
@itemx t
-True if the document is being processed by
-nroff (or a character device) or troff.
+True if the document is being processed by @code{nroff} (or a character
+device) resp.@: @code{troff}.
@item '@var{xxx}'@var{yyy}'
-True if the string @var{xxx} is equal to the string @var{yyy}.
-Other characters can be used in place of the single quotes.
-(Which?)
-The strings are `formatted' before being compared. (?)
+True if the string @var{xxx} is equal to the string @var{yyy}. Other
+characters can be used in place of the single quotes.
+@c XXX (Which?)
+The strings are `formatted' before being compared.
+@c XXX (?)
@item r@var{xxx}
True if there is a number register named @var{xxx}.
@item d@var{xxx}
True if there is a string, macro, diversion, or request named @var{xxx}.
@item c@var{ch}
-True if there is a character @var{ch} available; @var{ch} is
-either an @sc{ascii} character or a special character @code{\(@var{ch}} or
-@code{\[@var{ch}]}; the condition will also be true if @var{ch} has been
-defined by the @code{char} request.
+@findex char
+True if there is a character @var{ch} available; @var{ch} is either an
+@sc{ascii} character or a special character (@code{\(@var{ch}} or
+@code{\[@var{ch}]}); the condition will also be true if @var{ch} has
+been defined by the @code{char} request.
@end table
@menu
@@ -3972,31 +4027,35 @@ defined by the @code{char} request.
@subsection if-else
@cindex if-else
-Troff has if-then-else constructs like other languages, although
-the formatting can be painful.
+Troff has if-then-else constructs like other languages, although the
+formatting can be painful.
@findex if
-The @code{if} request is troff's if statement, it is called as
-@samp{.if @var{expr} @var{anything}}, where @var{expr} is the
-expression to be evaluated,
-and @var{anything} (the remainder of the line)
-which will be executed if
-the @var{expr} evaluates to non-zero (true).
-@var{anything} will be interpreted as though it was on a line by
-itself.
-@xref{Expressions}, for more info.
+The @code{if} request has the following syntax:
+
+@example
+.if @var{expr} @var{anything}
+@end example
+
+@noindent
+where @var{expr} is the expression to be evaluated; @var{anything} (the
+remainder of the line) will be executed if @var{expr} evaluates to
+non-zero (true). @var{anything} will be interpreted as though it was on
+a line by itself. @xref{Expressions}, for more info.
Here are some examples:
@example
.if t .ls 2 \" double spacing in troff
-.if 0 .ab how'd this happen??
+.if 0 .ab how'd this happen?
@end example
@findex ie
@findex el
-An if-then-else is written using two requests @code{ie} and @code{el}
-the first request is the if part and the latter is the else part.
+An if-then-else is written using two requests @code{ie} and @code{el}.
+The first request is the `if' part and the latter is the `else' part.
+
+@c XXX example
@example
.ie
@@ -4005,10 +4064,10 @@ the first request is the if part and the latter is the else part.
@findex \@{
@findex \@}
-In many cases you will want more than one request to be executed as a
-result of any of these requests, this can be done using the \@{ and
-\@} escapes.
-The following example shows the possible ways to use these escapes.
+In many cases you want more than one request to be executed as a result
+of any of these requests. This can be done using the @code{\@{} and
+@code{\@}} escapes. The following example shows the possible ways to
+use these escapes (note the position of the opening and closing braces).
@example
.ie t \@{\
@@ -4022,20 +4081,18 @@ The following example shows the possible ways to use these escapes.
.ds qq "
@end example
-
-@c distribute these through the text
-@xref{Expressions}
+@xref{Expressions}.
@node while, , if-else, Conditionals and Loops
@subsection while
@cindex while
@findex while
-Groff provides a looping construct using the @code{while} request,
-which is used much like the @code{if} (and related) requests.
-The first argument is an expression which will be evaluated.
-The @code{while} request will interpret the remainder of the line
-until the expression evaluates to 0 or false.
+@code{gtroff} provides a looping construct using the @code{while}
+request, which is used much like the @code{if} (and related) requests.
+The first argument is an expression which will be evaluated. The
+@code{while} request will interpret the remainder of the line until the
+expression evaluates to 0 or false.
@example
.nr a 0 1
@@ -4043,22 +4100,26 @@ until the expression evaluates to 0 or false.
\&\n+a
@end example
+@noindent
The preceding example produces:
@example
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
@end example
+@findex \&
+@noindent
+Note the usage of the @code{\&} escape to avoid a control character at
+the beginning of a line.
+
@findex break
@findex continue
-The @code{break} request will
-@dfn{break} out of a while loop.
-Be sure not to confuse this with the @code{.br} request.
-The @code{continue} request will
-finish the current iteration of a while loop.
+The @code{break} request will @dfn{break} out of a while loop. Be sure
+not to confuse this with the @code{br} request (causing a line break).
+The @code{continue} request will finish the current iteration of a while
+loop, immediately restarting the next iteration.
-@c distribute these through the text
-@xref{Expressions}
+@xref{Expressions}.
@node Writing Macros, Page Motions, Conditionals and Loops, Programming Tutorial
@@ -4067,17 +4128,16 @@ finish the current iteration of a while loop.
@cindex macros, writing
@findex de
-A macro is a collection of text and embedded commands which can be
+A @dfn{macro} is a collection of text and embedded commands which can be
invoked multiple times. Macros are used for defining common operations.
-Macros are defined using the @code{de} request. This request takes
-a name for the macro as the first argument. Subsequent lines are
-copied into an internal buffer until the line @code{..} is
-encountered. The optional second argument to @code{de} can change
-this ending token.
+Macros are defined using the @code{de} request. This request takes a
+name for the macro as the first argument. Subsequent lines are copied
+into an internal buffer until the line @code{..} is encountered. The
+optional second argument to @code{de} can change this ending token.
-For example, suppose at the beginning of each paragraph, you want
-cause a break, move down a partial line and indent the first line.
-Such a macro could be defined as follows:
+For example, suppose at the beginning of each paragraph, you want cause
+a break, move down a partial line and indent the first line. Such a
+macro (it is called @code{P}) could be defined as follows:
@example
.de P
@@ -4087,10 +4147,10 @@ Such a macro could be defined as follows:
@end example
@findex am
-The @code{am} request works similarily to @code{de} except it appends
+The @code{am} request works similarly to @code{de} except it appends
onto the macro named by the first argument. So, if we decide we want
-our previously @code{P} macro to actually do indented instead of
-block paragraphs we can add the necessary code to our existing macro.
+our previously defined @code{P} macro to actually do indented instead of
+block paragraphs we can add the necessary code to our existing macro:
@example
.am P
@@ -4103,15 +4163,23 @@ block paragraphs we can add the necessary code to our existing macro.
@cindex macro aliases
Macros can be aliased with the @code{als} request.
+@c XXX example
+
@findex rn
@code{rn}
+@c XXX
+
@findex rm
@code{rm}
+@c XXX
+
@findex chop
@code{chop}
+@c XXX
+
@menu
* Copy-in Mode::
* Parameters::
@@ -4127,19 +4195,20 @@ Macros can be aliased with the @code{als} request.
@findex \*
@findex \\
@findex \@key{RET}
-When troff reads in the test for a macro or diversion it copies the
-text (including request lines) into an internal buffer, except for
-escapes. Escapes will be converted into an internal form, except for
+When troff reads in the text for a macro or diversion it copies the text
+(including request lines, but excluding escapes) into an internal
+buffer. Escapes will be converted into an internal form, except for
@code{\n}, @code{\$}, @code{\*}, @code{\\} and @code{\@key{RET}} which
are evaluated and inserted into the text where the escape was located.
This is known as @dfn{copy-in} mode.
What this means is that you can specify when these escapes are to be
-evaluated (copy-in time or time of use) by insulating the escapes
-with an extra backslash.
+evaluated (either at copy-in time or at the time of use) by insulating
+the escapes with an extra backslash. Compare this to the @code{\def}
+and @code{\edef} commands in @TeX{}.
-For example, the following will result in the numbers 20 and 10 being
-printed.
+For example, the following will result in the numbers 20 and@c{ }10
+being printed:
@example
.nr x 20
@@ -4162,38 +4231,38 @@ The number of arguments is available in the @code{.$} number register.
Any individual argument can be retrieved with one of the following
escapes:
-The escapes @code{\$@var{n}}, @code{\$(@var{nn}}
-and @code{\$[@var{nnn}]}
-will result in the @var{n}th, @var{nn}th or @var{nnn}th
-argument. Macros can have a unlimited number of arguments.
-Note that due to copy-in mode, you will want to have two backslashes
-on these in actual use, since you do not want them interpolated until
-the macro is actually invoked.
+@cindex copy-in mode
+The escapes @code{\$@var{n}}, @code{\$(@var{nn}} and
+@code{\$[@var{nnn}]} will result in the @var{n}th, @var{nn}th or
+@var{nnn}th argument. As usual, the first form only accepts a single
+number (larger than zero), the second only a two-digit number (larger or
+equal to@w{ }10), and the third any positive integer value (larger than
+zero). Macros can have an unlimited number of arguments. Note that due
+to copy-in mode, you will want to have two backslashes on these in
+actual use, since you do not want them interpolated until the macro is
+actually invoked.
@findex shift
-The request @code{shift} will shift the arguments 1 position, or as
-many positions as specified by the first argument.
-After executing this request, argument
-@var{i} will become argument @var{i}-@var{n}; arguments 1 to @var{n}
-will no longer be available.
-Shifting by negative amounts is currently undefined.
+The request @code{shift} will shift the arguments 1@w{ }position, or as
+many positions as specified by its argument. After executing this
+request, argument@w{ }@var{i} will become argument @var{i}-@var{n};
+arguments 1 to@w{ }@var{n} will no longer be available. Shifting by
+negative amounts is currently undefined.
@findex \$*
@findex \$@@
In some cases you will want to just use all of the arguments at once.
-For example if you pass the arguments along to another macro.
-The @code{\$*} escape is
-the concatenation of all the arguments separated by spaces.
-A similar escape is @code{\$@@},
-which is
-the concatenation of all the arguments with each surrounded
-by double quotes, and separated by spaces.
+For example if you pass the arguments along to another macro. The
+@code{\$*} escape is the concatenation of all the arguments separated by
+spaces. A similar escape is @code{\$@@}, which is the concatenation of
+all the arguments with each surrounded by double quotes, and separated
+by spaces.
@findex \$0
@findex als
-The @code{\$0} escape is
-the name by which the current macro was invoked. The @code{als}
-request can make a macro have more than one name.
+The @code{\$0} escape is the name by which the current macro was
+invoked. The @code{als} request can make a macro have more than one
+name.
@example
.de vl
@@ -4205,12 +4274,10 @@ request can make a macro have more than one name.
This would be called as
@example
-.vl $Id: groff.texinfo,v 1.11 2000/02/28 11:02:02 wlemb Exp $
+.vl $Id: groff.texinfo,v 1.12 2000/02/29 10:35:51 wlemb Exp $
@end example
-
-@c distribute these through the text
-@xref{Request Arguments}
+@xref{Request Arguments}.
@node Page Motions, Drawing Functions, Writing Macros, Programming Tutorial
@@ -4220,62 +4287,65 @@ This would be called as
@findex sp
Motions up and down the page can be done with the @code{sp} request.
-However, this causes a break so that the actual effect is to move to
-the left margin and then to the specified location.
+However, this causes a break so that the actual effect is to move to the
+left margin and then to the specified location.
@findex mk
@findex rt
The request @code{mk} can be used to mark a location on a page, for
-movement to later. This request takes a register name as an
-argument in which to store the current page location, with no
-argument it will store the location in an internal register.
-The results of this can be used later by the @code{rt} or the
-@code{sp} request. The @code{rt} request will return
-@strong{upwards} to the location given in the register name given as
-an argument, with no argument it will return to the location marked
-with the @code{mk} request
+movement to later. This request takes a register name as an argument in
+which to store the current page location. With no argument it will
+store the location in an internal register. The results of this can be
+used later by the @code{rt} or the @code{sp} request. The @code{rt}
+request will return @emph{upwards} to the location given in the register
+name given as an argument, with no argument it will return to the
+location marked with the @code{mk} request
+
+@c XXX example
@example
... dual column example ...
@end example
-There are escapes which will give you much finer control of movements
+The following escapes will give you much finer control of movements
about the page.
@findex \v
+@cindex vertical motion
+@cindex motion, vertical
The @code{\v'@var{e}'} will let you do arbitrary vertical motion from
-the current location on the page. The argument @var{e} specifies the
-distance to move, positive is downwards and negative upwards. The
+the current location on the page. The argument@w{ }@var{e} specifies
+the distance to move; positive is downwards and negative upwards. The
default unit for this escape is vertical spaces, @code{v}'s. Beware,
-however, that troff will leave text processing to continue wherever
-the motion ends, so if you don't want to interfere with text
+however, that @code{gtroff} will leave text processing to continue
+wherever the motion ends, so if you don't want to interfere with text
processing, make sure your motions are balanced.
There are some special case escapes for vertical motion.
@ftable @code
@item \r
-move upwards 1v.
+move upwards@w{ }1@dmn{v}.
@item \u
-move upwards .5v.
+move upwards@w{ }.5@dmn{v}.
@item \d
-move down .5v.
+move down@w{ }.5@dmn{v}.
@end ftable
@findex \h
-Horizontal motions can be done via the @code{\h'@var{e}'} escape.
-The expression @var{e} indicates how far to move: positive is
-rightwards and negative leftwards.
+Horizontal motions can be done via the @code{\h'@var{e}'} escape. The
+expression@w{ }@var{e} indicates how far to move: positive is rightwards
+and negative leftwards.
There are a number of special case escapes for horizontal motion:
@ftable @code
@item \@key{SP}
-An unbreakable and unpadable (i.e.@: not expanded during filling) space.
-(Note: it is a backslash followed by a space.)
+an unbreakable and unpaddable (i.e.@: not expanded during filling)
+space. (Note: It is a backslash followed by a space.)
@item \~
-This produces an unbreakable space that stretches like a normal
-interword space when a line is adjusted.
+an unbreakable space that stretches like a normal interword space when a
+line is adjusted.
@item \|
a 1/6th em space.
@item \^
@@ -4285,11 +4355,13 @@ a space the size of a digit.
@item \&
A zero width space.
@item \)
-Like @code{\&} except that it behaves like a character declared with
-the @code{cflags} request to be transparent for the purposes of end
-of sentence recognition.
+Like @code{\&} except that it behaves like a character declared with the
+@code{cflags} request to be transparent for the purposes of end of
+sentence recognition.
@end ftable
+@c XXX example
+
@example
... tex logo example ...
@end example
@@ -4297,37 +4369,40 @@ of sentence recognition.
@findex \w
@cindex width escape
@cindex escape, width
-Often you will want to do horizontal movement based on the width of
-some arbitrary text (e.g.@: given as an argument to a macro).
-For that, there is the escape @code{\w'@var{text}'} which will
-interpolate to the width of the given @var{text} in basic units.
+Often you will want to do horizontal movement based on the width of some
+arbitrary text (e.g.@: given as an argument to a macro). For that,
+there is the escape @code{\w'@var{text}'} which will interpolate to the
+width of the given @var{text} in basic units.
+
+@c XXX example
@example
... strlen example ...
@end example
-Font changes may occur in @var{text} and not affect current settings.
+Font changes may occur in @var{text} which don't affect current
+settings.
-Also after use, @code{\w} sets several registers:
+After use, @code{\w} sets several registers:
@table @code
-@item st
@vindex st
-@itemx sb
@vindex sb
+@item st
+@itemx sb
The highest and lowest point, respectively, in @var{text}.
-@item rst
@vindex rst
-@itemx rsb
@vindex rsb
+@item rst
+@itemx rsb
Like the @code{st} and @code{sb} registers, but takes account of the
heights and depths of characters.
-@item ct
@vindex ct
-is set according to what kinds of characters occur in @var{text}.
+@item ct
+is set according to what kinds of characters occur in @var{text}:
@table @asis
@item 0
-all short characters, no decenders or tall characters.
+only short characters, no decenders or tall characters.
@item 1
decender
@item 2
@@ -4335,55 +4410,72 @@ tall character
@item 3
both a decender and a tall character
@end table
-@item ssc
@vindex ssc
-The amount of horizontal space (possibly negative) that should be
-added to the last character before a subscript.
-@item skw
+@item ssc
+The amount of horizontal space (possibly negative) that should be added
+to the last character before a subscript.
@vindex skw
+@item skw
How far to right of the center of the last character in the @code{\w}
-argument, the center of an accent from a roman font should be
-placed over that character.
+argument, the center of an accent from a roman font should be placed
+over that character.
@end table
@findex \k
@vindex .k
@code{\k}
+
@code{.k}
+@c XXX documentation
+
@node Drawing Functions, Traps, Page Motions, Programming Tutorial
@section Drawing Functions
@cindex drawing functions
@cindex functions for drawing
-Groff provides a number of ways to draw lines, and other figures on
-the page. Used in combination with the page motion commands
+@code{gtroff} provides a number of ways to draw lines and other figures
+on the page. Used in combination with the page motion commands
(@pxref{Page Motions}, for more info) you can draw a wide variety of
figures. However, for complex drawings these operations can be quite
-cumbersome, and it may be wise to use the pic preprocessor.
-@xref{gpic}, for more information.
+cumbersome, and it may be wise to use graphic preprocessors like
+@code{gpic} or @code{ggrn}. @xref{gpic}, and @ref{ggrn}, for more
+information.
All drawing is done via escapes.
@findex \l
-The @code{\l} will draw a line rightwards from the current location.
-The full syntax for this escape is @samp{\l'@var{l}@var{c}'}, where
-@var{l} is the length of the line to be drawn, starting at the
-current location, positive numbers will draw to the right, and
-negative will draw towards the left. This can also be specified
-absolutely (i.e.@: with a leading |) which will draw back to the
-begining of the line.
+@cindex horizontal line
+@cindex line, horizontal
+The @code{\l} escape will draw a line rightwards from the current
+location. The full syntax for this escape is
+
+@example
+\l'@var{l}@var{c}'
+@end example
+@noindent
+where @var{l} is the length of the line to be drawn, starting at the
+current location; positive numbers will draw to the right, and negative
+will draw towards the left. This can also be specified absolutely
+(i.e.@: with a leading @samp{|}) which will draw back to the beginning
+of the line.
+
+@cindex underscore character
+@cindex character, underscore
+@cindex line drawing character
+@cindex character for line drawing
The optional second parameter @var{c} is a character to draw the line
with. If this second argument is not specified, troff will use the
underscore character.
+@findex \&
If you need to separate the two arguments (to prevent troff from
interpreting a drawing character as a scaling indicator), you can
separate them with @code{\&}.
-And now, for a useful example:
+Here a small useful example:
@example
.de box
@@ -4391,64 +4483,85 @@ And now, for a useful example:
..
@end example
-Note that this works by outputing a box rule (a vertical line), then
-the text given as an argument and then another box rule.
-Then the line drawing escapes both draw from the current location to
-the beginning of the @emph{input} line.
+@noindent
+@findex |
+Note that this works by outputting a box rule (a vertical line), then
+the text given as an argument and then another box rule. Then the line
+drawing escapes both draw from the current location to the beginning of
+the @emph{input} line.
@findex \L
-Vertical lines are drawn using the @code{\L} escape. It's parameters
-are specified the same as the @code{\l} escape. If the length is
-positive, the movement will be downwards, and upwards for negative.
-The default character is the box rule character.
-As with the vertical motion escapes, text processing will blindly
-continue where the line ends.
+@cindex vertical line
+@cindex line, vertical
+@cindex line drawing character
+@cindex character for line drawing
+@cindex box rule character
+@cindex character, box rule
+Vertical lines are drawn using the @code{\L} escape. Its parameters are
+specified similar to the @code{\l} escape. If the length is positive,
+the movement will be downwards, and upwards for negative values. The
+default character is the box rule character. As with the vertical
+motion escapes, text processing will blindly continue where the line
+ends.
+
+@c XXX example
@example
...box macro...
@end example
@findex \D
-More flexible drawing functions are available via the @code{\D}
-escape. While the previous escapes will work on a character device,
-these escapes will not.
+More flexible drawing functions are available via the @code{\D} escape.
+While the previous escapes will work on a character device, these
+escapes will not.
@table @code
-@item \D'l @var{x} @var{y}'
-Draw a line from the current location to the relative point specified
-by @var{x}, @var{y}.
+@item \D'l @var{dx} @var{dy}'
+Draw a line from the current location to the relative point specified by
+(@var{dx},@var{dy}).
+
+@c XXX example
@example
...revised box macro...
@end example
@item \D'c @var{d}'
-Draw a circle with a diameter of @var{d} with the leftmost point at
-the current position.
+@cindex circles
+Draw a circle with a diameter of @var{d} with the leftmost point at the
+current position.
@item \D'C @var{d}'
Draw a solid circle with the same parameters as an outlined circle.
@item \D'e @var{dx} @var{dy}'
+@cindex ellipses
Draw an ellipse with a horizontal diameter of @var{dx} and a vertical
diameter of @var{dy} with the leftmost point at the current position.
@item \D'E @var{dx} @var{dy}'
-Draw a solid elipse with the same parameters as an outlined elipse.
+Draw a solid ellipse with the same parameters as an outlined ellipse.
@item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
+@cindex arcs
Draw an arc clockwise from the current location through the two
-specified locations.
+specified locations (@var{dx1},@var{dy1}) and (@var{dx2},@var{dy2}).
@item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
-Draw a spline from the current location to
-@var{dx1}, @var{dy1} and then to @var{dx2}, @var{dy2}, and so on.
+@cindex splines
+Draw a spline from the current location to (@var{dx1},@var{dy1}) and
+then to (@var{dx2},@var{dy2}), and so on.
@item \D'f @var{n}'
-Set the shade of gray to be used for filling solid objects to @var{n};
-@var{n} must be an integer between 0 and 1000, where 0 corresponds
-solid white and 1000 to solid black, and values in between correspond
-to intermediate shades of gray. This applies only to solid circles,
-solid ellipses and solid polygons. By default, a level of 1000 will
-be used.
-@item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
-Draw a polygon from the current location to @var{dx1}, @var{dy1}
-and then to @var{dx2}, @var{dy2} and so on. When the specified data
-points are exhausted, a line is drawn back to the starting point.
+@cindex gray shading
+@cindex shading
+Set the shade of gray to be used for filling solid objects to@w{
+}@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
+corresponds solid white and 1000 to solid black, and values in between
+correspond to intermediate shades of gray. This applies only to solid
+circles, solid ellipses and solid polygons. By default, a level of@w{
+}1000 will be used.
+@item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
+@cindex polygons
+Draw a polygon from the current location to (@var{dx1},@var{dy1}) and
+then to (@var{dx2},@var{dy2}) and so on. When the specified data points
+are exhausted, a line is drawn back to the starting point.
+
+@c XXX example
@example
... box example (yes, again)...
@@ -4457,24 +4570,27 @@ points are exhausted, a line is drawn back to the starting point.
@itemx \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
Draw a solid polygon with the same parameters as an outlined polygon.
+@c XXX example
+
@example
... shaded box example ...
@end example
@item \D't @var{n}'
-Set the current line thickness to @var{n} machine units.
-A value of zero selects the smallest available line thickness.
-
+@cindex line thickness
+@cindex thickness of lines
+Set the current line thickness to @var{n} machine units. A value of
+zero selects the smallest available line thickness. A negative value
+makes the line thickness proportional to the current point size (this is
+the default behaviour of @code{ditroff}).
@end table
-Current position
-
@findex \b
@cindex pile, character
@cindex character pile
The @code{\b} escape will @dfn{pile} a sequence of characters
-vertically, and center it vertically on the current line.
-This can be used to build large brackets and braces.
+vertically, and center it vertically on the current line. This can be
+used to build large brackets and braces.
@example
\b'\(lt\(bv\(lk\(bv\(lb'
diff --git a/src/devices/grolbp/grolbp.man b/src/devices/grolbp/grolbp.man
index cc0bf117..0b8fc463 100644
--- a/src/devices/grolbp/grolbp.man
+++ b/src/devices/grolbp/grolbp.man
@@ -1,4 +1,6 @@
-.ig \"-*- nroff -*-
+'\" t
+.\" The above line should force the use of tbl as a preprocessor
+.ig
Copyright (C) 1994-2000 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
@@ -275,3 +277,7 @@ Font description file for font
.BR groff_out (@MAN5EXT@),
.BR groff_font (@MAN5EXT@),
.BR groff_char (@MAN7EXT@)
+.\"
+.\" Local Variables:
+.\" mode: nroff
+.\" End:
diff --git a/src/devices/grolbp/lbp.cc b/src/devices/grolbp/lbp.cc
index 361a8fa4..fe5a7609 100644
--- a/src/devices/grolbp/lbp.cc
+++ b/src/devices/grolbp/lbp.cc
@@ -26,7 +26,6 @@ TODO
- Add X command to include bitmaps
*/
#define _GNU_SOURCE
-#include <getopt.h>
#include <string.h>
#include "driver.h"
diff --git a/src/include/Makefile.sub b/src/include/Makefile.sub
index 191c4ccf..4e4a8f8d 100644
--- a/src/include/Makefile.sub
+++ b/src/include/Makefile.sub
@@ -1,6 +1,21 @@
HDRS=\
- assert.h cmap.h cset.h device.h driver.h errarg.h error.h font.h index.h \
- lib.h macropath.h printer.h ptable.h refid.h search.h searchpath.h \
+ assert.h \
+ cmap.h \
+ cset.h \
+ device.h \
+ driver.h \
+ errarg.h \
+ error.h \
+ font.h \
+ getopt.h \
+ index.h \
+ lib.h \
+ macropath.h \
+ printer.h \
+ ptable.h \
+ refid.h \
+ search.h \
+ searchpath.h \
stringclass.h
GENHDRS=defs.h
CLEANADD=$(GENHDRS)
diff --git a/src/include/getopt.h b/src/include/getopt.h
new file mode 100644
index 00000000..fb30719a
--- /dev/null
+++ b/src/include/getopt.h
@@ -0,0 +1,133 @@
+/* Declarations for getopt.
+ Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
+
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@gnu.org.
+
+ 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 2, 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#ifndef _GETOPT_H
+#define _GETOPT_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+extern char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+extern int optind;
+
+/* Callers store zero here to inhibit the error message `getopt' prints
+ for unrecognized options. */
+
+extern int opterr;
+
+/* Set to an option character which was unrecognized. */
+
+extern int optopt;
+
+/* Describe the long-named options requested by the application.
+ The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
+ of `struct option' terminated by an element containing a name which is
+ zero.
+
+ The field `has_arg' is:
+ no_argument (or 0) if the option does not take an argument,
+ required_argument (or 1) if the option requires an argument,
+ optional_argument (or 2) if the option takes an optional argument.
+
+ If the field `flag' is not NULL, it points to a variable that is set
+ to the value given in the field `val' when the option is found, but
+ left unchanged if the option is not found.
+
+ To have a long-named option do something other than set an `int' to
+ a compiled-in constant, such as set a value from `optarg', set the
+ option's `flag' field to zero and its `val' field to a nonzero
+ value (the equivalent single-letter option character, if there is
+ one). For long options that have a zero `flag' field, `getopt'
+ returns the contents of the `val' field. */
+
+struct option
+{
+#if defined (__STDC__) && __STDC__
+ const char *name;
+#else
+ char *name;
+#endif
+ /* has_arg can't be an enum because some compilers complain about
+ type mismatches in all the code that assumes it is an int. */
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+/* Names for the values of the `has_arg' field of `struct option'. */
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+#if defined (__STDC__) && __STDC__
+#ifdef __GNU_LIBRARY__
+/* Many other libraries have conflicting prototypes for getopt, with
+ differences in the consts, in stdlib.h. To avoid compilation
+ errors, only prototype getopt for the GNU C library. */
+extern int getopt (int argc, char *const *argv, const char *shortopts);
+#else /* not __GNU_LIBRARY__ */
+extern int getopt ();
+#endif /* __GNU_LIBRARY__ */
+extern int getopt_long (int argc, char *const *argv, const char *shortopts,
+ const struct option *longopts, int *longind);
+extern int getopt_long_only (int argc, char *const *argv,
+ const char *shortopts,
+ const struct option *longopts, int *longind);
+
+/* Internal only. Users should not call this directly. */
+extern int _getopt_internal (int argc, char *const *argv,
+ const char *shortopts,
+ const struct option *longopts, int *longind,
+ int long_only);
+#else /* not __STDC__ */
+extern int getopt ();
+extern int getopt_long ();
+extern int getopt_long_only ();
+
+extern int _getopt_internal ();
+#endif /* __STDC__ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* getopt.h */
diff --git a/src/include/lib.h b/src/include/lib.h
index 4ea5cd1f..8635802f 100644
--- a/src/include/lib.h
+++ b/src/include/lib.h
@@ -26,25 +26,7 @@ extern "C" {
const char *if_to_a(int, int);
}
-#ifdef STDLIB_H_DECLARES_GETOPT
-#include <stdlib.h>
-#else /* not STDLIB_H_DECLARES_GETOPT */
-#ifdef UNISTD_H_DECLARES_GETOPT
-#include <sys/types.h>
-#include <unistd.h>
-#else /* not UNISTD_H_DECLARES_GETOPT */
-extern "C" {
- int getopt(int, char *const *, const char *);
-}
-#endif /* not UNISTD_H_DECLARES_GETOPT */
-
-extern "C" {
- extern char *optarg;
- extern int optind;
- extern int opterr;
-}
-
-#endif /* not STDLIB_H_DECLARES_GETOPT */
+#include <getopt.h>
char *strsave(const char *s);
int is_prime(unsigned);
diff --git a/src/libs/libgroff/Makefile.sub b/src/libs/libgroff/Makefile.sub
index d854f4c7..fe3dee34 100644
--- a/src/libs/libgroff/Makefile.sub
+++ b/src/libs/libgroff/Makefile.sub
@@ -11,6 +11,9 @@ OBJS=\
filename.o \
font.o \
fontfile.o \
+ getopt.o \
+ getopt1.o \
+ illegal.o \
lf.o \
lineno.o \
macropath.o \
@@ -27,7 +30,6 @@ OBJS=\
itoa.o \
matherr.o \
version.o \
- illegal.o \
$(LIBOBJS)
CCSRCS=\
$(srcdir)/assert.cc \
@@ -41,6 +43,7 @@ CCSRCS=\
$(srcdir)/filename.cc \
$(srcdir)/font.cc \
$(srcdir)/fontfile.cc \
+ $(srcdir)/illegal.cc \
$(srcdir)/lf.cc \
$(srcdir)/lineno.cc \
$(srcdir)/macropath.cc \
@@ -53,17 +56,18 @@ CCSRCS=\
$(srcdir)/string.cc \
$(srcdir)/strsave.cc \
$(srcdir)/tmpfile.cc \
- version.cc \
- $(srcdir)/illegal.cc
+ version.cc
CSRCS=\
$(srcdir)/fmod.c \
$(srcdir)/getcwd.c \
+ $(srcdir)/getopt.c \
+ $(srcdir)/getopt1.c \
$(srcdir)/iftoa.c \
$(srcdir)/itoa.c \
$(srcdir)/matherr.c \
+ $(srcdir)/putenv.c \
$(srcdir)/strerror.c \
- $(srcdir)/strtol.c \
- $(srcdir)/putenv.c
+ $(srcdir)/strtol.c
GENSRCS=\
version.cc
diff --git a/src/libs/libgroff/getopt.c b/src/libs/libgroff/getopt.c
new file mode 100644
index 00000000..03effcbd
--- /dev/null
+++ b/src/libs/libgroff/getopt.c
@@ -0,0 +1,1052 @@
+/* Getopt for GNU.
+ NOTE: getopt is now part of the C library, so if you don't know what
+ "Keep this file name-space clean" means, talk to drepper@gnu.org
+ before changing it!
+
+ Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98
+ Free Software Foundation, Inc.
+
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@gnu.org.
+
+ 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 2, 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
+ Ditto for AIX 3.2 and <stdlib.h>. */
+#ifndef _NO_PROTO
+# define _NO_PROTO
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if !defined __STDC__ || !__STDC__
+/* This is a separate conditional since some stdc systems
+ reject `defined (const)'. */
+# ifndef const
+# define const
+# endif
+#endif
+
+#include <stdio.h>
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+ actually compiling the library itself. This code is part of the GNU C
+ Library, but also included in many other GNU distributions. Compiling
+ and linking in this code is a waste when using the GNU C library
+ (especially if it is a shared library). Rather than having every GNU
+ program understand `configure --with-gnu-libc' and omit the object files,
+ it is simpler to just do this in the source for each such file. */
+
+#define GETOPT_INTERFACE_VERSION 2
+#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
+# include <gnu-versions.h>
+# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
+# define ELIDE_CODE
+# endif
+#endif
+
+#ifndef ELIDE_CODE
+
+
+/* This needs to come after some library #include
+ to get __GNU_LIBRARY__ defined. */
+#ifdef __GNU_LIBRARY__
+/* Don't include stdlib.h for non-GNU C libraries because some of them
+ contain conflicting prototypes for getopt. */
+# include <stdlib.h>
+# include <unistd.h>
+#endif /* GNU C library. */
+
+#ifdef VMS
+# include <unixlib.h>
+# if HAVE_STRING_H - 0
+# include <string.h>
+# endif
+#endif
+
+#ifndef _
+/* This is for other GNU distributions with internationalized messages.
+ When compiling libc, the _ macro is predefined. */
+# ifdef HAVE_LIBINTL_H
+# include <libintl.h>
+# define _(msgid) gettext (msgid)
+# else
+# define _(msgid) (msgid)
+# endif
+#endif
+
+/* This version of `getopt' appears to the caller like standard Unix `getopt'
+ but it behaves differently for the user, since it allows the user
+ to intersperse the options with the other arguments.
+
+ As `getopt' works, it permutes the elements of ARGV so that,
+ when it is done, all the options precede everything else. Thus
+ all application programs are extended to handle flexible argument order.
+
+ Setting the environment variable POSIXLY_CORRECT disables permutation.
+ Then the behavior is completely standard.
+
+ GNU application programs can use a third alternative mode in which
+ they can distinguish the relative order of options and other arguments. */
+
+#include "getopt.h"
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+char *optarg = NULL;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+/* 1003.2 says this must be 1 before any call. */
+int optind = 1;
+
+/* Formerly, initialization of getopt depended on optind==0, which
+ causes problems with re-calling getopt as programs generally don't
+ know that. */
+
+int __getopt_initialized = 0;
+
+/* The next char to be scanned in the option-element
+ in which the last option character we returned was found.
+ This allows us to pick up the scan where we left off.
+
+ If this is zero, or a null string, it means resume the scan
+ by advancing to the next ARGV-element. */
+
+static char *nextchar;
+
+/* Callers store zero here to inhibit the error message
+ for unrecognized options. */
+
+int opterr = 1;
+
+/* Set to an option character which was unrecognized.
+ This must be initialized on some systems to avoid linking in the
+ system's own getopt implementation. */
+
+int optopt = '?';
+
+/* Describe how to deal with options that follow non-option ARGV-elements.
+
+ If the caller did not specify anything,
+ the default is REQUIRE_ORDER if the environment variable
+ POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+ REQUIRE_ORDER means don't recognize them as options;
+ stop option processing when the first non-option is seen.
+ This is what Unix does.
+ This mode of operation is selected by either setting the environment
+ variable POSIXLY_CORRECT, or using `+' as the first character
+ of the list of option characters.
+
+ PERMUTE is the default. We permute the contents of ARGV as we scan,
+ so that eventually all the non-options are at the end. This allows options
+ to be given in any order, even with programs that were not written to
+ expect this.
+
+ RETURN_IN_ORDER is an option available to programs that were written
+ to expect options and other ARGV-elements in any order and that care about
+ the ordering of the two. We describe each non-option ARGV-element
+ as if it were the argument of an option with character code 1.
+ Using `-' as the first character of the list of option characters
+ selects this mode of operation.
+
+ The special argument `--' forces an end of option-scanning regardless
+ of the value of `ordering'. In the case of RETURN_IN_ORDER, only
+ `--' can cause `getopt' to return -1 with `optind' != ARGC. */
+
+static enum
+{
+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+} ordering;
+
+/* Value of POSIXLY_CORRECT environment variable. */
+static char *posixly_correct;
+
+#ifdef __GNU_LIBRARY__
+/* We want to avoid inclusion of string.h with non-GNU libraries
+ because there are many ways it can cause trouble.
+ On some systems, it contains special magic macros that don't work
+ in GCC. */
+# include <string.h>
+# define my_index strchr
+#else
+
+# if HAVE_STRING_H
+# include <string.h>
+# else
+# include <strings.h>
+# endif
+
+/* Avoid depending on library functions or files
+ whose names are inconsistent. */
+
+#ifndef getenv
+extern char *getenv ();
+#endif
+
+static char *
+my_index (str, chr)
+ const char *str;
+ int chr;
+{
+ while (*str)
+ {
+ if (*str == chr)
+ return (char *) str;
+ str++;
+ }
+ return 0;
+}
+
+/* If using GCC, we can safely declare strlen this way.
+ If not using GCC, it is ok not to declare it. */
+#ifdef __GNUC__
+/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
+ That was relevant to code that was here before. */
+# if (!defined __STDC__ || !__STDC__) && !defined strlen
+/* gcc with -traditional declares the built-in strlen to return int,
+ and has done so at least since version 2.4.5. -- rms. */
+extern int strlen (const char *);
+# endif /* not __STDC__ */
+#endif /* __GNUC__ */
+
+#endif /* not __GNU_LIBRARY__ */
+
+/* Handle permutation of arguments. */
+
+/* Describe the part of ARGV that contains non-options that have
+ been skipped. `first_nonopt' is the index in ARGV of the first of them;
+ `last_nonopt' is the index after the last of them. */
+
+static int first_nonopt;
+static int last_nonopt;
+
+#ifdef _LIBC
+/* Bash 2.0 gives us an environment variable containing flags
+ indicating ARGV elements that should not be considered arguments. */
+
+/* Defined in getopt_init.c */
+extern char *__getopt_nonoption_flags;
+
+static int nonoption_flags_max_len;
+static int nonoption_flags_len;
+
+static int original_argc;
+static char *const *original_argv;
+
+/* Make sure the environment variable bash 2.0 puts in the environment
+ is valid for the getopt call we must make sure that the ARGV passed
+ to getopt is that one passed to the process. */
+static void
+__attribute__ ((unused))
+store_args_and_env (int argc, char *const *argv)
+{
+ /* XXX This is no good solution. We should rather copy the args so
+ that we can compare them later. But we must not use malloc(3). */
+ original_argc = argc;
+ original_argv = argv;
+}
+# ifdef text_set_element
+text_set_element (__libc_subinit, store_args_and_env);
+# endif /* text_set_element */
+
+# define SWAP_FLAGS(ch1, ch2) \
+ if (nonoption_flags_len > 0) \
+ { \
+ char __tmp = __getopt_nonoption_flags[ch1]; \
+ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
+ __getopt_nonoption_flags[ch2] = __tmp; \
+ }
+#else /* !_LIBC */
+# define SWAP_FLAGS(ch1, ch2)
+#endif /* _LIBC */
+
+/* Exchange two adjacent subsequences of ARGV.
+ One subsequence is elements [first_nonopt,last_nonopt)
+ which contains all the non-options that have been skipped so far.
+ The other is elements [last_nonopt,optind), which contains all
+ the options processed since those non-options were skipped.
+
+ `first_nonopt' and `last_nonopt' are relocated so that they describe
+ the new indices of the non-options in ARGV after they are moved. */
+
+#if defined __STDC__ && __STDC__
+static void exchange (char **);
+#endif
+
+static void
+exchange (argv)
+ char **argv;
+{
+ int bottom = first_nonopt;
+ int middle = last_nonopt;
+ int top = optind;
+ char *tem;
+
+ /* Exchange the shorter segment with the far end of the longer segment.
+ That puts the shorter segment into the right place.
+ It leaves the longer segment in the right place overall,
+ but it consists of two parts that need to be swapped next. */
+
+#ifdef _LIBC
+ /* First make sure the handling of the `__getopt_nonoption_flags'
+ string can work normally. Our top argument must be in the range
+ of the string. */
+ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
+ {
+ /* We must extend the array. The user plays games with us and
+ presents new arguments. */
+ char *new_str = malloc (top + 1);
+ if (new_str == NULL)
+ nonoption_flags_len = nonoption_flags_max_len = 0;
+ else
+ {
+ memset (__mempcpy (new_str, __getopt_nonoption_flags,
+ nonoption_flags_max_len),
+ '\0', top + 1 - nonoption_flags_max_len);
+ nonoption_flags_max_len = top + 1;
+ __getopt_nonoption_flags = new_str;
+ }
+ }
+#endif
+
+ while (top > middle && middle > bottom)
+ {
+ if (top - middle > middle - bottom)
+ {
+ /* Bottom segment is the short one. */
+ int len = middle - bottom;
+ register int i;
+
+ /* Swap it with the top part of the top segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[top - (middle - bottom) + i];
+ argv[top - (middle - bottom) + i] = tem;
+ SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
+ }
+ /* Exclude the moved bottom segment from further swapping. */
+ top -= len;
+ }
+ else
+ {
+ /* Top segment is the short one. */
+ int len = top - middle;
+ register int i;
+
+ /* Swap it with the bottom part of the bottom segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[middle + i];
+ argv[middle + i] = tem;
+ SWAP_FLAGS (bottom + i, middle + i);
+ }
+ /* Exclude the moved top segment from further swapping. */
+ bottom += len;
+ }
+ }
+
+ /* Update records for the slots the non-options now occupy. */
+
+ first_nonopt += (optind - last_nonopt);
+ last_nonopt = optind;
+}
+
+/* Initialize the internal data when the first call is made. */
+
+#if defined __STDC__ && __STDC__
+static const char *_getopt_initialize (int, char *const *, const char *);
+#endif
+static const char *
+_getopt_initialize (argc, argv, optstring)
+ int argc;
+ char *const *argv;
+ const char *optstring;
+{
+ /* Start processing options with ARGV-element 1 (since ARGV-element 0
+ is the program name); the sequence of previously skipped
+ non-option ARGV-elements is empty. */
+
+ first_nonopt = last_nonopt = optind;
+
+ nextchar = NULL;
+
+ posixly_correct = getenv ("POSIXLY_CORRECT");
+
+ /* Determine how to handle the ordering of options and nonoptions. */
+
+ if (optstring[0] == '-')
+ {
+ ordering = RETURN_IN_ORDER;
+ ++optstring;
+ }
+ else if (optstring[0] == '+')
+ {
+ ordering = REQUIRE_ORDER;
+ ++optstring;
+ }
+ else if (posixly_correct != NULL)
+ ordering = REQUIRE_ORDER;
+ else
+ ordering = PERMUTE;
+
+#ifdef _LIBC
+ if (posixly_correct == NULL
+ && argc == original_argc && argv == original_argv)
+ {
+ if (nonoption_flags_max_len == 0)
+ {
+ if (__getopt_nonoption_flags == NULL
+ || __getopt_nonoption_flags[0] == '\0')
+ nonoption_flags_max_len = -1;
+ else
+ {
+ const char *orig_str = __getopt_nonoption_flags;
+ int len = nonoption_flags_max_len = strlen (orig_str);
+ if (nonoption_flags_max_len < argc)
+ nonoption_flags_max_len = argc;
+ __getopt_nonoption_flags =
+ (char *) malloc (nonoption_flags_max_len);
+ if (__getopt_nonoption_flags == NULL)
+ nonoption_flags_max_len = -1;
+ else
+ memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
+ '\0', nonoption_flags_max_len - len);
+ }
+ }
+ nonoption_flags_len = nonoption_flags_max_len;
+ }
+ else
+ nonoption_flags_len = 0;
+#endif
+
+ return optstring;
+}
+
+/* Scan elements of ARGV (whose length is ARGC) for option characters
+ given in OPTSTRING.
+
+ If an element of ARGV starts with '-', and is not exactly "-" or "--",
+ then it is an option element. The characters of this element
+ (aside from the initial '-') are option characters. If `getopt'
+ is called repeatedly, it returns successively each of the option characters
+ from each of the option elements.
+
+ If `getopt' finds another option character, it returns that character,
+ updating `optind' and `nextchar' so that the next call to `getopt' can
+ resume the scan with the following option character or ARGV-element.
+
+ If there are no more option characters, `getopt' returns -1.
+ Then `optind' is the index in ARGV of the first ARGV-element
+ that is not an option. (The ARGV-elements have been permuted
+ so that those that are not options now come last.)
+
+ OPTSTRING is a string containing the legitimate option characters.
+ If an option character is seen that is not listed in OPTSTRING,
+ return '?' after printing an error message. If you set `opterr' to
+ zero, the error message is suppressed but we still return '?'.
+
+ If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+ so the following text in the same ARGV-element, or the text of the following
+ ARGV-element, is returned in `optarg'. Two colons mean an option that
+ wants an optional arg; if there is text in the current ARGV-element,
+ it is returned in `optarg', otherwise `optarg' is set to zero.
+
+ If OPTSTRING starts with `-' or `+', it requests different methods of
+ handling the non-option ARGV-elements.
+ See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+
+ Long-named options begin with `--' instead of `-'.
+ Their names may be abbreviated as long as the abbreviation is unique
+ or is an exact match for some defined option. If they have an
+ argument, it follows the option name in the same ARGV-element, separated
+ from the option name by a `=', or else the in next ARGV-element.
+ When `getopt' finds a long-named option, it returns 0 if that option's
+ `flag' field is nonzero, the value of the option's `val' field
+ if the `flag' field is zero.
+
+ The elements of ARGV aren't really const, because we permute them.
+ But we pretend they're const in the prototype to be compatible
+ with other systems.
+
+ LONGOPTS is a vector of `struct option' terminated by an
+ element containing a name which is zero.
+
+ LONGIND returns the index in LONGOPT of the long-named option found.
+ It is only valid when a long-named option has been found by the most
+ recent call.
+
+ If LONG_ONLY is nonzero, '-' as well as '--' can introduce
+ long-named options. */
+
+int
+_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
+ int argc;
+ char *const *argv;
+ const char *optstring;
+ const struct option *longopts;
+ int *longind;
+ int long_only;
+{
+ optarg = NULL;
+
+ if (optind == 0 || !__getopt_initialized)
+ {
+ if (optind == 0)
+ optind = 1; /* Don't scan ARGV[0], the program name. */
+ optstring = _getopt_initialize (argc, argv, optstring);
+ __getopt_initialized = 1;
+ }
+
+ /* Test whether ARGV[optind] points to a non-option argument.
+ Either it does not have option syntax, or there is an environment flag
+ from the shell indicating it is not an option. The later information
+ is only used when the used in the GNU libc. */
+#ifdef _LIBC
+# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
+ || (optind < nonoption_flags_len \
+ && __getopt_nonoption_flags[optind] == '1'))
+#else
+# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
+#endif
+
+ if (nextchar == NULL || *nextchar == '\0')
+ {
+ /* Advance to the next ARGV-element. */
+
+ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
+ moved back by the user (who may also have changed the arguments). */
+ if (last_nonopt > optind)
+ last_nonopt = optind;
+ if (first_nonopt > optind)
+ first_nonopt = optind;
+
+ if (ordering == PERMUTE)
+ {
+ /* If we have just processed some options following some non-options,
+ exchange them so that the options come first. */
+
+ if (first_nonopt != last_nonopt && last_nonopt != optind)
+ exchange ((char **) argv);
+ else if (last_nonopt != optind)
+ first_nonopt = optind;
+
+ /* Skip any additional non-options
+ and extend the range of non-options previously skipped. */
+
+ while (optind < argc && NONOPTION_P)
+ optind++;
+ last_nonopt = optind;
+ }
+
+ /* The special ARGV-element `--' means premature end of options.
+ Skip it like a null option,
+ then exchange with previous non-options as if it were an option,
+ then skip everything else like a non-option. */
+
+ if (optind != argc && !strcmp (argv[optind], "--"))
+ {
+ optind++;
+
+ if (first_nonopt != last_nonopt && last_nonopt != optind)
+ exchange ((char **) argv);
+ else if (first_nonopt == last_nonopt)
+ first_nonopt = optind;
+ last_nonopt = argc;
+
+ optind = argc;
+ }
+
+ /* If we have done all the ARGV-elements, stop the scan
+ and back over any non-options that we skipped and permuted. */
+
+ if (optind == argc)
+ {
+ /* Set the next-arg-index to point at the non-options
+ that we previously skipped, so the caller will digest them. */
+ if (first_nonopt != last_nonopt)
+ optind = first_nonopt;
+ return -1;
+ }
+
+ /* If we have come to a non-option and did not permute it,
+ either stop the scan or describe it to the caller and pass it by. */
+
+ if (NONOPTION_P)
+ {
+ if (ordering == REQUIRE_ORDER)
+ return -1;
+ optarg = argv[optind++];
+ return 1;
+ }
+
+ /* We have found another option-ARGV-element.
+ Skip the initial punctuation. */
+
+ nextchar = (argv[optind] + 1
+ + (longopts != NULL && argv[optind][1] == '-'));
+ }
+
+ /* Decode the current option-ARGV-element. */
+
+ /* Check whether the ARGV-element is a long option.
+
+ If long_only and the ARGV-element has the form "-f", where f is
+ a valid short option, don't consider it an abbreviated form of
+ a long option that starts with f. Otherwise there would be no
+ way to give the -f short option.
+
+ On the other hand, if there's a long option "fubar" and
+ the ARGV-element is "-fu", do consider that an abbreviation of
+ the long option, just like "--fu", and not "-f" with arg "u".
+
+ This distinction seems to be the most useful approach. */
+
+ if (longopts != NULL
+ && (argv[optind][1] == '-'
+ || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
+ {
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = -1;
+ int option_index;
+
+ for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
+ /* Do nothing. */ ;
+
+ /* Test all long options for either exact match
+ or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (!strncmp (p->name, nextchar, nameend - nextchar))
+ {
+ if ((unsigned int) (nameend - nextchar)
+ == (unsigned int) strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
+
+ if (ambig && !exact)
+ {
+ if (opterr)
+ fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
+ argv[0], argv[optind]);
+ nextchar += strlen (nextchar);
+ optind++;
+ optopt = 0;
+ return '?';
+ }
+
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ optind++;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ optarg = nameend + 1;
+ else
+ {
+ if (opterr)
+ if (argv[optind - 1][1] == '-')
+ /* --option */
+ fprintf (stderr,
+ _("%s: option `--%s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+ else
+ /* +option or -option */
+ fprintf (stderr,
+ _("%s: option `%c%s' doesn't allow an argument\n"),
+ argv[0], argv[optind - 1][0], pfound->name);
+
+ nextchar += strlen (nextchar);
+
+ optopt = pfound->val;
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (optind < argc)
+ optarg = argv[optind++];
+ else
+ {
+ if (opterr)
+ fprintf (stderr,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[optind - 1]);
+ nextchar += strlen (nextchar);
+ optopt = pfound->val;
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+ nextchar += strlen (nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+
+ /* Can't find it as a long option. If this is not getopt_long_only,
+ or the option starts with '--' or is not a valid short
+ option, then it's an error.
+ Otherwise interpret it as a short option. */
+ if (!long_only || argv[optind][1] == '-'
+ || my_index (optstring, *nextchar) == NULL)
+ {
+ if (opterr)
+ {
+ if (argv[optind][1] == '-')
+ /* --option */
+ fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
+ argv[0], nextchar);
+ else
+ /* +option or -option */
+ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
+ argv[0], argv[optind][0], nextchar);
+ }
+ nextchar = (char *) "";
+ optind++;
+ optopt = 0;
+ return '?';
+ }
+ }
+
+ /* Look at and handle the next short option-character. */
+
+ {
+ char c = *nextchar++;
+ char *temp = my_index (optstring, c);
+
+ /* Increment `optind' when we start to process its last character. */
+ if (*nextchar == '\0')
+ ++optind;
+
+ if (temp == NULL || c == ':')
+ {
+ if (opterr)
+ {
+ if (posixly_correct)
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr, _("%s: illegal option -- %c\n"),
+ argv[0], c);
+ else
+ fprintf (stderr, _("%s: invalid option -- %c\n"),
+ argv[0], c);
+ }
+ optopt = c;
+ return '?';
+ }
+ /* Convenience. Treat POSIX -W foo same as long option --foo */
+ if (temp[0] == 'W' && temp[1] == ';')
+ {
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = 0;
+ int option_index;
+
+ /* This is an option that requires an argument. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ optind++;
+ }
+ else if (optind == argc)
+ {
+ if (opterr)
+ {
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr, _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+ }
+ optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ return c;
+ }
+ else
+ /* We already incremented `optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ optarg = argv[optind++];
+
+ /* optarg is now the argument, see if it's in the
+ table of longopts. */
+
+ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
+ /* Do nothing. */ ;
+
+ /* Test all long options for either exact match
+ or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (!strncmp (p->name, nextchar, nameend - nextchar))
+ {
+ if ((unsigned int) (nameend - nextchar) == strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
+ if (ambig && !exact)
+ {
+ if (opterr)
+ fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
+ argv[0], argv[optind]);
+ nextchar += strlen (nextchar);
+ optind++;
+ return '?';
+ }
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ optarg = nameend + 1;
+ else
+ {
+ if (opterr)
+ fprintf (stderr, _("\
+%s: option `-W %s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+
+ nextchar += strlen (nextchar);
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (optind < argc)
+ optarg = argv[optind++];
+ else
+ {
+ if (opterr)
+ fprintf (stderr,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[optind - 1]);
+ nextchar += strlen (nextchar);
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+ nextchar += strlen (nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+ nextchar = NULL;
+ return 'W'; /* Let the application handle it. */
+ }
+ if (temp[1] == ':')
+ {
+ if (temp[2] == ':')
+ {
+ /* This is an option that accepts an argument optionally. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ optind++;
+ }
+ else
+ optarg = NULL;
+ nextchar = NULL;
+ }
+ else
+ {
+ /* This is an option that requires an argument. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ optind++;
+ }
+ else if (optind == argc)
+ {
+ if (opterr)
+ {
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr,
+ _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+ }
+ optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ }
+ else
+ /* We already incremented `optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ optarg = argv[optind++];
+ nextchar = NULL;
+ }
+ }
+ return c;
+ }
+}
+
+int
+getopt (argc, argv, optstring)
+ int argc;
+ char *const *argv;
+ const char *optstring;
+{
+ return _getopt_internal (argc, argv, optstring,
+ (const struct option *) 0,
+ (int *) 0,
+ 0);
+}
+
+#endif /* Not ELIDE_CODE. */
+
+#ifdef TEST
+
+/* Compile with -DTEST to make an executable for use in testing
+ the above definition of `getopt'. */
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+
+ c = getopt (argc, argv, "abc:d:0123456789");
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */
diff --git a/src/libs/libgroff/getopt1.c b/src/libs/libgroff/getopt1.c
new file mode 100644
index 00000000..ff257374
--- /dev/null
+++ b/src/libs/libgroff/getopt1.c
@@ -0,0 +1,190 @@
+/* getopt_long and getopt_long_only entry points for GNU getopt.
+ Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
+ Free Software Foundation, Inc.
+
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@gnu.org.
+
+ 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 2, 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "getopt.h"
+
+#if !defined __STDC__ || !__STDC__
+/* This is a separate conditional since some stdc systems
+ reject `defined (const)'. */
+#ifndef const
+#define const
+#endif
+#endif
+
+#include <stdio.h>
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+ actually compiling the library itself. This code is part of the GNU C
+ Library, but also included in many other GNU distributions. Compiling
+ and linking in this code is a waste when using the GNU C library
+ (especially if it is a shared library). Rather than having every GNU
+ program understand `configure --with-gnu-libc' and omit the object files,
+ it is simpler to just do this in the source for each such file. */
+
+#define GETOPT_INTERFACE_VERSION 2
+#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
+#include <gnu-versions.h>
+#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
+#define ELIDE_CODE
+#endif
+#endif
+
+#ifndef ELIDE_CODE
+
+
+/* This needs to come after some library #include
+ to get __GNU_LIBRARY__ defined. */
+#ifdef __GNU_LIBRARY__
+#include <stdlib.h>
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+int
+getopt_long (argc, argv, options, long_options, opt_index)
+ int argc;
+ char *const *argv;
+ const char *options;
+ const struct option *long_options;
+ int *opt_index;
+{
+ return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
+}
+
+/* Like getopt_long, but '-' as well as '--' can indicate a long option.
+ If an option that starts with '-' (not '--') doesn't match a long option,
+ but does match a short option, it is parsed as a short option
+ instead. */
+
+int
+getopt_long_only (argc, argv, options, long_options, opt_index)
+ int argc;
+ char *const *argv;
+ const char *options;
+ const struct option *long_options;
+ int *opt_index;
+{
+ return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
+}
+
+
+#endif /* Not ELIDE_CODE. */
+
+#ifdef TEST
+
+#include <stdio.h>
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+ int option_index = 0;
+ static struct option long_options[] =
+ {
+ {"add", 1, 0, 0},
+ {"append", 0, 0, 0},
+ {"delete", 1, 0, 0},
+ {"verbose", 0, 0, 0},
+ {"create", 0, 0, 0},
+ {"file", 1, 0, 0},
+ {0, 0, 0, 0}
+ };
+
+ c = getopt_long (argc, argv, "abc:d:0123456789",
+ long_options, &option_index);
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case 0:
+ printf ("option %s", long_options[option_index].name);
+ if (optarg)
+ printf (" with arg %s", optarg);
+ printf ("\n");
+ break;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case 'd':
+ printf ("option d with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */