Skip to content

Commit d1175ec

Browse files
evoclawitOS
andauthored
Added option "Ignore numbers" (#1025)
* 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 <[email protected]>
1 parent 98ff3fb commit d1175ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+443
-125
lines changed

Docs/Users/ChangeLog.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ <h2 id="winmerge-21616---2021-10-28">WinMerge 2.16.16 - 2021-10-28</h2>
2525
<h3 id="general">General</h3>
2626
<ul>
2727
<li>Fix a problem where the string in the Windows common dialog would not change to the language when switching languages.</li>
28+
<li>New Option to ignore numbers.</li>
2829
</ul>
2930
<h3 id="file-compare">File compare</h3>
3031
<ul>

Docs/Users/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

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

1011
### File compare
1112

Src/CompareEngines/ByteComparator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ ByteComparator::ByteComparator(const QuickCompareOptions * options)
110110
: m_ignore_case(options->m_bIgnoreCase)
111111
, m_ignore_eol_diff(options->m_bIgnoreEOLDifference)
112112
, m_ignore_blank_lines(options->m_bIgnoreBlankLines)
113+
, m_ignore_numbers(options->m_bIgnoreNumbers)
113114
// state
114115
, m_wsflag(false)
115116
, m_eol0(false)

Src/CompareEngines/ByteComparator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class ByteComparator
4949
private:
5050
// settings
5151
bool m_ignore_case; /**< Ignore character case */
52+
bool m_ignore_numbers; /**< Ignore character case */
5253
bool m_ignore_space_change; /**< Ignore change in whitespace char count */
5354
bool m_ignore_all_space; /**< Ignore all whitespace changes */
5455
bool m_ignore_eol_diff; /**< Ignore differences in EOL bytes */

Src/CompareOptions.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CompareOptions::CompareOptions()
1919
, m_bIgnoreBlankLines(false)
2020
, m_bIgnoreCase(false)
2121
, m_bIgnoreEOLDifference(false)
22+
, m_bIgnoreNumbers(false)
2223
{
2324
}
2425

@@ -30,6 +31,7 @@ CompareOptions::CompareOptions(const CompareOptions & options)
3031
, m_bIgnoreBlankLines(options.m_bIgnoreBlankLines)
3132
, m_bIgnoreCase(options.m_bIgnoreCase)
3233
, m_bIgnoreEOLDifference(options.m_bIgnoreEOLDifference)
34+
, m_bIgnoreNumbers(options.m_bIgnoreNumbers)
3335
{
3436
}
3537

@@ -72,6 +74,7 @@ void CompareOptions::SetFromDiffOptions(const DIFFOPTIONS &options)
7274
m_bIgnoreBlankLines = options.bIgnoreBlankLines;
7375
m_bIgnoreCase = options.bIgnoreCase;
7476
m_bIgnoreEOLDifference = options.bIgnoreEol;
77+
m_bIgnoreNumbers = options.bIgnoreNumbers;
7578
}
7679

7780
/**
@@ -191,6 +194,8 @@ void DiffutilsOptions::SetToDiffUtils()
191194
else
192195
ignore_case_flag = 0;
193196

197+
ignore_numbers_flag = m_bIgnoreNumbers ? 1 : 0;
198+
194199
if (m_bIgnoreEOLDifference)
195200
ignore_eol_diff = 1;
196201
else
@@ -225,7 +230,8 @@ void DiffutilsOptions::GetAsDiffOptions(DIFFOPTIONS &options) const
225230
options.bIgnoreBlankLines = m_bIgnoreBlankLines;
226231
options.bIgnoreCase = m_bIgnoreCase;
227232
options.bIgnoreEol = m_bIgnoreEOLDifference;
228-
233+
options.bIgnoreNumbers = m_bIgnoreNumbers;
234+
229235
switch (m_ignoreWhitespace)
230236
{
231237
case WHITESPACE_COMPARE_ALL:

Src/CompareOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ struct DIFFOPTIONS
7979
{
8080
int nIgnoreWhitespace; /**< Ignore whitespace -option. */
8181
bool bIgnoreCase; /**< Ignore case -option. */
82+
bool bIgnoreNumbers; /**< Ignore numbers -option. */
8283
bool bIgnoreBlankLines; /**< Ignore blank lines -option. */
8384
bool bIgnoreEol; /**< Ignore EOL differences -option. */
8485
bool bFilterCommentsLines; /**< Ignore Multiline comments differences -option. */
@@ -102,6 +103,7 @@ class CompareOptions
102103
enum WhitespaceIgnoreChoices m_ignoreWhitespace; /**< Ignore whitespace characters */
103104
bool m_bIgnoreBlankLines; /**< Ignore blank lines (both sides) */
104105
bool m_bIgnoreCase; /**< Ignore case differences? */
106+
bool m_bIgnoreNumbers; /**< Ignore number differences? */
105107
bool m_bIgnoreEOLDifference; /**< Ignore EOL style differences? */
106108
};
107109

Src/DiffWrapper.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,27 @@ static void ReplaceSpaces(std::string & str, const char *rep)
309309
pos += replen;
310310
}
311311
}
312+
313+
/**
314+
* @brief Replace spaces in a string
315+
* @param [in] str - String to search
316+
* @param [in] rep - String to replace
317+
*/
318+
static void ReplaceNumbers(std::string& str, const char* rep)
319+
{
320+
std::string::size_type pos = 0;
321+
size_t replen = strlen(rep);
322+
while ((pos = str.find_first_of("0123456789", pos)) != std::string::npos)
323+
{
324+
std::string::size_type posend = str.find_first_not_of("0123456789", pos);
325+
if (posend != String::npos)
326+
str.replace(pos, posend - pos, rep);
327+
else
328+
str.replace(pos, 1, rep);
329+
pos += replen;
330+
}
331+
}
332+
312333
/**
313334
@brief The main entry for post filtering. Performs post-filtering, by setting comment blocks to trivial
314335
@param [in] LineNumberLeft - First line number to read from left file
@@ -369,6 +390,13 @@ void CDiffWrapper::PostFilter(PostFilterContext& ctxt, int LineNumberLeft, int Q
369390
ReplaceSpaces(LineDataRight, " ");
370391
}
371392

393+
if (m_options.m_bIgnoreNumbers )
394+
{
395+
//Ignore number character case
396+
ReplaceNumbers(LineDataLeft, "");
397+
ReplaceNumbers(LineDataRight, "");
398+
}
399+
372400
if (m_options.m_bIgnoreCase)
373401
{
374402
//ignore case

Src/MainFrm.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
255255
ON_UPDATE_COMMAND_UI_RANGE(ID_DIFF_OPTIONS_WHITESPACE_COMPARE, ID_DIFF_OPTIONS_WHITESPACE_IGNOREALL, OnUpdateDiffWhitespace)
256256
ON_COMMAND(ID_DIFF_OPTIONS_IGNORE_BLANKLINES, OnDiffIgnoreBlankLines)
257257
ON_UPDATE_COMMAND_UI(ID_DIFF_OPTIONS_IGNORE_BLANKLINES, OnUpdateDiffIgnoreBlankLines)
258+
ON_COMMAND(IDC_DIFF_IGNORENUMBERS, OnDiffIgnoreNumbers)
259+
ON_UPDATE_COMMAND_UI(IDC_DIFF_IGNORENUMBERS, OnUpdateDiffIgnoreNumbers)
258260
ON_COMMAND(ID_DIFF_OPTIONS_IGNORE_CASE, OnDiffIgnoreCase)
259261
ON_UPDATE_COMMAND_UI(ID_DIFF_OPTIONS_IGNORE_CASE, OnUpdateDiffIgnoreCase)
260262
ON_COMMAND(ID_DIFF_OPTIONS_IGNORE_EOL, OnDiffIgnoreEOL)
@@ -2710,6 +2712,18 @@ void CMainFrame::OnUpdateDiffIgnoreCase(CCmdUI* pCmdUI)
27102712
pCmdUI->Enable();
27112713
}
27122714

2715+
void CMainFrame::OnDiffIgnoreNumbers()
2716+
{
2717+
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_NUMBERS, !GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_NUMBERS));
2718+
ApplyDiffOptions();
2719+
}
2720+
2721+
void CMainFrame::OnUpdateDiffIgnoreNumbers(CCmdUI* pCmdUI)
2722+
{
2723+
pCmdUI->SetCheck(GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_NUMBERS));
2724+
pCmdUI->Enable();
2725+
}
2726+
27132727
void CMainFrame::OnDiffIgnoreEOL()
27142728
{
27152729
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_EOL, !GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_EOL));

Src/MainFrm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ class CMainFrame : public CMDIFrameWnd
342342
afx_msg void OnUpdateDiffIgnoreBlankLines(CCmdUI* pCmdUI);
343343
afx_msg void OnDiffIgnoreCase();
344344
afx_msg void OnUpdateDiffIgnoreCase(CCmdUI* pCmdUI);
345+
afx_msg void OnDiffIgnoreNumbers();
346+
afx_msg void OnUpdateDiffIgnoreNumbers(CCmdUI* pCmdUI);
345347
afx_msg void OnDiffIgnoreEOL();
346348
afx_msg void OnUpdateDiffIgnoreEOL(CCmdUI* pCmdUI);
347349
afx_msg void OnDiffIgnoreCP();

Src/Merge.rc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@ BEGIN
891891
MENUITEM "Ignore &case", ID_DIFF_OPTIONS_IGNORE_CASE
892892
MENUITEM "Igno&re carriage return differences (Windows/Unix/Mac)", ID_DIFF_OPTIONS_IGNORE_EOL
893893
MENUITEM "Ignore codepage &differences", ID_DIFF_OPTIONS_IGNORE_CODEPAGE
894+
MENUITEM "Ignore num&bers", IDC_DIFF_IGNORENUMBERS
894895
MENUITEM "Ignore c&omment differences" ,ID_DIFF_OPTIONS_IGNORE_COMMENTS
895896
MENUITEM SEPARATOR
896897
MENUITEM "&Include Subfolders", ID_DIFF_OPTIONS_INCLUDE_SUBFOLDERS
@@ -1564,15 +1565,17 @@ BEGIN
15641565
CONTROL "Ignore &case",IDC_IGNCASE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,72,239,10
15651566
CONTROL "Igno&re carriage return differences (Windows/Unix/Mac)",IDC_EOL_SENSITIVE,
15661567
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,84,239,10
1567-
CONTROL "Ignore codepage &differences",IDC_CP_SENSITIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,96,239,10
1568-
CONTROL "Ignore c&omment differences",IDC_FILTERCOMMENTS_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,108,239,10
1569-
CONTROL "E&nable moved block detection",IDC_MOVED_BLOCKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,120,239,10
1570-
CONTROL "&Match similar lines",IDC_MATCH_SIMILAR_LINES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,132,239,10
1571-
LTEXT "Diff &algorithm (Experimental):",IDC_STATIC,7,144,239,10
1572-
COMBOBOX IDC_DIFF_ALGORITHM,6,156,240,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
1573-
CONTROL "Enable indent &heuristic",IDC_INDENT_HEURISTIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,174,239,10
1568+
CONTROL "Ignore num&bers",IDC_IGNORE_NUMBERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,96,239,10
1569+
CONTROL "Ignore codepage &differences",IDC_CP_SENSITIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,108,239,10
1570+
CONTROL "Ignore c&omment differences",IDC_FILTERCOMMENTS_CHECK,
1571+
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,120,239,10
1572+
CONTROL "E&nable moved block detection",IDC_MOVED_BLOCKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,132,239,10
1573+
CONTROL "&Match similar lines",IDC_MATCH_SIMILAR_LINES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,144,239,10
1574+
LTEXT "Diff &algorithm (Experimental):",IDC_STATIC,7,156,239,10
1575+
COMBOBOX IDC_DIFF_ALGORITHM,6,168,240,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
1576+
CONTROL "Enable indent &heuristic",IDC_INDENT_HEURISTIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,186,239,10
15741577
CONTROL "Completely unhighlight the ignored differences",IDC_COMPLETELY_BLANK_OUT_IGNORED_DIFFERENCES,
1575-
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,186,239,10
1578+
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,198,239,10
15761579
PUSHBUTTON "Defaults",IDC_COMPARE_DEFAULTS,161,228,88,14
15771580
END
15781581

Src/MergeDoc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ void CMergeDoc::FlagTrivialLines(void)
646646
!diffOptions.bIgnoreCase,
647647
!diffOptions.bIgnoreEol,
648648
diffOptions.nIgnoreWhitespace,
649+
diffOptions.bIgnoreNumbers,
649650
GetBreakType(), // whitespace only or include punctuation
650651
GetByteColoringOption());
651652
if (!worddiffs.empty())

Src/MergeDocDiffSync.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ int CMergeDoc::GetMatchCost(const String &sLine0, const String &sLine1)
147147
int breakType = GetBreakType(); // whitespace only or include punctuation
148148
bool byteColoring = GetByteColoringOption();
149149

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

152152
int nDiffLenSum = 0;
153153
for (std::vector<strdiff::wdiff>::const_iterator it = worddiffs.begin(); it != worddiffs.end(); ++it)

Src/MergeDocLineDiffs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ std::vector<WordDiff> CMergeDoc::GetWordDiffArray(int nLineIndex)
402402
bool byteColoring = GetByteColoringOption();
403403

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

407407
int i;
408408
std::vector<strdiff::wdiff>::iterator it;

Src/OptionsDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ inline const String OPT_CMP_IGNORE_WHITESPACE {_T("Settings/IgnoreSpace"s)};
197197
inline const String OPT_CMP_IGNORE_BLANKLINES {_T("Settings/IgnoreBlankLines"s)};
198198
inline const String OPT_CMP_FILTER_COMMENTLINES {_T("Settings/FilterCommentsLines"s)};
199199
inline const String OPT_CMP_IGNORE_CASE {_T("Settings/IgnoreCase"s)};
200+
inline const String OPT_CMP_IGNORE_NUMBERS {_T("Settings/IgnoreNumbers"s)};
200201
inline const String OPT_CMP_IGNORE_EOL {_T("Settings/IgnoreEol"s)};
201202
inline const String OPT_CMP_IGNORE_CODEPAGE {_T("Settings/IgnoreCodepage"s)};
202203
inline const String OPT_CMP_METHOD {_T("Settings/CompMethod2"s)};

Src/OptionsDiffOptions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void Init(COptionsMgr *pOptionsMgr)
2020
pOptionsMgr->InitOption(OPT_CMP_IGNORE_BLANKLINES, false);
2121
pOptionsMgr->InitOption(OPT_CMP_FILTER_COMMENTLINES, false);
2222
pOptionsMgr->InitOption(OPT_CMP_IGNORE_CASE, false);
23+
pOptionsMgr->InitOption(OPT_CMP_IGNORE_NUMBERS, false);
2324
pOptionsMgr->InitOption(OPT_CMP_IGNORE_EOL, false);
2425
pOptionsMgr->InitOption(OPT_CMP_DIFF_ALGORITHM, (int)0, 0, 3);
2526
pOptionsMgr->InitOption(OPT_CMP_INDENT_HEURISTIC, true);
@@ -32,6 +33,7 @@ void Load(const COptionsMgr *pOptionsMgr, DIFFOPTIONS& options)
3233
options.bIgnoreBlankLines = pOptionsMgr->GetBool(OPT_CMP_IGNORE_BLANKLINES);
3334
options.bFilterCommentsLines = pOptionsMgr->GetBool(OPT_CMP_FILTER_COMMENTLINES);
3435
options.bIgnoreCase = pOptionsMgr->GetBool(OPT_CMP_IGNORE_CASE);
36+
options.bIgnoreNumbers = pOptionsMgr->GetBool(OPT_CMP_IGNORE_NUMBERS);
3537
options.bIgnoreEol = pOptionsMgr->GetBool(OPT_CMP_IGNORE_EOL);
3638
options.nDiffAlgorithm = pOptionsMgr->GetInt(OPT_CMP_DIFF_ALGORITHM);
3739
options.bIndentHeuristic = pOptionsMgr->GetBool(OPT_CMP_INDENT_HEURISTIC);
@@ -44,6 +46,7 @@ void Save(COptionsMgr *pOptionsMgr, const DIFFOPTIONS& options)
4446
pOptionsMgr->SaveOption(OPT_CMP_IGNORE_BLANKLINES, options.bIgnoreBlankLines);
4547
pOptionsMgr->SaveOption(OPT_CMP_FILTER_COMMENTLINES, options.bFilterCommentsLines);
4648
pOptionsMgr->SaveOption(OPT_CMP_IGNORE_CASE, options.bIgnoreCase);
49+
pOptionsMgr->SaveOption(OPT_CMP_IGNORE_NUMBERS, options.bIgnoreNumbers);
4750
pOptionsMgr->SaveOption(OPT_CMP_IGNORE_EOL, options.bIgnoreEol);
4851
pOptionsMgr->SaveOption(OPT_CMP_DIFF_ALGORITHM, options.nDiffAlgorithm);
4952
pOptionsMgr->SaveOption(OPT_CMP_INDENT_HEURISTIC, options.bIndentHeuristic);

Src/PropCompare.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
PropCompare::PropCompare(COptionsMgr *optionsMgr)
2222
: OptionsPanel(optionsMgr, PropCompare::IDD)
2323
, m_bIgnoreCase(false)
24+
, m_bIgnoreNumbers(false)
2425
, m_bIgnoreBlankLines(false)
2526
, m_bIgnoreEol(true)
2627
, m_bIgnoreCodepage(true)
@@ -45,6 +46,7 @@ void PropCompare::DoDataExchange(CDataExchange* pDX)
4546
DDX_Check(pDX, IDC_FILTERCOMMENTS_CHECK, m_bFilterCommentsLines);
4647
DDX_Check(pDX, IDC_CP_SENSITIVE, m_bIgnoreCodepage);
4748
DDX_Check(pDX, IDC_EOL_SENSITIVE, m_bIgnoreEol);
49+
DDX_Check(pDX, IDC_IGNORE_NUMBERS, m_bIgnoreNumbers);
4850
DDX_Radio(pDX, IDC_WHITESPACE, m_nIgnoreWhite);
4951
DDX_Check(pDX, IDC_MOVED_BLOCKS, m_bMovedBlocks);
5052
DDX_Check(pDX, IDC_MATCH_SIMILAR_LINES, m_bMatchSimilarLines);
@@ -72,6 +74,7 @@ void PropCompare::ReadOptions()
7274
m_bIgnoreBlankLines = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_BLANKLINES);
7375
m_bFilterCommentsLines = GetOptionsMgr()->GetBool(OPT_CMP_FILTER_COMMENTLINES);
7476
m_bIgnoreCase = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CASE);
77+
m_bIgnoreNumbers = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_NUMBERS);
7578
m_bIgnoreEol = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_EOL);
7679
m_bIgnoreCodepage = GetOptionsMgr()->GetBool(OPT_CMP_IGNORE_CODEPAGE);
7780
m_bMovedBlocks = GetOptionsMgr()->GetBool(OPT_CMP_MOVED_BLOCKS);
@@ -94,6 +97,7 @@ void PropCompare::WriteOptions()
9497
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_CODEPAGE, m_bIgnoreCodepage);
9598
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_EOL, m_bIgnoreEol);
9699
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_CASE, m_bIgnoreCase);
100+
GetOptionsMgr()->SaveOption(OPT_CMP_IGNORE_NUMBERS, m_bIgnoreNumbers);
97101
GetOptionsMgr()->SaveOption(OPT_CMP_MOVED_BLOCKS, m_bMovedBlocks);
98102
GetOptionsMgr()->SaveOption(OPT_CMP_MATCH_SIMILAR_LINES, m_bMatchSimilarLines);
99103
GetOptionsMgr()->SaveOption(OPT_CMP_DIFF_ALGORITHM, m_nDiffAlgorithm);
@@ -129,6 +133,7 @@ void PropCompare::OnDefaults()
129133
m_bIgnoreBlankLines = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_BLANKLINES);
130134
m_bFilterCommentsLines = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_FILTER_COMMENTLINES);
131135
m_bIgnoreCase = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_CASE);
136+
m_bIgnoreNumbers = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_IGNORE_NUMBERS);
132137
m_bMovedBlocks = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_MOVED_BLOCKS);
133138
m_bMatchSimilarLines = GetOptionsMgr()->GetDefault<bool>(OPT_CMP_MATCH_SIMILAR_LINES);
134139
m_nDiffAlgorithm = GetOptionsMgr()->GetDefault<unsigned>(OPT_CMP_DIFF_ALGORITHM);

Src/PropCompare.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class PropCompare : public OptionsPanel
3333
bool m_bIgnoreCodepage;
3434
bool m_bIgnoreEol;
3535
bool m_bIgnoreCase;
36+
bool m_bIgnoreNumbers;
3637
bool m_bIgnoreBlankLines;
3738
int m_nIgnoreWhite;
3839
bool m_bMovedBlocks;

Src/diffutils/src/diff.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ EXTERN int ignore_some_changes;
124124
/* Ignore differences in case of letters (-i). */
125125
EXTERN int ignore_case_flag;
126126

127+
/* Ignore differences in case of numbers. */
128+
EXTERN int ignore_numbers_flag;
129+
127130
/* File labels for `-c' output headers (-L). */
128131
EXTERN char *file_label[2];
129132

Src/diffutils/src/io.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ find_and_hash_each_line (struct file_data *current)
304304
if (ignore_all_space_flag)
305305
while ((c = *p++) != '\n' && (c != '\r' || *p == '\n'))
306306
{
307+
if (ignore_numbers_flag && isdigit(c))
308+
continue;
307309
if (! ISWSPACE (c))
308310
h = HASH (h, isupper (c) ? tolower (c) : c);
309311
}
@@ -326,7 +328,12 @@ find_and_hash_each_line (struct file_data *current)
326328
h = HASH (h, ' ');
327329
}
328330
}
331+
329332
/* c is now the first non-space. */
333+
334+
if (ignore_numbers_flag && isdigit(c))
335+
continue;
336+
330337
/* c can be a \r (CR) if !ignore_eol_diff */
331338
h = HASH (h, isupper (c) ? tolower (c) : c);
332339
if (c == '\r' && *p != '\n')
@@ -335,6 +342,9 @@ find_and_hash_each_line (struct file_data *current)
335342
else
336343
while ((c = *p++) != '\n' && (c != '\r' || *p == '\n'))
337344
{
345+
if (ignore_numbers_flag && isdigit(c))
346+
continue;
347+
338348
h = HASH (h, isupper (c) ? tolower (c) : c);
339349
}
340350
}
@@ -343,6 +353,9 @@ find_and_hash_each_line (struct file_data *current)
343353
if (ignore_all_space_flag)
344354
while ((c = *p++) != '\n' && (c != '\r' || *p == '\n'))
345355
{
356+
if (ignore_numbers_flag && isdigit(c))
357+
continue;
358+
346359
if (! ISWSPACE (c))
347360
h = HASH (h, c);
348361
}
@@ -366,6 +379,9 @@ find_and_hash_each_line (struct file_data *current)
366379
}
367380
}
368381
/* c is now the first non-space. */
382+
if (ignore_numbers_flag && isdigit(c))
383+
continue;
384+
369385
/* c can be a \r (CR) if !ignore_eol_diff */
370386
h = HASH (h, c);
371387
if (c == '\r' && *p != '\n')
@@ -374,6 +390,9 @@ find_and_hash_each_line (struct file_data *current)
374390
else
375391
while ((c = *p++) != '\n' && (c != '\r' || *p == '\n'))
376392
{
393+
if (ignore_numbers_flag && isdigit(c))
394+
continue;
395+
377396
h = HASH (h, c);
378397
}
379398
}

0 commit comments

Comments
 (0)