Ticket #11180 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

wxCmdLineParser should allow "-abcd" as well as "-a -b -c -d" as per the documentation

Reported by: mfunduc Owned by:
Priority: normal Milestone: 2.9.0
Component: base Version: 2.9.0
Keywords: wxCmdLineParser switch parsing Cc:
Blocked By: Patch: yes
Blocking:

Description

Current argument needs to be truncated when the rest is pushed to a new argument.  Patch is below.

Index: cmdline.cpp
===================================================================
--- cmdline.cpp    (revision 237)
+++ cmdline.cpp    (working copy)
@@ -725,6 +725,7 @@
                        // next argument, in fact
                        wxString arg2 = arg[0u];
                        arg2 += arg.Mid(len + 1); // +1 for leading '-'
+                       arg = arg.Left(len + 1);  // The rest gets pushed to the next argument
 
                        m_data->m_arguments.insert
                            (m_data->m_arguments.begin() + n + 1, arg2);

Attachments

cmdline.patch download (0.6 KB) - added by mfunduc 4 years ago.

Change History

Changed 4 years ago by mfunduc

Changed 4 years ago by VZ

  • status changed from new to closed
  • resolution set to fixed

(In [61851]) Fix bug with parsing concatenated switches in wxCmdLineParser.

The constructs such as "-abcd" were not parsed correctly, i.e. the same as "-a
-b -c -d" because the code tried to parse a non-existent option "abcd" even if
it was supposed to not do this -- fix this.

Closes #11180.

Note: See TracTickets for help on using tickets.