curlx: add and use curlx_freopen()

To complement the existing `curlx_fopen()` internal API.
It's used by the curl's `--stderr` option.

`curlx_freopen()` adds two features to the bare `freopen()`:
- tracing for debug-enabled builds.
- Unicode and long-filename support for Windows builds.

In effect this adds long-filename and enables Unicode support for
the `--stderr <filename>` curl command-line option on Windows.

Also add to checksrc.

Follow-up to 2f17a9b654 #10673

Closes #19598
This commit is contained in:
Viktor Szakats
2025-11-19 01:10:48 +01:00
parent 2decbb1c1f
commit 3d80d37cf0
7 changed files with 68 additions and 11 deletions

View File

@@ -106,6 +106,7 @@ my %banfunc = (
"fclose" => 1,
"fdopen" => 1,
"fopen" => 1,
"freopen" => 1,
"open" => 1,
"stat" => 1,
);
@@ -961,7 +962,7 @@ sub scanfile {
}
# scan for use of non-binary fopen without the macro
if($l =~ /^(.*\W)(curlx_fopen|CURLX_FOPEN_LOW)\s*\([^,]*, *\"([^"]*)/) {
if($l =~ /^(.*\W)(curlx_fopen|CURLX_FOPEN_LOW|curlx_freopen|CURLX_FREOPEN_LOW)\s*\([^,]*, *\"([^"]*)/) {
my $mode = $3;
if($mode !~ /b/) {
checkwarn("FOPENMODE",