Subject: bug#26460: [PATCH 2/2] gnu: Add kiki.

From: Ricardo Wurmus <[email-masked]>
Date: Wed, 12 Apr 2017 11:33:52 +0200

* gnu/packages/games.scm (kiki): New variable.
* gnu/packages/patches/kiki-level-selection-crash.patch,
gnu/packages/patches/kiki-makefile.patch,
gnu/packages/patches/kiki-missing-includes.patch,
gnu/packages/patches/kiki-portability-64bit.patch: New patches.
* gnu/local.mk (dist_patch_DATA): Add them.
---
 gnu/local.mk                                       |   4 +
 gnu/packages/games.scm                             |  97 ++++++
 .../patches/kiki-level-selection-crash.patch       |  19 ++
 gnu/packages/patches/kiki-makefile.patch           |  57 ++++
 gnu/packages/patches/kiki-missing-includes.patch   |  55 ++++
 gnu/packages/patches/kiki-portability-64bit.patch  | 328 +++++++++++++++++++++
 6 files changed, 560 insertions(+)
 create mode 100644 gnu/packages/patches/kiki-level-selection-crash.patch
 create mode 100644 gnu/packages/patches/kiki-makefile.patch
 create mode 100644 gnu/packages/patches/kiki-missing-includes.patch
 create mode 100644 gnu/packages/patches/kiki-portability-64bit.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index d755d8248..78356753a 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -665,6 +665,10 @@ dist_patch_DATA =						\
   %D%/packages/patches/jq-CVE-2015-8863.patch			\
   %D%/packages/patches/kdbusaddons-kinit-file-name.patch	\
   %D%/packages/patches/khmer-use-libraries.patch                \
+  %D%/packages/patches/kiki-level-selection-crash.patch		\
+  %D%/packages/patches/kiki-makefile.patch			\
+  %D%/packages/patches/kiki-missing-includes.patch		\
+  %D%/packages/patches/kiki-portability-64bit.patch		\
   %D%/packages/patches/kio-CVE-2017-6410.patch			\
   %D%/packages/patches/kmod-module-directory.patch		\
   %D%/packages/patches/kobodeluxe-paths.patch			\
diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 71f35e2fe..710b2746c 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -89,6 +89,7 @@
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages sdl)
+  #:use-module (gnu packages swig)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages check)
   #:use-module (gnu packages fonts)
@@ -3552,3 +3553,99 @@ over 100 user-created campaigns.")
                    license:cc0
                    license:cc-by3.0
                    license:cc-by-sa3.0))))
+
+(define-public kiki
+  (package
+    (name "kiki")
+    (version "1.0.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://sourceforge/kiki/kiki-src/"
+                                  version "/kiki-" version "-src.tgz"))
+              (sha256
+               (base32
+                "0ihjdsxbn8z3cz0gpcprafiipcqaiskgdnh1rhmw4qff8dszalbn"))
+              (modules '((guix build utils)))
+              (snippet
+               '(begin
+                  (for-each delete-file (find-files "." "\\.dll$"))
+                  #t))
+              (patches
+               (search-patches "kiki-level-selection-crash.patch"
+                               "kiki-makefile.patch"
+                               "kiki-missing-includes.patch"
+                               "kiki-portability-64bit.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f ; there are no tests
+       #:make-flags '("CXX=g++")
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'configure
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (setenv "CPLUS_INCLUDE_PATH"
+                     (string-append (assoc-ref inputs "sdl-union")
+                                    "/include/SDL:"
+                                    (assoc-ref inputs "python")
+                                    "/include/python2.7:"
+                                    (getenv "CPLUS_INCLUDE_PATH")))
+             (substitute* "src/main/main.cpp"
+               (("#include <SDL.h>" line)
+                (string-append line "
+#define K_INCLUDE_GLUT
+#include \"KIncludeTools.h\""))
+               (("// initialize SDL" line)
+                (string-append "glutInit(&argc,argv);\n" line)))
+             (substitute* "src/main/KikiController.cpp"
+               (("getenv\\(\"KIKI_HOME\"\\)")
+                (string-append "\"" (assoc-ref outputs "out") "/share/kiki/\"")))
+             (substitute* "linux/Makefile"
+               (("CXXOPTS =" line)
+                (string-append line " -fpermissive"))
+               (("PYTHON_VERSION=.*") "PYTHON_VERSION=2.7")
+               (("PYTHONHOME =.*")
+                (string-append "PYTHONHOME = "
+                               (assoc-ref inputs "python")
+                               "/lib/python2.7/"))
+               (("\\$\\(GLLIBS\\)" line)
+                (string-append line " -lm -lpython2.7")))
+             (substitute* "src/main/KikiPythonWidget.h"
+               (("#define __KikiPythonWidget" line)
+                (string-append line "\n#include \"KikiPython.h\"")))
+             #t))
+         (add-before 'build 'build-kodilib
+           (lambda* (#:key make-flags #:allow-other-keys)
+             (with-directory-excursion "kodilib/linux"
+               (zero? (apply system* "make" make-flags)))))
+         (add-after 'build-kodilib 'chdir
+           (lambda _ (chdir "linux") #t))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out   (assoc-ref outputs "out"))
+                    (bin   (string-append out "/bin"))
+                    (share (string-append out "/share/kiki")))
+               (mkdir-p bin)
+               (mkdir-p share)
+               (install-file "kiki" bin)
+               (copy-recursively "../py" (string-append share "/py"))
+               (copy-recursively "../sound" (string-append share "/sound"))
+               #t))))))
+    (inputs
+     `(("glu" ,glu)
+       ;; Kiki builds fine with freeglut 3.0.0 but segfaults on start.
+       ("freeglut" ,freeglut-2.8)
+       ("sdl-union" ,(sdl-union (list sdl
+                                      sdl-mixer
+                                      sdl-image)))
+       ("python" ,python-2)))
+    (native-inputs
+     `(("swig" ,swig)))
+    (home-page "http://kiki.sourceforge.net/")
+    (synopsis "3D puzzle game")
+    (description "Kiki the nano bot is a 3D puzzle game.  It is basically a
+mixture of the games Sokoban and Kula-World.  Your task is to help Kiki, a
+small robot living in the nano world, repair its maker.")
+    ;; See <http://metadata.ftp-master.debian.org/changelogs/main/k/
+    ;; kiki-the-nano-bot/kiki-the-nano-bot_1.0.2+dfsg1-4_copyright>
+    ;; for a statement from the author.
+    (license license:public-domain)))
diff --git a/gnu/packages/patches/kiki-level-selection-crash.patch b/gnu/packages/patches/kiki-level-selection-crash.patch
new file mode 100644
index 000000000..8cc647850
--- /dev/null
+++ b/gnu/packages/patches/kiki-level-selection-crash.patch
@@ -0,0 +1,19 @@
+Downloaded from https://anonscm.debian.org/viewvc/pkg-games/packages/trunk/kiki-the-nano-bot/debian/patches/level-selection-with-no-levels-solved.patch?revision=8291&view=co
+
+Kiki crashes if the user tries to use the level selection menu before
+finishing any level.
+
+Peter De Wachter ([email-masked])
+placed in the public domain
+
+--- a/py/levelselection.py
++++ b/py/levelselection.py
+@@ -25,6 +25,8 @@
+     # ............................................................................................................    
+     
+     last_level = highscore.getLastAvailableLevel()
++    if last_level < 0:
++        last_level = 0
+     current_level = (level_index >= 0) and level_index or last_level 
+         
+     world.max_level_index = last_level
diff --git a/gnu/packages/patches/kiki-makefile.patch b/gnu/packages/patches/kiki-makefile.patch
new file mode 100644
index 000000000..7329301f2
--- /dev/null
+++ b/gnu/packages/patches/kiki-makefile.patch
@@ -0,0 +1,57 @@
+Downloaded from https://anonscm.debian.org/viewvc/pkg-games/packages/trunk/kiki-the-nano-bot/debian/patches/Makefile.patch?revision=15681&view=co
+
+Makefile fixes:
+ - Make CXXFLAGS, CPPFLAGS, LDFLAGS available for user-specified flags.
+ - run SWIG before compiling
+
+Peter De Wachter ([email-masked])
+placed in the public domain
+
+--- a/kodilib/linux/Makefile
++++ b/kodilib/linux/Makefile
+@@ -21,7 +21,7 @@
+ 
+ INCLUDES = $(KODI_INCLUDES) $(X11_INCLUDES) $(SDL_INCLUDES)
+ 
+-CXXFLAGS = $(INCLUDES) $(SDL_CFLAGS)
++CXXOPTS = -Wall $(INCLUDES) $(SDL_CFLAGS) $(CPPFLAGS) $(CXXFLAGS)
+ 
+ src =  \
+ 	$(KODISRCDIR)/handler/KEventHandler.cpp \
+@@ -95,4 +95,4 @@
+ 	$(RM) -f $(obj) libkodi.a
+ 
+ %.o:    %.cpp
+-	$(CXX) -c $(CXXFLAGS) -o $@ $<
++	$(CXX) -c $(CXXOPTS) -o $@ $<
+--- a/linux/Makefile
++++ b/linux/Makefile
+@@ -46,7 +46,7 @@
+ 
+ INCLUDES = $(KIKI_INCLUDES) $(X11_INCLUDES) $(PYTHON_INCLUDES)
+ 
+-CXXFLAGS = $(INCLUDES) $(SDLCFLAGS)
++CXXOPTS = -Wall $(INCLUDES) $(SDLCFLAGS) $(CPPFLAGS) $(CXXFLAGS)
+ 
+ src =  \
+ 	$(KIKISRC)/base/KikiAction.cpp \
+@@ -105,8 +105,10 @@
+ obj = $(src:.cpp=.o)
+ 
+ kiki: $(KIKISRC)/../SWIG/KikiPy_wrap.cpp $(obj)
+-	-(cd ../SWIG; swig -c++ -python -globals kiki -o KikiPy_wrap.cpp KikiPy.i; cp kiki.py ../py)
+-	$(CXX) $(obj) $(KODILIB) -o kiki $(GLLIBS) $(SDLLIBS) $(PYTHONLIBS)
++	$(CXX) $(LDFLAGS) $(obj) $(KODILIB) -o kiki $(GLLIBS) $(SDLLIBS) $(PYTHONLIBS)
++
++$(KIKISRC)/../SWIG/KikiPy_wrap.cpp: $(wildcard ../SWIG/*.i)
++	(cd ../SWIG && swig -c++ -python -globals kiki -DSWIG_PYTHON_LEGACY_BOOL -o KikiPy_wrap.cpp KikiPy.i && cp kiki.py ../py)
+ 
+ obj-clean:
+ 	$(RM) -f $(obj)
+@@ -115,5 +117,5 @@
+ 	$(RM) -f $(obj) kiki
+ 
+ %.o:    %.cpp
+-	$(CXX) -c $(CXXFLAGS) -o $@ $<
++	$(CXX) -c $(CXXOPTS) -o $@ $<
+ 
diff --git a/gnu/packages/patches/kiki-missing-includes.patch b/gnu/packages/patches/kiki-missing-includes.patch
new file mode 100644
index 000000000..e5ee74f3e
--- /dev/null
+++ b/gnu/packages/patches/kiki-missing-includes.patch
@@ -0,0 +1,55 @@
+Downloaded from https://anonscm.debian.org/viewvc/pkg-games/packages/trunk/kiki-the-nano-bot/debian/patches/missing-includes.patch?revision=7984&view=co
+
+Status: in upstream CVS
+
+--- a/kodilib/src/handler/KPickable.h
++++ b/kodilib/src/handler/KPickable.h
+@@ -8,6 +8,7 @@
+ 
+ #include "KIntrospection.h"
+ #include <vector>
++#include <limits.h>
+ 
+ #define DEBUG_PICKING		false
+ 
+--- a/kodilib/src/tools/KIntrospection.h
++++ b/kodilib/src/tools/KIntrospection.h
+@@ -11,6 +11,7 @@
+ #endif
+ 
+ #include <string>
++#include <string.h>
+ 
+ // --------------------------------------------------------------------------------------------------------
+ class KClassInfo
+--- a/kodilib/src/tools/KStringTools.cpp
++++ b/kodilib/src/tools/KStringTools.cpp
+@@ -6,7 +6,7 @@
+ #include "KStringTools.h"
+ #include "KVector.h"
+ 
+-#include <sys/types.h> 	// INT_MAX
++#include <limits.h> // INT_MAX
+ #include <stdio.h>
+ 
+ // --------------------------------------------------------------------------------------------------------
+--- a/kodilib/src/tools/KStringTools.h
++++ b/kodilib/src/tools/KStringTools.h
+@@ -9,6 +9,7 @@
+ #include <string>
+ #include <vector>
+ #include <stdarg.h>
++#include <string.h>
+ 
+ // --------------------------------------------------------------------------------------------------------
+ 
+--- a/kodilib/src/tools/KXMLTools.cpp
++++ b/kodilib/src/tools/KXMLTools.cpp
+@@ -7,6 +7,7 @@
+ #include "KConsole.h"
+ #include "KSeparatedMatrix.h"
+ #include <stdio.h>
++#include <stdlib.h>
+ 
+ // --------------------------------------------------------------------------------------------------------
+ std::string kXMLTag ( const std::string & name, const std::string & attributes, int depth )
diff --git a/gnu/packages/patches/kiki-portability-64bit.patch b/gnu/packages/patches/kiki-portability-64bit.patch
new file mode 100644
index 000000000..456c00891
--- /dev/null
+++ b/gnu/packages/patches/kiki-portability-64bit.patch
@@ -0,0 +1,328 @@
+This patch was downloaded from Debian:
+https://anonscm.debian.org/viewvc/pkg-games/packages/trunk/kiki-the-nano-bot/debian/patches/portability-64bit.patch?revision=7984&view=co
+
+Make 64-bit clean (string positions don't fit in an int on 64-bit machines)
+
+Peter De Wachter ([email-masked])
+placed in the public domain
+
+Status: in upstream CVS
+
+--- a/kodilib/src/tools/KFileTools.cpp
++++ b/kodilib/src/tools/KFileTools.cpp
+@@ -214,8 +214,8 @@
+ // --------------------------------------------------------------------------------------------------------
+ string kFileSuffix ( const string & path )
+ {
+-    unsigned int lastDotPos = path.rfind(".");
+-    unsigned int lastSlashPos = path.rfind(kPathSep);
++    std::string::size_type lastDotPos = path.rfind(".");
++    std::string::size_type lastSlashPos = path.rfind(kPathSep);
+ 
+     if (lastDotPos < path.size() - 1 && (lastDotPos > lastSlashPos || lastSlashPos == string::npos))
+     {
+@@ -228,7 +228,7 @@
+ string kFileDirName ( const string & path )
+ {
+ 	string native = kFileNativePath(path);
+-    unsigned int lastSlashPos = native.rfind(kPathSep);
++    std::string::size_type lastSlashPos = native.rfind(kPathSep);
+     if (lastSlashPos < native.size())
+     {
+         return native.substr(0, lastSlashPos+1);
+@@ -241,7 +241,7 @@
+ {
+ 	string native = kFileNativePath(path);
+     string baseName = native;
+-    unsigned int lastSlashPos = native.rfind(kPathSep);
++    std::string::size_type lastSlashPos = native.rfind(kPathSep);
+     if (lastSlashPos < native.size() - 1) 
+     {
+         baseName = native.substr(lastSlashPos+1);
+--- a/kodilib/src/tools/KKeyTools.cpp
++++ b/kodilib/src/tools/KKeyTools.cpp
+@@ -170,7 +170,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ int kKeyGetDisplayWidthForKey ( const std::string & keyName )
+ {
+-    unsigned int keyPos = keyName.find('_', 0);
++    std::string::size_type keyPos = keyName.find('_', 0);
+     if (keyPos == std::string::npos) 
+     {
+         return kKeyGetDisplayWidthForPureKey(keyName) + KDL_MOD_KEY_SPACING;
+@@ -313,7 +313,7 @@
+ int kKeyDisplayKey ( const std::string & keyName, const KPosition & pos )
+ {
+     KPosition start = pos;
+-    unsigned int keyPos = keyName.find('_', 0);
++    std::string::size_type keyPos = keyName.find('_', 0);
+     if (keyPos == std::string::npos) 
+     {
+         return start.x + kKeyDisplayPureKey(keyName, start) + KDL_MOD_KEY_SPACING;
+@@ -380,7 +380,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ SDL_keysym kKeyGetKeysymForKeyName ( const std::string & keyName )
+ {
+-    unsigned int pos = keyName.find('_');
++    std::string::size_type pos = keyName.find('_');
+     
+     std::string modString;
+     std::string symString = keyName;
+--- a/kodilib/src/tools/KStringTools.cpp
++++ b/kodilib/src/tools/KStringTools.cpp
+@@ -13,7 +13,7 @@
+ void kStringInsertStringBehindTags ( std::string & str, const std::string & insertString, 
+                                      const std::string & tag )
+ {
+-    unsigned int oldPos = 0;
++    std::string::size_type oldPos = 0;
+     while ((oldPos = str.find(tag, oldPos)) != std::string::npos)
+     {
+         oldPos += tag.size();
+@@ -34,8 +34,8 @@
+ {
+     std::vector<std::string> components;
+     
+-    unsigned int dividerLength = divider.size();
+-    unsigned int oldpos = 0, pos;
++    std::string::size_type dividerLength = divider.size();
++    std::string::size_type oldpos = 0, pos;
+     
+     while ((pos = str.find(divider, oldpos)) != std::string::npos)
+     {
+@@ -50,7 +50,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ void kStringReplace ( std::string & str, const std::string & toReplace, const std::string & replacement )
+ {
+-    unsigned int pos = 0, chars = toReplace.size();
++    std::string::size_type pos = 0, chars = toReplace.size();
+     while ((pos = str.find(toReplace, pos)) != std::string::npos)
+     {
+         str.replace(pos, chars, replacement);
+@@ -60,11 +60,11 @@
+ // --------------------------------------------------------------------------------------------------------
+ void kStringReplaceTabs ( std::string & str, unsigned int tabWidth )
+ {
+-    unsigned int tabPos;
++    std::string::size_type tabPos;
+     while ((tabPos = str.find('\t')) != std::string::npos)
+     {
+-        unsigned int lastNewlinePos = str.rfind('\n', tabPos-1);
+-        unsigned int relPos = (lastNewlinePos == std::string::npos) ? tabPos : tabPos - lastNewlinePos; 
++        std::string::size_type lastNewlinePos = str.rfind('\n', tabPos-1);
++        std::string::size_type relPos = (lastNewlinePos == std::string::npos) ? tabPos : tabPos - lastNewlinePos; 
+         str.replace(tabPos, 1, std::string(tabWidth-(relPos % tabWidth), ' '));
+     }
+ }
+@@ -114,7 +114,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ unsigned int kStringNthCharPos ( const std::string & str, unsigned int n, char c )
+ {
+-    unsigned int loc = n, oloc = 0;
++    std::string::size_type loc = n, oloc = 0;
+     while (n > 0 && (loc = str.find(c, oloc)) != std::string::npos)
+     { 
+         n--; 
+@@ -138,7 +138,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ void kStringCropCols ( std::string & str, unsigned int columns )
+ {        
+-    unsigned int oloc = 0, nloc = 0;
++    std::string::size_type oloc = 0, nloc = 0;
+     while ((nloc = str.find('\n', oloc)) != std::string::npos)
+     {
+         if ((nloc - oloc) > columns)
+@@ -160,10 +160,10 @@
+ unsigned int kStringCols ( const std::string & str )
+ {
+     if (str.size() == 0) return 0;
+-    int oloc = 0, nloc;
++    long oloc = 0, nloc;
+     std::string substring;
+     int maxlength = 0, length;
+-    while ((nloc = str.find('\n', oloc)) != (int)std::string::npos) 
++    while ((nloc = str.find('\n', oloc)) != (long)std::string::npos) 
+     {
+         substring = str.substr(oloc, nloc - oloc);
+         length = substring.size();
+@@ -181,7 +181,7 @@
+ unsigned int kStringRows ( const std::string & str )
+ {
+     if (str.size() == 0) return 1;
+-    unsigned int loc = 0, lines = 0;
++    std::string::size_type loc = 0, lines = 0;
+     while ((loc = str.find('\n', loc)) != std::string::npos) { lines++; loc++; }
+     if (str[str.size()-1] == '\n') return lines;
+     return lines+1;
+@@ -204,8 +204,8 @@
+ {
+     static char str[256];
+     std::string format(fmt), subformat, text;
+-    unsigned int oloc = 0;
+-    unsigned int nloc = 0;
++    std::string::size_type oloc = 0;
++    std::string::size_type nloc = 0;
+     
+     kStringReplaceTabs(format);
+     
+@@ -260,7 +260,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ bool kStringHasSuffix ( const std::string & str, const std::string & suffix )
+ {
+-    unsigned int result = str.rfind(suffix);
++    std::string::size_type result = str.rfind(suffix);
+     if (result == std::string::npos) return false;
+     return (result == str.size()-suffix.size());
+ }
+--- a/kodilib/src/tools/KXMLTools.cpp
++++ b/kodilib/src/tools/KXMLTools.cpp
+@@ -58,11 +58,11 @@
+ std::string kXMLParseToTagsInVector ( std::string & xml, const std::vector<std::string> & tags )
+ {
+     std::string open("<");
+-    unsigned int minLoc = std::string::npos; 
++    std::string::size_type minLoc = std::string::npos; 
+     std::vector<std::string>::const_iterator iter = tags.begin();
+     while (iter != tags.end())
+     {
+-        unsigned int loc = xml.find(open+(*iter));
++        std::string::size_type loc = xml.find(open+(*iter));
+         if (loc < minLoc) minLoc = loc;
+         iter++;
+     }
+@@ -77,7 +77,7 @@
+     std::string value;
+     std::string nameStr(name);
+     nameStr += "='";
+-    unsigned int loc = xml.find(nameStr);
++    std::string::size_type loc = xml.find(nameStr);
+     if (loc != std::string::npos)
+     {	
+         loc += nameStr.size();
+@@ -90,7 +90,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ bool kXMLParseNamedCloseTag ( std::string & xml, const std::string & name, bool printError )
+ {
+-    unsigned int loc = xml.find('<');
++    std::string::size_type loc = xml.find('<');
+     if (loc == std::string::npos) 
+     {
+         if (printError) KConsole::printError(kStringPrintf("invalid XML:\nmissing close tag '%s'", 
+@@ -117,7 +117,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ bool kXMLReadNamedOpenTag ( const std::string & xml, const std::string & name, std::string * attributes )
+ {
+-    unsigned int loc = xml.find('<'), endloc;
++    std::string::size_type loc = xml.find('<'), endloc;
+     
+     if (loc == std::string::npos || xml[loc+1] == '/') return false;
+     
+@@ -140,7 +140,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ std::string kXMLParseNamedOpenTag ( std::string & xml, const std::string & name, std::string * attributes, bool printError )
+ {
+-    unsigned int loc = xml.find('<');
++    std::string::size_type loc = xml.find('<');
+     if (loc == std::string::npos || xml[loc+1] == '/') 
+     {
+         if (printError) KConsole::printError(kStringPrintf("invalid XML:\nmissing tag '%s'", name.c_str()));
+@@ -191,7 +191,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ bool kXMLParseOpenTag ( std::string & xml, std::string & name, std::string * attributes, bool printError )
+ {
+-    unsigned int loc = xml.find('<');
++    std::string::size_type loc = xml.find('<');
+     if (loc == std::string::npos || xml[loc+1] == '/') 
+     {
+         if (printError) KConsole::printError("invalid XML:\nmissing open tag");
+@@ -295,7 +295,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ bool kXMLParseValue( std::string & xml, const std::string & name, int type, void * value, bool printError )
+ {
+-    unsigned int loc = xml.find('<');
++    std::string::size_type loc = xml.find('<');
+     if (loc == std::string::npos || xml[loc+1] == '/')     
+     {
+         if (printError) KConsole::printError(kStringPrintf("invalid XML:\nmissing value '%s'", name.c_str()));
+@@ -379,8 +379,8 @@
+         }
+         else if (typeString == "string")
+         {
+-            unsigned int first = substring.find("\"")+1;
+-            unsigned int last  = substring.rfind("\"", std::string::npos);
++            std::string::size_type first = substring.find("\"")+1;
++            std::string::size_type last  = substring.rfind("\"", std::string::npos);
+             *((std::string*)value) = substring.substr(first, last-first);
+         }
+         
+--- a/kodilib/src/types/KKey.cpp
++++ b/kodilib/src/types/KKey.cpp
+@@ -31,7 +31,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ std::string KKey::getUnmodifiedName () const
+ {
+-    unsigned int keyPos = name.find('_', 0);
++    std::string::size_type keyPos = name.find('_', 0);
+     if (keyPos == std::string::npos) 
+     {
+         return name;
+@@ -42,7 +42,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ std::string KKey::getModifierName () const
+ {
+-    unsigned int keyPos = name.find('_', 0);
++    std::string::size_type keyPos = name.find('_', 0);
+     if (keyPos == std::string::npos) 
+     {
+         return "";
+--- a/kodilib/src/widgets/KFileNameField.cpp
++++ b/kodilib/src/widgets/KFileNameField.cpp
+@@ -41,7 +41,7 @@
+         std::string restPath; 				 // path behind cursor
+         
+         // map cropped path to current directory and rest path to file prefix
+-        unsigned int lastSlashPos = croppedPath.rfind("/");
++        std::string::size_type lastSlashPos = croppedPath.rfind("/");
+         if (lastSlashPos < croppedPath.size()-1)
+         {
+             restPath = croppedPath.substr(lastSlashPos+1);
+@@ -88,7 +88,7 @@
+         }
+ 
+         // ............................collect list of entries in searchDir that match prefix restPath
+-        unsigned int restLength = restPath.size();
++        std::string::size_type restLength = restPath.size();
+         std::vector<std::string> matchingEntries;
+         std::vector<std::string>::iterator iter = dir_entries.begin();
+         while (iter != dir_entries.end())
+@@ -223,7 +223,7 @@
+ // --------------------------------------------------------------------------------------------------------
+ void KFileNameField::selectLastPathComponent ()
+ {
+-    unsigned int lastSlashPos = text.rfind("/");
++    std::string::size_type lastSlashPos = text.rfind("/");
+     if (lastSlashPos == text.size()-1) lastSlashPos = text.rfind("/", lastSlashPos-1);
+     if (lastSlashPos < text.size()) cursor_pos = lastSlashPos+1;
+     else cursor_pos = 0;
+--- a/src/gui/KikiMenu.cpp
++++ b/src/gui/KikiMenu.cpp
+@@ -54,7 +54,7 @@
+ {
+     std::string item_text (itemText);
+     std::string event_name (itemText);
+-    unsigned int pos;
++    std::string::size_type pos;
+     float scale_factor = 1.0;
+ 
+     KikiMenuItem * menu_item = new KikiMenuItem ();
+--- a/src/gui/KikiTextLine.cpp
++++ b/src/gui/KikiTextLine.cpp
+@@ -46,7 +46,7 @@
+ void KikiTextLine::setText ( const std::string & str )
+ {
+     text = str;
+-    unsigned int pos;
++    std::string::size_type pos;
+  
+     if ((pos = text.find ("$scale(")) != std::string::npos)
+     {
-- 
2.12.2