VirtualBox

Changeset 69316 in vbox for trunk


Ignore:
Timestamp:
Oct 25, 2017 3:02:31 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
118640
Message:

scm: added --treat-as option

Location:
trunk/src/bldprogs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bldprogs/scm.cpp

    r69312 r69316  
    102102    SCMOPT_TAB_SIZE,
    103103    SCMOPT_WIDTH,
     104    SCMOPT_TREAT_AS,
    104105    SCMOPT_FILTER_OUT_DIRS,
    105106    SCMOPT_FILTER_FILES,
     
    176177    /* .cchTab = */                                 8,
    177178    /* .cchWidth = */                               130,
     179    /* .pszTreatAsName = */                         NULL,
    178180    /* .pszFilterFiles = */                         (char *)"",
    179181    /* .pszFilterOutFiles = */                      (char *)"*.exe|*.com|20*-*-*.log",
     
    225227    { "--tab-size",                         SCMOPT_TAB_SIZE,                        RTGETOPT_REQ_UINT8   },
    226228    { "--width",                            SCMOPT_WIDTH,                           RTGETOPT_REQ_UINT8   },
     229    { "--treat-as",                         SCMOPT_TREAT_AS,                        RTGETOPT_REQ_STRING  },
    227230    { "--filter-out-dirs",                  SCMOPT_FILTER_OUT_DIRS,                 RTGETOPT_REQ_STRING  },
    228231    { "--filter-files",                     SCMOPT_FILTER_FILES,                    RTGETOPT_REQ_STRING  },
     
    518521            rc = RTStrDupEx(&pSettings->pszFilterOutDirs, pSrc->pszFilterOutDirs);
    519522            if (RT_SUCCESS(rc))
    520                 return VINF_SUCCESS;
    521 
     523            {
     524                if (pSrc->pszTreatAsName)
     525                    rc = RTStrDupEx(&pSettings->pszTreatAsName, pSrc->pszTreatAsName);
     526                if (RT_SUCCESS(rc))
     527                    return VINF_SUCCESS;
     528
     529                RTStrFree(pSettings->pszFilterOutDirs);
     530            }
    522531            RTStrFree(pSettings->pszFilterOutFiles);
    523532        }
     
    528537    pSettings->pszFilterOutFiles = NULL;
    529538    pSettings->pszFilterOutDirs = NULL;
     539    pSettings->pszTreatAsName = NULL;
    530540    return rc;
    531541}
     
    562572        RTStrFree(pSettings->pszFilterOutDirs);
    563573        pSettings->pszFilterOutDirs = NULL;
     574
     575        RTStrFree(pSettings->pszTreatAsName);
     576        pSettings->pszTreatAsName = NULL;
    564577    }
    565578}
     
    735748            }
    736749            pSettings->cchWidth = pValueUnion->u8;
     750            return VINF_SUCCESS;
     751
     752        case SCMOPT_TREAT_AS:
     753            if (pSettings->pszTreatAsName)
     754            {
     755                RTStrFree(pSettings->pszTreatAsName);
     756                pSettings->pszTreatAsName = NULL;
     757            }
     758            if (*pValueUnion->psz)
     759            {
     760                pSettings->pszTreatAsName = RTStrDup(pValueUnion->psz);
     761                if (!pSettings->pszTreatAsName)
     762                    return VERR_NO_MEMORY;
     763            }
    737764            return VINF_SUCCESS;
    738765
     
    15101537     */
    15111538    PCSCMCFGENTRY pCfg = NULL;
    1512     for (size_t iCfg = 0; iCfg < RT_ELEMENTS(g_aConfigs); iCfg++)
    1513         if (RTStrSimplePatternMultiMatch(g_aConfigs[iCfg].pszFilePattern, RTSTR_MAX, pszBasename, cchBasename, NULL))
    1514         {
    1515             pCfg = &g_aConfigs[iCfg];
    1516             break;
    1517         }
     1539    if (!pBaseSettings->pszTreatAsName)
     1540    {
     1541        for (size_t iCfg = 0; iCfg < RT_ELEMENTS(g_aConfigs); iCfg++)
     1542            if (RTStrSimplePatternMultiMatch(g_aConfigs[iCfg].pszFilePattern, RTSTR_MAX, pszBasename, cchBasename, NULL))
     1543            {
     1544                pCfg = &g_aConfigs[iCfg];
     1545                break;
     1546            }
     1547    }
     1548    else
     1549    {
     1550        size_t cchTreatAsName = strlen(pBaseSettings->pszTreatAsName);
     1551        for (size_t iCfg = 0; iCfg < RT_ELEMENTS(g_aConfigs); iCfg++)
     1552            if (RTStrSimplePatternMultiMatch(g_aConfigs[iCfg].pszFilePattern, RTSTR_MAX,
     1553                                             pBaseSettings->pszTreatAsName, cchTreatAsName, NULL))
     1554            {
     1555                pCfg = &g_aConfigs[iCfg];
     1556                break;
     1557            }
     1558    }
    15181559    if (!pCfg)
    15191560    {
     
    20322073            case SCMOPT_TAB_SIZE:               RTPrintf("      Default: %u\n", g_Defaults.cchTab); break;
    20332074            case SCMOPT_WIDTH:                  RTPrintf("      Default: %u\n", g_Defaults.cchWidth); break;
     2075
     2076            case SCMOPT_TREAT_AS:
     2077                RTPrintf("      For files not using the default extension.\n");
     2078                break;
     2079
    20342080            case SCMOPT_FILTER_OUT_DIRS:        RTPrintf("      Default: %s\n", g_Defaults.pszFilterOutDirs); break;
    20352081            case SCMOPT_FILTER_FILES:           RTPrintf("      Default: %s\n", g_Defaults.pszFilterFiles); break;
  • trunk/src/bldprogs/scm.h

    r69295 r69316  
    287287    /** Optimal source code width. */
    288288    uint8_t         cchWidth;
     289    /** Treat the file as if it had the given name (for finding SCMCFGENTRY). */
     290    char           *pszTreatAsName;
    289291    /** Only consider files matching these patterns.  This is only applied to the
    290292     *  base names. */
Note: See TracChangeset for help on using the changeset viewer.

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