From 6a37ba9eff6456116d933a0bdc7c85802cc33b10 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Tue, 6 Apr 2010 09:51:50 +0200 Subject: win32: process.c: add next_path_sep() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy --- win32/process.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'win32') diff --git a/win32/process.c b/win32/process.c index c97474fb9..5049be030 100644 --- a/win32/process.c +++ b/win32/process.c @@ -9,6 +9,26 @@ int waitpid(pid_t pid, int *status, unsigned options) return -1; } +const char * +next_path_sep(const char *path) +{ + static const char *from = NULL, *to; + static int has_semicolon; + int len = strlen(path); + + if (!from || !(path >= from && path+len <= to)) { + from = path; + to = from+len; + has_semicolon = strchr(path, ';') != NULL; + } + + /* Semicolons take precedence, it's Windows PATH */ + if (has_semicolon) + return strchr(path, ';'); + /* PATH=C:, not really a separator */ + return strchr(has_dos_drive_prefix(path) ? path+2 : path, ':'); +} + /* * Splits the PATH into parts. */ -- cgit v1.2.3-55-g6feb