Skip to content

Commit

Permalink
Added option "Ignore numbers" (#1025)
Browse files Browse the repository at this point in the history
* added ignore numbers option

* updated .po files

* fixed Merge.rc

* actually using options flag for numbers

* added ignore numbers to toolbar menu

* added unit test IgnoreNumbers

* re-added some german translations

* added ignore numbers option
updated .po files

* actually using options flag for numbers

* added ignore numbers to toolbar menu

* added unit test IgnoreNumbers

* prepare for merge

* setting private build stringdiffs.cpp.orig
* skip building ARM64 in BuildAll.vs2019x64_vs2017Win32.cmd
* disabled UploadToVirusTotal.cmd

* updated ChangeLog to include option "ignore numbers"

* cleanung build scripts

Co-authored-by: wittenburg <wittenburg@optimal-systems.de>
  • Loading branch information
evoc and wittenburg committed Oct 28, 2021
1 parent 98ff3fb commit d1175ec
Show file tree
Hide file tree
Showing 65 changed files with 443 additions and 125 deletions.
1 change: 1 addition & 0 deletions Docs/Users/ChangeLog.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ <h2 id="winmerge-21616---2021-10-28">WinMerge 2.16.16 - 2021-10-28</h2>
<h3 id="general">General</h3>
<ul>
<li>Fix a problem where the string in the Windows common dialog would not change to the language when switching languages.</li>
<li>New Option to ignore numbers.</li>
</ul>
<h3 id="file-compare">File compare</h3>
<ul>
Expand Down
1 change: 1 addition & 0 deletions Docs/Users/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Fix a problem where the string in the Windows common dialog would not
change to the language when switching languages.
- New Option to ignore numbers.

### File compare

Expand Down
2 changes: 1 addition & 1 deletion Externals/winimerge
1 change: 1 addition & 0 deletions Src/CompareEngines/ByteComparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ ByteComparator::ByteComparator(const QuickCompareOptions * options)
: m_ignore_case(options->m_bIgnoreCase)
, m_ignore_eol_diff(options->m_bIgnoreEOLDifference)
, m_ignore_blank_lines(options->m_bIgnoreBlankLines)
, m_ignore_numbers(options->m_bIgnoreNumbers)
// state
, m_wsflag(false)
, m_eol0(false)
Expand Down
1 change: 1 addition & 0 deletions Src/CompareEngines/ByteComparator.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ByteComparator
private:
// settings
bool m_ignore_case; /**< Ignore character case */
bool m_ignore_numbers; /**< Ignore character case */
bool m_ignore_space_change; /**< Ignore change in whitespace char count */
bool m_ignore_all_space; /**< Ignore all whitespace changes */
bool m_ignore_eol_diff; /**< Ignore differences in EOL bytes */
Expand Down
8 changes: 7 additions & 1 deletion Src/CompareOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ CompareOptions::CompareOptions()
, m_bIgnoreBlankLines(false)
, m_bIgnoreCase(false)
, m_bIgnoreEOLDifference(false)
, m_bIgnoreNumbers(false)
{
}

Expand All @@ -30,6 +31,7 @@ CompareOptions::CompareOptions(const CompareOptions & options)
, m_bIgnoreBlankLines(options.m_bIgnoreBlankLines)
, m_bIgnoreCase(options.m_bIgnoreCase)
, m_bIgnoreEOLDifference(options.m_bIgnoreEOLDifference)
, m_bIgnoreNumbers(options.m_bIgnoreNumbers)
{
}

Expand Down Expand Up @@ -72,6 +74,7 @@ void CompareOptions::SetFromDiffOptions(const DIFFOPTIONS &options)
m_bIgnoreBlankLines = options.bIgnoreBlankLines;
m_bIgnoreCase = options.bIgnoreCase;
m_bIgnoreEOLDifference = options.bIgnoreEol;
m_bIgnoreNumbers = options.bIgnoreNumbers;
}

/**
Expand Down Expand Up @@ -191,6 +194,8 @@ void DiffutilsOptions::SetToDiffUtils()
else
ignore_case_flag = 0;

ignore_numbers_flag = m_bIgnoreNumbers ? 1 : 0;

if (m_bIgnoreEOLDifference)
ignore_eol_diff = 1;
else
Expand Down Expand Up @@ -225,7 +230,8 @@ void DiffutilsOptions::GetAsDiffOptions(DIFFOPTIONS &options) const
options.bIgnoreBlankLines = m_bIgnoreBlankLines;
options.bIgnoreCase = m_bIgnoreCase;
options.bIgnoreEol = m_bIgnoreEOLDifference;

options.bIgnoreNumbers = m_bIgnoreNumbers;

switch (m_ignoreWhitespace)
{
case WHITESPACE_COMPARE_ALL:
Expand Down
2 changes: 2 additions & 0 deletions Src/CompareOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ struct DIFFOPTIONS
{
int nIgnoreWhitespace; /**< Ignore whitespace -option. */
bool bIgnoreCase; /**< Ignore case -option. */
bool bIgnoreNumbers; /**< Ignore numbers -option. */
bool bIgnoreBlankLines; /**< Ignore blank lines -option. */
bool bIgnoreEol; /**< Ignore EOL differences -option. */
bool bFilterCommentsLines; /**< Ignore Multiline comments differences -option. */
Expand All @@ -102,6 +103,7 @@ class CompareOptions
enum WhitespaceIgnoreChoices m_ignoreWhitespace; /**< Ignore whitespace characters */
bool m_bIgnoreBlankLines; /**< Ignore blank lines (both sides) */
bool m_bIgnoreCase; /**< Ignore case differences? */
bool m_bIgnoreNumbers; /**< Ignore number differences? */
bool m_bIgnoreEOLDifference; /**< Ignore EOL style differences? */
};

Expand Down
28 changes: 28 additions & 0 deletions Src/DiffWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,27 @@ static void ReplaceSpaces(std::string & str, const char *rep)
pos += replen;
}
}

/**
* @brief Replace spaces in a string
* @param [in] str - String to search
* @param [in] rep - String to replace
*/
static void ReplaceNumbers(std::string& str, const char* rep)
{
std::string::size_type pos = 0;
size_t replen = strlen(rep);
while ((pos = str.find_first_of("0123456789", pos)) != std::string::npos)
{
std::string::size_type posend = str.find_first_not_of("0123456789", pos);
if (posend != String::npos)
str.replace(pos, posend - pos, rep);
else
str.replace(pos, 1, rep);
pos += replen;
}
}

/**
@brief The main entry for post filtering. Performs post-filtering, by setting comment blocks to trivial
@param [in] LineNumberLeft - First line number to read from left file
Expand Down Expand Up @@ -369,6 +390,13 @@ void CDiffWrapper::PostFilter(PostFilterContext& ctxt, int LineNumberLeft, int Q
ReplaceSpaces(LineDataRight, " ");
}

if (m_options.m_bIgnoreNumbers )
{
//Ignore number character case
ReplaceNumbers(LineDataLeft, "");
ReplaceNumbers(LineDataRight, "");
}

if (m_options.m_bIgnoreCase)
{
//ignore case
Expand Down
14 changes: 14 additions & 0 deletions Src/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
ON_UPDATE_COMMAND_UI_RANGE(ID_DIFF_OPTIONS_WHITESPACE_COMPARE, ID_DIFF_OPTIONS_WHITESPACE_IGNOREALL, OnUpdateDiffWhitespace)
ON_COMMAND(ID_DIFF_OPTIONS_IGNORE_BLANKLINES, OnDiffIgnoreBlankLines)
ON_UPDATE_COMMAND_UI(ID_DIFF_OPTIONS_IGNORE_BLANKLINES, OnUpdateDiffIgnoreBlankLines)
ON_COMMAND(IDC_DIFF_IGNORENUMBERS, OnDiffIgnoreNumbers)
ON_UPDATE_COMMAND_UI(IDC_DIFF_IGNORENUMBERS, OnUpdateDiffIgnoreNumbers)
ON_COMMAND(ID_DIFF_OPTIONS_IGNORE_CASE, OnDiffIgnoreCase)
ON_UPDATE_COMMAND_UI(ID_DIFF_OPTIONS_IGNORE_CASE, OnUpdateDiffIgnoreCase)
ON_COMMAND(ID_DIFF_OPTIONS_IGNORE_EOL, OnDiffIgnoreEOL)
Expand Down Expand Up @@ -2710,6 +2712,18 @@ void CMainFrame::OnUpdateDiffIgnoreCase(CCmdUI* pCmdUI)
pCmdUI->Enable();
}

void CMainFrame::OnDiffIgnoreNumbers()
{
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_NUMBERS, !GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_NUMBERS));
ApplyDiffOptions();
}

void CMainFrame::OnUpdateDiffIgnoreNumbers(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_NUMBERS));
pCmdUI->Enable();
}

void CMainFrame::OnDiffIgnoreEOL()
{
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_EOL, !GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_EOL));
Expand Down
2 changes: 2 additions & 0 deletions Src/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ class CMainFrame : public CMDIFrameWnd
afx_msg void OnUpdateDiffIgnoreBlankLines(CCmdUI* pCmdUI);
afx_msg void OnDiffIgnoreCase();
afx_msg void OnUpdateDiffIgnoreCase(CCmdUI* pCmdUI);
afx_msg void OnDiffIgnoreNumbers();
afx_msg void OnUpdateDiffIgnoreNumbers(CCmdUI* pCmdUI);
afx_msg void OnDiffIgnoreEOL();
afx_msg void OnUpdateDiffIgnoreEOL(CCmdUI* pCmdUI);
afx_msg void OnDiffIgnoreCP();
Expand Down
19 changes: 11 additions & 8 deletions Src/Merge.rc
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ BEGIN
MENUITEM "Ignore &case", ID_DIFF_OPTIONS_IGNORE_CASE
MENUITEM "Igno&re carriage return differences (Windows/Unix/Mac)", ID_DIFF_OPTIONS_IGNORE_EOL
MENUITEM "Ignore codepage &differences", ID_DIFF_OPTIONS_IGNORE_CODEPAGE
MENUITEM "Ignore num&bers", IDC_DIFF_IGNORENUMBERS
MENUITEM "Ignore c&omment differences" ,ID_DIFF_OPTIONS_IGNORE_COMMENTS
MENUITEM SEPARATOR
MENUITEM "&Include Subfolders", ID_DIFF_OPTIONS_INCLUDE_SUBFOLDERS
Expand Down Expand Up @@ -1564,15 +1565,17 @@ BEGIN
CONTROL "Ignore &case",IDC_IGNCASE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,72,239,10
CONTROL "Igno&re carriage return differences (Windows/Unix/Mac)",IDC_EOL_SENSITIVE,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,84,239,10
CONTROL "Ignore codepage &differences",IDC_CP_SENSITIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,96,239,10
CONTROL "Ignore c&omment differences",IDC_FILTERCOMMENTS_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,108,239,10
CONTROL "E&nable moved block detection",IDC_MOVED_BLOCKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,120,239,10
CONTROL "&Match similar lines",IDC_MATCH_SIMILAR_LINES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,132,239,10
LTEXT "Diff &algorithm (Experimental):",IDC_STATIC,7,144,239,10
COMBOBOX IDC_DIFF_ALGORITHM,6,156,240,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Enable indent &heuristic",IDC_INDENT_HEURISTIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,174,239,10
CONTROL "Ignore num&bers",IDC_IGNORE_NUMBERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,96,239,10
CONTROL "Ignore codepage &differences",IDC_CP_SENSITIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,108,239,10
CONTROL "Ignore c&omment differences",IDC_FILTERCOMMENTS_CHECK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,120,239,10
CONTROL "E&nable moved block detection",IDC_MOVED_BLOCKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,132,239,10
CONTROL "&Match similar lines",IDC_MATCH_SIMILAR_LINES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,144,239,10
LTEXT "Diff &algorithm (Experimental):",IDC_STATIC,7,156,239,10
COMBOBOX IDC_DIFF_ALGORITHM,6,168,240,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Enable indent &heuristic",IDC_INDENT_HEURISTIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,186,239,10
CONTROL "Completely unhighlight the ignored differences",IDC_COMPLETELY_BLANK_OUT_IGNORED_DIFFERENCES,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,186,239,10
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,198,239,10
PUSHBUTTON "Defaults",IDC_COMPARE_DEFAULTS,161,228,88,14
END

Expand Down
1 change: 1 addition & 0 deletions Src/MergeDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ void CMergeDoc::FlagTrivialLines(void)
!diffOptions.bIgnoreCase,
!diffOptions.bIgnoreEol,
diffOptions.nIgnoreWhitespace,
diffOptions.bIgnoreNumbers,
GetBreakType(), // whitespace only or include punctuation
GetByteColoringOption());
if (!worddiffs.empty())
Expand Down
2 changes: 1 addition & 1 deletion Src/MergeDocDiffSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int CMergeDoc::GetMatchCost(const String &sLine0, const String &sLine1)
int breakType = GetBreakType(); // whitespace only or include punctuation
bool byteColoring = GetByteColoringOption();

std::vector<strdiff::wdiff> worddiffs = strdiff::ComputeWordDiffs(2, str, casitive, eolSensitive, xwhite, breakType, byteColoring);
std::vector<strdiff::wdiff> worddiffs = strdiff::ComputeWordDiffs(2, str, casitive, eolSensitive, xwhite, diffOptions.bIgnoreNumbers, breakType, byteColoring);

int nDiffLenSum = 0;
for (std::vector<strdiff::wdiff>::const_iterator it = worddiffs.begin(); it != worddiffs.end(); ++it)
Expand Down
2 changes: 1 addition & 1 deletion Src/MergeDocLineDiffs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ std::vector<WordDiff> CMergeDoc::GetWordDiffArray(int nLineIndex)
bool byteColoring = GetByteColoringOption();

// Make the call to stringdiffs, which does all the hard & tedious computations
std::vector<strdiff::wdiff> wdiffs = strdiff::ComputeWordDiffs(m_nBuffers, str, casitive, eolSensitive, xwhite, breakType, byteColoring);
std::vector<strdiff::wdiff> wdiffs = strdiff::ComputeWordDiffs(m_nBuffers, str, casitive, eolSensitive, xwhite, diffOptions.bIgnoreNumbers ,breakType, byteColoring);

int i;
std::vector<strdiff::wdiff>::iterator it;
Expand Down
1 change: 1 addition & 0 deletions Src/OptionsDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ inline const String OPT_CMP_IGNORE_WHITESPACE {_T("Settings/IgnoreSpace"s)};
inline const String OPT_CMP_IGNORE_BLANKLINES {_T("Settings/IgnoreBlankLines"s)};
inline const String OPT_CMP_FILTER_COMMENTLINES {_T("Settings/FilterCommentsLines"s)};
inline const String OPT_CMP_IGNORE_CASE {_T("Settings/IgnoreCase"s)};
inline const String OPT_CMP_IGNORE_NUMBERS {_T("Settings/IgnoreNumbers"s)};
inline const String OPT_CMP_IGNORE_EOL {_T("Settings/IgnoreEol"s)};
inline const String OPT_CMP_IGNORE_CODEPAGE {_T("Settings/IgnoreCodepage"s)};
inline const String OPT_CMP_METHOD {_T("Settings/CompMethod2"s)};
Expand Down
3 changes: 3 additions & 0 deletions Src/OptionsDiffOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void Init(COptionsMgr *pOptionsMgr)
pOptionsMgr->InitOption(OPT_CMP_IGNORE_BLANKLINES, false);
pOptionsMgr->InitOption(OPT_CMP_FILTER_COMMENTLINES, false);
pOptionsMgr->InitOption(OPT_CMP_IGNORE_CASE, false);
pOptionsMgr->InitOption(OPT_CMP_IGNORE_NUMBERS, false);
pOptionsMgr->InitOption(OPT_CMP_IGNORE_EOL, false);
pOptionsMgr->InitOption(OPT_CMP_DIFF_ALGORITHM, (int)0, 0, 3);
pOptionsMgr->InitOption(OPT_CMP_INDENT_HEURISTIC, true);
Expand All @@ -32,6 +33,7 @@ void Load(const COptionsMgr *pOptionsMgr, DIFFOPTIONS& options)
options.bIgnoreBlankLines = pOptionsMgr->GetBool(OPT_CMP_IGNORE_BLANKLINES);
options.bFilterCommentsLines = pOptionsMgr->GetBool(OPT_CMP_FILTER_COMMENTLINES);
options.bIgnoreCase = pOptionsMgr->GetBool(OPT_CMP_IGNORE_CASE);
options.bIgnoreNumbers = pOptionsMgr->GetBool(OPT_CMP_IGNORE_NUMBERS);
options.bIgnoreEol = pOptionsMgr->GetBool(OPT_CMP_IGNORE_EOL);
options.nDiffAlgorithm = pOptionsMgr->GetInt(OPT_CMP_DIFF_ALGORITHM);
options.bIndentHeuristic = pOptionsMgr->GetBool(OPT_CMP_INDENT_HEURISTIC);
Expand All @@ -44,6 +46,7 @@ void Save(COptionsMgr *pOptionsMgr, const DIFFOPTIONS& options)
pOptionsMgr->SaveOption(OPT_CMP_IGNORE_BLANKLINES, options.bIgnoreBlankLines);
pOptionsMgr->SaveOption(OPT_CMP_FILTER_COMMENTLINES, options.bFilterCommentsLines);
pOptionsMgr->SaveOption(OPT_CMP_IGNORE_CASE, options.bIgnoreCase);
pOptionsMgr->SaveOption(OPT_CMP_IGNORE_NUMBERS, options.bIgnoreNumbers);
pOptionsMgr->SaveOption(OPT_CMP_IGNORE_EOL, options.bIgnoreEol);
pOptionsMgr->SaveOption(OPT_CMP_DIFF_ALGORITHM, options.nDiffAlgorithm);
pOptionsMgr->SaveOption(OPT_CMP_INDENT_HEURISTIC, options.bIndentHeuristic);
Expand Down
5 changes: 5 additions & 0 deletions Src/PropCompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
PropCompare::PropCompare(COptionsMgr *optionsMgr)
: OptionsPanel(optionsMgr, PropCompare::IDD)
, m_bIgnoreCase(false)
, m_bIgnoreNumbers(false)
, m_bIgnoreBlankLines(false)
, m_bIgnoreEol(true)
, m_bIgnoreCodepage(true)
Expand All @@ -45,6 +46,7 @@ void PropCompare::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_FILTERCOMMENTS_CHECK, m_bFilterCommentsLines);
DDX_Check(pDX, IDC_CP_SENSITIVE, m_bIgnoreCodepage);
DDX_Check(pDX, IDC_EOL_SENSITIVE, m_bIgnoreEol);
DDX_Check(pDX, IDC_IGNORE_NUMBERS, m_bIgnoreNumbers);
DDX_Radio(pDX, IDC_WHITESPACE, m_nIgnoreWhite);
DDX_Check(pDX, IDC_MOVED_BLOCKS, m_bMovedBlocks);
DDX_Check(pDX, IDC_MATCH_SIMILAR_LINES, m_bMatchSimilarLines);
Expand Down Expand Up @@ -72,6 +74,7 @@ void PropCompare::ReadOptions()
m_bIgnoreBlankLines = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_BLANKLINES);
m_bFilterCommentsLines = GetOptionsMgr()->GetBool(OPT_CMP_FILTER_COMMENTLINES);
m_bIgnoreCase = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CASE);
m_bIgnoreNumbers = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_NUMBERS);
m_bIgnoreEol = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_EOL);
m_bIgnoreCodepage = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CODEPAGE);
m_bMovedBlocks = GetOptionsMgr()->GetBool(OPT_CMP_MOVED_BLOCKS);
Expand All @@ -94,6 +97,7 @@ void PropCompare::WriteOptions()
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_CODEPAGE, m_bIgnoreCodepage);
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_EOL, m_bIgnoreEol);
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_CASE, m_bIgnoreCase);
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_NUMBERS, m_bIgnoreNumbers);
GetOptionsMgr()->SaveOption(OPT_CMP_MOVED_BLOCKS, m_bMovedBlocks);
GetOptionsMgr()->SaveOption(OPT_CMP_MATCH_SIMILAR_LINES, m_bMatchSimilarLines);
GetOptionsMgr()->SaveOption(OPT_CMP_DIFF_ALGORITHM, m_nDiffAlgorithm);
Expand Down Expand Up @@ -129,6 +133,7 @@ void PropCompare::OnDefaults()
m_bIgnoreBlankLines = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_BLANKLINES);
m_bFilterCommentsLines = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_FILTER_COMMENTLINES);
m_bIgnoreCase = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_CASE);
m_bIgnoreNumbers = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_NUMBERS);
m_bMovedBlocks = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_MOVED_BLOCKS);
m_bMatchSimilarLines = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_MATCH_SIMILAR_LINES);
m_nDiffAlgorithm = GetOptionsMgr()->GetDefault<unsigned>(OPT_CMP_DIFF_ALGORITHM);
Expand Down
1 change: 1 addition & 0 deletions Src/PropCompare.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class PropCompare : public OptionsPanel
bool m_bIgnoreCodepage;
bool m_bIgnoreEol;
bool m_bIgnoreCase;
bool m_bIgnoreNumbers;
bool m_bIgnoreBlankLines;
int m_nIgnoreWhite;
bool m_bMovedBlocks;
Expand Down
3 changes: 3 additions & 0 deletions Src/diffutils/src/diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ EXTERN int ignore_some_changes;
/* Ignore differences in case of letters (-i). */
EXTERN int ignore_case_flag;

/* Ignore differences in case of numbers. */
EXTERN int ignore_numbers_flag;

/* File labels for `-c' output headers (-L). */
EXTERN char *file_label[2];

Expand Down
19 changes: 19 additions & 0 deletions Src/diffutils/src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ find_and_hash_each_line (struct file_data *current)
if (ignore_all_space_flag)
while ((c = *p++) != '\n' && (c != '\r' || *p == '\n'))
{
if (ignore_numbers_flag && isdigit(c))
continue;
if (! ISWSPACE (c))
h = HASH (h, isupper (c) ? tolower (c) : c);
}
Expand All @@ -326,7 +328,12 @@ find_and_hash_each_line (struct file_data *current)
h = HASH (h, ' ');
}
}

/* c is now the first non-space. */

if (ignore_numbers_flag && isdigit(c))
continue;

/* c can be a \r (CR) if !ignore_eol_diff */
h = HASH (h, isupper (c) ? tolower (c) : c);
if (c == '\r' && *p != '\n')
Expand All @@ -335,6 +342,9 @@ find_and_hash_each_line (struct file_data *current)
else
while ((c = *p++) != '\n' && (c != '\r' || *p == '\n'))
{
if (ignore_numbers_flag && isdigit(c))
continue;

h = HASH (h, isupper (c) ? tolower (c) : c);
}
}
Expand All @@ -343,6 +353,9 @@ find_and_hash_each_line (struct file_data *current)
if (ignore_all_space_flag)
while ((c = *p++) != '\n' && (c != '\r' || *p == '\n'))
{
if (ignore_numbers_flag && isdigit(c))
continue;

if (! ISWSPACE (c))
h = HASH (h, c);
}
Expand All @@ -366,6 +379,9 @@ find_and_hash_each_line (struct file_data *current)
}
}
/* c is now the first non-space. */
if (ignore_numbers_flag && isdigit(c))
continue;

/* c can be a \r (CR) if !ignore_eol_diff */
h = HASH (h, c);
if (c == '\r' && *p != '\n')
Expand All @@ -374,6 +390,9 @@ find_and_hash_each_line (struct file_data *current)
else
while ((c = *p++) != '\n' && (c != '\r' || *p == '\n'))
{
if (ignore_numbers_flag && isdigit(c))
continue;

h = HASH (h, c);
}
}
Expand Down

0 comments on commit d1175ec

Please sign in to comment.