Ticket #3879: winmain.patch

File winmain.patch, 1.6 KB (added by anonymous, 13 years ago)
  • winmain.cpp

     
    3030   
    3131            std::string current;
    3232            bool inside_quoted = false;
     33            bool empty_quote = false;
    3334            int backslash_count = 0;
    3435           
    3536            for(; i != e; ++i) {
     
    3839                    // n/2 backslashes and is a quoted block delimiter
    3940                    if (backslash_count % 2 == 0) {
    4041                        current.append(backslash_count / 2, '\\');
     42                        empty_quote = inside_quoted && current.empty();
    4143                        inside_quoted = !inside_quoted;
    4244                        // '"' preceded by odd number (n) of backslashes generates
    4345                        // (n-1)/2 backslashes and is literal quote.
     
    5961                        // Space outside quoted section terminate the current argument
    6062                        result.push_back(current);
    6163                        current.resize(0);
     64                        empty_quote = false;
    6265                        for(;i != e && isspace((unsigned char)*i); ++i)
    6366                            ;
    6467                        --i;
     
    7477       
    7578            // If we have non-empty 'current' or we're still in quoted
    7679            // section (even if 'current' is empty), add the last token.
    77             if (!current.empty() || inside_quoted)
     80            if (!current.empty() || inside_quoted || empty_quote)
    7881                result.push_back(current);       
    7982        }
    8083        return result;