(svn r12428) -Fix [FS#1878]: loading from the config file could fail even when the data is correct. Patch by Dominik.
authorrubidium
Wed, 26 Mar 2008 11:50:53 +0000
changeset 8739 2cdee97876a8
parent 8738 05aca6d9471b
child 8740 46c8fc403ad6
(svn r12428) -Fix [FS#1878]: loading from the config file could fail even when the data is correct. Patch by Dominik.
src/osk_gui.cpp
--- a/src/osk_gui.cpp	Wed Mar 26 10:38:31 2008 +0000
+++ b/src/osk_gui.cpp	Wed Mar 26 11:50:53 2008 +0000
@@ -299,14 +299,22 @@
 	if (StrEmpty(_keyboard_opt[1])) {
 		GetString(keyboard[1], STR_OSK_KEYBOARD_LAYOUT_CAPS, lastof(keyboard[1]));
 	} else {
-		strncpy(keyboard[0], _keyboard_opt[0], lengthof(keyboard[1]));
+		strncpy(keyboard[1], _keyboard_opt[1], lengthof(keyboard[1]));
 	}
 
 	for (uint j = 0; j < 2; j++) {
 		const char *kbd = keyboard[j];
+		bool ended = false;
 		for (uint i = 0; i < OSK_KEYBOARD_ENTRIES; i++) {
 			_keyboard[j][i] = Utf8Consume(&kbd);
 
+			/* Be lenient when the last characters are missing (is quite normal) */
+			if (_keyboard[j][i] == '\0' || ended) {
+				ended = true;
+				_keyboard[j][i] = ' ';
+				continue;
+			}
+
 			if (IsPrintable(_keyboard[j][i])) {
 				errormark[j][i] = ' ';
 			} else {