build: update to not need _CRT_NONSTDC_NO_DEPRECATE with MSVC

Use non-deprecated CRT function variants on Windows.

- introduce `curlx_fdopen()`, `curlx_close()` and use them. Map them to
  non-deprecated, underscored, CRT functions on Windows.

- replace `close()` uses with either `sclose()` (for sockets) or
  `curlx_close()` (for files).

- map `fileno`, `unlink`, `isatty` to their non-deprecated, underscored,
  versions on Windows.

- tool_dirhie: map `mkdir` to `_mkdir` on Windows.

- easy: use `_strdup()` on Windows, regardless of how `HAVE_STRDUP` is
  set.

- cmake: assume `HAVE_STRDUP` on Windows. To allow dropping a detection
  hack using `_CRT_NONSTDC_NO_DEPRECATE` with MSVC. Windows always has
  `_strdup()` which the code uses, but also needs `HAVE_STRDUP` defined
  to disable curl's own `strdup()` implementation.

- curl_setup.h: drop `_CRT_NONSTDC_NO_DEPRECATE` as no longer necessary.

Closes #20212
This commit is contained in:
Viktor Szakats 2026-01-07 19:37:02 +01:00
parent dbc4603b09
commit e50aa46fb2
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
25 changed files with 54 additions and 49 deletions

View file

@ -849,7 +849,7 @@ send_ack:
write_behind(test, pf->f_convert);
/* close the output file as early as possible after upload completion */
if(test->ofile > 0) {
close(test->ofile);
curlx_close(test->ofile);
test->ofile = 0;
}
@ -875,7 +875,7 @@ send_ack:
abort:
/* make sure the output file is closed in case of abort */
if(test->ofile > 0) {
close(test->ofile);
curlx_close(test->ofile);
test->ofile = 0;
}
return;
@ -1305,7 +1305,7 @@ static int test_tftpd(int argc, char **argv)
tftpd_cleanup:
if(test.ofile > 0)
close(test.ofile);
curlx_close(test.ofile);
if((peer != sock) && (peer != CURL_SOCKET_BAD))
sclose(peer);

View file

@ -379,7 +379,7 @@ static void exit_signal_handler(int signum)
#endif
static const char msg[] = "exit_signal_handler: called\n";
(void)!write(fd, msg, sizeof(msg) - 1);
close(fd);
curlx_close(fd);
}
else {
static const char msg[] = "exit_signal_handler: failed opening ";