summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwlemb <wlemb>2002-06-05 13:46:41 +0000
committerwlemb <wlemb>2002-06-05 13:46:41 +0000
commitec2d1f2ff2ab2b46e4257ae15cb755898265d08e (patch)
tree43c1870873d873beba843a535ee16aa67200eecf
parent3054e1147ac18bdcc25fc06723f8788525c11307 (diff)
downloadgroff-ec2d1f2ff2ab2b46e4257ae15cb755898265d08e.tar.gz
* aclocal.m4 (GROFF_PAGE): Don't use `prefix' directly since it
is not initialized at the time we need it in case `--prefix' hasn't been set. Check for `ac_default_prefix' also. Test for `papersize' keyword also and generalize allowed whitespace. * configure: Regenerated. * font/devps/Makefile.sub (DESC): Use `papersize' instead of `paperlength'. * src/libs/libgroff/Makefile.sub (version, revision): Replaced with... (src_version, src_revision): New variables to avoid overwriting from parent make process. (version.cc): Updated. * contrib/mom/Makefile.sub (groff_bin_dirs): Fix typo (forgotten `src' element). * src/preproc/html/pre-html.cc: Include paper.h and font.h. (linebuf, linebufsize): New global variables. (sys_fatal): Use `fatal' to abort properly. (get_line): New function. (get_resolution): Use it. Improve error messages. (get_papersize): Check `papersize' also. Use `get_line'. Improve error messages.
-rw-r--r--ChangeLog29
-rw-r--r--aclocal.m427
-rwxr-xr-xconfigure63
-rw-r--r--contrib/mom/Makefile.sub6
-rw-r--r--font/devps/Makefile.sub4
-rw-r--r--src/libs/libgroff/Makefile.sub10
-rw-r--r--src/preproc/html/pre-html.cc91
7 files changed, 166 insertions, 64 deletions
diff --git a/ChangeLog b/ChangeLog
index 415a4743..316e666b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2002-06-04 Werner LEMBERG <wl@gnu.org>
+
+ * aclocal.m4 (GROFF_PAGE): Don't use `prefix' directly since it
+ is not initialized at the time we need it in case `--prefix' hasn't
+ been set. Check for `ac_default_prefix' also.
+ Test for `papersize' keyword also and generalize allowed whitespace.
+ * configure: Regenerated.
+
+ * font/devps/Makefile.sub (DESC): Use `papersize' instead of
+ `paperlength'.
+
+ * src/libs/libgroff/Makefile.sub (version, revision): Replaced
+ with...
+ (src_version, src_revision): New variables to avoid overwriting
+ from parent make process.
+ (version.cc): Updated.
+ * contrib/mom/Makefile.sub (groff_bin_dirs): Fix typo (forgotten
+ `src' element).
+
+ * src/preproc/html/pre-html.cc: Include paper.h and font.h.
+ (linebuf, linebufsize): New global variables.
+ (sys_fatal): Use `fatal' to abort properly.
+ (get_line): New function.
+ (get_resolution): Use it.
+ Improve error messages.
+ (get_papersize): Check `papersize' also.
+ Use `get_line'.
+ Improve error messages.
+
2002-06-03 Werner LEMBERG <wl@gnu.org>
* Makefile.comm (CLEANNOTSRCDIRADD): New target for files which
diff --git a/aclocal.m4 b/aclocal.m4
index ee75f770..9abb270f 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,5 +1,5 @@
dnl Autoconf macros for groff.
-dnl Copyright (C) 1989-1995, 2001 Free Software Foundation, Inc.
+dnl Copyright (C) 1989-1995, 2001, 2002 Free Software Foundation, Inc.
dnl
dnl This file is part of groff.
dnl
@@ -239,23 +239,32 @@ dnl
dnl
AC_DEFUN(GROFF_PAGE,
[AC_MSG_CHECKING([default paper size])
+groff_prefix=$prefix
+test "x$prefix" = xNONE && groff_prefix=$ac_default_prefix
if test -z "$PAGE"; then
descfile=
- if test -r $prefix/share/groff/font/devps/DESC; then
- descfile=$prefix/share/groff/font/devps/DESC
- elif test -r $prefix/lib/groff/font/devps/DESC; then
- descfile=$prefix/lib/groff/font/devps/DESC
+ if test -r $groff_prefix/share/groff/font/devps/DESC; then
+ descfile=$groff_prefix/share/groff/font/devps/DESC
+ elif test -r $groff_prefix/lib/groff/font/devps/DESC; then
+ descfile=$groff_prefix/lib/groff/font/devps/DESC
else
- for f in $prefix/share/groff/*/font/devps/DESC; do
+ for f in $groff_prefix/share/groff/*/font/devps/DESC; do
if test -r $f; then
descfile=$f
break
fi
done
fi
- if test -n "$descfile" \
- && grep "^paperlength 841890" $descfile >/dev/null 2>&1; then
- PAGE=A4
+ if test -n "$descfile"; then
+changequote(,)dnl
+ if grep '^paperlength[ ]\+841890' $descfile
+ >/dev/null 2>&1; then
+ PAGE=A4
+ elif grep '^papersize[ ]\+[aA]4' $descfile \
+ >/dev/null 2>&1; then
+ PAGE=A4
+ fi
+changequote([,])dnl
fi
fi
if test -z "$PAGE"; then
diff --git a/configure b/configure
index dca5aa79..da306dff 100755
--- a/configure
+++ b/configure
@@ -4917,23 +4917,30 @@ echo "${ECHO_T}$BROKEN_SPOOLER_FLAGS" >&6
echo "$as_me:4918: checking default paper size" >&5
echo $ECHO_N "checking default paper size... $ECHO_C" >&6
+groff_prefix=$prefix
+test "x$prefix" = xNONE && groff_prefix=$ac_default_prefix
if test -z "$PAGE"; then
descfile=
- if test -r $prefix/share/groff/font/devps/DESC; then
- descfile=$prefix/share/groff/font/devps/DESC
- elif test -r $prefix/lib/groff/font/devps/DESC; then
- descfile=$prefix/lib/groff/font/devps/DESC
+ if test -r $groff_prefix/share/groff/font/devps/DESC; then
+ descfile=$groff_prefix/share/groff/font/devps/DESC
+ elif test -r $groff_prefix/lib/groff/font/devps/DESC; then
+ descfile=$groff_prefix/lib/groff/font/devps/DESC
else
- for f in $prefix/share/groff/*/font/devps/DESC; do
+ for f in $groff_prefix/share/groff/*/font/devps/DESC; do
if test -r $f; then
descfile=$f
break
fi
done
fi
- if test -n "$descfile" \
- && grep "^paperlength 841890" $descfile >/dev/null 2>&1; then
- PAGE=A4
+ if test -n "$descfile"; then
+ if grep '^paperlength[ ]\+841890' $descfile
+ >/dev/null 2>&1; then
+ PAGE=A4
+ elif grep '^papersize[ ]\+[aA]4' $descfile \
+ >/dev/null 2>&1; then
+ PAGE=A4
+ fi
fi
fi
if test -z "$PAGE"; then
@@ -4961,22 +4968,22 @@ cat >>confdefs.h <<\EOF
EOF
fi
-echo "$as_me:4964: result: $PAGE" >&5
+echo "$as_me:4971: result: $PAGE" >&5
echo "${ECHO_T}$PAGE" >&6
-echo "$as_me:4967: checking for existing troff installation" >&5
+echo "$as_me:4974: checking for existing troff installation" >&5
echo $ECHO_N "checking for existing troff installation... $ECHO_C" >&6
if test "x`(echo .tm '|n(.g' | tr '|' '\\\\' | troff -z -i 2>&1) 2>/dev/null`" = x0; then
- echo "$as_me:4970: result: yes" >&5
+ echo "$as_me:4977: result: yes" >&5
echo "${ECHO_T}yes" >&6
g=g
else
- echo "$as_me:4974: result: no" >&5
+ echo "$as_me:4981: result: no" >&5
echo "${ECHO_T}no" >&6
g=
fi
-echo "$as_me:4979: checking for prefix of system macro packages" >&5
+echo "$as_me:4986: checking for prefix of system macro packages" >&5
echo $ECHO_N "checking for prefix of system macro packages... $ECHO_C" >&6
sys_tmac_prefix=
sys_tmac_file_prefix=
@@ -4993,11 +5000,11 @@ for d in /usr/share/lib/tmac /usr/lib/tmac; do
done
done
done
-echo "$as_me:4996: result: $sys_tmac_prefix" >&5
+echo "$as_me:5003: result: $sys_tmac_prefix" >&5
echo "${ECHO_T}$sys_tmac_prefix" >&6
tmac_wrap=
-echo "$as_me:5000: checking which system macro packages should be made available" >&5
+echo "$as_me:5007: checking which system macro packages should be made available" >&5
echo $ECHO_N "checking which system macro packages should be made available... $ECHO_C" >&6
if test "x$sys_tmac_file_prefix" = "xtmac."; then
for f in $sys_tmac_prefix*; do
@@ -5033,7 +5040,7 @@ elif test -n "$sys_tmac_prefix"; then
done
rm -f conftest.sol
fi
-echo "$as_me:5036: result: $tmac_wrap" >&5
+echo "$as_me:5043: result: $tmac_wrap" >&5
echo "${ECHO_T}$tmac_wrap" >&6
ac_config_files="$ac_config_files stamp-h"
@@ -5119,7 +5126,7 @@ DEFS=-DHAVE_CONFIG_H
: ${CONFIG_STATUS=./config.status}
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:5122: creating $CONFIG_STATUS" >&5
+{ echo "$as_me:5129: creating $CONFIG_STATUS" >&5
echo "$as_me: creating $CONFIG_STATUS" >&6;}
cat >$CONFIG_STATUS <<_ACEOF
#! $SHELL
@@ -5292,7 +5299,7 @@ cat >>$CONFIG_STATUS <<\EOF
echo "$ac_cs_version"; exit 0 ;;
--he | --h)
# Conflict between --help and --header
- { { echo "$as_me:5295: error: ambiguous option: $1
+ { { echo "$as_me:5302: error: ambiguous option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: ambiguous option: $1
Try \`$0 --help' for more information." >&2;}
@@ -5311,7 +5318,7 @@ Try \`$0 --help' for more information." >&2;}
ac_need_defaults=false;;
# This is an error.
- -*) { { echo "$as_me:5314: error: unrecognized option: $1
+ -*) { { echo "$as_me:5321: error: unrecognized option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: unrecognized option: $1
Try \`$0 --help' for more information." >&2;}
@@ -5351,7 +5358,7 @@ do
"doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
"src/xditview/Imakefile" ) CONFIG_FILES="$CONFIG_FILES src/xditview/Imakefile" ;;
"src/include/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS src/include/config.h:src/include/config.hin" ;;
- *) { { echo "$as_me:5354: error: invalid argument: $ac_config_target" >&5
+ *) { { echo "$as_me:5361: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
{ (exit 1); exit 1; }; };;
esac
@@ -5582,7 +5589,7 @@ done; }
esac
if test x"$ac_file" != x-; then
- { echo "$as_me:5585: creating $ac_file" >&5
+ { echo "$as_me:5592: creating $ac_file" >&5
echo "$as_me: creating $ac_file" >&6;}
rm -f "$ac_file"
fi
@@ -5600,7 +5607,7 @@ echo "$as_me: creating $ac_file" >&6;}
-) echo $tmp/stdin ;;
[\\/$]*)
# Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:5603: error: cannot find input file: $f" >&5
+ test -f "$f" || { { echo "$as_me:5610: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
echo $f;;
@@ -5613,7 +5620,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;}
echo $srcdir/$f
else
# /dev/null tree
- { { echo "$as_me:5616: error: cannot find input file: $f" >&5
+ { { echo "$as_me:5623: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
fi;;
@@ -5678,7 +5685,7 @@ for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
* ) ac_file_in=$ac_file.in ;;
esac
- test x"$ac_file" != x- && { echo "$as_me:5681: creating $ac_file" >&5
+ test x"$ac_file" != x- && { echo "$as_me:5688: creating $ac_file" >&5
echo "$as_me: creating $ac_file" >&6;}
# First look for the input files in the build tree, otherwise in the
@@ -5689,7 +5696,7 @@ echo "$as_me: creating $ac_file" >&6;}
-) echo $tmp/stdin ;;
[\\/$]*)
# Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:5692: error: cannot find input file: $f" >&5
+ test -f "$f" || { { echo "$as_me:5699: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
echo $f;;
@@ -5702,7 +5709,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;}
echo $srcdir/$f
else
# /dev/null tree
- { { echo "$as_me:5705: error: cannot find input file: $f" >&5
+ { { echo "$as_me:5712: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
fi;;
@@ -5819,7 +5826,7 @@ cat >>$CONFIG_STATUS <<\EOF
rm -f $tmp/in
if test x"$ac_file" != x-; then
if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
- { echo "$as_me:5822: $ac_file is unchanged" >&5
+ { echo "$as_me:5829: $ac_file is unchanged" >&5
echo "$as_me: $ac_file is unchanged" >&6;}
else
ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
@@ -5886,7 +5893,7 @@ if test "$no_create" != yes; then
$ac_cs_success || { (exit 1); exit 1; }
fi
-{ echo "$as_me:5889:
+{ echo "$as_me:5896:
Configuration completed.
diff --git a/contrib/mom/Makefile.sub b/contrib/mom/Makefile.sub
index abe16622..24f82b6b 100644
--- a/contrib/mom/Makefile.sub
+++ b/contrib/mom/Makefile.sub
@@ -18,9 +18,9 @@
# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
groff_bin_dirs=\
- $(top_builddir)/roff/groff \
- $(top_builddir)/roff/troff \
- $(top_builddir)/devices/grops
+ $(top_builddir)/src/roff/groff \
+ $(top_builddir)/src/roff/troff \
+ $(top_builddir)/src/devices/grops
groff_bin_path=`echo $(groff_bin_dirs) | sed -e 's| \+|:|g'`
FFLAG=-F$(top_builddir)/font
diff --git a/font/devps/Makefile.sub b/font/devps/Makefile.sub
index 08b61e27..434a0ac3 100644
--- a/font/devps/Makefile.sub
+++ b/font/devps/Makefile.sub
@@ -16,9 +16,9 @@ DESC: DESC.in
cat $(srcdir)/DESC.in >DESC
echo broken $(BROKEN_SPOOLER_FLAGS) >>DESC
if test "$(PAGE)" = A4; then \
- echo "paperlength 841890" >>DESC; \
+ echo "papersize a4" >>DESC; \
else \
- echo "paperlength 792000" >>DESC; \
+ echo "papersize letter" >>DESC; \
fi
test -z '$(PSPRINT)' || echo print '$(PSPRINT)' >>DESC
diff --git a/src/libs/libgroff/Makefile.sub b/src/libs/libgroff/Makefile.sub
index a62e7fbd..a8c773c8 100644
--- a/src/libs/libgroff/Makefile.sub
+++ b/src/libs/libgroff/Makefile.sub
@@ -87,14 +87,14 @@ CSRCS=\
GENSRCS=\
version.cc
-version=`cat $(top_srcdir)/VERSION`
-revision=`cat $(top_srcdir)/REVISION`
+src_version=`cat $(top_srcdir)/VERSION`
+src_revision=`cat $(top_srcdir)/REVISION`
version.cc: $(top_srcdir)/VERSION $(top_srcdir)/REVISION
@echo Making version.cc
- @echo const char \*version_string = \"$(version)\"\; >$@
- @echo const char \*revision_string = \"$(revision)\"\; >>$@
- @echo extern \"C\" const char \*Version_string = \"$(version).$(revision)\"\; | \
+ @echo const char \*version_string = \"$(src_version)\"\; >$@
+ @echo const char \*revision_string = \"$(src_revision)\"\; >>$@
+ @echo extern \"C\" const char \*Version_string = \"$(src_version).$(src_revision)\"\; | \
sed -e 's/\.0\"/\"/' >>$@
# We have to avoid $(COMPILE.c) since we must not use groff's `assert.h'
diff --git a/src/preproc/html/pre-html.cc b/src/preproc/html/pre-html.cc
index 48edbf2c..440fe11a 100644
--- a/src/preproc/html/pre-html.cc
+++ b/src/preproc/html/pre-html.cc
@@ -33,6 +33,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "posix.h"
#include "defs.h"
#include "searchpath.h"
+#include "paper.h"
+#include "font.h"
#include <errno.h>
#include <sys/types.h>
@@ -118,6 +120,9 @@ static char *troffFileName = NULL; // output of pre-html output whi
static char *htmlFileName = NULL; // output of pre-html output which is sent to troff -Thtml
#endif
+static char *linebuf = NULL; // for scanning devps/DESC
+static int linebufsize = 0;
+
const char *const FONT_ENV_VAR = "GROFF_FONT_PATH";
static search_path font_path(FONT_ENV_VAR, FONTPATH, 0, 0);
@@ -140,7 +145,51 @@ static int do_file(const char *filename);
void sys_fatal (const char *s)
{
- fprintf(stderr, "%s: %s: %s", program_name, s, strerror(errno));
+ fatal("%1: %2", s, strerror(errno));
+}
+
+/*
+ * get_line - copies a line (w/o newline) from a file to the global line buffer
+ */
+
+int get_line (FILE *f)
+{
+ if (f == 0)
+ return 0;
+ if (linebuf == 0) {
+ linebuf = new char[128];
+ linebufsize = 128;
+ }
+ int i = 0;
+ // skip leading whitespace
+ for (;;) {
+ int c = getc(f);
+ if (c == EOF)
+ return 0;
+ if (c != ' ' && c != '\t') {
+ ungetc(c, f);
+ break;
+ }
+ }
+ for (;;) {
+ int c = getc(f);
+ if (c == EOF)
+ break;
+ if (i + 1 >= linebufsize) {
+ char *old_linebuf = linebuf;
+ linebuf = new char[linebufsize * 2];
+ memcpy(linebuf, old_linebuf, linebufsize);
+ a_delete old_linebuf;
+ linebufsize *= 2;
+ }
+ linebuf[i++] = c;
+ if (c == '\n') {
+ i--;
+ break;
+ }
+ }
+ linebuf[i] = '\0';
+ return 1;
}
/*
@@ -152,20 +201,18 @@ static unsigned int get_resolution (void)
char *pathp;
FILE *f;
unsigned int res;
- int n;
- int c;
f = font_path.open_file("devps/DESC", &pathp);
- if (f == 0) sys_fatal("fopen");
- while (1) {
- n = fscanf(f, " res %u", &res);
- if (n < 0) sys_fatal("EOF");
+ if (f == 0)
+ fatal("can't open devps/DESC");
+ while (get_line(f)) {
+ int n = sscanf(linebuf, "res %u", &res);
if (n >= 1) {
fclose(f);
return res;
}
- while (( c = getc(f) ) != '\n')
- if (c == EOF) sys_fatal("EOF");
}
+ fatal("can't find `res' keyword in devps/DESC");
+ return 0;
}
/*
@@ -177,20 +224,30 @@ static int get_papersize (void)
char *pathp;
FILE *f;
int res;
- int n;
- int c;
f = font_path.open_file("devps/DESC", &pathp);
- if (f == 0) sys_fatal("fopen");
- while (1) {
- n = fscanf(f, " paperlength %d", &res);
- if (n < 0) sys_fatal("EOF");
+ if (f == 0)
+ fatal("can't open devps/DESC");
+ while (get_line(f)) {
+ int n = sscanf(linebuf, "paperlength %d", &res);
if (n >= 1) {
fclose(f);
return res;
}
- while (( c = getc(f) ) != '\n')
- if (c == EOF) sys_fatal("EOF");
+ if (!strncmp(linebuf, "papersize", 9)) {
+ double length;
+ char *p = linebuf + 9;
+ while (*p == ' ' || *p == '\t')
+ p++;
+ if (font::scan_papersize(p, 0, &length, 0)) {
+ fclose(f);
+ return int(length * postscriptRes + 0.5);
+ }
+ else
+ fatal("bad argument to `papersize' keyword in devps/DESC");
+ }
}
+ fatal("can't find `papersize' or `paperlength' keyword in devps/DESC");
+ return 0;
}
/*