From 22a5863afda2aec2bfe0a8b7c889302599ab0241 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 30 Sep 2019 12:38:05 -0300 Subject: [PATCH] Fixing errno use in "has_selection" attribute. --- src/include/lib3270.h | 10 +++++++++- src/selection/selection.c | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/include/lib3270.h b/src/include/lib3270.h index b081b1d..af3b97b 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -1066,7 +1066,7 @@ LIB3270_EXPORT const char * lib3270_get_default_charset(void); /** - * Get selected area. + * @brief Get selected area. * * @param h Session Handle. * @@ -1077,6 +1077,14 @@ LIB3270_EXPORT char * lib3270_cut_selected(H3270 *hSession); + /** + * @brief Check if the terminal has selected area (allways sets errno). + * + * @param hSession Session handle. + * + * @return Non zero if the terminal has selected area, 0 if not. + * + */ LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession); /** diff --git a/src/selection/selection.c b/src/selection/selection.c index 47cf8bf..031a6b4 100644 --- a/src/selection/selection.c +++ b/src/selection/selection.c @@ -392,10 +392,11 @@ LIB3270_EXPORT char * lib3270_get_field_string_at(H3270 *session, int baddr) LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession) { + errno = 0; if(check_online_session(hSession)) return 0; - return hSession->selected != 0; + return (hSession->selected != 0); } LIB3270_EXPORT int lib3270_get_selection_rectangle(H3270 *hSession, unsigned int *row, unsigned int *col, unsigned int *width, unsigned int *height) -- libgit2 0.21.2