Skip to content
This repository was archived by the owner on Sep 1, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ distclean: clean

u2ps.o: config.h
u2ps*.o: u2ps.h
u2ps_opts.o: u2ps_data.h
u2ps_opts.o: u2ps_data.h config.h
u2ps_data.o: u2ps_data.i
u2ps_pswr.o: config.h

Expand Down
12 changes: 12 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

unset prefix bindir datadir mandir man1dir basedir gs psfremdir cross

if [ -r /etc/papersize ]; then
defaultpaper=$(cat /etc/papersize)
else
defaultpaper=a4
fi



help() {
cat << EOF
Usage: $0 [OPTIONS]...
Expand All @@ -14,6 +22,7 @@ Options:
--mandir=/path base directory for manual pages [\$datadir/man]
--man1dir=/path directory for manual section 1 pages [\$mandir/man1]
--with-gs=... gs command to use [gs]
--default-paper=... default paper size [$defaultpaper]

EOF
exit
Expand Down Expand Up @@ -50,6 +59,7 @@ for arg in "$@"; do
cflags) cflags="$val" ;;
devel) cflags="-Wall -g"; basedir="res"; psfremdir="./" ;;
target) cross="$val-" ;;
default-paper) defaultpaper="$val" ;;
*)
echo "unexpected parameter $arg"
exit 1
Expand Down Expand Up @@ -86,6 +96,7 @@ cat > config.h <<END
#define GS "$gs"
#define PATH "$psfremdir"
#define BASE "$basedir"
#define PAPER "$defaultpaper"
END

cat > config.mk <<END
Expand All @@ -103,4 +114,5 @@ echo "u2ps executable dir: $bindir"
echo "u2ps postscript dir: $basedir"
echo "man section 1 path: $man1dir"
echo "ghostscript command: $gs"
echo "default paper size: $defaultpaper"
echo
7 changes: 6 additions & 1 deletion u2ps_opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>

#include "config.h"
#include "u2ps.h"
#include "warn.h"
#include "u2ps_data.h"
Expand Down Expand Up @@ -392,6 +393,10 @@ static int got_headings_set(void)
return memcmp(&headings, zero, size);
}

// to avoid horror of shell quoting, quote the paper size using C macros
#define STRINGIZE(A) #A
#define XSTR(S) STRINGIZE(S)

static void set_page_layout(struct pagelayout* pl)
{
const struct papersize* p;
Expand All @@ -403,7 +408,7 @@ static void set_page_layout(struct pagelayout* pl)
if(!paper)
paper = getenv("PAPER");
if(!paper)
paper = "a4";
paper = PAPER;

for(p = papersize; p->name; p++)
if(!strcmp(p->name, paper))
Expand Down