Discussion:
[gs-bugs] [Bug 698692] - Ghostscript - String modified by putinterval fails to be replaced by def
b***@artifex.com
2017-10-25 00:17:01 UTC
Permalink
http://bugs.ghostscript.com/show_bug.cgi?id=698692

Bug ID: 698692
Summary: String modified by putinterval fails to be replaced by
def
Product: Ghostscript
Version: 9.21
Hardware: Macintosh
OS: MacOS X
Status: UNCONFIRMED
Severity: major
Priority: P4
Component: General
Assignee: ghostpdl-***@artifex.com
Reporter: ***@mavericklabel.com
QA Contact: gs-***@ghostscript.com
Word Size: ---

Created attachment 14412
--> http://bugs.ghostscript.com/attachment.cgi?id=14412&action=edit
Code to reproduce the bug

The following code:

3 {
/testString (abc) def

(testString 1: ) print testString ==

testString 1 (Z) putinterval

(testString 2: ) print testString ==
} repeat

...produces the following output:

testString 1: (abc)
testString 2: (aZc)
testString 1: (aZc)
testString 2: (aZc)
testString 1: (aZc)
testString 2: (aZc)

The "testString 1" log line should always print (abc). Instead, after the first
run through the loop, it reports (aZc), even though the previous line should
replace testString with a fresh copy of (abc).
--
You are receiving this mail because:
You are the QA Contact for the bug.
b***@artifex.com
2017-10-25 07:11:16 UTC
Permalink
http://bugs.ghostscript.com/show_bug.cgi?id=698692

Ken Sharp <***@artifex.com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Severity|major |normal
--
You are receiving this mail because:
You are the QA Contact for the bug.
b***@artifex.com
2017-10-25 07:40:32 UTC
Permalink
http://bugs.ghostscript.com/show_bug.cgi?id=698692

Ken Sharp <***@artifex.com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Component|General |PS Interpreter
Assignee|ghostpdl-***@artifex.com |***@artifex.com

--- Comment #1 from Ken Sharp <***@artifex.com> ---
This isn't actually a fault with putinterval or def, it only happens if running
in a repeat loop.
--
You are receiving this mail because:
You are the QA Contact for the bug.
b***@artifex.com
2017-10-25 08:35:07 UTC
Permalink
http://bugs.ghostscript.com/show_bug.cgi?id=698692

Ken Sharp <***@artifex.com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED

--- Comment #2 from Ken Sharp <***@artifex.com> ---
OK I'm afraid this is one of the murkier areas of PostScript. The behaviour of
Ghostscript in this case is in fact precisely correct. To verify my own
understanding I've checked with Adobe Distiller and a PostScript interpreter
from another manufacturer, both behave identically.

The problem here is with the way that you have defined the procedure. repeat
takes an array and executes the array, so the string definition is actually
part of the array. You can see the same behaviour if you do this:

/myproc
{
/testString (abc) def
(testString 1: ) print testString ==
testString 1 (Z) putinterval
(testString 2: ) print testString ==
} def


myproc
myproc

The result is:

GPL Ghostscript GIT PRERELEASE 9.23 (2017-10-04)
Copyright (C) 2017 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
testString 1: (abc)
testString 2: (aZc)
testString 1: (aZc)
testString 2: (aZc)
GS>

This is rather hard to explain, its essentially a consequence of deferred
execution of the executable array. Because the string is stored as an element
of the array, executing 'def' has no effect on it, whereas executing
putinterval on the string does, because it directly manipulates the array
element.

There doesn't appear to be a bug here, but I readily concede the result is
counter-intuitive.
--
You are receiving this mail because:
You are the QA Contact for the bug.
b***@artifex.com
2017-10-25 15:37:25 UTC
Permalink
This post might be inappropriate. Click to display it.
Loading...