Show More
@@ -25,7 +25,7 b' from ctypes.wintypes import LPCWSTR, HLOCAL' | |||||
25 | from subprocess import STDOUT |
|
25 | from subprocess import STDOUT | |
26 |
|
26 | |||
27 | # our own imports |
|
27 | # our own imports | |
28 | from ._process_common import read_no_interrupt, process_handler |
|
28 | from ._process_common import read_no_interrupt, process_handler, arg_split as py_arg_split | |
29 | from . import py3compat |
|
29 | from . import py3compat | |
30 | from . import text |
|
30 | from . import text | |
31 |
|
31 | |||
@@ -159,15 +159,20 b' try:' | |||||
159 | LocalFree.res_type = HLOCAL |
|
159 | LocalFree.res_type = HLOCAL | |
160 | LocalFree.arg_types = [HLOCAL] |
|
160 | LocalFree.arg_types = [HLOCAL] | |
161 |
|
161 | |||
162 | def arg_split(commandline, posix=False): |
|
162 | def arg_split(commandline, posix=False, strict=True): | |
163 | """Split a command line's arguments in a shell-like manner. |
|
163 | """Split a command line's arguments in a shell-like manner. | |
164 |
|
164 | |||
165 | This is a special version for windows that use a ctypes call to CommandLineToArgvW |
|
165 | This is a special version for windows that use a ctypes call to CommandLineToArgvW | |
166 | to do the argv splitting. The posix paramter is ignored. |
|
166 | to do the argv splitting. The posix paramter is ignored. | |
|
167 | ||||
|
168 | If strict=False, process_common.arg_split(...strict=False) is used instead. | |||
167 | """ |
|
169 | """ | |
168 | #CommandLineToArgvW returns path to executable if called with empty string. |
|
170 | #CommandLineToArgvW returns path to executable if called with empty string. | |
169 | if commandline.strip() == "": |
|
171 | if commandline.strip() == "": | |
170 | return [] |
|
172 | return [] | |
|
173 | if not strict: | |||
|
174 | # not really a cl-arg, fallback on _process_common | |||
|
175 | return py_arg_split(commandline, posix=posix, strict=strict) | |||
171 | argvn = c_int() |
|
176 | argvn = c_int() | |
172 | result_pointer = CommandLineToArgvW(py3compat.cast_unicode(commandline.lstrip()), ctypes.byref(argvn)) |
|
177 | result_pointer = CommandLineToArgvW(py3compat.cast_unicode(commandline.lstrip()), ctypes.byref(argvn)) | |
173 | result_array_type = LPCWSTR * argvn.value |
|
178 | result_array_type = LPCWSTR * argvn.value | |
@@ -175,4 +180,4 b' try:' | |||||
175 | retval = LocalFree(result_pointer) |
|
180 | retval = LocalFree(result_pointer) | |
176 | return result |
|
181 | return result | |
177 | except AttributeError: |
|
182 | except AttributeError: | |
178 | from ._process_common import arg_split |
|
183 | arg_split = py_arg_split |
General Comments 0
You need to be logged in to leave comments.
Login now