--- psutils/pstops.1.paper Tue Mar 11 23:53:04 1997 +++ psutils/pstops.1 Thu Jul 19 15:21:51 2001 @@ -108,10 +108,11 @@ The .I \-p option can be used as an alternative, to set the paper size to -.B a3, a4, a5, b5, letter, legal, tabloid, statement, executive, folio, quarto +.B a3, a4, a5, b5, letter, legal, tabloid, statement, executive, folio, quarto, 10x14 or -.B 10x14. -The default paper size is +.B _glibc, +where latter one means the format of the current locale. The default +paper size is .B @PAPER@. .PP The @@ -154,6 +155,12 @@ 4:1L@.7(21cm,0)+-2L@.7(21cm,14.85cm) .sp for the reverse sides (or join them with a comma for duplex printing). +.SH "ENVIRONMENT VARIABLES" +.TP +.B LC_ALL, LC_PAPER +These variables are specifying the papertype when used paper is +.B _glibc. +For details see the locale(7) manpage. .SH AUTHOR Copyright (C) Angus J. C. Duggan 1991-1995 .SH "SEE ALSO" --- psutils/psutil.c.paper Tue Mar 11 23:53:04 1997 +++ psutils/psutil.c Thu Jul 19 15:21:51 2001 @@ -21,6 +21,11 @@ #include #include +#ifdef HAVE_LANGINFO_H +# include +# include +#endif + #define iscomment(x,y) (strncmp(x,y,strlen(y)) == 0) extern char *program ; @@ -31,6 +36,16 @@ extern char pagelabel[BUFSIZ]; extern int pageno; +#ifdef HAVE_LANGINFO_H +/* When using papertype _glibc we are comparing floating point values. Therefore + * and because values in the papersize table are not exactly we are needing an + * epsilon value. */ +static float PT_EPSILON = 2.0; + +/* The factor needed to convert lengths given in mm to length in pt.*/ +static float MM_TO_PT_FACTOR = 72/25.4; +#endif /* HAVE_LANGINFO_H */ + static char buffer[BUFSIZ]; static long bytes = 0; static long pagescmt = 0; @@ -64,16 +79,52 @@ { NULL, 0, 0 } }; +#ifdef HAVE_LANGINFO_H +/* Called if papertype is '_glibc'. It uses the current locale to determine the + * height and width of the current LC_PAPER and compares it with the items of + * the 'papersizes' list. */ +Paper* findpaperglibc() +{ + float height, width; + char *old_locale = setlocale (LC_PAPER, ""); + Paper *result = 0, *pp; + + height = MM_TO_PT_FACTOR * (unsigned int)(nl_langinfo(_NL_PAPER_HEIGHT)); + width = MM_TO_PT_FACTOR * (unsigned int)(nl_langinfo(_NL_PAPER_WIDTH)); + + for (pp = papersizes; PaperName(pp) && result==0; pp++) { + if ( abs(PaperWidth(pp)-width) header +# or does not know nl_langinfo() +LANGINFO_FLAG = -DHAVE_LANGINFO_H # Makefile for PSUtils under Unix @@ -39,7 +43,7 @@ MANDIR = $(DESTDIR)/usr/man/man$(MANEXT) CC = gcc -CFLAGS = -DPAPER=\"$(PAPER)\" -DUNIX $(RPM_OPT_FLAGS) -Wall +CFLAGS = -DPAPER=\"$(PAPER)\" -DUNIX $(RPM_OPT_FLAGS) $(LANGINFO_FLAG) -Wall BIN = psbook psselect pstops epsffit psnup \ psresize