scm.cpp revision 939e2ecb812c6402abcc63e7d615c5444acfd02e
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * IPRT Testcase / Tool - Source Code Massager.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Copyright (C) 2010 Oracle Corporation
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * available from http://www.virtualbox.org. This file is free software;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * you can redistribute it and/or modify it under the terms of the GNU
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * General Public License (GPL) as published by the Free Software
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/*******************************************************************************
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync* Header Files *
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync*******************************************************************************/
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/*******************************************************************************
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync* Defined Constants And Macros *
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync*******************************************************************************/
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** The name of the settings files. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/*******************************************************************************
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync* Structures and Typedefs *
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync*******************************************************************************/
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to const massager settings. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsynctypedef struct SCMSETTINGSBASE const *PCSCMSETTINGSBASE;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** End of line marker type. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to an end of line marker type. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Line record.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The offset of the line. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The line length, excluding the LF character.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @todo This could be derived from the offset of the next line if that wasn't
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * so tedious. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The end of line marker type. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to a line record. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Source code massager stream.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsynctypedef struct SCMSTREAM
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Pointer to the file memory. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The current stream position. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The current stream size. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The size of the memory pb points to. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Line records. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The current line. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The current stream size given in lines. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The sizeof the the memory backing paLines. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Set if write-only, clear if read-only. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Set if the memory pb points to is from RTFileReadAll. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Set if fully broken into lines. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Stream status code (IPRT). */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to a SCM stream. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to a const SCM stream. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * SVN property.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsynctypedef struct SCMSVNPROP
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The property. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The value.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * When used to record updates, this can be set to NULL to trigger the
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * deletion of the property. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to a SVN property. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to a const SVN property. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Rewriter state.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsynctypedef struct SCMRWSTATE
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The filename. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Set after the printing the first verbose message about a file under
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * rewrite. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The number of SVN property changes. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Pointer to an array of SVN property changes. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to the rewriter state. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * A rewriter.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * This works like a stream editor, reading @a pIn, modifying it and writing it
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * to @a pOut.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @returns true if any changes were made, false if not.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @param pIn The input stream.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @param pOut The output stream.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @param pSettings The settings.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsynctypedef bool (*PFNSCMREWRITER)(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Configuration entry.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsynctypedef struct SCMCFGENTRY
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Number of rewriters. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Pointer to an array of rewriters. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** File pattern (simple). */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Diff state.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsynctypedef struct SCMDIFFSTATE
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Whether to ignore end of line markers when diffing. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Whether to ignore trailing whitespace. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Whether to ignore leading whitespace. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Whether to print special characters in human readable form or not. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The tab size. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Where to push the diff. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to a diff state. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Source Code Massager Settings.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Only process files that are part of a SVN working copy. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Only recurse into directories containing an .svn dir. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Set svn:eol-style if missing or incorrect. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Set svn:executable according to type (unusually this means deleting it). */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Set svn:keyword if completely or partially missing. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Only consider files matching these patterns. This is only applied to the
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * base names. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Filter out files matching the following patterns. This is applied to base
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * names as well as the absolute paths. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Filter out directories matching the following patterns. This is applied
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * to base names as well as the absolute paths. All absolute paths ends with a
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * slash and dot ("/."). */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to massager settings. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Option identifiers.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @note The first chunk, down to SCMOPT_TAB_SIZE, are alternately set &
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * clear. So, the option setting a flag (boolean) will have an even
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * number and the one clearing it will have an odd number.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @note Down to SCMOPT_LAST_SETTINGS corresponds exactly to SCMSETTINGSBASE.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * File/dir pattern + options.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to a pattern + option pair. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to a settings set. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Settings set.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * This structure is constructed from the command line arguments or any
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * .scm-settings file found in a directory we recurse into. When recursing in
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * and out of a directory, we push and pop a settings set for it.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * The .scm-settings file has two kinds of setttings, first there are the
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * unqualified base settings and then there are the settings which applies to a
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * set of files or directories. The former are lines with command line options.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * For the latter, the options are preceded by a string pattern and a colon.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * The pattern specifies which files (and/or directories) the options applies
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * We parse the base options into the Base member and put the others into the
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * paPairs array.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsynctypedef struct SCMSETTINGS
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Pointer to the setting file below us in the stack. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** Pointer to the setting file above us in the stack. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** File/dir patterns and their options. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The number of entires in paPairs. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /** The base settings that was read out of the file. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Pointer to a const settings set. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/*******************************************************************************
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync* Internal Functions *
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync*******************************************************************************/
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool rewrite_StripTrailingBlanks(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool rewrite_ExpandTabs(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool rewrite_ForceNativeEol(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool rewrite_ForceLF(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool rewrite_ForceCRLF(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool rewrite_AdjustTrailingLines(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool rewrite_SvnNoExecutable(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool rewrite_SvnKeywords(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool rewrite_Makefile_kup(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool rewrite_Makefile_kmk(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool rewrite_C_and_CPP(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/*******************************************************************************
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync* Global Variables *
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync*******************************************************************************/
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool g_fDryRun = true;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool g_fDiffSpecialChars = true;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool g_fDiffIgnoreEol = false;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool g_fDiffIgnoreLeadingWS = false;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic bool g_fDiffIgnoreTrailingWS = false;
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** The global settings. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .fConvertEol = */ true,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .fConvertTabs = */ true,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .fForceFinalEol = */ true,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .fForceTrailingLine = */ false,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .fStripTrailingBlanks = */ true,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .fStripTrailingLines = */ true,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .fOnlySvnFiles = */ false,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .fOnlySvnDirs = */ false,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .fSetSvnEol = */ false,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .fSetSvnExecutable = */ false,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .fSetSvnKeywords = */ false,
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .pszFilterOutFiles = */ (char *)"*.exe|*.com|20*-*-*.log",
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* .pszFilterOutDirs = */ (char *)".svn|.hg|.git|CVS",
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Option definitions for the base settings. */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--convert-eol", SCMOPT_CONVERT_EOL, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--no-convert-eol", SCMOPT_NO_CONVERT_EOL, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--convert-tabs", SCMOPT_CONVERT_TABS, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--no-convert-tabs", SCMOPT_NO_CONVERT_TABS, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--force-final-eol", SCMOPT_FORCE_FINAL_EOL, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--no-force-final-eol", SCMOPT_NO_FORCE_FINAL_EOL, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--force-trailing-line", SCMOPT_FORCE_TRAILING_LINE, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--no-force-trailing-line", SCMOPT_NO_FORCE_TRAILING_LINE, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--strip-trailing-blanks", SCMOPT_STRIP_TRAILING_BLANKS, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--no-strip-trailing-blanks", SCMOPT_NO_STRIP_TRAILING_BLANKS, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--strip-trailing-lines", SCMOPT_STRIP_TRAILING_LINES, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--strip-no-trailing-lines", SCMOPT_NO_STRIP_TRAILING_LINES, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--only-svn-dirs", SCMOPT_ONLY_SVN_DIRS, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--not-only-svn-dirs", SCMOPT_NOT_ONLY_SVN_DIRS, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--only-svn-files", SCMOPT_ONLY_SVN_FILES, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--not-only-svn-files", SCMOPT_NOT_ONLY_SVN_FILES, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--set-svn-eol", SCMOPT_SET_SVN_EOL, RTGETOPT_REQ_NOTHING },
67c73271505adae0686ddbc74eaeef778ef16792vboxsync { "--dont-set-svn-eol", SCMOPT_DONT_SET_SVN_EOL, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--set-svn-executable", SCMOPT_SET_SVN_EXECUTABLE, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--dont-set-svn-executable", SCMOPT_DONT_SET_SVN_EXECUTABLE, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--set-svn-keywords", SCMOPT_SET_SVN_KEYWORDS, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--dont-set-svn-keywords", SCMOPT_DONT_SET_SVN_KEYWORDS, RTGETOPT_REQ_NOTHING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--tab-size", SCMOPT_TAB_SIZE, RTGETOPT_REQ_UINT8 },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--filter-out-dirs", SCMOPT_FILTER_OUT_DIRS, RTGETOPT_REQ_STRING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--filter-files", SCMOPT_FILTER_FILES, RTGETOPT_REQ_STRING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { "--filter-out-files", SCMOPT_FILTER_OUT_FILES, RTGETOPT_REQ_STRING },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/** Consider files matching the following patterns (base names only). */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic PFNSCMREWRITER const g_aRewritersFor_Makefile_kup[] =
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic PFNSCMREWRITER const g_aRewritersFor_Makefile_kmk[] =
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic PFNSCMREWRITER const g_aRewritersFor_C_and_CPP[] =
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic PFNSCMREWRITER const g_aRewritersFor_H_and_HPP[] =
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic PFNSCMREWRITER const g_aRewritersFor_ShellScripts[] =
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic PFNSCMREWRITER const g_aRewritersFor_BatchFiles[] =
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { RT_ELEMENTS(g_aRewritersFor_Makefile_kup), &g_aRewritersFor_Makefile_kup[0], "Makefile.kup" },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { RT_ELEMENTS(g_aRewritersFor_Makefile_kmk), &g_aRewritersFor_Makefile_kmk[0], "Makefile.kmk|Config.kmk" },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { RT_ELEMENTS(g_aRewritersFor_C_and_CPP), &g_aRewritersFor_C_and_CPP[0], "*.c|*.cpp|*.C|*.CPP|*.cxx|*.cc" },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { RT_ELEMENTS(g_aRewritersFor_H_and_HPP), &g_aRewritersFor_H_and_HPP[0], "*.h|*.hpp" },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { RT_ELEMENTS(g_aRewritersFor_RC), &g_aRewritersFor_RC[0], "*.rc" },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { RT_ELEMENTS(g_aRewritersFor_ShellScripts), &g_aRewritersFor_ShellScripts[0], "*.sh|configure" },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync { RT_ELEMENTS(g_aRewritersFor_BatchFiles), &g_aRewritersFor_BatchFiles[0], "*.bat|*.cmd|*.btm|*.vbs|*.ps1" },
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync/* -=-=-=-=-=- memory streams -=-=-=-=-=- */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Initializes the stream structure.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @param pStream The stream structure.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @param fWriteOrRead The value of the fWriteOrRead stream member.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncstatic void scmStreamInitInternal(PSCMSTREAM pStream, bool fWriteOrRead)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Initialize an input stream.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @returns IPRT status code.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @param pStream The stream to initialize.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @param pszFilename The file to take the stream content from.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncint ScmStreamInitForReading(PSCMSTREAM pStream, const char *pszFilename)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync scmStreamInitInternal(pStream, false /*fWriteOrRead*/);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync int rc = pStream->rc = RTFileReadAll(pszFilename, &pvFile, &cbFile);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Initialize an output stream.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @returns IPRT status code
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @param pStream The stream to initialize.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @param pRelatedStream Pointer to a related stream. NULL is fine.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsyncint ScmStreamInitForWriting(PSCMSTREAM pStream, PCSCMSTREAM pRelatedStream)
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync scmStreamInitInternal(pStream, true /*fWriteOrRead*/);
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync /* allocate stuff */
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync size_t cLinesEstimate = pRelatedStream && pRelatedStream->fFullyLineated
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync ? pRelatedStream->cLines + pRelatedStream->cLines / 10
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync pStream->paLines = (PSCMSTREAMLINE)RTMemAlloc(cLinesEstimate * sizeof(SCMSTREAMLINE));
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Frees the resources associated with the stream.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * Nothing is happens to whatever the stream was initialized from or dumped to.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync * @param pStream The stream to delete.
ae41886ba231ade1b868dd32ff24ee49813ebbabvboxsync RTFileReadAllFree(pStream->pch, pStream->cbAllocated);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Get the stream status code.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @returns IPRT status code.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param pStream The stream.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Grows the buffer of a write stream.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @returns IPRT status code.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param pStream The stream. Must be in write mode.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param cbAppending The minimum number of bytes to grow the buffer
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsyncstatic int scmStreamGrowBuffer(PSCMSTREAM pStream, size_t cbAppending)
b377a71756cce9f39d25b561f72bfa33ce8a39devboxsync cbAllocated += RT_MAX(0x1000 + cbAppending, cbAllocated);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync pvNew = RTMemDupEx(pStream->pch, pStream->off, cbAllocated - pStream->off);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync RTFileReadAllFree(pStream->pch, pStream->cbAllocated);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Grows the line array of a stream.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @returns IPRT status code.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param pStream The stream.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param iMinLine Minimum line number.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsyncstatic int scmStreamGrowLines(PSCMSTREAM pStream, size_t iMinLine)
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync cLinesAllocated += RT_MAX(512 + iMinLine, cLinesAllocated);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync void *pvNew = RTMemRealloc(pStream->paLines, cLinesAllocated * sizeof(SCMSTREAMLINE));
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Rewinds the stream and sets the mode to read.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param pStream The stream.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Rewinds the stream and sets the mode to write.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param pStream The stream.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Checks if it's a text stream.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Not 100% proof.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @returns true if it probably is a text file, false if not.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param pStream The stream. Write or read, doesn't matter.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync return false;
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync return false;
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync return true;
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Performs an integrity check of the stream.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @returns IPRT status code.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param pStream The stream.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Perform sanity checks.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync for (size_t iLine = 0; iLine < pStream->cLines; iLine++)
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync size_t offEol = pStream->paLines[iLine].off + pStream->paLines[iLine].cch;
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync AssertReturn(offEol + pStream->paLines[iLine].enmEol <= cbFile, VERR_INTERNAL_ERROR_2);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync AssertReturn(pStream->pch[offEol] == '\n', VERR_INTERNAL_ERROR_3);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync AssertReturn(pStream->pch[offEol] == '\r', VERR_INTERNAL_ERROR_3);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync AssertReturn(pStream->pch[offEol + 1] == '\n', VERR_INTERNAL_ERROR_3);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync AssertReturn(iLine + 1 >= pStream->cLines, VERR_INTERNAL_ERROR_4);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync AssertReturn(iLine + 1 >= pStream->cLines, VERR_INTERNAL_ERROR_5);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Writes the stream to a file.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @returns IPRT status code
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param pStream The stream.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param pszFilenameFmt The filename format string.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param ... Format arguments.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsyncint ScmStreamWriteToFile(PSCMSTREAM pStream, const char *pszFilenameFmt, ...)
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Check that what we're going to write makes sense first.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Do the actual writing.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync rc = RTFileOpenV(&hFile, RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_WRITE, pszFilenameFmt, va);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync rc = RTFileWrite(hFile, pStream->pch, pStream->cb, NULL);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Worker for ScmStreamGetLine that builds the line number index while parsing
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * the stream.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @returns Same as SCMStreamGetLine.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param pStream The stream. Must be in read mode.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param pcchLine Where to return the line length.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param penmEol Where to return the kind of end of line marker.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsyncstatic const char *scmStreamGetLineInternal(PSCMSTREAM pStream, size_t *pcchLine, PSCMEOL penmEol)
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync if (RT_UNLIKELY(iLine >= pStream->cLinesAllocated))
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync const char *pch = (const char *)memchr(pchRet, '\n', cb);
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync pStream->paLines[iLine].enmEol = *penmEol = SCMEOL_LF;
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync pStream->paLines[iLine].enmEol = *penmEol = SCMEOL_CRLF;
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync pStream->paLines[iLine].enmEol = *penmEol = SCMEOL_NONE;
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * Internal worker that delineates a stream.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @returns IPRT status code.
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * @param pStream The stream. Caller must check that it is in
bc0c1e33e433d1276ea1606ace81f61594ee3838vboxsync * read mode.
return rc;
return VINF_SUCCESS;
if (offRelative >= 0)
offAbsolute = 0;
return rc;
return VINF_SUCCESS;
static const char *ScmStreamGetLineByNo(PSCMSTREAM pStream, size_t iLine, size_t *pcchLine, PSCMEOL penmEol)
return NULL;
return NULL;
return NULL;
pStream->off = pStream->paLines[iLine].off + pStream->paLines[iLine].cch + pStream->paLines[iLine].enmEol;
return pchRet;
return VERR_EOF;
if (!pchLine)
return cchLine == 0;
return enmEol;
return enmEol;
return rc;
return rc;
return rc;
iLine++;
return VINF_SUCCESS;
return rc;
iLine--;
if (!pchLF)
return rc;
if ( cchLine
cchLine--;
iLine++;
if (!pchLF)
return VINF_SUCCESS;
return VINF_SUCCESS;
while (cLines-- > 0)
if (!pchLine)
return rc;
return VINF_SUCCESS;
static void scmDiffPrintLines(PSCMDIFFSTATE pState, char chPrefix, PSCMSTREAM pStream, size_t iLine, size_t cLines)
while (cLines-- > 0)
while (pchTab)
switch (cchTab)
if (cchLeft)
iLine++;
if (c >= iLeft)
iLeft = c;
cLeft = 0;
if (c >= iRight)
iRight = c;
cRight = 0;
: cRight == 0
RTStrmPrintf(pState->pDiff, "%zu,%zu%c%zu,%zu\n", iLeft + 1, iLeft + cLeft, ch, iRight + 1, iRight + cRight);
if (cLeft)
if (cRight)
cchLeft--;
cchRight--;
const char *pchRight = ScmStreamGetLineByNo(pState->pRight, iRight + iLine, &cchRight, &enmEolRight);
* ones, including iStartLeft/Right.
if (!pchLine)
if (!pchLine)
size_t ScmDiffStreams(const char *pszFilename, PSCMSTREAM pLeft, PSCMSTREAM pRight, bool fIgnoreEol,
#ifdef RT_STRICT
const char *pchLeft;
const char *pchRight;
if (pchLeft)
else if (pchRight)
return VINF_SUCCESS;
return rc;
if (pSettings)
switch (rc)
case SCMOPT_CONVERT_EOL:
return VINF_SUCCESS;
case SCMOPT_NO_CONVERT_EOL:
return VINF_SUCCESS;
case SCMOPT_CONVERT_TABS:
return VINF_SUCCESS;
case SCMOPT_NO_CONVERT_TABS:
return VINF_SUCCESS;
case SCMOPT_FORCE_FINAL_EOL:
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
case SCMOPT_ONLY_SVN_DIRS:
return VINF_SUCCESS;
case SCMOPT_NOT_ONLY_SVN_DIRS:
return VINF_SUCCESS;
case SCMOPT_ONLY_SVN_FILES:
return VINF_SUCCESS;
return VINF_SUCCESS;
case SCMOPT_SET_SVN_EOL:
return VINF_SUCCESS;
case SCMOPT_DONT_SET_SVN_EOL:
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
case SCMOPT_SET_SVN_KEYWORDS:
return VINF_SUCCESS;
return VINF_SUCCESS;
case SCMOPT_TAB_SIZE:
return VERR_OUT_OF_RANGE;
return VINF_SUCCESS;
case SCMOPT_FILTER_OUT_DIRS:
case SCMOPT_FILTER_FILES:
case SCMOPT_FILTER_OUT_FILES:
switch (rc)
pszSrc++;
cchSrc--;
if (!cchSrc)
return VINF_SUCCESS;
return VERR_GETOPT_UNKNOWN_OPTION;
int cArgs;
char **papszArgs;
rc = RTGetOptInit(&GetOptState, cArgs, papszArgs, &g_aScmOpts[0], RT_ELEMENTS(g_aScmOpts), 0, 0 /*fFlags*/);
return rc;
if (!pszLine)
return VERR_NO_MEMORY;
return rc;
return rc;
return VINF_SUCCESS;
if (!pSettings)
return VERR_NO_MEMORY;
return VINF_SUCCESS;
return rc;
if (pSettings)
if (!pchOptions)
return VERR_INVALID_PARAMETER;
pchOptions++;
cchPattern--;
cchOptions--;
return VINF_SUCCESS;
if (!pvNew)
return VERR_NO_MEMORY;
int rc;
return rc;
return rc;
const char *pchLine;
if (pchColon)
return rc;
static int scmSettingsCreateFromFile(PSCMSETTINGS *ppSettings, const char *pszFilename, PCSCMSETTINGSBASE pSettingsBase)
return VINF_SUCCESS;
return rc;
static int scmSettingsCreateForPath(PSCMSETTINGS *ppSettings, PCSCMSETTINGSBASE pBaseSettings, const char *pszPath)
return VERR_FILENAME_TOO_LONG;
return rc;
return rc;
if (pOld)
return VINF_SUCCESS;
return rc;
if (pNew)
if (pRet)
return pRet;
while (pCur)
if (cPairs)
return rc;
if (pszFormat)
#define SCM_WITHOUT_LIBSVN
#ifdef SCM_WITHOUT_LIBSVN
static DECLCALLBACK(int) scmSvnFindSvnBinaryCallback(char const *pchPath, size_t cchPath, void *pvUser1, void *pvUser2)
return VINF_SUCCESS;
return VERR_TRY_AGAIN;
#ifdef RT_OS_WINDOWS
if (pszPath)
static int scmSvnConstructName(PSCMRWSTATE pState, const char *pszDir, const char *pszSuff, char *pszDst)
return VINF_SUCCESS;
return rc;
size_t u = 0;
while (cch-- > 0)
*pu = u;
#ifdef SCM_WITHOUT_LIBSVN
if (!pszValue)
return VERR_NOT_FOUND;
if (ppszValue)
return VINF_SUCCESS;
#ifdef SCM_WITHOUT_LIBSVN
const char *pchLine;
|| cchKey == 0
RTMsgError("%s:%u: Unexpected data '%.*s'\n", szPath, ScmStreamTellLine(&Stream), cchLine, pchLine);
if (fMatch)
if (!pchLine)
if (!pchLine)
RTMsgError("%s:%u: Unexpected data '%.*s'\n", szPath, ScmStreamTellLine(&Stream), cchLine, pchLine);
if (fMatch)
if (!ppszValue)
char *pszValue;
return rc;
return VERR_NOT_FOUND;
if (!pszValue)
char *pszCopy;
return rc;
return VINF_SUCCESS;
if (!pvNew)
return VERR_NO_MEMORY;
return VERR_NO_MEMORY;
return VINF_SUCCESS;
if (pszValue)
return VINF_SUCCESS;
#ifdef SCM_WITHOUT_LIBSVN
return VERR_GENERAL_FAILURE;
return rc;
return VINF_SUCCESS;
return VERR_NOT_IMPLEMENTED;
static bool rewrite_StripTrailingBlanks(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
bool fModified = false;
const char *pchLine;
int rc;
if ( cchLine == 0
cchLine--;
cchLine--;
fModified = true;
if (fModified)
return fModified;
static bool rewrite_ExpandTabs(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
bool fModified = false;
const char *pchLine;
int rc;
if (!pchTab)
if (!pchTab)
fModified = true;
if (fModified)
return fModified;
static bool rewrite_ForceEol(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings,
bool fModified = false;
const char *pchLine;
fModified = true;
if (fModified)
char *pszEol;
return fModified;
static bool rewrite_ForceNativeEol(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
static bool rewrite_ForceLF(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
static bool rewrite_ForceCRLF(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
static bool rewrite_AdjustTrailingLines(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
cLinesNew--;
cLinesNew++;
if ( !fFixMissingEol
else if (fFixMissingEol)
static bool rewrite_SvnNoExecutable(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
static bool rewrite_SvnKeywords(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
char *pszKeywords;
static bool rewrite_Makefile_kup(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
static bool rewrite_Makefile_kmk(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
static bool rewrite_C_and_CPP(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
static int scmProcessFileInner(PSCMRWSTATE pState, const char *pszFilename, const char *pszBasename, size_t cchBasename,
&& !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;
return VINF_SUCCESS;
if (RTStrSimplePatternMultiMatch(g_aConfigs[iCfg].pszFilePattern, RTSTR_MAX, pszBasename, cchBasename, NULL))
if (!pCfg)
return VINF_SUCCESS;
return rc;
bool fModified = false;
if (fRc)
fModified = true;
if (fModified)
if (!g_fDryRun)
if (!g_fDryRun)
return rc;
int rc = scmSettingsStackMakeFileBase(pSettingsStack, pszFilename, pszBasename, cchBasename, &Base);
return rc;
return RTDIRENTRYTYPE_UNKNOWN;
return RTDIRENTRYTYPE_DIRECTORY;
return RTDIRENTRYTYPE_FILE;
return RTDIRENTRYTYPE_UNKNOWN;
int rc;
return rc;
return VINF_SUCCESS;
return rc;
return rc;
return rc;
if (pszBasename)
return rc;
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);
switch (rc)
g_fDryRun = true;
g_fDryRun = false;
bool fAdvanceTwo = false;
if (fAdvanceTwo)
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;
g_iVerbosity = 0;
g_iVerbosity++;
case SCMOPT_DIFF_IGNORE_EOL:
g_fDiffIgnoreEol = true;
g_fDiffIgnoreEol = false;
case SCMOPT_DIFF_IGNORE_SPACE:
g_fDiffIgnoreLeadingWS = true;
g_fDiffIgnoreLeadingWS = false;
g_fDiffIgnoreTrailingWS = true;
g_fDiffIgnoreTrailingWS = false;
g_fDiffSpecialChars = true;
g_fDiffSpecialChars = false;
case VINF_GETOPT_NOT_OPTION:
if (!g_fDryRun)
if (!cProcessed)
cProcessed++;
return rc;