From: erg Date: Tue, 19 May 2009 17:28:38 +0000 (+0000) Subject: Fix GPRPATH path handling for Windows X-Git-Tag: LAST_LIBGRAPH~32^2~2044 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39dd0589de7bfc05c1fbec31278348f4b2e05cb4;p=graphviz Fix GPRPATH path handling for Windows --- diff --git a/cmd/gvpr/gvpr.c b/cmd/gvpr/gvpr.c index 261a629d5..9c7a881ad 100644 --- a/cmd/gvpr/gvpr.c +++ b/cmd/gvpr/gvpr.c @@ -44,6 +44,11 @@ #else #include "compat_getopt.h" #endif +#ifdef WIN32 +#include +#include +#include "Shlwapi.h" +#endif char *Info[] = { "gvpr", /* Program */ @@ -175,6 +180,15 @@ static int parseArgs(char *s, int argc, char ***argv) return argc; } + +#ifdef WIN32 +#define PATHSEP '\\' +#define LISTSEP ';' +#else +#define PATHSEP '/' +#define LISTSEP ':' +#endif + /* resolve: * Translate -f arg parameter into a pathname. * If arg contains '/', return arg. @@ -189,7 +203,11 @@ static char *resolve(char *arg) Sfio_t *fp; size_t sz; +#ifdef WIN32 + if (!PathIsRelative (arg)) +#else if (strchr(arg, '/')) +#endif return arg; path = getenv("GPRPATH"); @@ -200,11 +218,11 @@ static char *resolve(char *arg) error(ERROR_FATAL, "Could not open buffer"); while (*path && !fname) { - if (*path == ':') { /* skip colons */ + if (*path == LISTSEP) { /* skip colons */ path++; continue; } - cp = strchr(path, ':'); + cp = strchr(path, LISTSEP); if (cp) { sz = (size_t) (cp - path); sfwrite(fp, path, sz); @@ -213,7 +231,7 @@ static char *resolve(char *arg) sz = sfprintf(fp, path); path += sz; } - sfputc(fp, '/'); + sfputc(fp, PATHSEP); sfprintf(fp, arg); s = sfstruse(fp);