From 551bed3add45ef909cf4cce02af255e08f4a0ec2 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 8 Feb 2018 09:57:23 +0300 Subject: [PATCH] Convert cord tests to valid C++ code 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 | 2 +- cord/tests/de_win.c | 12 ++++++------ cord/tests/de_win.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cord/tests/de.c b/cord/tests/de.c index 1c00270..01cc5c5 100644 --- a/cord/tests/de.c +++ b/cord/tests/de.c @@ -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(); diff --git a/cord/tests/de_win.c b/cord/tests/de_win.c index 64ab804..d99942e 100644 --- a/cord/tests/de_win.c +++ b/cord/tests/de_win.c @@ -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; diff --git a/cord/tests/de_win.h b/cord/tests/de_win.h index 93c5eeb..33ecfa2 100644 --- a/cord/tests/de_win.h +++ b/cord/tests/de_win.h @@ -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. */ -- 2.7.4