extrac32: Preprocess command line before passing to CommandLineToArgvW().

Sergey Guralnik serhio at etersoft.ru
Thu Apr 4 07:19:22 CDT 2013

Playing with one application, that uses extrac32.exe,
I've found that Wine's extrac32 can't process some
command lines, that cause no problem with native one.
For example builtin extrac32 can't eat command line
like this:
     extrac32 ... "path\to\dir\" "another\path"
Native extrac32 interprets each quoted string above
as separate argument, i.e. arg n - 'path\to\dir\',
arg n + 1 - 'another\path', but builtin does next -
arg n - 'path\to\dir" another\path'

This problem caused by CommandLineToArgvW(), that used
at builtin extrac32 for command line parsing. This API
uses special rules for processing quotes when they
are preceded by backslashes. This behavior leads to
problem described in example above (due \" sequence
after 'path\to\dir').

There are two ways to solve this promlem:
- write own parser for extrac32,
- perform some translation for command line before
   passing to CommandLineToArgvW().

I think that second variant is more appropriate.
Proposed solution translates original command line
to new by using next substitution:
n backslashes + " ==> 2n backslashes + "
This is symmetrical to CommandLineToArgvW's rule,
that causes described problem, and neutralizes it.
And after parsing we get arguments, that are
applicable for next actions.

  programs/extrac32/extrac32.c |   73 
  1 files changed, 72 insertions(+), 1 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-extrac32-Preprocess-command-line-before-passing-to-Com.txt
Type: text/x-c
Size: 3311 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20130404/dfb08aba/attachment-0001.bin>

More information about the wine-patches mailing list