[cmake-developers] Portability patches / bug fixes

Joerg Sonnenberger joerg at britannica.bec.de
Sat Sep 12 11:03:20 EDT 2015


Hi all,
attached are three patches for cmake. The first two should be trivial
and self-explaining. The third is a more involved change for ccmake. At
the moment, the form widget logic uses internal variables of the ncurses
implementation of form.h. There is at least one other implementation
which works different (in NetBSD). It seems to work as intended with
both ncurses and NetBSD's libform.

Joerg
-------------- next part --------------
>From ab83e103438b284335baec76037a8b69a6394a30 Mon Sep 17 00:00:00 2001
From: Joerg Sonnenberger <joerg at bec.de>
Date: Sat, 12 Sep 2015 16:34:12 +0200
Subject: [PATCH 1/3] In C99 mode, Solaris variants may already define
 isfinite, so check for the existance first.

---
 Utilities/cmjsoncpp/src/lib_json/json_writer.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp b/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp
index b64cdb0..e3f4e53 100644
--- a/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp
+++ b/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp
@@ -24,7 +24,9 @@
 // Solaris
 #if defined(__sun)
 # include <ieeefp.h>
-# define isfinite finite
+# if !defined(isfinite)
+#  define isfinite finite
+# endif
 #endif
 
 // AIX
-- 
1.9.1

-------------- next part --------------
>From 10eb3b7fbee75a3a97f732e314fba193f64931e1 Mon Sep 17 00:00:00 2001
From: Joerg Sonnenberger <joerg at bec.de>
Date: Sat, 12 Sep 2015 16:35:36 +0200
Subject: [PATCH 2/3] printw takes a format string as first argument, so don't
 pass variable strings to it directly.

---
 Source/CursesDialog/cmCursesLongMessageForm.cxx |  6 +++---
 Source/CursesDialog/cmCursesMainForm.cxx        | 15 +++++++--------
 Source/CursesDialog/cmCursesStringWidget.cxx    | 11 +++++------
 3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx
index 67e4aab..2e5e322 100644
--- a/Source/CursesDialog/cmCursesLongMessageForm.cxx
+++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx
@@ -82,10 +82,10 @@ void cmCursesLongMessageForm::UpdateStatusBar()
 
   curses_move(y-4,0);
   attron(A_STANDOUT);
-  printw(bar);
+  printw("%s", bar);
   attroff(A_STANDOUT);
   curses_move(y-3,0);
-  printw(version);
+  printw("%s", version);
   pos_form_cursor(this->Form);
 }
 
@@ -102,7 +102,7 @@ void cmCursesLongMessageForm::PrintKeys()
   sprintf(firstLine,  "Press [e] to exit help");
 
   curses_move(y-2,0);
-  printw(firstLine);
+  printw("%s", firstLine);
   pos_form_cursor(this->Form);
 
 }
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index be17a9f..d3a84d3 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -456,19 +456,19 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
     {
     strcpy(fmt, "                           ");
     }
-  printw(fmt);
+  printw("%s", fmt);
   curses_move(y-3,0);
-  printw(firstLine);
+  printw("%s", firstLine);
   curses_move(y-2,0);
-  printw(secondLine);
+  printw("%s", secondLine);
   curses_move(y-1,0);
-  printw(thirdLine);
+  printw("%s", thirdLine);
 
   if (cw)
     {
     sprintf(firstLine, "Page %d of %d", cw->GetPage(), this->NumberOfPages);
     curses_move(0,65-static_cast<unsigned int>(strlen(firstLine))-1);
-    printw(firstLine);
+    printw("%s", firstLine);
     }
 //    }
 
@@ -614,11 +614,10 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
   // Now print both lines
   curses_move(y-5,0);
   attron(A_STANDOUT);
-  char format[] = "%s";
-  printw(format, bar);
+  printw("%s", bar);
   attroff(A_STANDOUT);
   curses_move(y-4,0);
-  printw(version);
+  printw("%s", version);
   pos_form_cursor(this->Form);
 }
 
diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx
index acf262f..1fe0945 100644
--- a/Source/CursesDialog/cmCursesStringWidget.cxx
+++ b/Source/CursesDialog/cmCursesStringWidget.cxx
@@ -229,17 +229,16 @@ bool cmCursesStringWidget::PrintKeys()
       }
     firstLine[511] = '\0';
     curses_move(y-4,0);
-    printw(firstLine);
+    printw("%s", firstLine);
     curses_move(y-3,0);
-    printw(firstLine);
+    printw("%s", firstLine);
     curses_move(y-2,0);
-    printw(firstLine);
+    printw("%s", firstLine);
     curses_move(y-1,0);
-    printw(firstLine);
+    printw("%s", firstLine);
 
-    sprintf(firstLine,  "Editing option, press [enter] to leave edit.");
     curses_move(y-3,0);
-    printw(firstLine);
+    printw("Editing option, press [enter] to leave edit.");
     return true;
     }
   else
-- 
1.9.1

-------------- next part --------------
>From a0479b89439b8de5e1c900a9e9482ebf5638c23e Mon Sep 17 00:00:00 2001
From: Joerg Sonnenberger <joerg at bec.de>
Date: Sat, 12 Sep 2015 16:37:35 +0200
Subject: [PATCH 3/3] curcol is an implementation detail of ncurses, other form
 implementation may not have it. The switch-to-previous-field logic only
 exists for overloaded requests of REQ_DEL_PREV, so no need to check for
 REQ_DEL_CHAR. For REQ_DEL_PREV, check if the field changed and if it did,
 change it back.

---
 Source/CursesDialog/cmCursesStringWidget.cxx | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx
index 1fe0945..8be2aa0 100644
--- a/Source/CursesDialog/cmCursesStringWidget.cxx
+++ b/Source/CursesDialog/cmCursesStringWidget.cxx
@@ -168,17 +168,16 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
     else if ( key == 127 ||
               key == KEY_BACKSPACE )
       {
-      if ( form->curcol > 0 )
-        {
+        FIELD *cur = current_field(form);
         form_driver(form, REQ_DEL_PREV);
-        }
+        if (current_field(form) != cur)
+          {
+          set_current_field(form, cur);
+          }
       }
     else if ( key == ctrl('d') ||key == KEY_DC )
       {
-      if ( form->curcol >= 0 )
-        {
-        form_driver(form, REQ_DEL_CHAR);
-        }
+      form_driver(form, REQ_DEL_CHAR);
       }
     else
       {
-- 
1.9.1



More information about the cmake-developers mailing list