Use CPLIsInteractive()

This commit is contained in:
Even Rouault 2024-10-28 21:13:44 +01:00
parent 997537270c
commit 1a3335bed6
No known key found for this signature in database
GPG Key ID: 33EBBFC47B3DD87D
4 changed files with 4 additions and 30 deletions

View File

@ -26,12 +26,6 @@
#include <cctype>
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
/************************************************************************/
/* GetSRSAsWKT */
/************************************************************************/
@ -300,7 +294,7 @@ MAIN_START(argc, argv)
if (std::isnan(dfGeoX))
{
// Is it an interactive terminal ?
if (isatty(static_cast<int>(fileno(stdin))))
if (CPLIsInteractive(stdin))
{
if (!osSourceSRS.empty())
{

View File

@ -30,12 +30,6 @@
#include "ogr_srs_api.h"
#include "commonutils.h"
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
/************************************************************************/
/* Usage() */
/************************************************************************/
@ -359,7 +353,7 @@ MAIN_START(argc, argv)
if (!bCoordOnCommandLine)
{
// Is it an interactive terminal ?
if (isatty(static_cast<int>(fileno(stdin))))
if (CPLIsInteractive(stdin))
{
if (pszSrcFilename != nullptr)
{

View File

@ -27,12 +27,6 @@
#include <fcntl.h>
#endif
#ifndef _WIN32
#include <unistd.h> // isatty()
#else
#include <io.h> // _isatty()
#endif
#include <algorithm>
#include <set>
#include <string>
@ -901,11 +895,7 @@ static bool IsGdalinfoInteractive()
{
static const bool bIsGdalinfoInteractive = []()
{
#ifndef _WIN32
if (isatty(static_cast<int>(fileno(stdout))))
#else
if (_isatty(_fileno(stdout)))
#endif
if (CPLIsInteractive(stdout))
{
std::string osPath;
osPath.resize(1024);

View File

@ -15,10 +15,6 @@
#include "cpl_error.h"
#ifndef _WIN32
#include <unistd.h> // isatty()
#endif
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
@ -1052,7 +1048,7 @@ void CPL_STDCALL CPLDefaultErrorHandler(CPLErr eErrClass, CPLErrorNum nError,
#ifndef _WIN32
CPLErrorContext *psCtx = CPLGetErrorContext();
if (psCtx != nullptr && !IS_PREFEFINED_ERROR_CTX(psCtx) &&
fpLog == stderr && isatty(static_cast<int>(fileno(stderr))))
fpLog == stderr && CPLIsInteractive(stderr))
{
if (psCtx->bProgressMode)
{