VirtualBox

Changeset 55529 in vbox


Ignore:
Timestamp:
Apr 29, 2015 5:38:33 PM (9 years ago)
Author:
vboxsync
Message:

RTGetOptArgv: Added RTGETOPTARGV_CNV_UNQUOTED.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/getopt.h

    r48934 r55529  
    438438/** Quote strings according to the Unix Bourne Shell. */
    439439#define RTGETOPTARGV_CNV_QUOTE_BOURNE_SH    UINT32_C(1)
     440/** Don't quote any strings at all. */
     441#define RTGETOPTARGV_CNV_UNQUOTED           UINT32_C(2)
    440442/** Mask for the quoting style. */
    441 #define RTGETOPTARGV_CNV_QUOTE_MASK         UINT32_C(1)
     443#define RTGETOPTARGV_CNV_QUOTE_MASK         UINT32_C(3)
    442444/** @} */
    443445
  • trunk/src/VBox/Runtime/common/misc/getoptargv.cpp

    r55494 r55529  
    368368DECLINLINE(bool) rtGetOpArgvRequiresQuoting(const char *pszArg, uint32_t fFlags, size_t *pcch)
    369369{
    370     char const *psz = pszArg;
    371     unsigned char ch;
    372     while ((ch = (unsigned char)*psz))
    373     {
    374         if (   ch < 128
    375             && ASMBitTest(&g_abmQuoteChars[fFlags & RTGETOPTARGV_CNV_QUOTE_MASK], ch))
    376             return true;
    377         psz++;
    378     }
    379 
    380     *pcch = psz - pszArg;
     370    if ((fFlags & RTGETOPTARGV_CNV_QUOTE_MASK) != RTGETOPTARGV_CNV_UNQUOTED)
     371    {
     372        char const *psz = pszArg;
     373        unsigned char ch;
     374        while ((ch = (unsigned char)*psz))
     375        {
     376            if (   ch < 128
     377                && ASMBitTest(&g_abmQuoteChars[fFlags & RTGETOPTARGV_CNV_QUOTE_MASK], ch))
     378                return true;
     379            psz++;
     380        }
     381
     382        *pcch = psz - pszArg;
     383    }
     384    else
     385        *pcch = strlen(pszArg);
    381386    return false;
    382387}
     
    417422RTDECL(int) RTGetOptArgvToString(char **ppszCmdLine, const char * const *papszArgv, uint32_t fFlags)
    418423{
    419     AssertReturn(!(fFlags & ~RTGETOPTARGV_CNV_QUOTE_MASK), VERR_INVALID_PARAMETER);
     424    AssertReturn(fFlags <= RTGETOPTARGV_CNV_UNQUOTED, VERR_INVALID_PARAMETER);
    420425
    421426#define PUT_CH(ch) \
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette