lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master bac897e 3/5: Prefer getchar() to getch()


From: Greg Chicares
Subject: [lmi-commits] [lmi] master bac897e 3/5: Prefer getchar() to getch()
Date: Tue, 11 Apr 2017 19:59:22 -0400 (EDT)

branch: master
commit bac897e838e9c37d5b6d7b89b317fbdd6bfeb4e9
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Prefer getchar() to getch()
    
    getch() was used only in one situation that should virtually never
    arise. For *nix builds, avoiding an extra keystroke approximately
    zero times per decade does not justify adding a dependency on a
    library that would require a nasty workaround anyway to avoid macro
    pollution.
---
 alert_cli.cpp          | 8 ++------
 platform_dependent.hpp | 3 ++-
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/alert_cli.cpp b/alert_cli.cpp
index 39c4076..0f4baad 100644
--- a/alert_cli.cpp
+++ b/alert_cli.cpp
@@ -23,14 +23,10 @@
 
 #include "alert.hpp"
 
-#include <cstdio>                       // std::fputs()
+#include <cstdio>                       // std::fputs(), std::getchar()
 #include <iostream>
 #include <stdexcept>
 
-// Avoid including any 'curses' header that defines rude macros:
-//   http://lists.nongnu.org/archive/html/lmi/2008-06/msg00045.html
-extern "C" int getch();
-
 namespace
 {
 volatile bool ensure_setup = set_alert_functions
@@ -45,7 +41,7 @@ bool continue_anyway()
 {
     int c;
   ask:
-    c = getch();
+    c = getchar();
     if('y' == c || 'Y' == c)
         {
         std::cout << std::endl;
diff --git a/platform_dependent.hpp b/platform_dependent.hpp
index df708e0..a2adcea 100644
--- a/platform_dependent.hpp
+++ b/platform_dependent.hpp
@@ -90,7 +90,8 @@
 // pollutes the global namespace intolerably with ill-named macros:
 //   http://lists.nongnu.org/archive/html/lmi/2008-06/msg00045.html
 // and therefore a prototype for getch() is instead provided by other
-// means, locally, wherever it's needed.
+// means, locally, wherever it's needed. As of 2017-04, getch() is no
+// longer used; this paragraph is kept lest it be reintroduced.
 
 // GNU/Linux (but not MinGW) requires including certain headers while
 // __STRICT_ANSI__ is not defined in order to get prototypes for



reply via email to

[Prev in Thread] Current Thread [Next in Thread]