summaryrefslogtreecommitdiff
path: root/games/arx-libertatis/patches/patch-src_script_Script.cpp
blob: 4cdca6e23f29c83f4cd8683c96f204c3d19af229 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$NetBSD: patch-src_script_Script.cpp,v 1.1 2016/09/02 16:46:04 wiz Exp $

Something goes wrong with tolower and characters with value 0xA7,
so only apply to characters in the range A-Z.

--- src/script/Script.cpp.orig	2013-07-15 19:56:03.000000000 +0200
+++ src/script/Script.cpp	2013-07-15 19:57:38.000000000 +0200
@@ -103,6 +103,13 @@
 SCR_TIMER * scr_timer = NULL;
 long ActiveTimers = 0;
 
+static int ScriptToLower(int c) {
+	if(c >= 'A' && c <= 'Z') {
+		return tolower(c);
+	}
+	return c;
+}
+
 long FindScriptPos(const EERIE_SCRIPT * es, const string & str) {
 	
 	// TODO(script-parser) remove, respect quoted strings
@@ -2150,7 +2157,7 @@
 	script.data = file->readAlloc();
 	script.size = file->size();
 	
-	std::transform(script.data, script.data + script.size, script.data, ::tolower);
+	std::transform(script.data, script.data + script.size, script.data, ::ScriptToLower);
 	
 	script.allowevents = 0;