Fix null being inserted after non-ascii input on x11

This commit is contained in:
UnknownShadow200 2018-05-28 23:59:45 +10:00
parent f2c6b4c45b
commit 33dcb8599b
5 changed files with 14 additions and 5 deletions

View File

@ -350,6 +350,9 @@ namespace OpenTK.Platform.X11 {
EventHandler<KeyPressEventArgs> key_press = KeyPress; EventHandler<KeyPressEventArgs> key_press = KeyPress;
if (key_press != null) { if (key_press != null) {
for (int i = 0; i < status; i++) { for (int i = 0; i < status; i++) {
// ignore NULL char after non-ASCII input char, like ä or å on Finnish keyboard layout
if (chars[i] == '\0') continue;
KPEventArgs.KeyChar = chars[i]; KPEventArgs.KeyChar = chars[i];
key_press(this, KPEventArgs); key_press(this, KPEventArgs);
} }

View File

@ -829,7 +829,7 @@ static ReturnCode Deflate_FlushBlock(DeflateState* state, Int32 len) {
/* literals for last few bytes */ /* literals for last few bytes */
while (len > 0) { while (len > 0) {
Deflate_Lit(state, *cur); Deflate_Lit(state, *cur);
cur++; len--; len--; cur++;
} }
state->InputPosition = 0; state->InputPosition = 0;

View File

@ -14,6 +14,7 @@ extern UInt8* Platform_NewLine; /* Newline for text */
extern UInt8 Platform_DirectorySeparator; extern UInt8 Platform_DirectorySeparator;
extern ReturnCode ReturnCode_FileShareViolation; extern ReturnCode ReturnCode_FileShareViolation;
extern ReturnCode ReturnCode_FileNotFound; extern ReturnCode ReturnCode_FileNotFound;
extern ReturnCode ReturnCode_NotSupported;
void Platform_Init(void); void Platform_Init(void);
void Platform_Free(void); void Platform_Free(void);

View File

@ -86,11 +86,15 @@ ReturnCode Stream_Skip(Stream* stream, UInt32 count) {
} }
static ReturnCode Stream_DefaultIO(Stream* stream, UInt8* data, UInt32 count, UInt32* modified) { static ReturnCode Stream_DefaultIO(Stream* stream, UInt8* data, UInt32 count, UInt32* modified) {
*modified = 0; return 1; *modified = 0; return ReturnCode_NotSupported;
} }
static ReturnCode Stream_DefaultClose(Stream* stream) { return 0; } static ReturnCode Stream_DefaultClose(Stream* stream) { return 0; }
static ReturnCode Stream_DefaultSeek(Stream* stream, Int32 offset, Int32 seekType) { return 1; } static ReturnCode Stream_DefaultSeek(Stream* stream, Int32 offset, Int32 seekType) {
static ReturnCode Stream_DefaultGet(Stream* stream, UInt32* value) { *value = 0; return 1; } return ReturnCode_NotSupported;
}
static ReturnCode Stream_DefaultGet(Stream* stream, UInt32* value) {
*value = 0; return ReturnCode_NotSupported;
}
void Stream_SetDefaultOps(Stream* stream) { void Stream_SetDefaultOps(Stream* stream) {
stream->Read = Stream_DefaultIO; stream->Read = Stream_DefaultIO;

View File

@ -24,6 +24,7 @@ UInt8* Platform_NewLine = "\r\n";
UInt8 Platform_DirectorySeparator = '\\'; UInt8 Platform_DirectorySeparator = '\\';
ReturnCode ReturnCode_FileShareViolation = ERROR_SHARING_VIOLATION; ReturnCode ReturnCode_FileShareViolation = ERROR_SHARING_VIOLATION;
ReturnCode ReturnCode_FileNotFound = ERROR_FILE_NOT_FOUND; ReturnCode ReturnCode_FileNotFound = ERROR_FILE_NOT_FOUND;
ReturnCode ReturnCode_NotSupported = ERROR_NOT_SUPPORTED;
void Platform_Init(void) { void Platform_Init(void) {
heap = GetProcessHeap(); /* TODO: HeapCreate instead? probably not */ heap = GetProcessHeap(); /* TODO: HeapCreate instead? probably not */
@ -653,7 +654,7 @@ ReturnCode Platform_HttpGetRequestHeaders(AsyncRequest* request, void* handle, U
} }
ReturnCode Platform_HttpGetRequestData(AsyncRequest* request, void* handle, void** data, UInt32 size, volatile Int32* progress) { ReturnCode Platform_HttpGetRequestData(AsyncRequest* request, void* handle, void** data, UInt32 size, volatile Int32* progress) {
if (size == 0) return 1; if (size == 0) return ERROR_NOT_SUPPORTED;
*data = Platform_MemAlloc(size, 1); *data = Platform_MemAlloc(size, 1);
if (*data == NULL) ErrorHandler_Fail("Failed to allocate memory for http get data"); if (*data == NULL) ErrorHandler_Fail("Failed to allocate memory for http get data");