Skip to content

tool_parsecfg: count skipped lines in config file line numbers - #23600

Closed
trestoncuzzort wants to merge 1 commit into
curl:masterfrom
trestoncuzzort:tool_parsecfg-lineno
Closed

trestoncuzzort wants to merge 1 commit into
curl:masterfrom
trestoncuzzort:tool_parsecfg-lineno

Conversation

@trestoncuzzort

Copy link
Copy Markdown
Contributor

Since 8.13.0 the line numbers in config file warnings and errors leave out comment and blank lines. a7fda9a moved skipping those into my_get_line(), and parseconfig() only counts the lines it gets back.

$ printf '# a\n\n# b\nbogus-option = 1\n' > cfg
$ curl -K cfg https://example.com
curl: cfg:1 config file option 'bogus-option' is unknown

The option is on line 4. With this change my_get_line() counts every line it reads when the caller passes a counter, and parseconfig() passes one. The other callers pass NULL.

Test 466 is test 459 with comment and blank lines first. It fails on master and passes with the fix. Locally the full test suite passes (1757 tests run) and checksrc is clean.

Since curl 8.13.0, warnings and errors for config files show the wrong
line number when comments or blank lines come before the option.
a7fda9a moved the skipping of those lines into my_get_line(), and
parseconfig() only counts the lines it gets back, so an option on line
4 after two comments and a blank line is reported as line 1.

Let my_get_line() count every line it reads, including the skipped
ones, when the caller passes a counter. The other callers pass NULL.

Test 466 checks the line number in a warning after comment lines.

Follow-up to a7fda9a curl#16590
@testclutch

Copy link
Copy Markdown

Analysis of PR #23600 at 939ebcf5:

Test ../../tests/http/test_02_download.py::TestDownload::test_02_06_download_many_parallel[h3] failed, but it has been 0.4% flaky lately, so it's probably NOT a fault of the PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them).

Generated by Testclutch

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix counts skipped lines correctly, updates callers consistently, and includes regression coverage for the reported defect.

No open issues 🎉

What changed in this PR

Fixes config-file diagnostic line numbers so they include skipped comments and blank lines.

Changes:

  • Adds an optional line counter to my_get_line() and uses it in parseconfig().
  • Updates other callers to pass NULL, preserving their behavior.
  • Adds and registers a regression test for warnings after skipped lines.
File Description
tests/​data/​test466 Verifies the warning reports line 4 after comments and a blank line.
tests/​data/​Makefile.am Registers test 466.
src/​tool_ssls.c Passes NULL for the unused line counter.
src/​tool_parsecfg.h Declares the optional line-counter parameter.
src/​tool_parsecfg.c Counts every successfully read line, including skipped lines.
src/​tool_getparam.c Updates URL and header readers for the new signature.
src/​tool_formparse.c Updates the form-header reader for the new signature.

Review effort: Balanced

@bagder

bagder commented Oct 26, 2026

Copy link
Copy Markdown
Member

Thanks!

@bagder bagder closed this in 2d4493d Oct 26, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Oct 26, 2026
vszakats added a commit that referenced this pull request Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants