scm.cpp revision f1cdf99d4db5875ae9e1432c7e4a8222e685a0e3
/* $Id$ */
/** @file
* IPRT Testcase / Tool - Source Code Massager.
*/
/*
* Copyright (C) 2010-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/initterm.h>
#include "scm.h"
#include "scmdiff.h"
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** The name of the settings files. */
#define SCM_SETTINGS_FILENAME ".scm-settings"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Option identifiers.
*
* @note The first chunk, down to SCMOPT_TAB_SIZE, are alternately set &
* clear. So, the option setting a flag (boolean) will have an even
* number and the one clearing it will have an odd number.
* @note Down to SCMOPT_LAST_SETTINGS corresponds exactly to SCMSETTINGSBASE.
*/
typedef enum SCMOPT
{
SCMOPT_CONVERT_EOL = 10000,
//
} SCMOPT;
/*******************************************************************************
* Global Variables *
*******************************************************************************/
static const char g_szProgName[] = "scm";
static const char *g_pszChangedSuff = "";
static bool g_fDryRun = true;
static bool g_fDiffSpecialChars = true;
static bool g_fDiffIgnoreEol = false;
static bool g_fDiffIgnoreLeadingWS = false;
static bool g_fDiffIgnoreTrailingWS = false;
/** The global settings. */
static SCMSETTINGSBASE const g_Defaults =
{
/* .fConvertEol = */ true,
/* .fConvertTabs = */ true,
/* .fForceFinalEol = */ true,
/* .fForceTrailingLine = */ false,
/* .fStripTrailingBlanks = */ true,
/* .fStripTrailingLines = */ true,
/* .fOnlySvnFiles = */ false,
/* .fOnlySvnDirs = */ false,
/* .fSetSvnEol = */ false,
/* .fSetSvnExecutable = */ false,
/* .fSetSvnKeywords = */ false,
/* .cchTab = */ 8,
/* .pszFilterFiles = */ (char *)"",
/* .pszFilterOutFiles = */ (char *)"*.exe|*.com|20*-*-*.log",
/* .pszFilterOutDirs = */ (char *)".svn|.hg|.git|CVS",
};
/** Option definitions for the base settings. */
static RTGETOPTDEF g_aScmOpts[] =
{
};
/** Consider files matching the following patterns (base names only). */
static const char *g_pszFileFilter = NULL;
static PFNSCMREWRITER const g_aRewritersFor_Makefile_kup[] =
{
};
static PFNSCMREWRITER const g_aRewritersFor_Makefile_kmk[] =
{
};
static PFNSCMREWRITER const g_aRewritersFor_C_and_CPP[] =
{
};
static PFNSCMREWRITER const g_aRewritersFor_H_and_HPP[] =
{
};
static PFNSCMREWRITER const g_aRewritersFor_RC[] =
{
};
static PFNSCMREWRITER const g_aRewritersFor_ShellScripts[] =
{
};
static PFNSCMREWRITER const g_aRewritersFor_BatchFiles[] =
{
};
static SCMCFGENTRY const g_aConfigs[] =
{
{ RT_ELEMENTS(g_aRewritersFor_Makefile_kmk), &g_aRewritersFor_Makefile_kmk[0], "Makefile.kmk|Config.kmk" },
{ RT_ELEMENTS(g_aRewritersFor_C_and_CPP), &g_aRewritersFor_C_and_CPP[0], "*.c|*.cpp|*.C|*.CPP|*.cxx|*.cc" },
{ RT_ELEMENTS(g_aRewritersFor_BatchFiles), &g_aRewritersFor_BatchFiles[0], "*.bat|*.cmd|*.btm|*.vbs|*.ps1" },
};
/* -=-=-=-=-=- settings -=-=-=-=-=- */
/**
* Init a settings structure with settings from @a pSrc.
*
* @returns IPRT status code
* @param pSettings The settings.
* @param pSrc The source settings.
*/
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
return VINF_SUCCESS;
}
}
return rc;
}
/**
* Init a settings structure.
*
* @returns IPRT status code
* @param pSettings The settings.
*/
{
}
/**
* Deletes the settings, i.e. free any dynamically allocated content.
*
* @param pSettings The settings.
*/
{
if (pSettings)
{
}
}
/**
* Processes a RTGetOpt result.
*
* @retval VINF_SUCCESS if handled.
* @retval VERR_OUT_OF_RANGE if the option value was out of range.
* @retval VERR_GETOPT_UNKNOWN_OPTION if the option was not recognized.
*
* @param pSettings The settings to change.
* @param rc The RTGetOpt return value.
* @param pValueUnion The RTGetOpt value union.
*/
{
switch (rc)
{
case SCMOPT_CONVERT_EOL:
pSettings->fConvertEol = true;
return VINF_SUCCESS;
case SCMOPT_NO_CONVERT_EOL:
pSettings->fConvertEol = false;
return VINF_SUCCESS;
case SCMOPT_CONVERT_TABS:
pSettings->fConvertTabs = true;
return VINF_SUCCESS;
case SCMOPT_NO_CONVERT_TABS:
pSettings->fConvertTabs = false;
return VINF_SUCCESS;
case SCMOPT_FORCE_FINAL_EOL:
pSettings->fForceFinalEol = true;
return VINF_SUCCESS;
pSettings->fForceFinalEol = false;
return VINF_SUCCESS;
pSettings->fForceTrailingLine = true;
return VINF_SUCCESS;
pSettings->fForceTrailingLine = false;
return VINF_SUCCESS;
pSettings->fStripTrailingBlanks = true;
return VINF_SUCCESS;
pSettings->fStripTrailingBlanks = false;
return VINF_SUCCESS;
pSettings->fStripTrailingLines = true;
return VINF_SUCCESS;
pSettings->fStripTrailingLines = false;
return VINF_SUCCESS;
case SCMOPT_ONLY_SVN_DIRS:
pSettings->fOnlySvnDirs = true;
return VINF_SUCCESS;
case SCMOPT_NOT_ONLY_SVN_DIRS:
pSettings->fOnlySvnDirs = false;
return VINF_SUCCESS;
case SCMOPT_ONLY_SVN_FILES:
pSettings->fOnlySvnFiles = true;
return VINF_SUCCESS;
pSettings->fOnlySvnFiles = false;
return VINF_SUCCESS;
case SCMOPT_SET_SVN_EOL:
pSettings->fSetSvnEol = true;
return VINF_SUCCESS;
case SCMOPT_DONT_SET_SVN_EOL:
pSettings->fSetSvnEol = false;
return VINF_SUCCESS;
pSettings->fSetSvnExecutable = true;
return VINF_SUCCESS;
pSettings->fSetSvnExecutable = false;
return VINF_SUCCESS;
case SCMOPT_SET_SVN_KEYWORDS:
pSettings->fSetSvnKeywords = true;
return VINF_SUCCESS;
pSettings->fSetSvnKeywords = false;
return VINF_SUCCESS;
case SCMOPT_TAB_SIZE:
{
RTMsgError("Invalid tab size: %u - must be in {1..%u}\n",
return VERR_OUT_OF_RANGE;
}
return VINF_SUCCESS;
case SCMOPT_FILTER_OUT_DIRS:
case SCMOPT_FILTER_FILES:
case SCMOPT_FILTER_OUT_FILES:
{
switch (rc)
{
}
/*
* An empty string zaps the current list.
*/
if (!*pValueUnion->psz)
return RTStrATruncate(ppsz, 0);
/*
* Non-empty strings are appended to the pattern list.
*
* Strip leading and trailing pattern separators before attempting
* to append it. If it's just separators, don't do anything.
*/
while (*pszSrc == '|')
pszSrc++;
cchSrc--;
if (!cchSrc)
return VINF_SUCCESS;
}
default:
return VERR_GETOPT_UNKNOWN_OPTION;
}
}
/**
* Parses an option string.
*
* @returns IPRT status code.
* @param pBase The base settings structure to apply the options
* to.
* @param pszOptions The options to parse.
*/
{
int cArgs;
char **papszArgs;
if (RT_SUCCESS(rc))
{
rc = RTGetOptInit(&GetOptState, cArgs, papszArgs, &g_aScmOpts[0], RT_ELEMENTS(g_aScmOpts), 0, 0 /*fFlags*/);
if (RT_SUCCESS(rc))
{
{
if (RT_FAILURE(rc))
break;
}
}
}
return rc;
}
/**
* Parses an unterminated option string.
*
* @returns IPRT status code.
* @param pBase The base settings structure to apply the options
* to.
* @param pchLine The line.
* @param cchLine The line length.
*/
{
if (!pszLine)
return VERR_NO_MEMORY;
return rc;
}
/**
* Verifies the options string.
*
* @returns IPRT status code.
* @param pszOptions The options to verify .
*/
static int scmSettingsBaseVerifyString(const char *pszOptions)
{
if (RT_SUCCESS(rc))
{
}
return rc;
}
/**
* Loads settings found in editor and SCM settings directives within the
* document (@a pStream).
*
* @returns IPRT status code.
* @param pBase The settings base to load settings into.
* @param pStream The stream to scan for settings directives.
*/
{
/** @todo Editor and SCM settings directives in documents. */
return VINF_SUCCESS;
}
/**
* Creates a new settings file struct, cloning @a pSettings.
*
* @returns IPRT status code.
* @param ppSettings Where to return the new struct.
* @param pSettingsBase The settings to inherit from.
*/
{
if (!pSettings)
return VERR_NO_MEMORY;
if (RT_SUCCESS(rc))
{
*ppSettings = pSettings;
return VINF_SUCCESS;
}
return rc;
}
/**
* Destroys a settings structure.
*
* @param pSettings The settings structure to destroy. NULL is OK.
*/
{
if (pSettings)
{
{
}
}
}
/**
*
* @returns IPRT status code.
* @param pSettings The settings.
* @param pchLine The line containing the unparsed pair.
* @param cchLine The length of the line.
*/
{
/*
* Split the string.
*/
if (!pchOptions)
return VERR_INVALID_PARAMETER;
pchOptions++;
/* strip spaces everywhere */
cchPattern--;
cchPattern--, pchLine++;
cchOptions--;
cchOptions--, pchOptions++;
/* Quietly ignore empty patterns and empty options. */
if (!cchOptions || !cchPattern)
return VINF_SUCCESS;
/*
* Add the pair and verify the option string.
*/
if ((iPair % 32) == 0)
{
if (!pvNew)
return VERR_NO_MEMORY;
}
int rc;
else
rc = VERR_NO_MEMORY;
if (RT_SUCCESS(rc))
else
{
}
return rc;
}
/**
* Loads in the settings from @a pszFilename.
*
* @returns IPRT status code.
* @param pSettings Where to load the settings file.
* @param pszFilename The file to load.
*/
{
if (RT_FAILURE(rc))
{
return rc;
}
const char *pchLine;
{
/* Ignore leading spaces. */
/* Ignore empty lines and comment lines. */
continue;
/* What kind of line is it? */
if (pchColon)
else
if (RT_FAILURE(rc))
{
break;
}
}
if (RT_SUCCESS(rc))
{
if (RT_FAILURE(rc))
}
return rc;
}
/**
* Parse the specified settings file creating a new settings struct from it.
*
* @returns IPRT status code
* @param ppSettings Where to return the new settings.
* @param pszFilename The file to parse.
* @param pSettingsBase The base settings we inherit from.
*/
static int scmSettingsCreateFromFile(PSCMSETTINGS *ppSettings, const char *pszFilename, PCSCMSETTINGSBASE pSettingsBase)
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
*ppSettings = pSettings;
return VINF_SUCCESS;
}
}
*ppSettings = NULL;
return rc;
}
/**
* Create an initial settings structure when starting processing a new file or
* directory.
*
* This will look for .scm-settings files from the root and down to the
* specified directory, combining them into the returned settings structure.
*
* @returns IPRT status code.
* @param ppSettings Where to return the pointer to the top stack
* object.
* @param pBaseSettings The base settings we inherit from (globals
* typically).
* @param pszPath The absolute path to the new directory or file.
*/
static int scmSettingsCreateForPath(PSCMSETTINGS *ppSettings, PCSCMSETTINGSBASE pBaseSettings, const char *pszPath)
{
/*
* We'll be working with a stack copy of the path.
*/
char szFile[RTPATH_MAX];
return VERR_FILENAME_TOO_LONG;
/*
* Create the bottom-most settings.
*/
if (RT_FAILURE(rc))
return rc;
/*
* Enumerate the path components from the root and down. Load any setting
* files we find.
*/
{
if (RT_SUCCESS(rc))
if (RT_FAILURE(rc))
break;
if (RTFileExists(szFile))
{
if (RT_FAILURE(rc))
break;
}
}
if (RT_SUCCESS(rc))
*ppSettings = pSettings;
else
return rc;
}
/**
* Pushes a new settings set onto the stack.
*
* @param ppSettingsStack The pointer to the pointer to the top stack
* element. This will be used as input and output.
* @param pSettings The settings to push onto the stack.
*/
{
if (pOld)
}
/**
* Pushes the settings of the specified directory onto the stack.
*
* We will load any .scm-settings in the directory. A stack entry is added even
* if no settings file was found.
*
* @returns IPRT status code.
* @param ppSettingsStack The pointer to the pointer to the top stack
* element. This will be used as input and output.
* @param pszDir The directory to do this for.
*/
{
char szFile[RTPATH_MAX];
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
if (RTFileExists(szFile))
if (RT_SUCCESS(rc))
{
return VINF_SUCCESS;
}
}
}
return rc;
}
/**
* Pops a settings set off the stack.
*
* @returns The popped setttings.
* @param ppSettingsStack The pointer to the pointer to the top stack
* element. This will be used as input and output.
*/
{
*ppSettingsStack = pNew;
if (pNew)
if (pRet)
{
}
return pRet;
}
/**
* Pops and destroys the top entry of the stack.
*
* @param ppSettingsStack The pointer to the pointer to the top stack
* element. This will be used as input and output.
*/
{
}
/**
* Constructs the base settings for the specified file name.
*
* @returns IPRT status code.
* @param pSettingsStack The top element on the settings stack.
* @param pszFilename The file name.
* @param pszBasename The base name (pointer within @a pszFilename).
* @param cchBasename The length of the base name. (For passing to
* RTStrSimplePatternMultiMatch.)
* @param pBase Base settings to initialize.
*/
{
if (RT_SUCCESS(rc))
{
/* find the bottom entry in the stack. */
/* Work our way up thru the stack and look for matching pairs. */
while (pCur)
{
if (cPairs)
{
{
if (RT_FAILURE(rc))
break;
}
if (RT_FAILURE(rc))
break;
}
/* advance */
}
}
if (RT_FAILURE(rc))
return rc;
}
/* -=-=-=-=-=- misc -=-=-=-=-=- */
/**
* Prints a verbose message if the level is high enough.
*
* @param pState The rewrite state. Optional.
* @param iLevel The required verbosity level.
* @param pszFormat The message format string. Can be NULL if we
* only want to trigger the per file message.
* @param ... Format arguments.
*/
{
if (iLevel <= g_iVerbosity)
{
{
}
if (pszFormat)
{
? "%s: info: "
: "%s: info: ",
}
}
}
/* -=-=-=-=-=- file and directory processing -=-=-=-=-=- */
/**
* Processes a file.
*
* @returns IPRT status code.
* @param pState The rewriter state.
* @param pszFilename The file name.
* @param pszBasename The base name (pointer within @a pszFilename).
* @param cchBasename The length of the base name. (For passing to
* RTStrSimplePatternMultiMatch.)
* @param pBaseSettings The base settings to use. It's OK to modify
* these.
*/
static int scmProcessFileInner(PSCMRWSTATE pState, const char *pszFilename, const char *pszBasename, size_t cchBasename,
{
/*
* Do the file level filtering.
*/
if ( pBaseSettings->pszFilterFiles
&& !RTStrSimplePatternMultiMatch(pBaseSettings->pszFilterFiles, RTSTR_MAX, pszBasename, cchBasename, NULL))
{
return VINF_SUCCESS;
}
&& ( RTStrSimplePatternMultiMatch(pBaseSettings->pszFilterOutFiles, RTSTR_MAX, pszBasename, cchBasename, NULL)
|| RTStrSimplePatternMultiMatch(pBaseSettings->pszFilterOutFiles, RTSTR_MAX, pszFilename, RTSTR_MAX, NULL)) )
{
return VINF_SUCCESS;
}
if ( pBaseSettings->fOnlySvnFiles
&& !ScmSvnIsInWorkingCopy(pState))
{
return VINF_SUCCESS;
}
/*
* Try find a matching rewrite config for this filename.
*/
if (RTStrSimplePatternMultiMatch(g_aConfigs[iCfg].pszFilePattern, RTSTR_MAX, pszBasename, cchBasename, NULL))
{
break;
}
if (!pCfg)
{
return VINF_SUCCESS;
}
/*
* Create an input stream from the file and check that it's text.
*/
if (RT_FAILURE(rc))
{
return rc;
}
if (ScmStreamIsText(&Stream1))
{
/*
* Gather SCM and editor settings from the stream.
*/
if (RT_SUCCESS(rc))
{
/*
* Create two more streams for output and push the text thru all the
* rewriters, switching the two streams around when something is
* actually rewritten. Stream1 remains unchanged.
*/
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
bool fModified = false;
{
if (fRc)
{
fModified = true;
}
}
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
/*
* If rewritten, write it back to disk.
*/
if (fModified)
{
if (!g_fDryRun)
{
if (RT_FAILURE(rc))
}
else
{
}
}
/*
* If pending SVN property changes, apply them.
*/
{
if (!g_fDryRun)
{
if (RT_FAILURE(rc))
}
else
}
}
else
}
else
}
else
}
else
}
else
return rc;
}
/**
* Processes a file.
*
* This is just a wrapper for scmProcessFileInner for avoid wasting stack in the
* directory recursion method.
*
* @returns IPRT status code.
* @param pszFilename The file name.
* @param pszBasename The base name (pointer within @a pszFilename).
* @param cchBasename The length of the base name. (For passing to
* RTStrSimplePatternMultiMatch.)
* @param pSettingsStack The settings stack (pointer to the top element).
*/
{
int rc = scmSettingsStackMakeFileBase(pSettingsStack, pszFilename, pszBasename, cchBasename, &Base);
if (RT_SUCCESS(rc))
{
State.cSvnPropChanges = 0;
while (i-- > 0)
{
}
}
return rc;
}
/**
* Tries to correct RTDIRENTRY_UNKNOWN.
*
* @returns Corrected type.
* @param pszPath The path to the object in question.
*/
{
if (RT_FAILURE(rc))
return RTDIRENTRYTYPE_UNKNOWN;
return RTDIRENTRYTYPE_DIRECTORY;
return RTDIRENTRYTYPE_FILE;
return RTDIRENTRYTYPE_UNKNOWN;
}
/**
* Recurse into a sub-directory and process all the files and directories.
*
* @returns IPRT status code.
* @param pszBuf Path buffer containing the directory path on
* entry. This ends with a dot. This is passed
* along when recursing in order to save stack space
* and avoid needless copying.
* @param cchDir Length of our path in pszbuf.
* @param pEntry Directory entry buffer. This is also passed
* along when recursing to save stack space.
* @param pSettingsStack The settings stack (pointer to the top element).
* @param iRecursion The recursion depth. This is used to restrict
* the recursions.
*/
{
int rc;
/*
* Make sure we stop somewhere.
*/
if (iRecursion > 128)
{
return VINF_SUCCESS; /* ignore */
}
/*
* Check if it's excluded by --only-svn-dir.
*/
{
if (!ScmSvnIsDirInWorkingCopy(pszBuf))
return VINF_SUCCESS;
}
/*
* Try open and read the directory.
*/
if (RT_FAILURE(rc))
{
return rc;
}
for (;;)
{
/* Read the next entry. */
if (RT_FAILURE(rc))
{
if (rc == VERR_NO_MORE_FILES)
rc = VINF_SUCCESS;
else
break;
}
/* Skip '.' and '..'. */
continue;
/* Enter it into the buffer so we've got a full name to work
with when needed. */
{
continue;
}
/* Figure the type. */
if (enmType == RTDIRENTRYTYPE_UNKNOWN)
/* Process the file or directory, skip the rest. */
if (enmType == RTDIRENTRYTYPE_FILE)
else if (enmType == RTDIRENTRYTYPE_DIRECTORY)
{
/* Append the dot for the benefit of the pattern matching. */
{
continue;
}
)
)
{
if (RT_SUCCESS(rc))
{
}
}
}
if (RT_FAILURE(rc))
break;
}
return rc;
}
/**
* Process a directory tree.
*
* @returns IPRT status code.
* @param pszDir The directory to start with. This is pointer to
* a RTPATH_MAX sized buffer.
*/
{
/*
* Setup the recursion.
*/
if (RT_SUCCESS(rc))
{
}
else
return rc;
}
/**
* Processes a file or directory specified as an command line argument.
*
* @returns IPRT status code
* @param pszSomething What we found in the command line arguments.
* @param pSettingsStack The settings stack (pointer to the top element).
*/
{
char szBuf[RTPATH_MAX];
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
if (RTFileExists(szBuf))
{
if (pszBasename)
{
}
else
{
RTMsgError("RTPathFilename: NULL\n");
}
}
else
}
else
}
else
return rc;
}
{
if (RT_FAILURE(rc))
return 1;
/*
* Init the settings.
*/
if (RT_FAILURE(rc))
{
return 1;
}
/*
* Parse arguments and process input in order (because this is the only
* thing that works at the moment).
*/
{
};
memcpy(&s_aOpts[RT_ELEMENTS(s_aOpts) - RT_ELEMENTS(g_aScmOpts)], &g_aScmOpts[0], sizeof(g_aScmOpts));
rc = RTGetOptInit(&GetOptState, argc, argv, &s_aOpts[0], RT_ELEMENTS(s_aOpts), 1, RTGETOPTINIT_FLAGS_OPTS_FIRST);
size_t cProcessed = 0;
{
switch (rc)
{
case 'd':
g_fDryRun = true;
break;
case 'D':
g_fDryRun = false;
break;
case 'f':
break;
case 'h':
RTPrintf("VirtualBox Source Code Massager\n"
"\n"
"Usage: %s [options] <files & dirs>\n"
"\n"
"Options:\n", g_szProgName);
{
bool fAdvanceTwo = false;
{
);
if (fAdvanceTwo)
else
}
else
{
case SCMOPT_FORCE_TRAILING_LINE: RTPrintf(" Default: %RTbool\n", g_Defaults.fForceTrailingLine); break;
case SCMOPT_STRIP_TRAILING_BLANKS: RTPrintf(" Default: %RTbool\n", g_Defaults.fStripTrailingBlanks); break;
case SCMOPT_STRIP_TRAILING_LINES: RTPrintf(" Default: %RTbool\n", g_Defaults.fStripTrailingLines); break;
case SCMOPT_SET_SVN_EXECUTABLE: RTPrintf(" Default: %RTbool\n", g_Defaults.fSetSvnExecutable); break;
}
i += fAdvanceTwo;
}
return 1;
case 'q':
g_iVerbosity = 0;
break;
case 'v':
g_iVerbosity++;
break;
case 'V':
{
/* The following is assuming that svn does it's job here. */
static const char s_szRev[] = "$Revision$";
return 0;
}
case SCMOPT_DIFF_IGNORE_EOL:
g_fDiffIgnoreEol = true;
break;
g_fDiffIgnoreEol = false;
break;
case SCMOPT_DIFF_IGNORE_SPACE:
break;
g_fDiffIgnoreTrailingWS = g_fDiffIgnoreLeadingWS = false;
break;
g_fDiffIgnoreLeadingWS = true;
break;
g_fDiffIgnoreLeadingWS = false;
break;
g_fDiffIgnoreTrailingWS = true;
break;
g_fDiffIgnoreTrailingWS = false;
break;
g_fDiffSpecialChars = true;
break;
g_fDiffSpecialChars = false;
break;
case VINF_GETOPT_NOT_OPTION:
{
if (!g_fDryRun)
{
if (!cProcessed)
{
RTPrintf("%s: Warning! This program will make changes to your source files and\n"
"%s: there is a slight risk that bugs or a full disk may cause\n"
"%s: LOSS OF DATA. So, please make sure you have checked in\n"
"%s: all your changes already. If you didn't, then don't blame\n"
"%s: anyone for not warning you!\n"
"%s:\n"
"%s: Press any key to continue...\n",
}
cProcessed++;
}
if (RT_FAILURE(rc))
return rc;
break;
}
default:
{
if (RT_SUCCESS(rc2))
break;
if (rc2 != VERR_GETOPT_UNKNOWN_OPTION)
return 2;
}
}
}
return 0;
}