Skip to content

fix(#1941): convert IccMatrixMath.cpp to LF so a touched line stops tripping diff --check - #1945

Merged
xsscx merged 1 commit into
masterfrom
fix/1941-crlf-iccmatrixmath
Aug 1, 2026
Merged

fix(#1941): convert IccMatrixMath.cpp to LF so a touched line stops tripping diff --check#1945
xsscx merged 1 commit into
masterfrom
fix/1941-crlf-iccmatrixmath

Conversation

@colourbill-ctrl

Copy link
Copy Markdown
Contributor

Fixes #1941

What the issue reported, and what is actually wrong

The issue reports that IccMatrixMath.cpp has CRLF characters that git diff --check
treats as trailing whitespace, and proposes:

perl -0pi -e 's/[ \t]+\r\n/\r\n/g; s/[ \t]+\n/\n/g' IccMatrixMath.cpp

That is necessary but not sufficient. It strips the trailing space/tab runs but leaves the
CRLF in place, and the CR is itself what diff --check is reporting: .gitattributes
carries rules for *.sh and .githooks/* only, and git's cr-at-eol whitespace rule is
off by default, so git counts the carriage return as trailing whitespace. Every line a
change touches in this file is flagged regardless of what that line contains.

Red-tested on 8b66b43a, adding a single line with no trailing whitespace at all:

$ git diff --check -- IccProfLib/IccMatrixMath.cpp
IccProfLib/IccMatrixMath.cpp:78: trailing whitespace.
+// probe
(exit 2)

After this change the same probe edit exits 0.

This is not a style change

IccMatrixMath.cpp is the only CRLF file among the 259 tracked C/C++ sources in the
tree:

$ for f in $(git ls-files '*.cpp' '*.h' '*.c' '*.hpp'); do
    grep -q $'\r$' "$f" && echo "$f"; done
IccProfLib/IccMatrixMath.cpp

It has been CRLF since 1f0a9dd (Sep 2015). Converting it brings it into line with its
258 siblings rather than imposing a new convention on any of them.

What changed

Both halves, in one pass:

  • the 32 trailing space/tab runs are stripped — all of them in the licence header and the
    function banner comments, none in code;
  • the line terminators are converted CRLF → LF.

Every CR in the file was a line terminator; none appeared inside a string literal or
anywhere else that would make the conversion meaningful (grep -cP '\r(?!$)' → 0).

Verification: byte-identical object, not an assertion

The change is provably semantics-free. Compiling the file before and after with the
project's own IccProfLib2 command line (clang-18, ASAN+UBSAN, -Wall -Wextra -Wshadow -Wnull-dereference -Werror=uninitialized, -std=gnu++17 -g) produces an
identical object both times:

e51a30c0532344b71539b8bc1102d9952791afc5bcd4bbeb0ac136a0066dde68  before.o
e51a30c0532344b71539b8bc1102d9952791afc5bcd4bbeb0ac136a0066dde68  after.o

The line count is unchanged at 516, so no debug line numbers move either.

For review: git show -w --ignore-cr-at-eol renders this commit as an empty diff.

Pre-flight

  • Build: 0 warnings (grep -cE 'warning:' build.log → 0).
  • Full local CTest: 145 tests. Three failures, none related and all reproducible on an
    unmodified tree:
    • iccdev.spectral-tiff-previewModuleNotFoundError: No module named 'imagecodecs',
      a missing local Python dependency that CI installs.
    • iccdev.tool-coverage — the known parallel-load flake; passes standalone (51.4s).
    • iccdev.issue-1781-applytolink-qa-matrix — same family, newly observed: 123.9s under
      -j4, 42.9s standalone
      on the identical tree. It regenerates CMYK fixtures in the
      shared Testing/ dir, so it races with tool-coverage / create-profiles the same way.

No CTest is added: there is no behaviour to assert, and the byte-identical object is the
stronger evidence.

Deliberately not included

Preventing recurrence repo-wide would mean adding a *.cpp / *.h rule to
.gitattributes. That has a far wider blast radius than this one file and is a
maintainer call, so it is left out. Happy to follow up with it if wanted.

…ripping diff --check

IccMatrixMath.cpp is the only CRLF file among the 259 tracked C/C++ sources in the
tree. .gitattributes carries rules for *.sh and .githooks/* only, and git's cr-at-eol
whitespace rule is off by default, so git counts the CR itself as trailing whitespace.
The consequence is that every line a change touches in this one file is reported by
`git diff --check`, whatever that line actually contains.

Red-tested on master 8b66b43 by adding a single line carrying no trailing whitespace
at all:

    $ git diff --check -- IccProfLib/IccMatrixMath.cpp
    IccProfLib/IccMatrixMath.cpp:78: trailing whitespace.
    +// probe
    (exit 2)

After this change the same probe edit exits 0.

The issue proposed stripping the trailing space/tab runs:

    perl -0pi -e 's/[ \t]+\r\n/\r\n/g; s/[ \t]+\n/\n/g'

That is necessary but not sufficient — it leaves the CRLF in place, so diff --check
still fires on every touched line for the reason above. This change does both: it
strips the 32 trailing-whitespace runs and converts the line terminators to LF, which
also brings the file into line with its 258 siblings.

All 32 trailing-whitespace runs are in the licence header and the function banner
comments; none are in code. Every CR in the file was a line terminator — none appeared
inside a string literal or anywhere else that would make the conversion meaningful.

No semantic change, and that is verified rather than asserted: compiling the file
before and after with the project's own flags (clang-18, ASAN+UBSAN, -Wall -Wextra
and the rest of the IccProfLib2 command line) yields a byte-identical object,
sha256 e51a30c0532344b71539b8bc1102d9952791afc5bcd4bbeb0ac136a0066dde68 both times.
The line count is unchanged at 516, so no debug line numbers move either.

For review, `git show -w --ignore-cr-at-eol` renders this as an empty diff.

The file has been CRLF since 1f0a9dd (Sep 2015). Preventing recurrence across the repo
would mean adding a *.cpp / *.h rule to .gitattributes; that has a much wider blast
radius and is a maintainer call, so it is deliberately not part of this change.
@github-actions github-actions Bot added Source C or C++ source code changes pending CI checks still running labels Aug 1, 2026
@xsscx
xsscx enabled auto-merge (squash) August 1, 2026 22:33
@xsscx
xsscx merged commit df62374 into master Aug 1, 2026
35 checks passed
@xsscx

xsscx commented Aug 1, 2026

Copy link
Copy Markdown
Member

Pre Merge Report

2026-08-01 22:42:29 UTC

  1. PR Candidate for Maintainer PR Fast Lane
  2. Graph is Clean
  3. Single .cpp file
  4. Bisect & Pickaxe
  5. CRLF Corrections
  6. Coverage Envelope - ci-pr-lint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending CI checks still running Source C or C++ source code changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: CRLF in IccMatrixMath.cpp

2 participants