summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Lang <gsview@ghostgum.com.au>2009-01-08 09:17:18 +0000
committerRussell Lang <gsview@ghostgum.com.au>2009-01-08 09:17:18 +0000
commitcd4914d8f7b3911301ae9db62cee233275c5010a (patch)
tree26f23c0f613a6cefdd59d2dfd4500e9dd900d2d4
parentc9d32ad521db92aa177f677bbae9115d838bd09b (diff)
downloadghostpdl-cd4914d8f7b3911301ae9db62cee233275c5010a.tar.gz
Automatically select the default paper size from the locale
on the Windows platform, and make provision for doing this on Linux. DETAILS: This adds a new platform function gp_defaultpapersize and a new operator .defaultpapersize. In order of priority, the paper size is set from PAPERSIZE, DEFAULTPAPERSIZE, .defaultpapersize, or the compiled in device paper size. It has been tested on Windows 98, XP and Vista. git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@9334 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r--gs/Resource/Init/gs_init.ps23
-rw-r--r--gs/base/gp.h25
-rw-r--r--gs/base/gp_paper.c29
-rw-r--r--gs/base/gp_upapr.c57
-rw-r--r--gs/base/gp_wpapr.c89
-rw-r--r--gs/base/lib.mak10
-rw-r--r--gs/base/macos-mcp.mak2
-rw-r--r--gs/base/openvms.mak2
-rw-r--r--gs/base/openvms.mmk2
-rw-r--r--gs/base/unix-aux.mak4
-rw-r--r--gs/base/watclib.mak2
-rw-r--r--gs/base/winlib.mak5
-rw-r--r--gs/doc/Develop.htm3
-rw-r--r--gs/doc/Language.htm8
-rw-r--r--gs/doc/Use.htm7
-rw-r--r--gs/psi/os2.mak2
-rw-r--r--gs/psi/zmisc.c33
17 files changed, 290 insertions, 13 deletions
diff --git a/gs/Resource/Init/gs_init.ps b/gs/Resource/Init/gs_init.ps
index cea25cc81..0833f76c9 100644
--- a/gs/Resource/Init/gs_init.ps
+++ b/gs/Resource/Init/gs_init.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 1989-2004 Artifex Software, Inc. All rights reserved.
+% Copyright (C) 1989-2009 Artifex Software, Inc. All rights reserved.
%
% This software is provided AS-IS with no warranty, either express or
% implied.
@@ -1752,6 +1752,27 @@ defaultdevice
% If the paper size is not specifed and the device defaults to
% letter or A4 paper, select the DEFAULTPAPERSIZE.
+systemdict /DEFAULTPAPERSIZE known not
+ {
+ % Use .defaultpapersize if it returns a known paper size
+ .defaultpapersize
+ {
+ false statusdict /.pagetypenames get
+ {
+ 2 index eq { pop true exit } if
+ }
+ forall
+ {systemdict exch /DEFAULTPAPERSIZE exch put}
+ {QUIET
+ { pop }
+ { (Unknown .defaultpapersize: ) print ==only (.) = }
+ ifelse
+ }
+ ifelse
+ }
+ if
+ }
+if
systemdict /DEFAULTPAPERSIZE known
systemdict /PAPERSIZE known not and
systemdict /DEVICEWIDTH known not and
diff --git a/gs/base/gp.h b/gs/base/gp.h
index aa61e99b8..6ece24e46 100644
--- a/gs/base/gp.h
+++ b/gs/base/gp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2006 Artifex Software, Inc.
+/* Copyright (C) 2001-2009 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -72,6 +72,29 @@ void gp_do_exit(int exit_status);
*/
const char *gp_strerror(int);
+/*
+ * Get the system default paper size, which is usually letter for
+ * countries using the imperial system, and a4 for countries
+ * using the metric system.
+ *
+ * If there is no default paper size, set *ptr = 0 (if *plen > 0),
+ * set *plen = 1, and return 1.
+ *
+ * If there is a default paper size and the length len of the value
+ * (not counting the terminating \0) is less than *plen,
+ * copy the value to ptr, set *plen = len + 1, and return 0.
+ *
+ * If there is a default paper size and len >= *plen, set *plen = len + 1,
+ * don't store anything at ptr, and return -1.
+ *
+ * Note that *plen is the size of the buffer, not the length of the string:
+ * because of the terminating \0, the maximum string length is 1 less than
+ * the size of the buffer.
+ *
+ * The use of ptr and plen as described above are the same as gp_getenv.
+ */
+int gp_defaultpapersize(char *ptr, int *plen);
+
/* ------ Date and time ------ */
/*
diff --git a/gs/base/gp_paper.c b/gs/base/gp_paper.c
new file mode 100644
index 000000000..808f9f049
--- /dev/null
+++ b/gs/base/gp_paper.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2009 Artifex Software, Inc.
+ All Rights Reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+ implied.
+
+ This software is distributed under license and may not be copied, modified
+ or distributed except as expressly authorized under the terms of that
+ license. Refer to licensing information at http://www.artifex.com/
+ or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
+ San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
+*/
+
+/* $Id:$ */
+/* Standard implementation of gp_defaultpapersize */
+#include "gx.h"
+#include "gp.h"
+
+/* Get the system default paper size. See gp_paper.h for details. */
+int
+gp_defaultpapersize(char *ptr, int *plen)
+{
+
+ /* None available */
+ if (*plen > 0)
+ *ptr = 0;
+ *plen = 1;
+ return 1;
+}
diff --git a/gs/base/gp_upapr.c b/gs/base/gp_upapr.c
new file mode 100644
index 000000000..d74544b1a
--- /dev/null
+++ b/gs/base/gp_upapr.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 2009 Artifex Software, Inc.
+ All Rights Reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+ implied.
+
+ This software is distributed under license and may not be copied, modified
+ or distributed except as expressly authorized under the terms of that
+ license. Refer to licensing information at http://www.artifex.com/
+ or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
+ San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
+*/
+
+/* $Id:$ */
+/* Unix implementation of gp_defaultpapersize */
+
+#ifdef USE_LIBPAPER
+#include <paper.h>
+#endif
+
+#include "string_.h"
+#include "gx.h"
+#include "gp.h"
+
+/* ------ Default paper size ------ */
+
+/* Get the default paper size. See gp_paper.h for details. */
+int
+gp_defaultpapersize(char *ptr, int *plen)
+{
+#ifdef USE_LIBPAPER
+ const char *paper = systempapername();
+
+ if (paper) {
+ int len = strlen(paper);
+
+ if (len < *plen) {
+ /* string fits */
+ strcpy(ptr, paper);
+ *plen = len + 1;
+ return 0;
+ }
+ /* string doesn't fit */
+ *plen = len + 1;
+ return -1;
+ }
+#endif
+
+ /* No default paper size */
+
+ if (*plen > 0)
+ *ptr = 0;
+ *plen = 1;
+ return 1;
+}
+
+
diff --git a/gs/base/gp_wpapr.c b/gs/base/gp_wpapr.c
new file mode 100644
index 000000000..36a6013c0
--- /dev/null
+++ b/gs/base/gp_wpapr.c
@@ -0,0 +1,89 @@
+/* Copyright (C) 2009 Artifex Software, Inc.
+ All Rights Reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+ implied.
+
+ This software is distributed under license and may not be copied, modified
+ or distributed except as expressly authorized under the terms of that
+ license. Refer to licensing information at http://www.artifex.com/
+ or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
+ San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
+*/
+
+/* $Id:$ */
+/* MS Windows implementation of gp_defaultpapersize */
+
+#include <windows.h>
+#include <string.h>
+#include "gx.h"
+#include "gp.h"
+
+/* ------ Default paper size ------ */
+
+/* Get the default paper size. See gp_paper.h for details. */
+int
+gp_defaultpapersize(char *ptr, int *plen)
+{
+ char buf[6];
+ char *paper = NULL;
+
+ /* Determine the default paper size using the Windows locale.
+ * LOCALE_IPAPERSIZE is only supported on Windows 2000 or later.
+ */
+ if (GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_IPAPERSIZE,
+ buf, sizeof(buf))) {
+ int val = atoi(buf);
+ if (val == 1)
+ paper = "letter";
+ else if (val == 5)
+ paper = "legal";
+ else if (val == 8)
+ paper = "a3";
+ else if (val == 9)
+ paper = "a4";
+ }
+
+ /* Fall back to the default paper size method described in
+ * http://msdn.microsoft.com/en-us/library/ms801585.aspx
+ */
+ if ((paper == 0) &&
+ GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_ICOUNTRY,
+ buf, sizeof(buf))) {
+ int country = atoi(buf);
+ if ((country == CTRY_UNITED_STATES) ||
+ (country == CTRY_CANADA) ||
+ ((country >= 50) && (country < 60) && (country != CTRY_BRAZIL)) ||
+ ((country >= 500) && (country < 600)) ) {
+ /* Imperial measurement system */
+ paper = "letter";
+ }
+ else {
+ /* Metric measurement system */
+ paper = "a4";
+ }
+ }
+
+ if (paper) {
+ int len = strlen(paper);
+
+ if (len < *plen) {
+ /* string fits */
+ strcpy(ptr, paper);
+ *plen = len + 1;
+ return 0;
+ }
+ /* string doesn't fit */
+ *plen = len + 1;
+ return -1;
+ }
+
+ /* No default paper size */
+
+ if (*plen > 0)
+ *ptr = 0;
+ *plen = 1;
+ return 1;
+}
+
+
diff --git a/gs/base/lib.mak b/gs/base/lib.mak
index 3418ca381..c88c36361 100644
--- a/gs/base/lib.mak
+++ b/gs/base/lib.mak
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2008 Artifex Software, Inc.
+# Copyright (C) 2001-2009 Artifex Software, Inc.
# All Rights Reserved.
#
# This software is provided AS-IS with no warranty, either express or
@@ -2764,6 +2764,14 @@ $(GLOBJ)gp_getnv.$(OBJ) : $(GLSRC)gp_getnv.c $(AK) $(stdio__h) $(string__h)\
$(gp_h) $(gsmemory_h) $(gstypes_h)
$(GLCC) $(GLO_)gp_getnv.$(OBJ) $(C_) $(GLSRC)gp_getnv.c
+# Standard implementation of gp_defaultpapersize.
+$(GLOBJ)gp_paper.$(OBJ) : $(GLSRC)gp_paper.c $(AK) $(gp_h)
+ $(GLCC) $(GLO_)gp_paper.$(OBJ) $(C_) $(GLSRC)gp_paper.c
+
+# Unix implementation of gp_defaultpapersize.
+$(GLOBJ)gp_upapr.$(OBJ) : $(GLSRC)gp_upapr.c $(AK) $(gp_h)
+ $(GLCC) $(GLO_)gp_upapr.$(OBJ) $(C_) $(GLSRC)gp_upapr.c
+
# File system implementation.
# MS-DOS file system, also used by Desqview/X.
diff --git a/gs/base/macos-mcp.mak b/gs/base/macos-mcp.mak
index e6e75de16..808dcd5d7 100644
--- a/gs/base/macos-mcp.mak
+++ b/gs/base/macos-mcp.mak
@@ -327,7 +327,7 @@ $(GLOBJ)gp_stdin.$(OBJ): $(GLSRC)gp_stdin.c $(AK) $(stdio__h) $(gx_h) $(gp_h)
# ------------------------------------------------------------------- #
MAC1=$(GLOBJ)gp_macio.$(OBJ) $(GLOBJ)gp_mac.$(OBJ) $(GLOBJ)gdevmacxf.$(OBJ) $(GLOBJ)gp_stdin.$(OBJ)
-MAC2=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_nsync.$(OBJ) $(GLOBJ)gdevemap.$(OBJ) $(GLOBJ)gsdll.$(OBJ)
+MAC2=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_paper.$(OBJ) $(GLOBJ)gp_nsync.$(OBJ) $(GLOBJ)gdevemap.$(OBJ) $(GLOBJ)gsdll.$(OBJ)
$(GLD)macos_.dev: $(MAC1)
$(SETMOD) $(DD)macos_ $(MAC1) $(MAC)
diff --git a/gs/base/openvms.mak b/gs/base/openvms.mak
index a846102dd..3463689bd 100644
--- a/gs/base/openvms.mak
+++ b/gs/base/openvms.mak
@@ -444,7 +444,7 @@ $(GS_XE) : openvms $(GLOBJDIR)gs.$(OBJ) $(INT_ALL) $(LIB_ALL)
# OpenVMS.dev
-openvms__=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_vms.$(OBJ) $(GLOBJ)gp_stdia.$(OBJ)
+openvms__=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_paper.$(OBJ) $(GLOBJ)gp_vms.$(OBJ) $(GLOBJ)gp_stdia.$(OBJ)
$(GLGEN)openvms_.dev : $(openvms__) $(GLGEN)nosync.dev
$(SETMOD) $(GLGEN)openvms_ $(openvms__) -include $(GLGEN)nosync
diff --git a/gs/base/openvms.mmk b/gs/base/openvms.mmk
index 0be6861b3..b9db44d49 100644
--- a/gs/base/openvms.mmk
+++ b/gs/base/openvms.mmk
@@ -476,7 +476,7 @@ $(GS_XE) : openvms $(GLGEN)arch.h $(GLOBJDIR)gs.$(OBJ) $(INT_ALL) $(LIB_ALL)
# OpenVMS.dev
-openvms__=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_vms.$(OBJ) $(GLOBJ)gp_stdia.$(OBJ)
+openvms__=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_paper.$(OBJ) $(GLOBJ)gp_vms.$(OBJ) $(GLOBJ)gp_stdia.$(OBJ)
$(GLGEN)openvms_.dev : $(openvms__) $(GLGEN)nosync.dev
$(SETMOD) $(GLGEN)openvms_ $(openvms__) -include $(GLGEN)nosync
diff --git a/gs/base/unix-aux.mak b/gs/base/unix-aux.mak
index f9e45a33e..4b9697e62 100644
--- a/gs/base/unix-aux.mak
+++ b/gs/base/unix-aux.mak
@@ -27,7 +27,7 @@ UNIX_AUX_MAK=$(GLSRC)unix-aux.mak
# Unix platforms other than System V, and also System V Release 4
# (SVR4) platforms.
-unix__=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_unix.$(OBJ) $(GLOBJ)gp_unifs.$(OBJ) $(GLOBJ)gp_unifn.$(OBJ) $(GLOBJ)gp_stdia.$(OBJ) $(GLOBJ)gp_unix_cache.$(OBJ)
+unix__=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_upapr.$(OBJ) $(GLOBJ)gp_unix.$(OBJ) $(GLOBJ)gp_unifs.$(OBJ) $(GLOBJ)gp_unifn.$(OBJ) $(GLOBJ)gp_stdia.$(OBJ) $(GLOBJ)gp_unix_cache.$(OBJ)
$(GLGEN)unix_.dev: $(unix__) $(GLD)nosync.dev $(GLD)smd5.dev
$(SETMOD) $(GLGEN)unix_ $(unix__) -include $(GLD)nosync
$(ADDMOD) $(GLGEN)unix_ -include $(GLD)smd5
@@ -48,7 +48,7 @@ $(GLOBJ)gp_stdia.$(OBJ): $(GLSRC)gp_stdia.c $(AK)\
# System V platforms other than SVR4, which lack some system calls,
# but have pipes.
-sysv__=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_unix.$(OBJ) $(GLOBJ)gp_unifs.$(OBJ) $(GLOBJ)gp_unifn.$(OBJ) $(GLOBJ)gp_sysv.$(OBJ)
+sysv__=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_upapr.$(OBJ) $(GLOBJ)gp_unix.$(OBJ) $(GLOBJ)gp_unifs.$(OBJ) $(GLOBJ)gp_unifn.$(OBJ) $(GLOBJ)gp_sysv.$(OBJ)
$(GLGEN)sysv_.dev: $(sysv__) $(GLD)nosync.dev
$(SETMOD) $(GLGEN)sysv_ $(sysv__) -include $(GLD)nosync
diff --git a/gs/base/watclib.mak b/gs/base/watclib.mak
index 88f300bc8..e1abafaac 100644
--- a/gs/base/watclib.mak
+++ b/gs/base/watclib.mak
@@ -152,7 +152,7 @@ STDIO_IMPLEMENTATION=
GLCCWIN=$(GLCC)
!include $(GLSRCDIR)\winplat.mak
-watclib_1=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_iwatc.$(OBJ)
+watclib_1=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_paper.$(OBJ) $(GLOBJ)gp_iwatc.$(OBJ)
!ifeq WAT32 0
watclib_2=$(GLOBJ)gp_dosfs.$(OBJ) $(GLOBJ)gp_dosfe.$(OBJ) $(GLOBJ)gp_msdos.$(OBJ)
watclib_inc=
diff --git a/gs/base/winlib.mak b/gs/base/winlib.mak
index eef6c9799..9e4c787f5 100644
--- a/gs/base/winlib.mak
+++ b/gs/base/winlib.mak
@@ -133,7 +133,7 @@ $(gconfig__h): $(TOP_MAKEFILES)
# The Windows Win32 platform
-mswin32__=$(GLOBJ)gp_mswin.$(OBJ) $(GLOBJ)gp_wgetv.$(OBJ) $(GLOBJ)gp_stdia.$(OBJ)
+mswin32__=$(GLOBJ)gp_mswin.$(OBJ) $(GLOBJ)gp_wgetv.$(OBJ) $(GLOBJ)gp_wpapr.$(OBJ) $(GLOBJ)gp_stdia.$(OBJ)
mswin32_inc=$(GLD)nosync.dev $(GLD)winplat.dev
$(GLGEN)mswin32_.dev: $(mswin32__) $(ECHOGS_XE) $(mswin32_inc)
@@ -149,6 +149,9 @@ $(GLOBJ)gp_mswin.$(OBJ): $(GLSRC)gp_mswin.c $(AK) $(gp_mswin_h) \
$(GLOBJ)gp_wgetv.$(OBJ): $(GLSRC)gp_wgetv.c $(AK) $(gscdefs_h)
$(GLCCWIN) $(GLO_)gp_wgetv.$(OBJ) $(C_) $(GLSRC)gp_wgetv.c
+$(GLOBJ)gp_wpapr.$(OBJ): $(GLSRC)gp_wpapr.c $(AK) $(gp_h)
+ $(GLCCWIN) $(GLO_)gp_wpapr.$(OBJ) $(C_) $(GLSRC)gp_wpapr.c
+
$(GLOBJ)gp_stdia.$(OBJ): $(GLSRC)gp_stdia.c $(AK)\
$(stdio__h) $(time__h) $(unistd__h) $(gx_h) $(gp_h)
$(GLCCWIN) $(GLO_)gp_stdia.$(OBJ) $(C_) $(GLSRC)gp_stdia.c
diff --git a/gs/doc/Develop.htm b/gs/doc/Develop.htm
index 8bc1fb36e..0ba5c38fc 100644
--- a/gs/doc/Develop.htm
+++ b/gs/doc/Develop.htm
@@ -4282,6 +4282,7 @@ Implementation files shared among multiple platforms:
<a href="../base/gp_getnv.c">base/gp_getnv.c</a>,
<a href="../base/gp_mktmp.c">base/gp_mktmp.c</a>,
<a href="../base/gp_nsync.c">base/gp_nsync.c</a>,
+<a href="../base/gp_paper.c">base/gp_paper.c</a>,
<a href="../base/gp_psync.c">base/gp_psync.c</a>,
<a href="../base/gp_strdl.c">base/gp_strdl.c</a>,
<a href="../base/gpmisc.c">base/gpmisc.c</a>.
@@ -4310,9 +4311,11 @@ Platform-specific implementation files:
<a href="../base/gp_unifs.c">base/gp_unifs.c</a>,
<a href="../base/gp_unix.c">base/gp_unix.c</a>,
<a href="../base/gp_unix.cache.c">base/gp_unix.cache.c</a>,
+<a href="../base/gp_upapr.c">base/gp_upapr.c</a>,
<a href="../base/gp_vms.c">base/gp_vms.c</a>,
<a href="../base/gp_wgetv.c">base/gp_wgetv.c</a>,
<a href="../base/gp_win32.c">base/gp_win32.c</a>,
+<a href="../base/gp_wpapr.c">base/gp_wpapr.c</a>,
<a href="../base/gp_wsync.c">base/gp_wsync.c</a>,
<a href="../base/gs_dll_call.h">base/gs_dll_call.h</a>.
diff --git a/gs/doc/Language.htm b/gs/doc/Language.htm
index 175a42752..87d27789e 100644
--- a/gs/doc/Language.htm
+++ b/gs/doc/Language.htm
@@ -1204,6 +1204,14 @@ false.
</dl>
<dl>
+<dt><code>.defaultpapersize &lt;string&gt; true</code>
+<dt><code>.defaultpapersize false</code>
+<dd>Get the system default paper size, which is usually
+<code>a4</code> for countries using the metric system, and
+<code>letter</code> for countries using the imperial system.
+</dl>
+
+<dl>
<dt><code>&lt;name&gt; &lt;array&gt; .makeoperator &lt;operator&gt;</code>
<dd>Constructs and returns a new operator that is actually the given
procedure in disguise. The name is only used for printing. The operator
diff --git a/gs/doc/Use.htm b/gs/doc/Use.htm
index 8c17b51b4..44be80b26 100644
--- a/gs/doc/Use.htm
+++ b/gs/doc/Use.htm
@@ -474,7 +474,7 @@ page size matches one of the default page sizes.
<p>
You can change the installed default paper size on an installed version of Ghostscript, by editing the initialization file <code>gs_init.ps</code>.
-This file is usually in the <tt>lib</tt> directory somewhere in the search path. See the section on <a href="#Finding_files">finding files</a> for details.
+This file is usually in the <tt>Resource/Init</tt> directory somewhere in the search path. See the section on <a href="#Finding_files">finding files</a> for details.
<p>
Find the line
@@ -502,6 +502,11 @@ This supecedes the previous method of uncommenting the line
<p>
Sometimes the initialization files are compiled into Ghostscript and cannot be changed.
+<p>
+On Windows and some Linux builds, the default paper size will be
+selected to be a4 or letter depending
+on the locale.
+
<h2><a name="Pipes"></a>Interacting with pipes</h2>
<p>
diff --git a/gs/psi/os2.mak b/gs/psi/os2.mak
index 813f6d3b3..d2dc80d3a 100644
--- a/gs/psi/os2.mak
+++ b/gs/psi/os2.mak
@@ -469,7 +469,7 @@ DEVICE_DEVS21= $(DD)spotcmyk.dev $(DD)devicen.dev $(DD)bmpsep1.dev $(DD)bmpsep8.
# The GCC/EMX platform
-os2__=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_os2.$(OBJ) $(GLOBJ)gp_os2fs.$(OBJ) $(GLOBJ)gp_stdia.$(OBJ)
+os2__=$(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_getnv.$(OBJ) $(GLOBJ)gp_os2.$(OBJ) $(GLOBJ)gp_os2fs.$(OBJ) $(GLOBJ)gp_stdia.$(OBJ)
$(GLGEN)os2_.dev: $(os2__) $(GLD)nosync.dev
$(SETMOD) $(GLGEN)os2_ $(os2__) -include $(GLD)nosync
diff --git a/gs/psi/zmisc.c b/gs/psi/zmisc.c
index 08a2ae452..a832a0ae0 100644
--- a/gs/psi/zmisc.c
+++ b/gs/psi/zmisc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2006 Artifex Software, Inc.
+/* Copyright (C) 2001-2009 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -245,6 +245,36 @@ zgetenv(i_ctx_t *i_ctx_p)
return 0;
}
+/* - .defaultpapersize <string> true */
+/* - .defaultpapersize false */
+static int
+zdefaultpapersize(i_ctx_t *i_ctx_p)
+{
+ os_ptr op = osp;
+ byte *value;
+ int len = 0;
+
+ if (gp_defaultpapersize((char *)0, &len) > 0) {
+ /* no default paper size */
+ push(1);
+ make_false(op);
+ return 0;
+ }
+
+ value = ialloc_string(len, "defaultpapersize value");
+ if (value == 0) {
+ return_error(e_VMerror);
+ }
+ DISCARD(gp_defaultpapersize((char *)value, &len)); /* can't fail */
+ /* Delete the stupid C string terminator. */
+ value = iresize_string(value, len, len - 1,
+ "defaultpapersize value"); /* can't fail */
+ push(2);
+ make_string(op - 1, a_all | icurrent_space, len - 1, value);
+ make_true(op);
+ return 0;
+}
+
/* <name> <proc> .makeoperator <oper> */
static int
zmakeoperator(i_ctx_t *i_ctx_p)
@@ -475,6 +505,7 @@ const op_def zmisc_op_defs[] =
{
{"1bind", zbind},
{"1getenv", zgetenv},
+ {"0.defaultpapersize", zdefaultpapersize},
{"2.makeoperator", zmakeoperator},
{"0.oserrno", zoserrno},
{"1.oserrorstring", zoserrorstring},