File khunphan-0.55-codecleanup.diff of Package khunphan

--- khunphan/bstring.cpp
+++ khunphan/bstring.cpp
@@ -197,8 +197,10 @@
 	char *p;
 
 	p = &str[0];
-	while (*p != '\0')
-		*(p++) = toupper(*p);
+	while (*p != '\0') {
+		*p = toupper(*p);
+		p++;
+	}
 } 
 
 void BString::downcase(void)
@@ -206,8 +208,10 @@
 	char *p;
 	
 	p = &str[0];
-	while (*p != '\0')
-		*(p++) = tolower(*p);
+	while (*p != '\0') {
+		*p = tolower(*p);
+		p++;
+	}
 } 
 
 char BString::firstchar(void) const
--- khunphan/bstring.h
+++ khunphan/bstring.h
@@ -122,35 +122,35 @@
 
 void FScat(const char *s1, const char *s2, BString& s3);
 
-inline int BString::empty(void) const { return str[0] == '\0'; };
-inline const char *BString::chars(void) const { return &str[0]; };
-inline int BString::allocation(void) const { return sz; };
-
-inline void cat(BString& s1, BString& s2, BString& s3) { FScat(s1.chars(), s2.chars(), s3); };
-inline void cat(const char *s1, BString& s2, BString& s3) { FScat(s1, s2.chars(), s3); };
-inline void cat(BString& s1, const char *s2, BString& s3) { FScat(s1.chars(), s2, s3); };
-inline void cat(const char *s1, const char *s2, BString& s3) { FScat(s1, s2, s3); };
-
-inline BString& BString::operator = (const BString& s) { alloc(s.chars()); return *this; };
-inline BString& BString::operator = (const char *_s) { alloc(_s); return *this; };
-inline BString& BString::operator = (const char c) { char _s[2]; _s[0] = c; _s[1] = '\0'; alloc(_s); return *this; };
-
-inline BString& BString::operator += (const BString& s) { FSadd(s.chars()); return *this; };
-inline BString& BString::operator += (const char *s) { FSadd(s); return *this; };
-inline BString& BString::operator += (const char c) { char s[2]; s[0] = c; s[1] = '\0'; FSadd(s); return *this; };
-
-inline BString BString::operator + (const BString& s) const  { BString r(this->chars()); r.FSadd(s.chars()); return r; };
-inline BString BString::operator + (const char *s) const { BString r(this->chars()); r.FSadd(s); return r; };
-inline BString BString::operator + (const char c) const { char s[2]; s[0] = c; s[1] = '\0'; BString r(this->chars()); r.FSadd(s); return r; };
-
-inline int BString::index (const BString& _s, int startpos) const { return index(_s.chars(), startpos); };
-inline int BString::index (const char c, int startpos) const { char s[2]; s[0] = c; s[1] = '\0';  return this->index(s, startpos); };
-
-inline int BString::contains (const BString& _s) const { return index(_s.chars()) >= 0; };
-inline int BString::contains (const char *_s) const { return index(_s) >= 0; };
-inline int BString::contains (const char c) const { char _s[2]; _s[0] = c; _s[1] = '\0'; return index(_s) >= 0; };
+inline int BString::empty(void) const { return str[0] == '\0'; }
+inline const char *BString::chars(void) const { return &str[0]; }
+inline int BString::allocation(void) const { return sz; }
+
+inline void cat(BString& s1, BString& s2, BString& s3) { FScat(s1.chars(), s2.chars(), s3); }
+inline void cat(const char *s1, BString& s2, BString& s3) { FScat(s1, s2.chars(), s3); }
+inline void cat(BString& s1, const char *s2, BString& s3) { FScat(s1.chars(), s2, s3); }
+inline void cat(const char *s1, const char *s2, BString& s3) { FScat(s1, s2, s3); }
+
+inline BString& BString::operator = (const BString& s) { alloc(s.chars()); return *this; }
+inline BString& BString::operator = (const char *_s) { alloc(_s); return *this; }
+inline BString& BString::operator = (const char c) { char _s[2]; _s[0] = c; _s[1] = '\0'; alloc(_s); return *this; }
+
+inline BString& BString::operator += (const BString& s) { FSadd(s.chars()); return *this; }
+inline BString& BString::operator += (const char *s) { FSadd(s); return *this; }
+inline BString& BString::operator += (const char c) { char s[2]; s[0] = c; s[1] = '\0'; FSadd(s); return *this; }
+
+inline BString BString::operator + (const BString& s) const  { BString r(this->chars()); r.FSadd(s.chars()); return r; }
+inline BString BString::operator + (const char *s) const { BString r(this->chars()); r.FSadd(s); return r; }
+inline BString BString::operator + (const char c) const { char s[2]; s[0] = c; s[1] = '\0'; BString r(this->chars()); r.FSadd(s); return r; }
+
+inline int BString::index (const BString& _s, int startpos) const { return index(_s.chars(), startpos); }
+inline int BString::index (const char c, int startpos) const { char s[2]; s[0] = c; s[1] = '\0';  return this->index(s, startpos); }
+
+inline int BString::contains (const BString& _s) const { return index(_s.chars()) >= 0; }
+inline int BString::contains (const char *_s) const { return index(_s) >= 0; }
+inline int BString::contains (const char c) const { char _s[2]; _s[0] = c; _s[1] = '\0'; return index(_s) >= 0; }
 
-inline BString::operator const char *() const { return chars(); };
+inline BString::operator const char *() const { return chars(); }
 
 #endif // #ifndef __bstring_h__
 
--- khunphan/bthreadfactory.cpp
+++ khunphan/bthreadfactory.cpp
@@ -39,7 +39,7 @@
       atexit ( BThreadFactory::finalize );
    }
    return *instance;
-};
+}
 
 BThreadImp *BThreadFactory::CreateBThreadImp()
 {
@@ -52,4 +52,4 @@
     return NULL; // Sw: Which other platforms to support ???
   #endif
 #endif
-};
+}
--- khunphan/kpboard.cpp
+++ khunphan/kpboard.cpp
@@ -227,10 +227,10 @@
 		::fprintf(fp, "\n");
 	}
   uint64_t anID = GetID();
-  ::fprintf(fp, "%llx\n", anID);
+  ::fprintf(fp, FMT_UINT64 "\n", anID);
 }
 
-inline uint64_t KPboard::GetID() const
+uint64_t KPboard::GetID() const
 {
 	// internal caching: if id is zero it first has to be calculated
 
--- khunphan/kpboard.h
+++ khunphan/kpboard.h
@@ -50,7 +50,7 @@
 	bool Move(tKPTokenID id, tKPDirection d);
   bool CanMove(tKPTokenID aTokenID, tKPDirection d) const;
 	VIRTUAL void CopyFrom(const KPboard& src);
-	inline uint64_t GetID() const;
+	uint64_t GetID() const;
 	static KPIdHash idHash;
 	bool IsSolved(void) const;
   int GetX(tKPTokenID aTokenID) const;
--- khunphan/kpglutuserinterface.cpp
+++ khunphan/kpglutuserinterface.cpp
@@ -24,6 +24,7 @@
 #include <windows.h>
 #endif
 #include <GL/glut.h>
+
 #include "kpglutuserinterface.h"
 
  
--- khunphan/kpidhash.cpp
+++ khunphan/kpidhash.cpp
@@ -168,9 +168,9 @@
 			continue;
 		while ((n = p->pnext) != NULL) {
 			if (p->data == n->data)
-				::fprintf(fp, "Hash id %d: same data: %llx\n", i, p->data);
+				::fprintf(fp, "Hash id %d: same data: " FMT_UINT64 "\n", i, p->data);
 			if (p->data > n->data)
-				::fprintf(fp, "Hash id %d: wrong order: %llx, %llx\n", i, p->data, n->data);
+				::fprintf(fp, "Hash id %d: wrong order: " FMT_UINT64" , " FMT_UINT64 "\n", i, p->data, n->data);
 			p = p->pnext;
 		}
 	}
--- khunphan/main.cpp
+++ khunphan/main.cpp
@@ -46,7 +46,7 @@
 {
   DEBUGPRINT(PACKAGE " aborted by user\n");
   exit(0);
-};
+}
 //#endif
 
 #ifdef WIN32
--- khunphan/misc1.h
+++ khunphan/misc1.h
@@ -92,6 +92,10 @@
   #include <stdlib.h>
 #endif
 
+#include <cstdio>
+using std::printf;
+using std::sprintf;
+
 /* PATHSEPARATORSTRING shoud be a define to do */
 /* implicit concatenation by the compiler!     */
 #ifdef WIN32
@@ -110,14 +114,10 @@
       typedef __int64 int64_t;
    #endif
 #else
-   #ifndef uint64_t
-      typedef unsigned long long int uint64_t;
-   #endif
-   #ifndef int64_t
-      typedef long long int int64_t;
-   #endif
+   #include <stdint.h>
 #endif
 
+
 #define VIRTUAL  virtual
 
 #ifdef LINUX
@@ -125,8 +125,13 @@
 #endif
 
 #ifdef LINUX
-#define FMT_UINT64 "%llx"
+  #if __WORDSIZE == 64
+    #define FMT_UINT64 "%lx"
+  #else
+    #define FMT_UINT64 "%llx"
+  #endif
 #endif
+
 #ifdef WIN32
 #define FMT_UINT64 "%I64x"
 #endif
openSUSE Build Service is sponsored by