Changeset - r28335:7107f9cc6900
[Not reviewed]
master
0 5 0
Rubidium - 11 months ago 2023-12-25 23:24:59
rubidium@openttd.org
Codechange: replace NULL with nullptr
5 files changed with 16 insertions and 16 deletions:
0 comments (0 inline, 0 general)
src/network/core/http_winhttp.cpp
Show inline comments
 
@@ -64,13 +64,13 @@ NetworkHTTPRequest::NetworkHTTPRequest(c
 
static std::string GetLastErrorAsString()
 
{
 
	char buffer[512];
 
	DWORD error_code = GetLastError();
 

	
 
	if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, GetModuleHandleA("winhttp.dll"), error_code,
 
		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, sizeof(buffer), NULL) == 0) {
 
		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, sizeof(buffer), nullptr) == 0) {
 
		return fmt::format("unknown error {}", error_code);
 
	}
 

	
 
	return buffer;
 
}
 

	
src/network/core/os_abstraction.cpp
Show inline comments
 
@@ -78,14 +78,14 @@ bool NetworkError::IsConnectInProgress()
 
 */
 
const std::string &NetworkError::AsString() const
 
{
 
	if (this->message.empty()) {
 
#if defined(_WIN32)
 
		char buffer[512];
 
		if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, this->error,
 
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, sizeof(buffer), NULL) == 0) {
 
		if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, this->error,
 
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, sizeof(buffer), nullptr) == 0) {
 
			this->message.assign(fmt::format("Unknown error {}", this->error));
 
		} else {
 
			this->message.assign(buffer);
 
		}
 
#else
 
		/* Make strerror thread safe by locking access to it. There is a thread safe strerror_r, however
src/video/cocoa/cocoa_v.mm
Show inline comments
 
@@ -661,13 +661,13 @@ void VideoDriver_CocoaQuartz::AllocateBa
 
		8,                         // bits per component
 
		this->window_pitch * 4,    // bytes per row
 
		this->color_space,         // color space
 
		kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host
 
	);
 

	
 
	assert(this->cgcontext != NULL);
 
	assert(this->cgcontext != nullptr);
 
	CGContextSetShouldAntialias(this->cgcontext, FALSE);
 
	CGContextSetAllowsAntialiasing(this->cgcontext, FALSE);
 
	CGContextSetInterpolationQuality(this->cgcontext, kCGInterpolationNone);
 

	
 
	if (this->buffer_depth == 8) {
 
		free(this->pixel_buffer);
src/video/cocoa/cocoa_wnd.mm
Show inline comments
 
@@ -926,22 +926,22 @@ void CocoaDialog(const char *title, cons
 
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
 
{
 
	if (!EditBoxInGlobalFocus()) return;
 

	
 
	NSString *s = [ aString isKindOfClass:[ NSAttributedString class ] ] ? [ aString string ] : (NSString *)aString;
 

	
 
	const char *insert_point = NULL;
 
	const char *replace_range = NULL;
 
	const char *insert_point = nullptr;
 
	const char *replace_range = nullptr;
 
	if (replacementRange.location != NSNotFound) {
 
		/* Calculate the part to be replaced. */
 
		insert_point = Utf8AdvanceByUtf16Units(_focused_window->GetFocusedTextbuf()->GetText(), replacementRange.location);
 
		replace_range = Utf8AdvanceByUtf16Units(insert_point, replacementRange.length);
 
	}
 

	
 
	HandleTextInput(NULL, true);
 
	HandleTextInput([ s UTF8String ], false, NULL, insert_point, replace_range);
 
	HandleTextInput(nullptr, true);
 
	HandleTextInput([ s UTF8String ], false, nullptr, insert_point, replace_range);
 
}
 

	
 
/** Insert the given text at the caret. */
 
- (void)insertText:(id)aString
 
{
 
	[ self insertText:aString replacementRange:NSMakeRange(NSNotFound, 0) ];
 
@@ -952,15 +952,15 @@ void CocoaDialog(const char *title, cons
 
{
 
	if (!EditBoxInGlobalFocus()) return;
 

	
 
	NSString *s = [ aString isKindOfClass:[ NSAttributedString class ] ] ? [ aString string ] : (NSString *)aString;
 

	
 
	const char *utf8 = [ s UTF8String ];
 
	if (utf8 != NULL) {
 
		const char *insert_point = NULL;
 
		const char *replace_range = NULL;
 
	if (utf8 != nullptr) {
 
		const char *insert_point = nullptr;
 
		const char *replace_range = nullptr;
 
		if (replacementRange.location != NSNotFound) {
 
			/* Calculate the part to be replaced. */
 
			NSRange marked = [ self markedRange ];
 
			insert_point = Utf8AdvanceByUtf16Units(_focused_window->GetFocusedTextbuf()->GetText(), replacementRange.location + (marked.location != NSNotFound ? marked.location : 0u));
 
			replace_range = Utf8AdvanceByUtf16Units(insert_point, replacementRange.length);
 
		}
src/video/win32_v.cpp
Show inline comments
 
@@ -272,13 +272,13 @@ static bool DrawIMECompositionString()
 
}
 

	
 
/** Set position of the composition window to the caret position. */
 
static void SetCompositionPos(HWND hwnd)
 
{
 
	HIMC hIMC = ImmGetContext(hwnd);
 
	if (hIMC != NULL) {
 
	if (hIMC != nullptr) {
 
		COMPOSITIONFORM cf;
 
		cf.dwStyle = CFS_POINT;
 

	
 
		if (EditBoxInGlobalFocus()) {
 
			/* Get caret position. */
 
			Point pt = _focused_window->GetCaretPosition();
 
@@ -294,13 +294,13 @@ static void SetCompositionPos(HWND hwnd)
 
}
 

	
 
/** Set the position of the candidate window. */
 
static void SetCandidatePos(HWND hwnd)
 
{
 
	HIMC hIMC = ImmGetContext(hwnd);
 
	if (hIMC != NULL) {
 
	if (hIMC != nullptr) {
 
		CANDIDATEFORM cf;
 
		cf.dwIndex = 0;
 
		cf.dwStyle = CFS_EXCLUDE;
 

	
 
		if (EditBoxInGlobalFocus()) {
 
			Point pt = _focused_window->GetCaretPosition();
 
@@ -329,13 +329,13 @@ static void SetCandidatePos(HWND hwnd)
 

	
 
/** Handle WM_IME_COMPOSITION messages. */
 
static LRESULT HandleIMEComposition(HWND hwnd, WPARAM wParam, LPARAM lParam)
 
{
 
	HIMC hIMC = ImmGetContext(hwnd);
 

	
 
	if (hIMC != NULL) {
 
	if (hIMC != nullptr) {
 
		if (lParam & GCS_RESULTSTR) {
 
			/* Read result string from the IME. */
 
			LONG len = ImmGetCompositionString(hIMC, GCS_RESULTSTR, nullptr, 0); // Length is always in bytes, even in UNICODE build.
 
			std::wstring str(len + 1, L'\0');
 
			len = ImmGetCompositionString(hIMC, GCS_RESULTSTR, str.data(), len);
 
			str[len / sizeof(wchar_t)] = L'\0';
 
@@ -388,13 +388,13 @@ static LRESULT HandleIMEComposition(HWND
 
}
 

	
 
/** Clear the current composition string. */
 
static void CancelIMEComposition(HWND hwnd)
 
{
 
	HIMC hIMC = ImmGetContext(hwnd);
 
	if (hIMC != NULL) ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
 
	if (hIMC != nullptr) ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
 
	ImmReleaseContext(hwnd, hIMC);
 
	/* Clear any marked string from the current edit box. */
 
	HandleTextInput(nullptr, true);
 
}
 

	
 
LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
@@ -685,13 +685,13 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, U
 
		case WM_DPICHANGED: {
 
			auto did_adjust = AdjustGUIZoom(true);
 

	
 
			/* Resize the window to match the new DPI setting. */
 
			RECT *prcNewWindow = (RECT *)lParam;
 
			SetWindowPos(hwnd,
 
				NULL,
 
				nullptr,
 
				prcNewWindow->left,
 
				prcNewWindow->top,
 
				prcNewWindow->right - prcNewWindow->left,
 
				prcNewWindow->bottom - prcNewWindow->top,
 
				SWP_NOZORDER | SWP_NOACTIVATE);
 

	
0 comments (0 inline, 0 general)