[gs-commits] rev 11515 - trunk/gs/Resource/Init

alexcher at ghostscript.com alexcher at ghostscript.com
Fri Jul 16 20:40:49 UTC 2010


Author: alexcher
Date: 2010-07-16 20:40:49 +0000 (Fri, 16 Jul 2010)
New Revision: 11515

Modified:
   trunk/gs/Resource/Init/gs_res.ps
Log:
Fix the bug that prevented recognition of GenericResourceDir/Category/Name
as a valid resource path and required inclusion of GenericResourceDir in
the search path to find the same resource by searching.

New procedure does the following:
1. Returns GenericResourceDir/Category/Name if it exists.
2. Searches for Category/Name in LIBPATH. Returns actual path if found.
3. For non-existing resources return the same path as (1).

Old implementation added GenericResourceDir twice, didn't close files,
used system memory, called expensive procedures twice, etc.

Regression testing shows trivial differences in 23-07.ps, which prints
the length of ResourceFileName procedure.
This is a partial fix for bug 691408.


Modified: trunk/gs/Resource/Init/gs_res.ps
===================================================================
--- trunk/gs/Resource/Init/gs_res.ps	2010-07-16 19:58:03 UTC (rev 11514)
+++ trunk/gs/Resource/Init/gs_res.ps	2010-07-16 20:40:49 UTC (rev 11515)
@@ -558,45 +558,28 @@
 	{ forall } 0 get
   	currentdict end 2 .execn begin
 } bind
-/.file_name_is_iodevice_or_absolute
-{ {
-    dup length 0 gt {
-      dup 0 get (%) 0 get eq {
-        pop true exit
-      } if
-    } if
-    .file_name_is_absolute exit
-  } loop
-} bind def
-/ResourceFileName
-	  {                                             % /in (scr)
+
+/ResourceFileName  {                          % /in (scr) --> (p/c/n)
 	    exch //.rfnstring cvs                       % (scr) (n)
             /GenericResourcePathSep getsystemparam exch % (scr) (/) (n)
             Category .namestring                        % (scr) (/) (n) (c)
             3 1 roll                                    % (scr) (c) (/) (n)
 	    concatstrings concatstrings                 % (scr) (c/n)
-            /GenericResourceDir getsystemparam //.file_name_is_iodevice_or_absolute exec not {
-              /GenericResourceDir getsystemparam exch concatstrings
-	      findlibfile
-	      {                                         % (scr) (p/c/n) file
-	        pop exch copy true                      % (p/c/n) true
-	      } {                                       % (scr) (c/n)
-	        false                                   % (scr) (c/n) false
+  /GenericResourceDir getsystemparam 1 index  % (scr) (c/n) (p/) (c/n)
+  concatstrings                               % (scr) (c/n) (p/c/n)
+  dup status {
+    pop pop pop pop exch pop                  % (scr) (p/c/n)
+  } {
+    exch                                      % (scr) (p/c/n) (c/n)
+    .libfile {
+      dup .filename pop                       % (scr) (p/c/n) file (p/c/n')
+      exch closefile                          % (scr) (p/c/n) (p/c/n')
+      exch pop                                % (scr) (p/c/n')
+    } {
+      pop                                     % (scr) (p/c/n)
 	      } ifelse
-	    } {                                         % (scr) (c/n)
-	      false                                     % (scr) (c/n) false
 	    } ifelse
-	    not {                                       % (scr) (c/n)
-              /GenericResourceDir getsystemparam        % (scr) (c/n) (d/)
-              dup length exch                           % (scr) (c/n) Ld (d/)
-              3 index copy pop                          % (scr') (c/n) Ld
-              1 index length                            % (scr') (c/n) Ld Lcn
-              3 index 3 copy pop                        % (scr') (c/n) Ld Lcn (scr') Ld Lcn
-              getinterval                               % (scr') (c/n) Ld Lcn (scr[Ld:Lcn])
-              4 3 roll exch                             % (scr') Ld Lcn (c/n) (scr[Ld:Lcn])
-              copy pop                                  % (scr'') Ld Lcn
-              add 0 exch getinterval                    % (scr''[0:Ld+Lcn])
-	    } if
+  exch copy                                   % (p/c/n)
 	  } bind
 
 		% Additional entries



More information about the gs-commits mailing list