VirtualBox

Ignore:
Timestamp:
Jun 28, 2011 12:32:13 PM (13 years ago)
Author:
vboxsync
Message:

Runtime/getopt: add new option flag to switch to case insensitive matching

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/getopt.cpp

    r34542 r37665  
    55
    66/*
    7  * Copyright (C) 2007-2010 Oracle Corporation
     7 * Copyright (C) 2007-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    217217                 */
    218218                size_t cchLong = strlen(pOpt->pszLong);
    219                 if (!strncmp(pszOption, pOpt->pszLong, cchLong))
     219                if (   !strncmp(pszOption, pOpt->pszLong, cchLong)
     220                    || (   pOpt->fFlags & RTGETOPT_FLAG_ICASE
     221                        && !RTStrNICmp(pszOption, pOpt->pszLong, cchLong)))
    220222                {
    221223                    if (pOpt->fFlags & RTGETOPT_FLAG_INDEX)
     
    235237                 */
    236238                size_t cchLong = strlen(pOpt->pszLong);
    237                 if (!strncmp(pszOption, pOpt->pszLong, cchLong))
     239                if (   !strncmp(pszOption, pOpt->pszLong, cchLong)
     240                    || (   pOpt->fFlags & RTGETOPT_FLAG_ICASE
     241                        && !RTStrNICmp(pszOption, pOpt->pszLong, cchLong)))
    238242                {
    239243                    while (RT_C_IS_DIGIT(pszOption[cchLong]))
     
    243247                }
    244248            }
    245             else if (!strcmp(pszOption, pOpt->pszLong))
     249            else if (   !strcmp(pszOption, pOpt->pszLong)
     250                     || (   pOpt->fFlags & RTGETOPT_FLAG_ICASE
     251                         && !RTStrICmp(pszOption, pOpt->pszLong)))
    246252                return pOpt;
    247253        }
     
    251257    if (!(fFlags & RTGETOPTINIT_FLAGS_NO_STD_OPTS))
    252258        for (uint32_t i = 0; i < RT_ELEMENTS(g_aStdOptions); i++)
    253             if (!strcmp(pszOption, g_aStdOptions[i].pszLong))
     259            if (   !strcmp(pszOption, g_aStdOptions[i].pszLong)
     260                || (   pOpt->fFlags & RTGETOPT_FLAG_ICASE
     261                    && !RTStrICmp(pszOption, g_aStdOptions[i].pszLong)))
    254262                return &g_aStdOptions[i];
    255263
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