Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Steven Simpson Newsgroups: comp.lang.java.programmer Subject: Re: exec problem is JDK 1.7.0_21 Date: Thu, 25 Apr 2013 09:50:12 +0100 Organization: A noiseless patient Spider Lines: 44 Message-ID: <4b7n4a-b9d.ln1@s.simpson148.btinternet.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: mx05.eternal-september.org; posting-host="847c23adf71594bde0de355f9bb56936"; logging-data="12553"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wOH/InWnOHpZB/b+xxmD+LcDpHE53auI=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 In-Reply-To: Cancel-Lock: sha1:Xcz/iTYJXczQSMZaB8ZmrEfNvqI= Xref: csiph.com comp.lang.java.programmer:23643 On 25/04/13 09:02, Chris Uppal wrote: > Steven Simpson wrote: > >> Cross-compiled with mingw32: > ... >> int main(void) > What is doing the argument splitting here, and where is its spec ? Um, the call to CommandLineToArgvW here: static void test(const wchar_t *s) { printf("\nInput line: %ls\n", s); int argc; LPWSTR *argv = CommandLineToArgvW(s, &argc); if (!argv) { printf(" unable to parse\n"); } else { printf(" arg count: %d\n", argc); for (int i = 0; i < argc; i++) printf(" [%d]=[%ls]\n", i, argv[i]); LocalFree(argv); } } The program itself takes no arguments. All "command lines" are hard-coded into the program to avoid any possibility of being mangled by any hidden parser (whether it's in the invoking shell or in the program before main() is invoked). Since the command lines are embedded in the program, the only escaping we need to apply to them is as for C strings, which is well understood. The program even prints out both the original command line and the resulting argument list, so we can see both input and output with even the C-string escaping removed. The 'spec' for CommandLineToArgvW: -- ss at comp dot lancs dot ac dot uk