Re: Fix for 687151, gswin32 starts with 7s delay..., improved log message

Ray Johnston <[email protected]>
Newsgroups gmane.comp.printing.ghostscript.patches
Organization Artifex Software Inc.
Message-ID <[email protected]>
Igor,

I think your code for finding the 'head_size' searching back from
the end is not correct. You check pattern[i] without updating 'i'.

I think you meant:

       for (i = j - 1; i > 0; i--)
          if(pattern[i] == '/' || pattern[i] == '\\' || pattern[i] == ':')
              break;
      hsize = i + 1;

But with no directory serparator, this will terminate with i==0,
setting hsize to 1 instead of 0. You probably also meant to have
the loop run as long as 'i >= 0'.

The code I had initialized hsize=0, so with no directory separator,
hsize would be left at 0.

I agree that some sort of error might bereasonable if there is a
'\*' or '\?' in the template (since these aren't valid characters for
Windows filenames). Also an error might be reasonable if there is
a ? or * in the directory portion (head) since that is not implemented.

I am not sure if 'invalidaccess' is the best error to throw for either
case. Possibly 'ioerror' for the \? an \* case and 'rangecheck' or
'limitcheck' for the second case (although 'limitcheck' is not listed
in the PLRM as a possible error, it tends to be used for implementation
limitations).

When we fix the gp_os2.c and gp_unifs.c cases, we can decide on a
consistent error policy.

Thanks for your input.

Regards,
Ray
______________________________________________________________________
Igor V. Melichev wrote:

> Ray,
> 
> Your \lib/* case is useful.
> 
> But I've got 2 remarks :
> 
> 1. IMO \* and/or \? on Windows and/or OS/2 should return invalidaccess.
> 
> 2. You wrote :
> 
> 
>>!     for (i = 0, j=0; i < patlen; i++) {
>>!       if (pat[i] == '\\') {
>>             i++;
>>!           if (i == patlen)
>>!               break;          /* '\' at end ignored */
>>         }
>>+       pattern[j++]=pat[i];
>>+     }
>>+     /* Scan for last path separator to determine 'head_size' (directory
> 
> part)
> 
>>*/
>>+     for (i = 0; i < j; i++) {
>>+       if(pattern[i] == '/' || pattern[i] == '\\' || pattern[i] == ':')
>>+       hsize = i+1;
>>       }
> 
> 
> I would code it like this :
> 
>      for (i = 0, j=0; i < patlen; i++)
>         if (pat[i] != '\\')
>             pattern[j++]=pat[i];
>      for (i = j - 1; j > 0; j--)
>         if(pattern[i] == '/' || pattern[i] == '\\' || pattern[i] == ':')
>             break;
>     hsize = i + 1;
> 
> Note how the 2nd cycle behaves with no dir separator.
> 
> I suggest to return all this to Alex for refinishing.
> 
> Igor.
> 
> 
> 
> _______________________________________________
> gs-code-review mailing list
> [email protected]
> http://www.ghostscript.com/mailman/listinfo/gs-code-review
> 
> 

-- 
Ray Johnston
Director of Engineering                          Tel: (714) 484-0376
Artifex Software Inc.                            Fax: (714) 220-1022
______________________________________________________________________
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.