--- /dev/null
+--- a2ps-4.13.rh/src/main.c Fri Feb 23 17:39:02 2001
++++ a2ps-4.13.euc/src/main.c Fri Feb 23 23:07:40 2001
+@@ -31,6 +31,8 @@
+ /* */
+ /************************************************************************/
+ #include <assert.h>
++#include <string.h>
++#include <locale.h>
+
+ #include "a2ps.h"
+ #include "argmatch.h"
+@@ -925,6 +927,7 @@
+ main (int argc, char *argv[])
+ {
+ int argn;
++ char *locale;
+
+ /* Architecture specific initialization. */
+ #ifdef __EMX__
+@@ -947,6 +950,9 @@
+ setlocale (LC_CTYPE, "");
+ setlocale (LC_PAPER, "");
+
++ locale = setlocale (LC_ALL, "");
++ /* fprintf(stderr, "locale : %s\n", locale); */
++
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+
+@@ -1013,6 +1019,10 @@
+ yet read sheets. */
+ sheets_map = sheets_map_new ();
+ style_sheets = new_style_sheets ();
++
++ /* Process special case: Japanese Document */
++ if (! strncmp (locale, "ja", 2) )
++ job->requested_encoding_name = xstrdup ("euc-jp");
+
+ /* Process the command line options. */
+ argn = a2ps_handle_options (job, argc, argv);
--- /dev/null
+--- a2ps-4.13/configure.config Wed Feb 9 09:32:31 2000
++++ a2ps-4.13/configure Thu Apr 27 19:56:05 2000
+@@ -8433,9 +8433,13 @@
+ echo "configure:8434: checking for PostScript fonts path" 1>&5
+ # Try to find some PostScript fonts.
+ # Find out if ghostscript is installed
++# for ac_dir in /usr/local/ghostscript/fonts \
++# /usr/local/share/ghostscript/fonts;
+ ac_psfont_path=
+-for ac_dir in /usr/local/ghostscript/fonts \
+- /usr/local/share/ghostscript/fonts;
++for ac_dir in /usr/share/fonts/default/Type1 \
++ /usr/share/fonts/default/ghostscript \
++ /usr/share/fonts/afms/adobe \
++ /usr/share/fonts/ISO8859-2/Type1/afm ;
+ do
+ if test "cd $ac_dir 2>/dev/null && echo *.afm"; then
+ ac_psfont_path="$ac_psfont_path:$ac_dir";
--- /dev/null
+--- a2ps-4.13/etc/Makefile.in.etc Wed Feb 9 09:32:55 2000
++++ a2ps-4.13/etc/Makefile.in Thu Apr 27 22:45:03 2000
+@@ -297,7 +297,9 @@
+
+ # Building the correct a2ps.cfg
+ a2ps.cfg: a2ps_cfg Makefile
+- sed "s!@libpath@!$(libpath)!" a2ps_cfg > a2ps.cfg
++ sed -e "s!@libpath@!$(libpath)!" \
++ -e "s!@apppath@!$(PSFONT_PATH)!" \
++ a2ps_cfg > a2ps.cfg
+
+ # Building a time stamp to know the version.
+ README: README.in Makefile
+--- a2ps-4.13/etc/a2ps_cfg.in.etc Tue Feb 8 03:24:03 2000
++++ a2ps-4.13/etc/a2ps_cfg.in Thu Apr 27 20:49:04 2000
+@@ -73,6 +73,7 @@
+ # It may be useful to extend it so that a2ps can see some
+ # TeX or X11 resources: it likes AFM files and PF[AB] files.
+ #AppendLibraryPath: foo
++AppendLibraryPath: @apppath@
+
+
+ #################################################################
--- /dev/null
+--- a2ps-4.13/lib/Makefile.in.flex Wed Feb 9 09:33:01 2000
++++ a2ps-4.13/lib/Makefile.in Thu Apr 27 19:00:20 2000
+@@ -100,7 +100,7 @@
+ INTLDEPS = @INTLDEPS@
+ INTLLIBS = @INTLLIBS@
+ INTLOBJS = @INTLOBJS@
+-LEX = @LEX@
++LEX = @LEX@ -CFe
+ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+ LIBOBJS = @LIBOBJS@
+ LIBTOOL = @LIBTOOL@
+--- a2ps-4.13/lib/fonts.l.flex Wed Dec 15 18:27:01 1999
++++ a2ps-4.13/lib/fonts.l Thu Apr 27 19:00:20 2000
+@@ -178,7 +178,7 @@
+
+ %}
+
+-%option yylineno
++/* %option yylineno */
+ %option prefix="afm"
+ %option outfile="lex.yy.c"
+
+@@ -524,7 +524,7 @@
+ const char * filename;
+ FILE * stream;
+
+- yylineno = 0;
++ /* yylineno = 0; */
+
+ /* Find its AFM file: first resolve its font file name */
+ filename = fonts_map_resolve_alias (job->fonts_map, font->key);
+--- a2ps-4.13/src/Makefile.in.flex Wed Feb 9 09:34:18 2000
++++ a2ps-4.13/src/Makefile.in Thu Apr 27 19:00:20 2000
+@@ -100,7 +100,7 @@
+ INTLDEPS = @INTLDEPS@
+ INTLLIBS = @INTLLIBS@
+ INTLOBJS = @INTLOBJS@
+-LEX = @LEX@
++LEX = @LEX@ -CFe
+ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+ LIBOBJS = @LIBOBJS@
+ LIBTOOL = @LIBTOOL@
+@@ -154,7 +154,7 @@
+ BUILT_SOURCES = parsessh.h
+
+ YFLAGS = -dtv
+-LEX = @LEX@
++LEX = @LEX@ -CFe
+ # I don't really understand why I have to put srcdir here, but
+ # it is needed for yacc and lex files (seems related to #line, but
+ # I really don't understand why)...
+--- a2ps-4.13/src/lexps.l.flex Mon Feb 7 17:05:43 2000
++++ a2ps-4.13/src/lexps.l Thu Apr 27 19:00:20 2000
+@@ -35,7 +35,7 @@
+ void pslex_initialize PARAMS ((void));
+ %}
+
+-%option yylineno
++/* %option yylineno */
+ %option prefix="ps"
+ %option outfile="lex.yy.c"
+
+--- a2ps-4.13/Makefile.in.flex Wed Feb 9 09:32:25 2000
++++ a2ps-4.13/Makefile.in Thu Apr 27 19:00:20 2000
+@@ -100,7 +100,7 @@
+ INTLDEPS = @INTLDEPS@
+ INTLLIBS = @INTLLIBS@
+ INTLOBJS = @INTLOBJS@
+-LEX = @LEX@
++LEX = @LEX@ -CFe
+ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+ LIBOBJS = @LIBOBJS@
+ LIBTOOL = @LIBTOOL@
--- /dev/null
+--- a2ps-4.13/lib/jobs.c.glibcpaper Sat Jan 15 18:15:07 2000
++++ a2ps-4.13/lib/jobs.c Tue Feb 20 18:44:48 2001
+@@ -138,6 +138,7 @@
+ setlocale (LC_MESSAGES, "");
+ #endif
+ setlocale (LC_CTYPE, "");
++ setlocale (LC_PAPER, "");
+
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+--- a2ps-4.13/lib/options.c.glibcpaper Tue Aug 31 13:42:41 1999
++++ a2ps-4.13/lib/options.c Tue Feb 20 18:44:48 2001
+@@ -54,6 +54,8 @@
+ #include "argv.h"
+ #include "quotearg.h"
+ #include "filalign.h"
++#include <locale.h>
++#include <langinfo.h>
+
+ #define MAN_LINES 66 /* no lines for a man */
+ extern char *program_name;
+@@ -281,7 +283,8 @@
+ struct opt_optarg *opt_optarg_head = NULL;
+ struct opt_optarg *opt_optarg = NULL;
+ int res;
+-
++ unsigned int paper_height=0;
++
+ /* Reset optind so that getopt is reinitialized. */
+ optind = 0;
+
+@@ -545,7 +548,14 @@
+ break;
+
+ case 'M': /* select a medium */
+- xstrcpy (job->medium_request, optarg);
++ if(strcasecmp("_glibc",optarg)==0){
++ paper_height = ((union { char *string; unsigned int word; })nl_langinfo(_NL_PAPER_HEIGHT)).word;
++ if(paper_height==279) /* US Letter */
++ strcpy(optarg,"letter");
++ else /* Everyone else */
++ strcpy(optarg,"a4");
++ }
++ xstrcpy (job->medium_request, optarg);
+ break;
+
+ case 'n': /* n copies */
+--- a2ps-4.13/src/main.c.glibcpaper Wed Jan 26 19:29:15 2000
++++ a2ps-4.13/src/main.c Tue Feb 20 18:45:18 2001
+@@ -945,6 +945,7 @@
+ setlocale (LC_MESSAGES, "");
+ #endif
+ setlocale (LC_CTYPE, "");
++ setlocale (LC_PAPER, "");
+
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
--- /dev/null
+diff -ur a2ps-4.13.orig/lib/routines.c a2ps-4.13/lib/routines.c\r
+--- a2ps-4.13.orig/lib/routines.c Sat Oct 16 06:46:37 1999\r
++++ a2ps-4.13/lib/routines.c Fri Jan 5 12:51:20 2001\r
+@@ -242,3 +242,50 @@\r
+ /* Don't complain if you can't unlink. Who cares of a tmp file? */\r
+ unlink (filename);\r
+ }\r
++\r
++/*\r
++ * Securely generate a temp file, and make sure it gets\r
++ * deleted upon exit.\r
++ */\r
++static char ** tempfiles;\r
++static unsigned ntempfiles;\r
++\r
++static void\r
++cleanup_tempfiles()\r
++{\r
++ while (ntempfiles--)\r
++ unlink(tempfiles[ntempfiles]);\r
++}\r
++\r
++char *\r
++safe_tempnam(const char *pfx)\r
++{\r
++ char *dirname, *filename;\r
++ int fd;\r
++\r
++ if (!(dirname = getenv("TMPDIR")))\r
++ dirname = "/tmp";\r
++\r
++ tempfiles = (char **) realloc(tempfiles,\r
++ (ntempfiles+1) * sizeof(char *));\r
++ if (tempfiles == NULL)\r
++ return NULL;\r
++\r
++ filename = malloc(strlen(dirname) + strlen(pfx) + sizeof("/XXXXXX"));\r
++ if (!filename)\r
++ return NULL;\r
++\r
++ sprintf(filename, "%s/%sXXXXXX", dirname, filename);\r
++\r
++ if ((fd = mkstemp(filename)) < 0) {\r
++ free(filename);\r
++ return NULL;\r
++ }\r
++ close(fd);\r
++\r
++ if (ntempfiles == 0)\r
++ atexit(cleanup_tempfiles);\r
++ tempfiles[ntempfiles++] = filename;\r
++\r
++ return filename;\r
++}\r
+diff -ur a2ps-4.13.orig/lib/routines.h a2ps-4.13/lib/routines.h\r
+--- a2ps-4.13.orig/lib/routines.h Mon Oct 18 22:24:41 1999\r
++++ a2ps-4.13/lib/routines.h Fri Jan 5 12:37:53 2001\r
+@@ -255,7 +255,8 @@\r
+ /* If _STR_ is not defined, give it a tempname in _TMPDIR_ */\r
+ #define tempname_ensure(Str) \\r
+ do { \\r
+- (Str) = (Str) ? (Str) : tempnam (NULL, "a2_"); \\r
++ (Str) = (Str) ? (Str) : safe_tempnam("a2_"); \\r
+ } while (0)\r
++char * safe_tempnam(const char *);\r
+ \r
+ #endif\r