[PATCH v2 0/6] Allow spaces in loader options

2017-08-24 Thread Justin Cinkelj
v1 patch failed on simple ./scripts/run.py -e "/asdf" Problem was in: [PATCH 4/6] command line: use loader_parse_cmdline core/commands:cc assert(cmdline == __loader_argv[0]); v2 updates only this. The string returned by strdup is now stored into static variable, so it can be easly free-d later.

[PATCH v2 6/6] command line: check for empty cmdline case after parsing cmdline

2017-08-24 Thread Justin Cinkelj
Always parse app_cmdline. It there is nothing to run, commands array will be empty. Signed-off-by: Justin Cinkelj --- loader.cc | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/loader.cc b/loader.cc index 504e230..c3a7256 100644 --- a/loader.cc +++ b/loader.cc @@ -295,

[PATCH v2 2/6] libc: fix of-by-one error in stresep

2017-08-24 Thread Justin Cinkelj
memcpy had of-by-one error. Also, remove unneeded defines. Signed-off-by: Justin Cinkelj --- libc/string/stresep.c | 16 ++-- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/libc/string/stresep.c b/libc/string/stresep.c index 4d72391..5ac4b85 100644 --- a/libc/string/s

[PATCH v2 3/6] command line: add loader_parse_cmdline with tests

2017-08-24 Thread Justin Cinkelj
loader_parse_cmdline accepts input str - OSv commandline, say: --env=AA=aa --env=BB=bb1\ bb2 app.so arg1 arg2 The loader options are parsed and saved into argv, up to first not-loader-option token. argc is set to number of loader options. app_cmdline is set to unconsumed part of input str. Note:

[PATCH v2 4/6] command line: use loader_parse_cmdline

2017-08-24 Thread Justin Cinkelj
Parse loader options with loader_parse_cmdline instead of strtok_r. The cmdline passed in prepare_commands to osv::parse_command_line is not reassebled from already parsed argv anymore, as app_cmdline contains unmodifed commandline string (only loader options are removed). Minor bug: commandline w

[PATCH v2 1/6] libc: add stresep

2017-08-24 Thread Justin Cinkelj
File is literal copy from ftp.tku.edu.tw/NetBSD/NetBSD-current/src/lib/libc/string/stresep.c Signed-off-by: Justin Cinkelj --- Makefile | 1 + include/api/string.h | 1 + libc/string/stresep.c | 94 +++ 3 files changed, 96 insertion

[PATCH v2 5/6] command line: add tests for empty commandline string parsing

2017-08-24 Thread Justin Cinkelj
Signed-off-by: Justin Cinkelj --- tests/tst-commands.cc | 57 +++ 1 file changed, 57 insertions(+) diff --git a/tests/tst-commands.cc b/tests/tst-commands.cc index 78f4155..cc7ffdc 100644 --- a/tests/tst-commands.cc +++ b/tests/tst-commands.cc @@ -

[PATCH 6/6] command line: check for empty cmdline case after parsing cmdline

2017-08-24 Thread Justin Cinkelj
Always parse app_cmdline. It there is nothing to run, commands array will be empty. Signed-off-by: Justin Cinkelj --- loader.cc | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/loader.cc b/loader.cc index 504e230..c3a7256 100644 --- a/loader.cc +++ b/loader.cc @@ -295,

[PATCH 3/6] command line: add loader_parse_cmdline with tests

2017-08-24 Thread Justin Cinkelj
loader_parse_cmdline accepts input str - OSv commandline, say: --env=AA=aa --env=BB=bb1\ bb2 app.so arg1 arg2 The loader options are parsed and saved into argv, up to first not-loader-option token. argc is set to number of loader options. app_cmdline is set to unconsumed part of input str. Note:

[PATCH 5/6] command line: add tests for empty commandline string parsing

2017-08-24 Thread Justin Cinkelj
Signed-off-by: Justin Cinkelj --- tests/tst-commands.cc | 57 +++ 1 file changed, 57 insertions(+) diff --git a/tests/tst-commands.cc b/tests/tst-commands.cc index 78f4155..cc7ffdc 100644 --- a/tests/tst-commands.cc +++ b/tests/tst-commands.cc @@ -

[PATCH 4/6] command line: use loader_parse_cmdline

2017-08-24 Thread Justin Cinkelj
Parse loader options with loader_parse_cmdline instead of strtok_r. The cmdline passed in prepare_commands to osv::parse_command_line is not reassebled from already parsed argv anymore, as app_cmdline contains unmodifed commandline string (only loader options are removed). Minor bug: commandline w

[PATCH 2/6] libc: fix of-by-one error in stresep

2017-08-24 Thread Justin Cinkelj
memcpy had of-by-one error. Also, remove unneeded defines. Signed-off-by: Justin Cinkelj --- libc/string/stresep.c | 16 ++-- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/libc/string/stresep.c b/libc/string/stresep.c index 4d72391..5ac4b85 100644 --- a/libc/string/s

[PATCH 0/6] Allow spaces in loader options

2017-08-24 Thread Justin Cinkelj
This patches allow to set environment variables with spaces via run.py, as is run.py -e '--env=AAA=aaa\ bbb /hello_env.so arg1 arg2' The spaces has to be escaped with \. stresep implementation is from NetBSD. The hello-world example of using stresep (NetSBD man page, http://netbsd.gw.com/cgi-bin/

[PATCH 1/6] libc: add stresep

2017-08-24 Thread Justin Cinkelj
File is literal copy from ftp.tku.edu.tw/NetBSD/NetBSD-current/src/lib/libc/string/stresep.c Signed-off-by: Justin Cinkelj --- Makefile | 1 + include/api/string.h | 1 + libc/string/stresep.c | 94 +++ 3 files changed, 96 insertion