From 67f89f27a256ae6a61aa188ed3d208419542942a Mon Sep 17 00:00:00 2001 From: athile Date: Sun, 27 Jun 2010 18:12:31 -0700 Subject: [PATCH] Properly removing the old 'misc' file and fixing a minor error in the platform CMake --- components/misc/fileops.cpp | 8 --- components/misc/fileops.hpp | 7 -- components/misc/slice_array.hpp | 75 -------------------- components/misc/stringops.cpp | 59 --------------- components/misc/stringops.hpp | 16 ----- components/misc/tests/.gitignore | 1 - components/misc/tests/Makefile | 12 ---- components/misc/tests/output/slice_test.out | 6 -- components/misc/tests/output/strops_test.out | 0 components/misc/tests/slice_test.cpp | 30 -------- components/misc/tests/strops_test.cpp | 48 ------------- components/misc/tests/test.sh | 18 ----- libs/platform/CMakeLists.txt | 3 - 13 files changed, 283 deletions(-) delete mode 100644 components/misc/fileops.cpp delete mode 100644 components/misc/fileops.hpp delete mode 100644 components/misc/slice_array.hpp delete mode 100644 components/misc/stringops.cpp delete mode 100644 components/misc/stringops.hpp delete mode 100644 components/misc/tests/.gitignore delete mode 100644 components/misc/tests/Makefile delete mode 100644 components/misc/tests/output/slice_test.out delete mode 100644 components/misc/tests/output/strops_test.out delete mode 100644 components/misc/tests/slice_test.cpp delete mode 100644 components/misc/tests/strops_test.cpp delete mode 100755 components/misc/tests/test.sh diff --git a/components/misc/fileops.cpp b/components/misc/fileops.cpp deleted file mode 100644 index bb859836b..000000000 --- a/components/misc/fileops.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "fileops.hpp" -#include - -bool isFile(const char *name) -{ - boost::filesystem::path cfg_file_path(name); - return boost::filesystem::exists(cfg_file_path); -} diff --git a/components/misc/fileops.hpp b/components/misc/fileops.hpp deleted file mode 100644 index 6a5ad7c61..000000000 --- a/components/misc/fileops.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __FILEOPS_H_ -#define __FILEOPS_H_ - -/// Check if a given path is an existing file (not a directory) -bool isFile(const char *name); - -#endif diff --git a/components/misc/slice_array.hpp b/components/misc/slice_array.hpp deleted file mode 100644 index 4dde8143b..000000000 --- a/components/misc/slice_array.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - OpenMW - The completely unofficial reimplementation of Morrowind - Copyright (C) 2008-2010 Nicolay Korslund - Email: < korslund@gmail.com > - WWW: http://openmw.sourceforge.net/ - - This file (slice_array.h) is part of the OpenMW package. - - OpenMW is distributed as free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - version 3, as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - version 3 along with this program. If not, see - http://www.gnu.org/licenses/ . - - */ - -#ifndef _SLICE_ARRAY_H_ -#define _SLICE_ARRAY_H_ - -// A simple array implementation containing a pointer and a -// length. Used for holding slices into a data buffer. -#include -template -struct SliceArray -{ - const T* ptr; - size_t length; - - /// Initialize to zero length - SliceArray() : ptr(0), length(0) {} - - /// Initialize from pointer + length - SliceArray(const T* _ptr, size_t _length) - : ptr(_ptr), length(_length) {} - - /// Initialize from null-terminated string - SliceArray(const char* str) - { - ptr = str; - length = strlen(str); - } - - bool operator==(SliceArray &t) - { - return - length == t.length && - (memcmp(ptr,t.ptr, length*sizeof(T)) == 0); - } - - /// Only use this for stings - bool operator==(const char* str) - { - return - str[length] == 0 && - (strncmp(ptr, str, length) == 0); - } - - /** This allocates a copy of the data. Only use this for debugging - and error messages. */ - std::string toString() - { return std::string(ptr,length); } -}; - -typedef SliceArray SString; -typedef SliceArray IntArray; -typedef SliceArray FloatArray; - -#endif diff --git a/components/misc/stringops.cpp b/components/misc/stringops.cpp deleted file mode 100644 index f6b63372c..000000000 --- a/components/misc/stringops.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "stringops.hpp" - -#include -#include - -bool begins(const char* str1, const char* str2) -{ - while(*str2) - { - if(*str1 == 0 || *str1 != *str2) return false; - - str1++; - str2++; - } - return true; -} - -bool ends(const char* str1, const char* str2) -{ - int len1 = strlen(str1); - int len2 = strlen(str2); - - if(len1 < len2) return false; - - return strcmp(str2, str1+len1-len2) == 0; -} - -// True if the given chars match, case insensitive -static bool icmp(char a, char b) -{ - if(a >= 'A' && a <= 'Z') - a += 'a' - 'A'; - if(b >= 'A' && b <= 'Z') - b += 'a' - 'A'; - - return a == b; -} - -bool ibegins(const char* str1, const char* str2) -{ - while(*str2) - { - if(*str1 == 0 || !icmp(*str1,*str2)) return false; - - str1++; - str2++; - } - return true; -} - -bool iends(const char* str1, const char* str2) -{ - int len1 = strlen(str1); - int len2 = strlen(str2); - - if(len1 < len2) return false; - - return strcasecmp(str2, str1+len1-len2) == 0; -} diff --git a/components/misc/stringops.hpp b/components/misc/stringops.hpp deleted file mode 100644 index e76b8a87a..000000000 --- a/components/misc/stringops.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __STRINGOPS_H -#define __STRINGOPS_H - -/// Returns true if str1 begins with substring str2 -bool begins(const char* str1, const char* str2); - -/// Returns true if str1 ends with substring str2 -bool ends(const char* str1, const char* str2); - -/// Case insensitive, returns true if str1 begins with substring str2 -bool ibegins(const char* str1, const char* str2); - -/// Case insensitive, returns true if str1 ends with substring str2 -bool iends(const char* str1, const char* str2); - -#endif diff --git a/components/misc/tests/.gitignore b/components/misc/tests/.gitignore deleted file mode 100644 index 814490404..000000000 --- a/components/misc/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*_test diff --git a/components/misc/tests/Makefile b/components/misc/tests/Makefile deleted file mode 100644 index dc1ded5ff..000000000 --- a/components/misc/tests/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -GCC=g++ - -all: strops_test slice_test - -slice_test: slice_test.cpp ../slice_array.hpp - $(GCC) $< -o $@ - -strops_test: strops_test.cpp ../stringops.hpp ../stringops.cpp - $(GCC) $< -o $@ ../stringops.cpp - -clean: - rm *_test diff --git a/components/misc/tests/output/slice_test.out b/components/misc/tests/output/slice_test.out deleted file mode 100644 index 7b054082b..000000000 --- a/components/misc/tests/output/slice_test.out +++ /dev/null @@ -1,6 +0,0 @@ -hello, len=5 -001 -hell, len=4 -010 -01 -4 3 diff --git a/components/misc/tests/output/strops_test.out b/components/misc/tests/output/strops_test.out deleted file mode 100644 index e69de29bb..000000000 diff --git a/components/misc/tests/slice_test.cpp b/components/misc/tests/slice_test.cpp deleted file mode 100644 index 950194279..000000000 --- a/components/misc/tests/slice_test.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include - -using namespace std; - -#include - -#include "../slice_array.hpp" - -int main() -{ - SString s, t; - s = SString("hello"); - cout << s.toString() << ", len=" << s.length << endl; - cout << (s=="hel") << (s=="hell") << (s=="hello") << endl; - t = s; - - s = SString("othello"+2, 4); - cout << s.toString() << ", len=" << s.length << endl; - cout << (s=="hel") << (s=="hell") << (s=="hello") << endl; - - cout << (s==t) << (SString("hello")==t) << endl; - - const int arr[4] = {1,2,3,4}; - - IntArray ia(arr,4); - - cout << ia.length << " " << ia.ptr[2] << endl; - - return 0; -} diff --git a/components/misc/tests/strops_test.cpp b/components/misc/tests/strops_test.cpp deleted file mode 100644 index ca5bd55a9..000000000 --- a/components/misc/tests/strops_test.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include - -#include "../stringops.hpp" - -int main() -{ - assert(begins("abc", "a")); - assert(begins("abc", "ab")); - assert(begins("abc", "abc")); - assert(begins("abcd", "abc")); - - assert(!begins("abc", "b")); - assert(!begins("abc", "bc")); - assert(!begins("abc", "bcd")); - assert(!begins("abc", "abcd")); - - assert(ibegins("Abc", "a")); - assert(ibegins("aBc", "ab")); - assert(ibegins("abC", "abc")); - assert(ibegins("abcD", "abc")); - - assert(!ibegins("abc", "b")); - assert(!ibegins("abc", "bc")); - assert(!ibegins("abc", "bcd")); - assert(!ibegins("abc", "abcd")); - - assert(ends("abc", "c")); - assert(ends("abc", "bc")); - assert(ends("abc", "abc")); - assert(ends("abcd", "abcd")); - - assert(!ends("abc", "b")); - assert(!ends("abc", "ab")); - assert(!ends("abc", "bcd")); - assert(!ends("abc", "abcd")); - - assert(iends("Abc", "c")); - assert(iends("aBc", "bc")); - assert(iends("abC", "abc")); - assert(iends("abcD", "abcd")); - - assert(!iends("abc", "b")); - assert(!iends("abc", "ab")); - assert(!iends("abc", "bcd")); - assert(!iends("abc", "abcd")); - - return 0; -} diff --git a/components/misc/tests/test.sh b/components/misc/tests/test.sh deleted file mode 100755 index 2d07708ad..000000000 --- a/components/misc/tests/test.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -make || exit - -mkdir -p output - -PROGS=*_test - -for a in $PROGS; do - if [ -f "output/$a.out" ]; then - echo "Running $a:" - ./$a | diff output/$a.out - - else - echo "Creating $a.out" - ./$a > "output/$a.out" - git add "output/$a.out" - fi -done diff --git a/libs/platform/CMakeLists.txt b/libs/platform/CMakeLists.txt index 42d56e8a8..672f815b0 100755 --- a/libs/platform/CMakeLists.txt +++ b/libs/platform/CMakeLists.txt @@ -1,8 +1,5 @@ project(Platform) -file(GLOB_RECURSE SOURCES src/*) -file(GLOB_RECURSE CAELUM_HDR include/*) - set(SOURCES fileops.cpp fileops.hpp