Skip to content

Commit 449e1a7

Browse files
committed
whitespace: trim trailing before comparison
1 parent 599fe5f commit 449e1a7

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,14 @@ add_test(NAME fixdiff8
114114
-P ${CMAKE_CURRENT_SOURCE_DIR}/tests/runtest.cmake
115115
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/8)
116116

117+
add_test(NAME fixdiff9
118+
COMMAND ${CMAKE_COMMAND}
119+
-DCMD=$<TARGET_FILE:${PROJECT_NAME}>
120+
-DSRC=s-ws-builder.c
121+
-DPATCH=gemini.patch
122+
-DEXPSHA=ac6512d0861605b5dbea4c07e15faed64fab98742c7b9830ce6adfd0af077d09
123+
-DEXPSHA_WIN=2e6b9b12ae0128c9edfc109744b9c67848712b0521c322a45104895aa4cbc3b1
124+
-P ${CMAKE_CURRENT_SOURCE_DIR}/tests/runtest.cmake
125+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/9)
126+
117127

fixdiff.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,17 @@ fixdiff_find_original(dp_t *pdp, int *line_start)
466466
char *p1 = in_temp + 1, *p1_end = p1 + lt - 1 - (int)let,
467467
*p2 = in_src, *p2_end = p2 + ls - (int)les;
468468

469+
/*
470+
* Let's trim back any trailing whitespace so that
471+
* either source or patch with it and the other not
472+
* doesn't trigger a mismatch
473+
*/
474+
475+
while (p1_end > p1 && (p1_end[-1] == ' ' || p1_end[-1] == '\t'))
476+
p1_end--;
477+
while (p2_end > p2 && (p2_end[-1] == ' ' || p2_end[-1] == '\t'))
478+
p2_end--;
479+
469480
while (p1 < p1_end && p2 < p2_end) {
470481
char wst1 = 0, wst2 = 0;
471482

0 commit comments

Comments
 (0)