[PATCH] Cross-platform: progname: Made Path Seperator for Win

Guillem Jover guillem at hadrons.org
Thu Mar 8 01:15:44 UTC 2018


Hi!

On Sun, 2018-03-04 at 23:34:00 +0000, Thorsten Glaser wrote:
> bprogyan at gmail.com dixit:
> 
> >+#if defined(_WIN32) || defined(__WIN32__)
> >+        # define ENV_PATH_SEPERATOR '\\'
> 
> >-	last_slash = strrchr(progname, '/');
> >+	last_slash = strrchr(progname, ENV_PATH_SEPERATOR);
> 
> No, Windows (and DOS and OS/2 and and and…) support both,
> so on these platforms you have to use something like strcspn.

Actually we need to find the last char, so strcspn() would not do. I've
just rewritten the function into a loop from the back, checking for the
valid dir separator(s) depending on the platform.

Thanks,
Guillem


More information about the libbsd mailing list