unix: Fix path seperator used depending on OS
';' is the standard seperator used for paths in environment variables on Windows
This commit is contained in:
parent
1e82ef3ae8
commit
df3ab07994
10
unix/main.c
10
unix/main.c
@ -261,6 +261,12 @@ void pre_process_options(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define PATHLIST_SEP_CHAR ';'
|
||||||
|
#else
|
||||||
|
#define PATHLIST_SEP_CHAR ':'
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
volatile int stack_dummy;
|
volatile int stack_dummy;
|
||||||
stack_top = (char*)&stack_dummy;
|
stack_top = (char*)&stack_dummy;
|
||||||
@ -281,7 +287,7 @@ int main(int argc, char **argv) {
|
|||||||
path = "~/.micropython/lib:/usr/lib/micropython";
|
path = "~/.micropython/lib:/usr/lib/micropython";
|
||||||
}
|
}
|
||||||
uint path_num = 1; // [0] is for current dir (or base dir of the script)
|
uint path_num = 1; // [0] is for current dir (or base dir of the script)
|
||||||
for (char *p = path; p != NULL; p = strchr(p, ':')) {
|
for (char *p = path; p != NULL; p = strchr(p, PATHLIST_SEP_CHAR)) {
|
||||||
path_num++;
|
path_num++;
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
p++;
|
p++;
|
||||||
@ -293,7 +299,7 @@ int main(int argc, char **argv) {
|
|||||||
path_items[0] = MP_OBJ_NEW_QSTR(MP_QSTR_);
|
path_items[0] = MP_OBJ_NEW_QSTR(MP_QSTR_);
|
||||||
char *p = path;
|
char *p = path;
|
||||||
for (int i = 1; i < path_num; i++) {
|
for (int i = 1; i < path_num; i++) {
|
||||||
char *p1 = strchr(p, ':');
|
char *p1 = strchr(p, PATHLIST_SEP_CHAR);
|
||||||
if (p1 == NULL) {
|
if (p1 == NULL) {
|
||||||
p1 = p + strlen(p);
|
p1 = p + strlen(p);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user