From 18bc24be140ac152a8f1ee58b486e23f455338e2 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 12:49:20 +0200 Subject: [PATCH] Remove more unused libnall code --- nall/string.hpp | 1 - nall/string/base.hpp | 5 --- nall/string/bsv.hpp | 75 ---------------------------------------- nall/string/filename.hpp | 12 ------- nall/string/math.hpp | 20 ----------- nall/string/split.hpp | 30 ---------------- 6 files changed, 143 deletions(-) delete mode 100644 nall/string/bsv.hpp diff --git a/nall/string.hpp b/nall/string.hpp index f3c9c48..c888d31 100644 --- a/nall/string.hpp +++ b/nall/string.hpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include diff --git a/nall/string/base.hpp b/nall/string/base.hpp index 45353c7..924d65c 100644 --- a/nall/string/base.hpp +++ b/nall/string/base.hpp @@ -139,7 +139,6 @@ namespace nall { template inline lstring& operator<<(const T& value); inline void split (const char*, const char*, unsigned = 0); - inline void qsplit(const char*, const char*, unsigned = 0); lstring(); @@ -183,10 +182,6 @@ namespace nall { //match.hpp inline bool match(const char *pattern, const char *str); - //math.hpp - inline bool strint (const char *str, int &result); - inline bool strmath(const char *str, int &result); - //strl.hpp inline unsigned strlcpy(char *dest, const char *src, unsigned length); inline unsigned strlcat(char *dest, const char *src, unsigned length); diff --git a/nall/string/bsv.hpp b/nall/string/bsv.hpp deleted file mode 100644 index d4b919e..0000000 --- a/nall/string/bsv.hpp +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef NALL_STRING_BSV_HPP -#define NALL_STRING_BSV_HPP - -//BSV parser -//version 0.01 - -namespace nall { - -inline string bsv_decode(const char *input) { - string output; - unsigned offset = 0; - while(*input) { - //illegal characters - if(*input == '}' ) return ""; - if(*input == '\r') return ""; - if(*input == '\n') return ""; - - //normal characters - if(*input != '{') { output[offset++] = *input++; continue; } - - //entities - if(strbegin(input, "{lf}")) { output[offset++] = '\n'; input += 4; continue; } - if(strbegin(input, "{lb}")) { output[offset++] = '{'; input += 4; continue; } - if(strbegin(input, "{rb}")) { output[offset++] = '}'; input += 4; continue; } - - //illegal entities - return ""; - } - output[offset] = 0; - return output; -} - -inline string bsv_encode(const char *input) { - string output; - unsigned offset = 0; - while(*input) { - //illegal characters - if(*input == '\r') return ""; - - if(*input == '\n') { - output[offset++] = '{'; - output[offset++] = 'l'; - output[offset++] = 'f'; - output[offset++] = '}'; - input++; - continue; - } - - if(*input == '{') { - output[offset++] = '{'; - output[offset++] = 'l'; - output[offset++] = 'b'; - output[offset++] = '}'; - input++; - continue; - } - - if(*input == '}') { - output[offset++] = '{'; - output[offset++] = 'r'; - output[offset++] = 'b'; - output[offset++] = '}'; - input++; - continue; - } - - output[offset++] = *input++; - } - output[offset] = 0; - return output; -} - -} - -#endif diff --git a/nall/string/filename.hpp b/nall/string/filename.hpp index f375076..acaf964 100644 --- a/nall/string/filename.hpp +++ b/nall/string/filename.hpp @@ -44,18 +44,6 @@ inline string basename(char const *name) { return result; } -// "foo/bar.c" -> "c" -inline string extension(char const *name) { - for(signed i = strlen(name); i >= 0; i--) { - if(name[i] == '.') { - name += i + 1; - break; - } - } - string result = name; - return result; -} - } #endif diff --git a/nall/string/math.hpp b/nall/string/math.hpp index 496315f..8da6216 100644 --- a/nall/string/math.hpp +++ b/nall/string/math.hpp @@ -139,26 +139,6 @@ inline int eval(const char *&s, int depth = 0) { return value; } -inline bool strint(const char *s, int &result) { - try { - result = eval_integer(s); - return true; - } catch(const char*) { - result = 0; - return false; - } -} - -inline bool strmath(const char *s, int &result) { - try { - result = eval(s); - return true; - } catch(const char*) { - result = 0; - return false; - } -} - } #endif diff --git a/nall/string/split.hpp b/nall/string/split.hpp index bb77dfc..921df44 100644 --- a/nall/string/split.hpp +++ b/nall/string/split.hpp @@ -21,36 +21,6 @@ void lstring::split(const char *key, const char *src, unsigned limit) { operator[](split_count++) = src + lp; } -void lstring::qsplit(const char *key, const char *src, unsigned limit) { - reset(); - - int ssl = strlen(src), ksl = strlen(key); - int lp = 0, split_count = 0; - - for(int i = 0; i <= ssl - ksl;) { - uint8_t x = src[i]; - - if(x == '\"' || x == '\'') { - int z = i++; //skip opening quote - while(i < ssl && src[i] != x) i++; - if(i >= ssl) i = z; //failed match, rewind i - else { - i++; //skip closing quote - continue; //restart in case next char is also a quote - } - } - - if(!memcmp(src + i, key, ksl)) { - strlcpy(operator[](split_count++), src + lp, i - lp + 1); - i += ksl; - lp = i; - if(!--limit) break; - } else i++; - } - - operator[](split_count++) = src + lp; -} - }; #endif