[gjs/mozjs78: 26/50] console: Reduce scope of HAVE_READLINE_READLINE_H




commit 0812c949a799df44754757c3fe45b7c580f182ee
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Aug 1 13:51:40 2020 -0700

    console: Reduce scope of HAVE_READLINE_READLINE_H
    
    Remove some duplicated code.

 modules/console.cpp | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/modules/console.cpp b/modules/console.cpp
index 7f8b9477..100bbbda 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -247,9 +247,9 @@ public:
     }
 };
 
-#ifdef HAVE_READLINE_READLINE_H
 GJS_USE
 static bool gjs_console_readline(char** bufp, const char* prompt) {
+#ifdef HAVE_READLINE_READLINE_H
     char *line;
     line = readline(prompt);
     if (!line)
@@ -257,20 +257,16 @@ static bool gjs_console_readline(char** bufp, const char* prompt) {
     if (line[0] != '\0')
         add_history(line);
     *bufp = line;
-    return true;
-}
-#else
-GJS_USE
-static bool gjs_console_readline(char** bufp, const char* prompt) {
+#else   // !HAVE_READLINE_READLINE_H
     char line[256];
     fprintf(stdout, "%s", prompt);
     fflush(stdout);
     if (!fgets(line, sizeof line, stdin))
         return false;
     *bufp = g_strdup(line);
+#endif  // !HAVE_READLINE_READLINE_H
     return true;
 }
-#endif
 
 /* Return value of false indicates an uncatchable exception, rather than any
  * exception. (This is because the exception should be auto-printed around the


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