fix C89 forbidden mixed declarations

This commit is contained in:
Bayemite 2021-06-03 22:02:24 +10:00
parent 5ddb905a6a
commit 3c44229af8
3 changed files with 24 additions and 18 deletions

View File

@ -2907,7 +2907,7 @@ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
* GLFW_PLATFORM_ERROR. * GLFW_PLATFORM_ERROR.
* *
* @remark Do not forget to free the returned char* when you are done with it. * @remark Do not forget to free the returned char* when you are done with it.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_title * @sa @ref window_title
@ -2935,7 +2935,7 @@ GLFWAPI char* glfwGetWindowTitle(GLFWwindow* window);
* *
* @sa @ref window_title * @sa @ref window_title
* @sa @ref glfwGetWindowTitle * @sa @ref glfwGetWindowTitle
* *
* @since Added in version 1.0. * @since Added in version 1.0.
* @glfw3 Added window handle parameter. * @glfw3 Added window handle parameter.
* *

View File

@ -1464,11 +1464,14 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
char* _glfwPlatformGetWindowTitle(_GLFWwindow* window) char* _glfwPlatformGetWindowTitle(_GLFWwindow* window)
{ {
int count = GetWindowTextLengthW(window->win32.handle); int count;
SetLastError(0);
count = GetWindowTextLengthW(window->win32.handle);
if(count == 0) if(count == 0)
{ {
SetLastError(0); int error;
int error = GetLastError(); error = GetLastError();
if(error != 0) if(error != 0)
{ {
@ -1477,18 +1480,21 @@ char* _glfwPlatformGetWindowTitle(_GLFWwindow* window)
} }
else else
return calloc(1, sizeof(char)); // single \0 return calloc(1, sizeof(char)); // single \0
} }
else else
{ {
WCHAR* wideTitle;
char* title;
count += 1; // the \0 count += 1; // the \0
WCHAR* wideTitle = calloc(count, sizeof(WCHAR));
wideTitle = calloc(count, sizeof(WCHAR));
GetWindowTextW(window->win32.handle, wideTitle, count); GetWindowTextW(window->win32.handle, wideTitle, count);
char* title = _glfwCreateUTF8FromWideStringWin32(wideTitle); title = _glfwCreateUTF8FromWideStringWin32(wideTitle);
if(!title) if(!title)
return calloc(1, sizeof(char)); // single \0 return calloc(1, sizeof(char)); // single \0
return title; return title;
} }
} }

View File

@ -2084,7 +2084,7 @@ char* _glfwPlatformGetWindowTitle(_GLFWwindow* window)
char* title; char* title;
_glfwGrabErrorHandlerX11(); _glfwGrabErrorHandlerX11();
if (XGetWMName(_glfw.x11.display, window->x11.handle, &textProperty) == 0) if (XGetWMName(_glfw.x11.display, window->x11.handle, &textProperty) == 0)
{ {
_glfwInputErrorX11(GLFW_PLATFORM_ERROR, "X11: Could not get window title"); _glfwInputErrorX11(GLFW_PLATFORM_ERROR, "X11: Could not get window title");
@ -2100,10 +2100,10 @@ char* _glfwPlatformGetWindowTitle(_GLFWwindow* window)
_glfwInputErrorX11(GLFW_PLATFORM_ERROR, "X11: No memory to convert window title to UTF-8"); _glfwInputErrorX11(GLFW_PLATFORM_ERROR, "X11: No memory to convert window title to UTF-8");
else if (ret == XLocaleNotSupported || ret == XConverterNotFound) else if (ret == XLocaleNotSupported || ret == XConverterNotFound)
_glfwInputErrorX11(GLFW_PLATFORM_ERROR, "X11: Cannot convert window title, unsupported locale"); _glfwInputErrorX11(GLFW_PLATFORM_ERROR, "X11: Cannot convert window title, unsupported locale");
if (textProperty.value != NULL) if (textProperty.value != NULL)
XFree(textProperty.value); XFree(textProperty.value);
return NULL; return NULL;
} }
@ -2112,19 +2112,19 @@ char* _glfwPlatformGetWindowTitle(_GLFWwindow* window)
_glfwReleaseErrorHandlerX11(); _glfwReleaseErrorHandlerX11();
if (textProperty.value != NULL) if (textProperty.value != NULL)
XFree(textProperty.value); XFree(textProperty.value);
if (charList != NULL) if (charList != NULL)
XFreeStringList(charList); XFreeStringList(charList);
return calloc(1, sizeof(char)); return calloc(1, sizeof(char));
} }
title = _glfw_strdup(charList[0]); title = _glfw_strdup(charList[0]);
_glfwReleaseErrorHandlerX11(); _glfwReleaseErrorHandlerX11();
if (textProperty.value != NULL) if (textProperty.value != NULL)
XFree(textProperty.value); XFree(textProperty.value);
if (charList != NULL) if (charList != NULL)
XFreeStringList(charList); XFreeStringList(charList);