Convert cord tests to valid C++ code
authorIvan Maidanski <ivmai@mail.ru>
Thu, 8 Feb 2018 06:57:23 +0000 (09:57 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 8 Feb 2018 06:57:23 +0000 (09:57 +0300)
Issue #201 (bdwgc).

* cord/tests/de.c (main): Cast buf to char* when passed to setvbuf().
* cord/tests/de_win.c (de_error): Change "char*" to "const char*" for
the argument (because ISO C++ forbids converting a string constant to
char*).
* cord/tests/de_win.h (de_error): Likewise.
* cord/tests/de_win.c (WinMain): Change type of hAccel local variable
from HANDLE to HACCEL; cast GetStockObject(WHITE_BRUSH) result to
HBRUSH type.
* cord/tests/de_win.c (plain_chars, control_chars): Cast
GC_MALLOC_ATOMIC() result to char*.
* cord/tests/de_win.c (WndProc): Change type of hInstance static
variable from HANDLE to HINSTANCE.

cord/tests/de.c
cord/tests/de_win.c
cord/tests/de_win.h

index 1c00270..01cc5c5 100644 (file)
@@ -595,7 +595,7 @@ int main(int argc, char **argv)
     arg_file_name = argv[1];
     buf = GC_MALLOC_ATOMIC(8192);
     if (NULL == buf) OUT_OF_MEMORY;
-    setvbuf(stdout, buf, _IOFBF, 8192);
+    setvbuf(stdout, (char *)buf, _IOFBF, 8192);
     initscr();
     noecho(); nonl(); cbreak();
     generic_init();
index 64ab804..d99942e 100644 (file)
@@ -32,7 +32,7 @@ int COLS = 0;
 
 HWND        hwnd;
 
-void de_error(char *s)
+void de_error(const char *s)
 {
     (void)MessageBoxA(hwnd, s, "Demonstration Editor",
                       MB_ICONINFORMATION | MB_OK);
@@ -44,7 +44,7 @@ int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
 {
    MSG         msg;
    WNDCLASS    wndclass;
-   HANDLE      hAccel;
+   HACCEL      hAccel;
 
    GC_INIT();
 #  if defined(CPPCHECK)
@@ -60,7 +60,7 @@ int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
       wndclass.hInstance      = hInstance;
       wndclass.hIcon          = LoadIcon (hInstance, szAppName);
       wndclass.hCursor        = LoadCursor (NULL, IDC_ARROW);
-      wndclass.hbrBackground  = GetStockObject(WHITE_BRUSH);
+      wndclass.hbrBackground  = (HBRUSH)GetStockObject(WHITE_BRUSH);
       wndclass.lpszMenuName   = TEXT("DE");
       wndclass.lpszClassName  = szAppName;
 
@@ -120,7 +120,7 @@ int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
 /* Return the argument with all control characters replaced by blanks.  */
 char * plain_chars(char * text, size_t len)
 {
-    char * result = GC_MALLOC_ATOMIC(len + 1);
+    char * result = (char *)GC_MALLOC_ATOMIC(len + 1);
     register size_t i;
 
     if (NULL == result) return NULL;
@@ -139,7 +139,7 @@ char * plain_chars(char * text, size_t len)
 /* blank, and all control characters c replaced by c + 32.              */
 char * control_chars(char * text, size_t len)
 {
-    char * result = GC_MALLOC_ATOMIC(len + 1);
+    char * result = (char *)GC_MALLOC_ATOMIC(len + 1);
     register size_t i;
 
     if (NULL == result) return NULL;
@@ -201,7 +201,7 @@ INT_PTR CALLBACK AboutBoxCallback( HWND hDlg, UINT message,
 LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
                           WPARAM wParam, LPARAM lParam)
 {
-   static HANDLE  hInstance;
+   static HINSTANCE hInstance;
    HDC dc;
    PAINTSTRUCT ps;
    RECT client_area;
index 93c5eeb..33ecfa2 100644 (file)
@@ -93,5 +93,5 @@ void move_cursor(int column, int line);
 void invalidate_line(int line);
                         /* Invalidate line i on the screen.     */
 
-void de_error(char *s);
+void de_error(const char *s);
                         /* Display error message.       */