Merge branch 'development' into LTS_development

This commit is contained in:
Thulinma 2018-10-03 11:00:09 +02:00
commit 9d702dbc78
2 changed files with 13 additions and 1 deletions

View file

@ -509,7 +509,12 @@ namespace EBML{
return val; return val;
} }
std::string Element::getValString() const{return std::string(getPayload(), getPayloadLen());} std::string Element::getValString() const{
uint64_t strLen = getPayloadLen();
const char * strPtr = getPayload();
while (strLen && strPtr[strLen-1] == 0){--strLen;}
return std::string(strPtr, strLen);
}
uint64_t Block::getTrackNum() const{return UniInt::readInt(getPayload());} uint64_t Block::getTrackNum() const{return UniInt::readInt(getPayload());}

View file

@ -16,6 +16,7 @@ int main(int argc, char* argv[]){
uint32_t i = 0; //Current line byte counter uint32_t i = 0; //Current line byte counter
uint32_t total = 0; //Finished lines so far byte counter uint32_t total = 0; //Finished lines so far byte counter
std::ifstream inFile(argv[1]); std::ifstream inFile(argv[1]);
bool sawQ = false;
while (inFile.good()){ while (inFile.good()){
unsigned char thisChar = inFile.get(); unsigned char thisChar = inFile.get();
if (!inFile.good()){break;} if (!inFile.good()){break;}
@ -26,6 +27,11 @@ int main(int argc, char* argv[]){
case '\t': tmp << "\\t"; break; case '\t': tmp << "\\t"; break;
case '\\': tmp << "\\\\"; break; case '\\': tmp << "\\\\"; break;
case '\"': tmp << "\\\""; break; case '\"': tmp << "\\\""; break;
case '?':
if (sawQ){tmp << "\"\"";}
tmp << "?";
sawQ = true;
break;
default: default:
if (thisChar < 32 || thisChar > 126){ if (thisChar < 32 || thisChar > 126){
//Convert to octal. //Convert to octal.
@ -33,6 +39,7 @@ int main(int argc, char* argv[]){
}else{ }else{
tmp << thisChar; tmp << thisChar;
} }
sawQ = false;
} }
++i; ++i;
// We print 80 bytes per line, regardless of special characters // We print 80 bytes per line, regardless of special characters