aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Panzenböck <grosser.meister.morti@gmx.net>2011-06-25 01:10:19 +0200
committerMathias Panzenböck <grosser.meister.morti@gmx.net>2011-06-25 01:10:19 +0200
commit89861cf77ad3611b5ef16bdd6c94180fe6bc0af5 (patch)
tree3f95a7d5e47410f5a194b1c4ed6a645f4a176e01
parenta04d7d0bbca9bd330ac97307a00ae52672bc1bef (diff)
style fixes: { on same line with if/else/for
-rw-r--r--taglib/it/itfile.cpp30
-rw-r--r--taglib/it/itproperties.cpp3
-rw-r--r--taglib/mod/modfile.cpp30
-rw-r--r--taglib/mod/modtag.cpp4
-rw-r--r--taglib/s3m/s3mfile.cpp18
-rw-r--r--taglib/xm/xmfile.cpp74
6 files changed, 57 insertions, 102 deletions
diff --git a/taglib/it/itfile.cpp b/taglib/it/itfile.cpp
index 3b2ca876..7d702edf 100644
--- a/taglib/it/itfile.cpp
+++ b/taglib/it/itfile.cpp
@@ -94,8 +94,7 @@ bool IT::File::save()
// write comment as instrument and sample names:
StringList lines = d->tag.comment().split("\n");
- for(ushort i = 0; i < instrumentCount; ++ i)
- {
+ for(ushort i = 0; i < instrumentCount; ++ i) {
seek(192L + length + ((long)i << 2));
ulong instrumentOffset = 0;
if(!readU32L(instrumentOffset))
@@ -110,8 +109,7 @@ bool IT::File::save()
writeByte(0);
}
- for(ushort i = 0; i < sampleCount; ++ i)
- {
+ for(ushort i = 0; i < sampleCount; ++ i) {
seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2));
ulong sampleOffset = 0;
if(!readU32L(sampleOffset))
@@ -147,8 +145,7 @@ bool IT::File::save()
return false;
long fileSize = this->length();
- if(special & 0x1)
- {
+ if(special & Properties::S_MESSAGE) {
seek(54);
if(!readU16L(messageLength) || !readU32L(messageOffset))
return false;
@@ -163,8 +160,7 @@ bool IT::File::save()
writeU16L(special | 0x1);
}
- if((messageOffset + messageLength) >= fileSize)
- {
+ if((messageOffset + messageLength) >= fileSize) {
// append new message
seek(54);
writeU16L(message.size());
@@ -173,8 +169,7 @@ bool IT::File::save()
writeBlock(message);
truncate(messageOffset + message.size());
}
- else
- {
+ else {
// Only overwrite existing message.
// I'd need to parse (understand!) the whole file for more.
// Although I could just move the message to the end of file
@@ -220,8 +215,7 @@ void IT::File::read(bool)
// sample/instrument names are abused as comments so
// I just add all together.
String message;
- if(special & 0x1)
- {
+ if(special & Properties::S_MESSAGE) {
READ_U16L_AS(messageLength);
READ_U32L_AS(messageOffset);
seek(messageOffset);
@@ -240,8 +234,7 @@ void IT::File::read(bool)
ByteVector volumes = readBlock(64);
READ_ASSERT(pannings.size() == 64 && volumes.size() == 64);
int channels = 0;
- for(int i = 0; i < 64; ++ i)
- {
+ for(int i = 0; i < 64; ++ i) {
// Strictly speaking an IT file has always 64 channels, but
// I don't count disabled and muted channels.
// But this always gives 64 channels for all my files anyway.
@@ -253,8 +246,7 @@ void IT::File::read(bool)
// real length might be shorter because of skips and terminator
ushort realLength = 0;
- for(ushort i = 0; i < length; ++ i)
- {
+ for(ushort i = 0; i < length; ++ i) {
READ_BYTE_AS(order);
if(order == 255) break;
if(order != 254) ++ realLength;
@@ -268,8 +260,7 @@ void IT::File::read(bool)
// Currently I just discard anything after a nil, but
// e.g. VLC seems to interprete a nil as a space. I
// don't know what is the proper behaviour.
- for(ushort i = 0; i < instrumentCount; ++ i)
- {
+ for(ushort i = 0; i < instrumentCount; ++ i) {
seek(192L + length + ((long)i << 2));
READ_U32L_AS(instrumentOffset);
seek(instrumentOffset);
@@ -285,8 +276,7 @@ void IT::File::read(bool)
comment.append(instrumentName);
}
- for(ushort i = 0; i < sampleCount; ++ i)
- {
+ for(ushort i = 0; i < sampleCount; ++ i) {
seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2));
READ_U32L_AS(sampleOffset);
diff --git a/taglib/it/itproperties.cpp b/taglib/it/itproperties.cpp
index 7d181d57..416b70d1 100644
--- a/taglib/it/itproperties.cpp
+++ b/taglib/it/itproperties.cpp
@@ -179,7 +179,8 @@ void IT::Properties::setLengthInPatterns(ushort lengthInPatterns)
d->lengthInPatterns = lengthInPatterns;
}
-void IT::Properties::setInstrumentCount(ushort instrumentCount) {
+void IT::Properties::setInstrumentCount(ushort instrumentCount)
+{
d->instrumentCount = instrumentCount;
}
diff --git a/taglib/mod/modfile.cpp b/taglib/mod/modfile.cpp
index 9eb74f4b..f242ea51 100644
--- a/taglib/mod/modfile.cpp
+++ b/taglib/mod/modfile.cpp
@@ -72,8 +72,7 @@ Mod::Properties *Mod::File::audioProperties() const
bool Mod::File::save()
{
- if(readOnly())
- {
+ if(readOnly()) {
debug("Mod::File::save() - Cannot save to a read only file.");
return false;
}
@@ -81,14 +80,12 @@ bool Mod::File::save()
writeString(d->tag.title(), 20);
StringList lines = d->tag.comment().split("\n");
uint n = std::min(lines.size(), d->properties.instrumentCount());
- for(uint i = 0; i < n; ++ i)
- {
+ for(uint i = 0; i < n; ++ i) {
writeString(lines[i], 22);
seek(8, Current);
}
- for(uint i = n; i < d->properties.instrumentCount(); ++ i)
- {
+ for(uint i = n; i < d->properties.instrumentCount(); ++ i) {
writeString(String::null, 22);
seek(8, Current);
}
@@ -106,32 +103,27 @@ void Mod::File::read(bool)
int channels = 4;
uint instruments = 31;
- if(modId == "M.K." || modId == "M!K!" || modId == "M&K!" || modId == "N.T.")
- {
+ if(modId == "M.K." || modId == "M!K!" || modId == "M&K!" || modId == "N.T.") {
d->tag.setTrackerName("ProTracker");
channels = 4;
}
- else if(modId.startsWith("FLT") || modId.startsWith("TDZ"))
- {
+ else if(modId.startsWith("FLT") || modId.startsWith("TDZ")) {
d->tag.setTrackerName("StarTrekker");
char digit = modId[3];
READ_ASSERT(digit >= '0' && digit <= '9');
channels = digit - '0';
}
- else if(modId.endsWith("CHN"))
- {
+ else if(modId.endsWith("CHN")) {
d->tag.setTrackerName("StarTrekker");
char digit = modId[0];
READ_ASSERT(digit >= '0' && digit <= '9');
channels = digit - '0';
}
- else if(modId == "CD81" || modId == "OKTA")
- {
+ else if(modId == "CD81" || modId == "OKTA") {
d->tag.setTrackerName("Atari Oktalyzer");
channels = 8;
}
- else if(modId.endsWith("CH") || modId.endsWith("CN"))
- {
+ else if(modId.endsWith("CH") || modId.endsWith("CN")) {
d->tag.setTrackerName("TakeTracker");
char digit = modId[0];
READ_ASSERT(digit >= '0' && digit <= '9');
@@ -140,8 +132,7 @@ void Mod::File::read(bool)
READ_ASSERT(digit >= '0' && digit <= '9');
channels += digit - '0';
}
- else
- {
+ else {
// Not sure if this is correct. I'd need a file
// created with NoiseTracker to check this.
d->tag.setTrackerName("NoiseTracker"); // probably
@@ -155,8 +146,7 @@ void Mod::File::read(bool)
READ_STRING(d->tag.setTitle, 20);
StringList comment;
- for(uint i = 0; i < instruments; ++ i)
- {
+ for(uint i = 0; i < instruments; ++ i) {
READ_STRING_AS(instrumentName, 22);
// value in words, * 2 (<< 1) for bytes:
READ_U16B_AS(sampleLength);
diff --git a/taglib/mod/modtag.cpp b/taglib/mod/modtag.cpp
index a1b11388..1dabe30e 100644
--- a/taglib/mod/modtag.cpp
+++ b/taglib/mod/modtag.cpp
@@ -27,7 +27,9 @@ using namespace Mod;
class Mod::Tag::TagPrivate
{
public:
- TagPrivate() {}
+ TagPrivate()
+ {
+ }
String title;
String comment;
diff --git a/taglib/s3m/s3mfile.cpp b/taglib/s3m/s3mfile.cpp
index e3f9c8ec..0c8a712d 100644
--- a/taglib/s3m/s3mfile.cpp
+++ b/taglib/s3m/s3mfile.cpp
@@ -74,8 +74,7 @@ S3M::Properties *S3M::File::audioProperties() const
bool S3M::File::save()
{
- if(readOnly())
- {
+ if(readOnly()) {
debug("S3M::File::save() - Cannot save to a read only file.");
return false;
}
@@ -97,8 +96,7 @@ bool S3M::File::save()
seek(28, Current);
int channels = 0;
- for(int i = 0; i < 32; ++ i)
- {
+ for(int i = 0; i < 32; ++ i) {
uchar setting = 0;
if(!readByte(setting))
return false;
@@ -112,8 +110,7 @@ bool S3M::File::save()
StringList lines = d->tag.comment().split("\n");
// write comment as sample names:
- for(ushort i = 0; i < sampleCount; ++ i)
- {
+ for(ushort i = 0; i < sampleCount; ++ i) {
seek(96L + length + ((long)i << 1));
ushort instrumentOffset = 0;
@@ -173,8 +170,7 @@ void S3M::File::read(bool)
seek(12, Current);
int channels = 0;
- for(int i = 0; i < 32; ++ i)
- {
+ for(int i = 0; i < 32; ++ i) {
READ_BYTE_AS(setting);
// or if(setting >= 128)?
// or channels = i + 1;?
@@ -185,8 +181,7 @@ void S3M::File::read(bool)
seek(96);
ushort realLength = 0;
- for(ushort i = 0; i < length; ++ i)
- {
+ for(ushort i = 0; i < length; ++ i) {
READ_BYTE_AS(order);
if(order == 255) break;
if(order != 254) ++ realLength;
@@ -200,8 +195,7 @@ void S3M::File::read(bool)
// However, there I never found instruments (SCRI) but
// instead samples (SCRS).
StringList comment;
- for(ushort i = 0; i < sampleCount; ++ i)
- {
+ for(ushort i = 0; i < sampleCount; ++ i) {
seek(96L + length + ((long)i << 1));
READ_U16L_AS(sampleHeaderOffset);
diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp
index 1ea9e027..8f001e9e 100644
--- a/taglib/xm/xmfile.cpp
+++ b/taglib/xm/xmfile.cpp
@@ -41,14 +41,11 @@ using TagLib::ulong;
*
* Using these classes this code:
*
- * if(headerSize >= 4)
- * {
+ * if(headerSize >= 4) {
* if(!readU16L(value1)) ERROR();
- * if(headerSize >= 8)
- * {
+ * if(headerSize >= 8) {
* if(!readU16L(value2)) ERROR();
- * if(headerSize >= 12)
- * {
+ * if(headerSize >= 12) {
* if(!readString(value3, 22)) ERROR();
* ...
* }
@@ -132,8 +129,7 @@ public:
ByteVector data = file.readBlock(std::min(m_size,limit));
uint count = data.size();
int index = data.find((char) 0);
- if(index > -1)
- {
+ if(index > -1) {
data.resize(index);
}
data.replace((char) 0xff, ' ');
@@ -158,8 +154,7 @@ public:
uint read(TagLib::File &file, uint limit)
{
ByteVector data = file.readBlock(std::min(1U,limit));
- if(data.size() > 0)
- {
+ if(data.size() > 0) {
value = data[0];
}
return data.size();
@@ -323,8 +318,8 @@ public:
uint size() const
{
uint size = 0;
- for(List<Reader*>::ConstIterator i = m_readers.begin(); i != m_readers.end(); ++ i)
- {
+ for(List<Reader*>::ConstIterator i = m_readers.begin();
+ i != m_readers.end(); ++ i) {
size += (*i)->size();
}
return size;
@@ -333,8 +328,8 @@ public:
uint read(TagLib::File &file, uint limit)
{
uint sumcount = 0;
- for(List<Reader*>::Iterator i = m_readers.begin(); limit > 0 && i != m_readers.end(); ++ i)
- {
+ for(List<Reader*>::Iterator i = m_readers.begin();
+ limit > 0 && i != m_readers.end(); ++ i) {
uint count = (*i)->read(file, limit);
limit -= count;
sumcount += count;
@@ -391,8 +386,7 @@ XM::Properties *XM::File::audioProperties() const
bool XM::File::save()
{
- if(readOnly())
- {
+ if(readOnly()) {
debug("XM::File::save() - Cannot save to a read only file.");
return false;
}
@@ -414,8 +408,7 @@ bool XM::File::save()
seek(60 + headerSize);
// need to read patterns again in order to seek to the instruments:
- for(ushort i = 0; i < patternCount; ++ i)
- {
+ for(ushort i = 0; i < patternCount; ++ i) {
ulong patternHeaderLength = 0;
if(!readU32L(patternHeaderLength) || patternHeaderLength < 4)
return false;
@@ -433,8 +426,7 @@ bool XM::File::save()
StringList lines = d->tag.comment().split("\n");
uint sampleNameIndex = instrumentCount;
- for(ushort i = 0; i < instrumentCount; ++ i)
- {
+ for(ushort i = 0; i < instrumentCount; ++ i) {
ulong instrumentHeaderSize = 0;
if(!readU32L(instrumentHeaderSize) || instrumentHeaderSize < 4)
return false;
@@ -446,33 +438,28 @@ bool XM::File::save()
writeString(lines[i], len);
long offset = 0;
- if(instrumentHeaderSize >= 29U)
- {
+ if(instrumentHeaderSize >= 29U) {
ushort sampleCount = 0;
seek(1, Current);
if(!readU16L(sampleCount))
return false;
- if(sampleCount > 0)
- {
+ if(sampleCount > 0) {
ulong sampleHeaderSize = 0;
if(instrumentHeaderSize < 33U || !readU32L(sampleHeaderSize))
return false;
// skip unhandeled header proportion:
seek(instrumentHeaderSize - 33, Current);
- for(ushort j = 0; j < sampleCount; ++ j)
- {
- if(sampleHeaderSize > 4U)
- {
+ for(ushort j = 0; j < sampleCount; ++ j) {
+ if(sampleHeaderSize > 4U) {
ulong sampleLength = 0;
if(!readU32L(sampleLength))
return false;
offset += sampleLength;
seek(std::min(sampleHeaderSize, 14UL), Current);
- if(sampleHeaderSize > 18U)
- {
+ if(sampleHeaderSize > 18U) {
uint len = std::min(sampleHeaderSize - 18U, 22UL);
if(sampleNameIndex >= lines.size())
writeString(String::null, len);
@@ -481,19 +468,16 @@ bool XM::File::save()
seek(sampleHeaderSize - (18U + len), Current);
}
}
- else
- {
+ else {
seek(sampleHeaderSize, Current);
}
}
}
- else
- {
+ else {
offset = instrumentHeaderSize - 29;
}
}
- else
- {
+ else {
offset = instrumentHeaderSize - (4 + len);
}
seek(offset, Current);
@@ -559,8 +543,7 @@ void XM::File::read(bool)
seek(60 + headerSize);
// read patterns:
- for(ushort i = 0; i < patternCount; ++ i)
- {
+ for(ushort i = 0; i < patternCount; ++ i) {
READ_U32L_AS(patternHeaderLength);
READ_ASSERT(patternHeaderLength >= 4);
@@ -581,8 +564,7 @@ void XM::File::read(bool)
uint sumSampleCount = 0;
// read instruments:
- for(ushort i = 0; i < instrumentCount; ++ i)
- {
+ for(ushort i = 0; i < instrumentCount; ++ i) {
READ_U32L_AS(instrumentHeaderSize);
READ_ASSERT(instrumentHeaderSize >= 4);
@@ -599,16 +581,14 @@ void XM::File::read(bool)
ulong sampleHeaderSize = 0;
long offset = 0;
- if(sampleCount > 0)
- {
+ if(sampleCount > 0) {
sumSampleCount += sampleCount;
// wouldn't know which header size to assume otherwise:
READ_ASSERT(instrumentHeaderSize >= count + 4 && readU32L(sampleHeaderSize));
// skip unhandeled header proportion:
seek(instrumentHeaderSize - count - 4, Current);
- for(ushort j = 0; j < sampleCount; ++ j)
- {
+ for(ushort j = 0; j < sampleCount; ++ j) {
ulong sampleLength = 0;
ulong loopStart = 0;
ulong loopLength = 0;
@@ -640,8 +620,7 @@ void XM::File::read(bool)
sampleNames.append(sampleName);
}
}
- else
- {
+ else {
offset = instrumentHeaderSize - count;
}
intrumentNames.append(instrumentName);
@@ -650,8 +629,7 @@ void XM::File::read(bool)
d->properties.setSampleCount(sumSampleCount);
String comment(intrumentNames.toString("\n"));
- if(sampleNames.size() > 0)
- {
+ if(sampleNames.size() > 0) {
comment += "\n";
comment += sampleNames.toString("\n");
}