Repository navigation
autoconf_hdr: Rewrite template directives as config.status does - #279
Merged
Merged
Conversation
config.status rewrites both `#define NAME` and `#undef NAME` lines that start a line, when configure defines NAME, and ends every line of a header with a newline. autoconf_hdr rewrites only `#undef` lines, skips one followed by a comment, matches one in the middle of a line, and keeps a template's missing final newline. Compare against GNU autoconf for these, and against goldens for inlined content and the subst and all modes. The conformance tester compared `splitlines()`, which hides carriage returns and the final newline; compare the raw lines and whether the file ends with a newline instead. A directive line a substitution writes should be kept, even over a result. The generator test's helper passed temporaries to SourceGenerator, which keeps references to them; name them instead.
Match `#define` and `#undef` lines the way config.status does: at the start of a line, with the name followed by a blank, `(` or the end of the line. A directive for a name with a definition becomes that definition, keeping the whitespace around the `#`. Otherwise an `#undef` is commented out and a `#define` is kept. A directive line a substitution writes is kept as written. config.status has no substitutions, and overlays use them to pin a define over a result (`#undef NL_LANGINFO_MTSAFE` to `#define NL_LANGINFO_MTSAFE 1` in wget, wget2, grep and grub on macOS), as the converter's `define:` decisions do. End every line of a config header with a newline, and write headers in binary mode so they end in LF on every platform. Templates are still read in text mode, so a CRLF checkout on Windows keeps working.
sallustfire
force-pushed
the
fix/hdr-define-rewrite
branch
from
November 13, 2026 06:41
360b83f to
70ce4b3
Compare
abrisco
enabled auto-merge (squash)
November 22, 2026 20:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks again for taking a few PRs. I've got another failure against my jemalloc fidelity oracle.
autoconf_hdronly rewrites#undef NAMElines, but config.status rewrites both#define NAMEand#undef NAMEwhenever configure defines NAME. Templates that ship a default as a#defineline render differently from configure's output. jemalloc 5.4.0 is one:configure turns the fallback into
# define JEMALLOC_INFALLIBLE_NEW 1, while we left0. TeX Live'sWEB2CVERSIONline in the integration overlay works around the same gap. I believe this makes@texlive//texk/web2c:c_auto_in_substitutedunnecessary.The
#undefmatcher also diverges:#undef NAME /* comment */, leaving a macro undefined even though the checks define it.#undefin the middle of a line, e.g. inside a comment.The first commit adds the tests. They mostly use GNU autoconf itself as the oracle, with goldens only where GNU has no equivalent (inlines, subst and all modes). It also tightens the conformance tester to compare raw lines plus the final newline, since
splitlines()hid both. The second commit adds one line-anchored matcher that mirrors config.status's rule for both directives.Notes: