|
From: <sag...@us...> - 2012-10-28 22:57:46
|
Revision: 1410
http://modplug.svn.sourceforge.net/modplug/?rev=1410&view=rev
Author: saga-games
Date: 2012-10-28 22:57:35 +0000 (Sun, 28 Oct 2012)
Log Message:
-----------
[Ref] FileReader::ReadMagic doesn't advance cursor anymore if magic couldn't be found (fits the usual usage better)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/FileReader.h
trunk/OpenMPT/soundlib/Load_xm.cpp
Modified: trunk/OpenMPT/soundlib/FileReader.h
===================================================================
--- trunk/OpenMPT/soundlib/FileReader.h 2012-10-28 18:24:37 UTC (rev 1409)
+++ trunk/OpenMPT/soundlib/FileReader.h 2012-10-28 22:57:35 UTC (rev 1410)
@@ -410,16 +410,15 @@
}
// Compare a magic string with the current stream position.
- // Returns true if they are identical.
- // The file cursor is advanced by the the length of the "magic" string.
- bool ReadMagic(const char *magic)
+ // Returns true if they are identical and advances the file cursor by the the length of the "magic" string.
+ // Returns false if the string could not be found. The file cursor is not advanced in this case.
+ bool ReadMagic(const char *const magic)
{
const size_t magicLength = strlen(magic);
- if(CanRead(magicLength))
+ if(CanRead(magicLength) && !memcmp(streamData + streamPos, magic, magicLength))
{
- bool result = !memcmp(streamData + streamPos, magic, magicLength);
streamPos += magicLength;
- return result;
+ return true;
} else
{
return false;
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp 2012-10-28 18:24:37 UTC (rev 1409)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp 2012-10-28 22:57:35 UTC (rev 1410)
@@ -443,9 +443,6 @@
{
ReadMessage(file, file.ReadUint32LE(), leCR);
madeWith |= verConfirmed;
- } else
- {
- file.SkipBack(4);
}
// Read midi config: "MIDI"
@@ -455,9 +452,6 @@
m_MidiCfg.Sanitize();
m_SongFlags |= SONG_EMBEDMIDICFG;
madeWith |= verConfirmed;
- } else
- {
- file.SkipBack(4);
}
// Read pattern names: "PNAM"
@@ -472,9 +466,6 @@
Patterns[pat].SetName(patName);
}
madeWith |= verConfirmed;
- } else
- {
- file.SkipBack(4);
}
// Read channel names: "CNAM"
@@ -486,9 +477,6 @@
file.ReadString<StringFixer::maybeNullTerminated>(ChnSettings[chn].szName, MAX_CHANNELNAME);
}
madeWith |= verConfirmed;
- } else
- {
- file.SkipBack(4);
}
// Read mix plugins information
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|