Changeset 69493 in vbox for trunk/src/bldprogs
- Timestamp:
- Oct 28, 2017 2:47:09 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 118832
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/scm.cpp
r69486 r69493 108 108 SCMOPT_TREAT_AS, 109 109 SCMOPT_ADD_ACTION, 110 SCMOPT_LAST_SETTINGS = SCMOPT_ADD_ACTION, 110 SCMOPT_DEL_ACTION, 111 SCMOPT_LAST_SETTINGS = SCMOPT_DEL_ACTION, 111 112 // 112 113 SCMOPT_DIFF_IGNORE_EOL, … … 243 244 { "--treat-as", SCMOPT_TREAT_AS, RTGETOPT_REQ_STRING }, 244 245 { "--add-action", SCMOPT_ADD_ACTION, RTGETOPT_REQ_STRING }, 246 { "--del-action", SCMOPT_DEL_ACTION, RTGETOPT_REQ_STRING }, 245 247 246 248 /* Additional help */ … … 665 667 SCM_CFG_ENTRY("iasl", g_apRewritersFor_DSL, false, "*.dsl" ), 666 668 SCM_CFG_ENTRY("shell", g_apRewritersFor_ShellScripts, false, "*.sh|configure" ), 667 SCM_CFG_ENTRY("bat ",g_apRewritersFor_BatchFiles, false, "*.bat|*.cmd|*.btm" ),669 SCM_CFG_ENTRY("batch", g_apRewritersFor_BatchFiles, false, "*.bat|*.cmd|*.btm" ), 668 670 SCM_CFG_ENTRY("vbs", g_apRewritersFor_BasicScripts, false, "*.vbs|*.vb" ), 669 671 SCM_CFG_ENTRY("sed", g_apRewritersFor_SedScripts, false, "*.sed" ), … … 697 699 /* -=-=-=-=-=- settings -=-=-=-=-=- */ 698 700 701 /** 702 * Delete the given config entry. 703 * 704 * @param pEntry The configuration entry to delete. 705 */ 699 706 static void scmCfgEntryDelete(PSCMCFGENTRY pEntry) 700 707 { … … 704 711 } 705 712 706 static PSCMCFGENTRY scmCfgEntryDup(PCSCMCFGENTRY pEntry) 707 { 708 PSCMCFGENTRY pDup = (PSCMCFGENTRY)RTMemDup(pEntry, sizeof(*pEntry)); 709 if (pDup) 710 { 711 size_t cbRewriters = sizeof(pEntry->paRewriters[0]) * RT_ALIGN_Z(pEntry->cRewriters, 8); 712 pDup->paRewriters = (PCSCMREWRITERCFG const *)RTMemDup(pEntry->paRewriters, cbRewriters); 713 if (pDup->paRewriters) 714 return pDup; 715 716 RTMemFree(pDup); 717 } 718 return NULL; 719 } 720 721 #if 0 713 /** 714 * Create a new configuration entry. 715 * 716 * @returns The new entry. NULL if out of memory. 717 * @param pEntry The configuration entry to duplicate. 718 */ 722 719 static PSCMCFGENTRY scmCfgEntryNew(void) 723 720 { … … 733 730 return pNew; 734 731 } 735 #endif 736 737 static int scmCfgEntryAddAction(PSCMCFGENTRY pEntry, PCSCMREWRITERCFG pActions) 732 733 /** 734 * Duplicate the given config entry. 735 * 736 * @returns The duplicate. NULL if out of memory. 737 * @param pEntry The configuration entry to duplicate. 738 */ 739 static PSCMCFGENTRY scmCfgEntryDup(PCSCMCFGENTRY pEntry) 740 { 741 if (pEntry) 742 { 743 PSCMCFGENTRY pDup = (PSCMCFGENTRY)RTMemDup(pEntry, sizeof(*pEntry)); 744 if (pDup) 745 { 746 size_t cbRewriters = sizeof(pEntry->paRewriters[0]) * RT_ALIGN_Z(pEntry->cRewriters, 8); 747 pDup->paRewriters = (PCSCMREWRITERCFG const *)RTMemDup(pEntry->paRewriters, cbRewriters); 748 if (pDup->paRewriters) 749 return pDup; 750 751 RTMemFree(pDup); 752 } 753 return NULL; 754 } 755 return scmCfgEntryNew(); 756 } 757 758 /** 759 * Adds a rewriter action to the given config entry (--add-action). 760 * 761 * @returns VINF_SUCCESS. 762 * @param pEntry The configuration entry. 763 * @param pAction The rewriter action to add. 764 */ 765 static int scmCfgEntryAddAction(PSCMCFGENTRY pEntry, PCSCMREWRITERCFG pAction) 738 766 { 739 767 PCSCMREWRITERCFG *paRewriters = (PCSCMREWRITERCFG *)pEntry->paRewriters; 740 if ( (pEntry->cRewriters + 1)% 8 == 0)768 if (pEntry->cRewriters % 8 == 0) 741 769 { 742 770 size_t cbRewriters = sizeof(pEntry->paRewriters[0]) * RT_ALIGN_Z((pEntry->cRewriters + 1), 8); … … 748 776 } 749 777 750 paRewriters[pEntry->cRewriters++] = pAction s;778 paRewriters[pEntry->cRewriters++] = pAction; 751 779 return VINF_SUCCESS; 780 } 781 782 /** 783 * Delets an rewriter action from the given config entry (--del-action). 784 * 785 * @param pEntry The configuration entry. 786 * @param pAction The rewriter action to remove. 787 */ 788 static void scmCfgEntryDelAction(PSCMCFGENTRY pEntry, PCSCMREWRITERCFG pAction) 789 { 790 PCSCMREWRITERCFG *paRewriters = (PCSCMREWRITERCFG *)pEntry->paRewriters; 791 size_t const cEntries = pEntry->cRewriters; 792 size_t iDst = 0; 793 for (size_t iSrc = 0; iSrc < cEntries; iSrc++) 794 { 795 PCSCMREWRITERCFG pCurAction = paRewriters[iSrc]; 796 if (pCurAction == pAction) 797 paRewriters[iDst++] = pAction; 798 } 799 pEntry->cRewriters = iDst; 752 800 } 753 801 … … 1126 1174 RTMsgError("Unknown --add-action value '%s'. Try --help-actions for a list.", pValueUnion->psz); 1127 1175 return VERR_NOT_FOUND; 1176 1177 case SCMOPT_DEL_ACTION: 1178 { 1179 uint32_t cActions = 0; 1180 for (uint32_t iAction = 0; iAction < RT_ELEMENTS(g_papRewriterActions); iAction++) 1181 if (RTStrSimplePatternMatch(pValueUnion->psz, g_papRewriterActions[iAction]->pszName)) 1182 { 1183 cActions++; 1184 PSCMCFGENTRY pEntry = (PSCMCFGENTRY)pSettings->pTreatAs; 1185 if (!pSettings->fFreeTreatAs) 1186 { 1187 pEntry = scmCfgEntryDup(pEntry); 1188 if (!pEntry) 1189 return VERR_NO_MEMORY; 1190 pSettings->pTreatAs = pEntry; 1191 pSettings->fFreeTreatAs = true; 1192 } 1193 scmCfgEntryDelAction(pEntry, g_papRewriterActions[iAction]); 1194 if (!strchr(pValueUnion->psz, '*')) 1195 return VINF_SUCCESS; 1196 } 1197 if (cActions > 0) 1198 return VINF_SUCCESS; 1199 RTMsgError("Unknown --del-action value '%s'. Try --help-actions for a list.", pValueUnion->psz); 1200 return VERR_NOT_FOUND; 1201 } 1128 1202 1129 1203 default: … … 2493 2567 } 2494 2568 else if ((paOpts[i].fFlags & RTGETOPT_REQ_MASK) == RTGETOPT_REQ_STRING) 2495 RTPrintf(" %s string\n", paOpts[i].pszLong); 2569 switch (paOpts[i].iShort) 2570 { 2571 case SCMOPT_DEL_ACTION: 2572 RTPrintf(" %s pattern\n", paOpts[i].pszLong); 2573 break; 2574 case SCMOPT_FILTER_OUT_DIRS: 2575 case SCMOPT_FILTER_FILES: 2576 case SCMOPT_FILTER_OUT_FILES: 2577 RTPrintf(" %s multi-pattern\n", paOpts[i].pszLong); 2578 break; 2579 default: 2580 RTPrintf(" %s string\n", paOpts[i].pszLong); 2581 } 2496 2582 else 2497 2583 RTPrintf(" %s value\n", paOpts[i].pszLong); … … 2561 2647 " the action list selected by the --treat-as. The actuion list will be\n" 2562 2648 " flushed by --treat-as.\n"); 2649 break; 2650 2651 case SCMOPT_DEL_ACTION: 2652 RTPrintf(" Deletes one or more rewriter action (pattern). Best used after\n" 2653 " a --treat-as.\n"); 2563 2654 break; 2564 2655
Note:
See TracChangeset
for help on using the changeset viewer.