On Wed, May 31, 2006 at 01:04:30AM +0000, Angus Leeming wrote:
> Enrico Forestieri <[EMAIL PROTECTED]> writes:
> > Agreed. But what's your point? I didn't mean to correct the possibly
> > broken dvipost code but only to let it work (or not work) on Windows
> > in the same way it works (or doesn't work) on *nix.
> 
> Fair enough.
> 
> Note, however, that "foo\bar/baz" is a valid path on Windows and might be
> expected to work the same way as the equally valid "foo/bar/baz".
> 
> Personally, I'd change your code to something like
> 
>   char* p1 = strrchr(arg, '/');
>   char* p2 = strrchr(arg, '\\');
>   /* Not sure whether the casts are needed. */
>   char* p = ((void*)p2 > (void*)p1) ? p2 : p1;

The casts are not needed if both pointers are pointing into the same
string (the unlikely case). If either is 0, you produce undefined behaviour.

Andre'

Reply via email to