aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-09-10 18:00:36 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-09-10 19:28:22 +1000
commitc9158195f6bf0a73bdd5d057d8db7f182397f17c (patch)
tree45553390d4b6e94636473354165397b01b20a393
parent5161fa8edd5a84f5b02898f13f343254c68eca23 (diff)
downloadbusybox-w32-c9158195f6bf0a73bdd5d057d8db7f182397f17c.tar.gz
busybox-w32-c9158195f6bf0a73bdd5d057d8db7f182397f17c.tar.bz2
busybox-w32-c9158195f6bf0a73bdd5d057d8db7f182397f17c.zip
win32: add next_path_sep()
-rw-r--r--include/mingw.h4
-rw-r--r--win32/process.c20
2 files changed, 24 insertions, 0 deletions
diff --git a/include/mingw.h b/include/mingw.h
index f9773a9a2..57fa6177d 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -309,6 +309,10 @@ pid_t mingw_spawn_1(int mode, const char *cmd, const char *const *argv, const ch
309#define execve mingw_execve 309#define execve mingw_execve
310#define execv mingw_execv 310#define execv mingw_execv
311 311
312const char * next_path_sep(const char *path);
313#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
314#define is_absolute_path(path) ((path)[0] == '/' || has_dos_drive_prefix(path))
315
312/* 316/*
313 * helpers 317 * helpers
314 */ 318 */
diff --git a/win32/process.c b/win32/process.c
index 55f5fef14..0936e1c42 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -9,6 +9,26 @@ int waitpid(pid_t pid, int *status, unsigned options)
9 return -1; 9 return -1;
10} 10}
11 11
12const char *
13next_path_sep(const char *path)
14{
15 static const char *from = NULL, *to;
16 static int has_semicolon;
17 int len = strlen(path);
18
19 if (!from || !(path >= from && path+len <= to)) {
20 from = path;
21 to = from+len;
22 has_semicolon = strchr(path, ';') != NULL;
23 }
24
25 /* Semicolons take precedence, it's Windows PATH */
26 if (has_semicolon)
27 return strchr(path, ';');
28 /* PATH=C:, not really a separator */
29 return strchr(has_dos_drive_prefix(path) ? path+2 : path, ':');
30}
31
12static const char * 32static const char *
13parse_interpreter(const char *cmd) 33parse_interpreter(const char *cmd)
14{ 34{