Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmake/modules/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,18 @@ check_symbol_exists (vsnprintf stdio.h HAVE_VSNPRINTF_)
if (HAVE_UNISTD_H_)
check_symbol_exists (access unistd.h HAVE_ACCESS)
check_symbol_exists (getpid unistd.h HAVE_GETPID)
check_symbol_exists (isatty unistd.h HAVE_ISATTY)
else (HAVE_UNISTD_H_)
# in MinGW:
check_symbol_exists (access io.h HAVE_ACCESS)
check_symbol_exists (_getpid process.h HAVE__GETPID)
check_symbol_exists (isatty io.h HAVE_ISATTY)
endif (HAVE_UNISTD_H_)

if (WIN32)
check_symbol_exists (_access io.h HAVE__ACCESS)
check_symbol_exists (_fileno stdio.h HAVE__FILENO)
check_symbol_exists (_isatty io.h HAVE__ISATTY)
check_symbol_exists (_getcwd direct.h HAVE__GETCWD)
check_symbol_exists (_mkdir direct.h HAVE__MKDIR)
check_symbol_exists (_setmode io.h HAVE__SETMODE)
Expand Down
3 changes: 3 additions & 0 deletions src/gmt_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -7868,6 +7868,9 @@ GMT_LOCAL int gmtapi_init_import (struct GMTAPI_CTRL *API, enum GMT_enum_family
/* Note that n_reg can have changed if we added file args above */

if ((mode & GMT_ADD_STDIO_ALWAYS) || ((mode & GMT_ADD_STDIO_IF_NONE) && n_reg == 0)) { /* Wish to register stdin pointer as a source */
if (n_reg == 0 && isatty (fileno (API->GMT->session.std[GMT_IN])))
GMT_Report (API, GMT_MSG_WARNING, "No input file given - reading table data from standard input (this terminal). "
"Type your data and press Ctrl-D when done. To use a file or a pipe instead, press Ctrl-C now and rerun the command with that input.\n");
if ((object_ID = GMT_Register_IO (API, family|GMT_VIA_MODULE_INPUT, GMT_IS_STREAM, geometry, GMT_IN, NULL, API->GMT->session.std[GMT_IN])) == GMT_NOTSET)
return_value (API, API->error, GMT_NOTSET); /* Failure to register stdin */
n_reg++; /* Add the single item */
Expand Down
2 changes: 2 additions & 0 deletions src/gmt_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
#cmakedefine HAVE_FCNTL
#cmakedefine HAVE_FILENO
#cmakedefine HAVE__FILENO
#cmakedefine HAVE_ISATTY
#cmakedefine HAVE__ISATTY
#cmakedefine HAVE_FSEEKO
#cmakedefine HAVE_FTELLO
#cmakedefine HAVE__FSEEKI64
Expand Down
7 changes: 7 additions & 0 deletions src/gmt_notposix.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,13 @@
# define fileno _fileno
#endif

/* isatty is usually in unistd.h; we use a macro here
* since the same function under WIN32 is prefixed with _
* and defined in io.h */
#if defined HAVE__ISATTY && !defined HAVE_ISATTY
# define isatty _isatty
#endif

/* rmdir is usually in unistd.h; we use a macro here
* since the same function under WIN32 is prefixed with _
* and defined in direct.h */
Expand Down
Loading