Dead code tells no tales

This commit is contained in:
Rémi Verschelde 2017-08-27 21:07:15 +02:00
parent 37da8155a4
commit 7ad14e7a3e
215 changed files with 153 additions and 56138 deletions

View file

@ -1252,66 +1252,7 @@ String String::utf8(const char *p_utf8, int p_len) {
return ret;
};
#if 0
_FORCE_INLINE static int parse_utf8_char(const char *p_utf8,unsigned int *p_ucs4,int p_left) { //return len
int len=0;
/* Determine the number of characters in sequence */
if ((*p_utf8 & 0x80)==0)
len=1;
else if ((*p_utf8 & 0xE0)==0xC0)
len=2;
else if ((*p_utf8 & 0xF0)==0xE0)
len=3;
else if ((*p_utf8 & 0xF8)==0xF0)
len=4;
else if ((*p_utf8 & 0xFC)==0xF8)
len=5;
else if ((*p_utf8 & 0xFE)==0xFC)
len=6;
else
return -1; //invalid UTF8
if (len>p_left)
return -1; //not enough space
if (len==2 && (*p_utf8&0x1E)==0) {
//printf("overlong rejected\n");
return -1; //reject overlong
}
/* Convert the first character */
unsigned int unichar=0;
if (len == 1)
unichar=*p_utf8;
else {
unichar=(0xFF >> (len +1)) & *p_utf8;
for (int i=1;i<len;i++) {
if ((p_utf8[i] & 0xC0) != 0x80) {
//printf("invalid utf8\n");
return -1; //invalid utf8
}
if (unichar==0 && i==2 && ((p_utf8[i] & 0x7F) >> (7 - len)) == 0) {
//printf("no overlong\n");
return -1; //no overlong
}
unichar = (unichar << 6) | (p_utf8[i] & 0x3F);
}
}
*p_ucs4=unichar;
return len;
}
#endif
bool String::parse_utf8(const char *p_utf8, int p_len) {
#define _UNICERROR(m_err) print_line("unicode error: " + String(m_err));
@ -1998,94 +1939,6 @@ double String::to_double(const char *p_str) {
#else
return built_in_strtod<char>(p_str);
#endif
#if 0
#if 0
return atof(p_str);
#else
if (!p_str[0])
return 0;
///@todo make more exact so saving and loading does not lose precision
double integer=0;
double decimal=0;
double decimal_mult=0.1;
double sign=1.0;
double exp=0;
double exp_sign=1.0;
int reading=READING_SIGN;
const char *str=p_str;
while(*str && reading!=READING_DONE) {
CharType c=*(str++);
switch(reading) {
case READING_SIGN: {
if (c>='0' && c<='9')
reading=READING_INT;
// let it fallthrough
else if (c=='-') {
sign=-1.0;
reading=READING_INT;
break;
} else if (c=='.') {
reading=READING_DEC;
break;
} else {
break;
}
}
case READING_INT: {
if (c>='0' && c<='9') {
integer*=10;
integer+=c-'0';
} else if (c=='.') {
reading=READING_DEC;
} else if (c=='e') {
reading=READING_EXP;
} else {
reading=READING_DONE;
}
} break;
case READING_DEC: {
if (c>='0' && c<='9') {
decimal+=(c-'0')*decimal_mult;
decimal_mult*=0.1;
} else if (c=='e') {
reading=READING_EXP;
} else {
reading=READING_DONE;
}
} break;
case READING_EXP: {
if (c>='0' && c<='9') {
exp*=10.0;
exp+=(c-'0');
} else if (c=='-' && exp==0) {
exp_sign=-1.0;
} else if (exp_sign>=0 && c=='+') {
//redundant...
exp_sign=1.0;
} else {
reading=READING_DONE;
}
} break;
}
}
return sign*(integer+decimal)*Math::pow(10,exp_sign*exp);
#endif
#endif
}
float String::to_float() const {
@ -2096,100 +1949,6 @@ float String::to_float() const {
double String::to_double(const CharType *p_str, const CharType **r_end) {
return built_in_strtod<CharType>(p_str, (CharType **)r_end);
#if 0
#if 0
//ndef NO_USE_STDLIB
return wcstod(p_str,p_len<0?NULL:p_str+p_len);
#else
if (p_len==0 || !p_str[0])
return 0;
///@todo make more exact so saving and loading does not lose precision
double integer=0;
double decimal=0;
double decimal_mult=0.1;
double sign=1.0;
double exp=0;
double exp_sign=1.0;
int reading=READING_SIGN;
const CharType *str=p_str;
const CharType *limit=&p_str[p_len];
while(reading!=READING_DONE && str!=limit) {
CharType c=*(str++);
switch(reading) {
case READING_SIGN: {
if (c>='0' && c<='9')
reading=READING_INT;
// let it fallthrough
else if (c=='-') {
sign=-1.0;
reading=READING_INT;
break;
} else if (c=='.') {
reading=READING_DEC;
break;
} else if (c==0) {
reading=READING_DONE;
break;
} else {
break;
}
}
case READING_INT: {
if (c>='0' && c<='9') {
integer*=10;
integer+=c-'0';
} else if (c=='.') {
reading=READING_DEC;
} else if (c=='e' || c=='E') {
reading=READING_EXP;
} else {
reading=READING_DONE;
}
} break;
case READING_DEC: {
if (c>='0' && c<='9') {
decimal+=(c-'0')*decimal_mult;
decimal_mult*=0.1;
} else if (c=='e' || c=='E') {
reading=READING_EXP;
} else {
reading=READING_DONE;
}
} break;
case READING_EXP: {
if (c>='0' && c<='9') {
exp*=10.0;
exp+=(c-'0');
} else if (c=='-' && exp==0) {
exp_sign=-1.0;
} else if (exp_sign>=0 && c=='+') {
//redundant...
exp_sign=1.0;
} else {
reading=READING_DONE;
}
} break;
}
}
if (r_end)
*r_end=str-1;
return sign*(integer+decimal)*Math::pow(10,exp_sign*exp);
#endif
#endif
}
int64_t String::to_int(const CharType *p_str, int p_len) {
@ -2252,98 +2011,6 @@ double String::to_double() const {
#else
return built_in_strtod<CharType>(c_str());
#endif
#if 0
#ifndef NO_USE_STDLIB
return atof(utf8().get_data());
#else
double integer=0;
double decimal=0;
double decimal_mult=0.1;
double sign=1.0;
double exp=0;
double exp_sign=1.0;
int reading=READING_SIGN;
const CharType *str=&operator[](0);
while(*str && reading!=READING_DONE) {
CharType c=*(str++);
switch(reading) {
case READING_SIGN: {
if (c>='0' && c<='9')
reading=READING_INT;
// let it fallthrough
else if (c=='-') {
sign=-1.0;
reading=READING_INT;
break;
} else if (c=='.') {
reading=READING_DEC;
break;
} else {
break;
}
}
case READING_INT: {
if (c>='0' && c<='9') {
integer*=10;
integer+=c-'0';
} else if (c=='.') {
reading=READING_DEC;
} else if (c=='e') {
reading=READING_EXP;
} else {
reading=READING_DONE;
}
} break;
case READING_DEC: {
if (c>='0' && c<='9') {
decimal+=(c-'0')*decimal_mult;
decimal_mult*=0.1;
} else if (c=='e') {
reading=READING_EXP;
} else {
reading=READING_DONE;
}
} break;
case READING_EXP: {
if (c>='0' && c<='9') {
exp*=10.0;
exp+=(c-'0');
} else if (c=='-' && exp==0) {
exp_sign=-1.0;
} else if (exp_sign>=0 && c=='+') {
//redundant...
exp_sign=1.0;
} else {
reading=READING_DONE;
}
} break;
}
}
return sign*(integer+decimal)*Math::pow(10,exp_sign*exp);
#endif
#if 0
double ret=sign*(integer+decimal)*Math::pow(10,exp_sign*exp);
print_line(*this +" == "+rtos(ret));
return ret;
#endif
#endif
}
bool operator==(const char *p_chr, const String &p_str) {