[Scummvm-cvs-logs] SF.net SVN: scummvm:[34315] scummvm/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Wed Sep 3 19:53:31 CEST 2008
Revision: 34315
http://scummvm.svn.sourceforge.net/scummvm/?rev=34315&view=rev
Author: fingolfin
Date: 2008-09-03 17:53:25 +0000 (Wed, 03 Sep 2008)
Log Message:
-----------
Renamed SeekableReadStream::readLine to SeekableReadStream::readLine_OLD; added a new alternate SeekableReadStream::readLine() instead
Modified Paths:
--------------
scummvm/trunk/common/config-file.cpp
scummvm/trunk/common/stream.cpp
scummvm/trunk/common/stream.h
scummvm/trunk/engines/drascula/saveload.cpp
scummvm/trunk/engines/m4/mads_anim.cpp
scummvm/trunk/engines/parallaction/detection.cpp
scummvm/trunk/engines/parallaction/saveload.cpp
scummvm/trunk/engines/queen/resource.cpp
scummvm/trunk/engines/sword1/animation.cpp
scummvm/trunk/engines/sword2/resman.cpp
scummvm/trunk/engines/sword2/screen.cpp
scummvm/trunk/engines/sword2/startup.cpp
Modified: scummvm/trunk/common/config-file.cpp
===================================================================
--- scummvm/trunk/common/config-file.cpp 2008-09-03 17:46:42 UTC (rev 34314)
+++ scummvm/trunk/common/config-file.cpp 2008-09-03 17:53:25 UTC (rev 34315)
@@ -88,7 +88,7 @@
while (!stream.eos()) {
lineno++;
- if (!stream.readLine(buf, MAXLINELEN))
+ if (!stream.readLine_OLD(buf, MAXLINELEN))
break;
if (buf[0] == '#') {
Modified: scummvm/trunk/common/stream.cpp
===================================================================
--- scummvm/trunk/common/stream.cpp 2008-09-03 17:46:42 UTC (rev 34314)
+++ scummvm/trunk/common/stream.cpp 2008-09-03 17:53:25 UTC (rev 34315)
@@ -86,7 +86,7 @@
#define LF 0x0A
#define CR 0x0D
-char *SeekableReadStream::readLine(char *buf, size_t bufSize) {
+char *SeekableReadStream::readLine_OLD(char *buf, size_t bufSize) {
assert(buf && bufSize > 0);
char *p = buf;
size_t len = 0;
@@ -202,7 +202,21 @@
return buf;
}
+String SeekableReadStream::readLine() {
+ // Read a line
+ String line;
+ while (line.lastChar() != '\n') {
+ char buf[256];
+ if (!readLine_NEW(buf, 256))
+ break;
+ line += buf;
+ }
+ return line;
+}
+
+
+
uint32 SubReadStream::read(void *dataPtr, uint32 dataSize) {
dataSize = MIN(dataSize, _end - _pos);
Modified: scummvm/trunk/common/stream.h
===================================================================
--- scummvm/trunk/common/stream.h 2008-09-03 17:46:42 UTC (rev 34314)
+++ scummvm/trunk/common/stream.h 2008-09-03 17:53:25 UTC (rev 34315)
@@ -320,9 +320,10 @@
* Read one line of text from a CR or CR/LF terminated plain text file.
* This method is a rough analog of the (f)gets function.
*
- * @bug A main difference (and flaw) in this function is that there is no
- * way to detect that a line exceeeds the length of the buffer.
- * Code which needs this should use the new readLine_NEW() method instead.
+ * @deprecated This method has a major flaw: There is no way to detect
+ * whether a line exceeeds the length of the buffer, resulting in breakage
+ * when overlong lines are encountered.
+ * Use readLine_NEW() or readline() instead.
*
* @param buf the buffer to store into
* @param bufSize the size of the buffer
@@ -331,16 +332,16 @@
* @note The line terminator (CR or CR/LF) is stripped and not inserted
* into the buffer.
*/
- virtual char *readLine(char *buf, size_t bufSize);
+ virtual char *readLine_OLD(char *buf, size_t bufSize);
/**
* Reads at most one less than the number of characters specified
* by bufSize from the and stores them in the string buf. Reading
- * stops when the end of a line is reached (CR, CR/LF or LF), at
- * end-of-file or error. The newline, if any, is retained (CR and
- * CR/LF are translated to LF = 0xA = '\n'). If any characters are
- * read and there is no error, a `\0' character is appended to end
- * the string.
+ * stops when the end of a line is reached (CR, CR/LF or LF), and
+ * at end-of-file or error. The newline, if any, is retained (CR
+ * and CR/LF are translated to LF = 0xA = '\n'). If any characters
+ * are read and there is no error, a `\0' character is appended
+ * to end the string.
*
* Upon successful completion, return a pointer to the string. If
* end-of-file occurs before any characters are read, returns NULL
@@ -354,6 +355,19 @@
* @return a pointer to the read string, or NULL if an error occurred
*/
virtual char *readLine_NEW(char *s, size_t bufSize);
+
+
+ /**
+ * Reads a full line and returns it as a Common::String. Reading
+ * stops when the end of a line is reached (CR, CR/LF or LF), and
+ * at end-of-file or error.
+ *
+ * Upon successful completion, return a string with the content
+ * of the line, *without* the end of a line marker. This method
+ * does not indicate whether an error occured. Callers muse use
+ * ioFailed() or eos() to determine whether an exception occurred.
+ */
+ virtual String readLine();
};
/**
Modified: scummvm/trunk/engines/drascula/saveload.cpp
===================================================================
--- scummvm/trunk/engines/drascula/saveload.cpp 2008-09-03 17:46:42 UTC (rev 34314)
+++ scummvm/trunk/engines/drascula/saveload.cpp 2008-09-03 17:53:25 UTC (rev 34315)
@@ -50,7 +50,7 @@
}
}
for (n = 0; n < NUM_SAVES; n++)
- sav->readLine(names[n], 23);
+ sav->readLine_OLD(names[n], 23);
delete sav;
loadPic("savescr.alg", bgSurface, HALF_PAL);
Modified: scummvm/trunk/engines/m4/mads_anim.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_anim.cpp 2008-09-03 17:46:42 UTC (rev 34314)
+++ scummvm/trunk/engines/m4/mads_anim.cpp 2008-09-03 17:53:25 UTC (rev 34315)
@@ -251,7 +251,7 @@
error("Attempted to read past end of response file");
while (!_script->eos()) {
- _script->readLine(_currentLine, 79);
+ _script->readLine_OLD(_currentLine, 79);
// Commented out line, so go loop for another
if (_currentLine[0] == '#')
@@ -601,7 +601,7 @@
}
while (!_script->eos()) {
- _script->readLine(_currentLine, 79);
+ _script->readLine_OLD(_currentLine, 79);
// Process the line
char *cStart = strchr(_currentLine, '-');
Modified: scummvm/trunk/engines/parallaction/detection.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/detection.cpp 2008-09-03 17:46:42 UTC (rev 34314)
+++ scummvm/trunk/engines/parallaction/detection.cpp 2008-09-03 17:53:25 UTC (rev 34315)
@@ -293,7 +293,7 @@
if (slotNum >= 0 && slotNum <= 99) {
Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
if (in) {
- in->readLine(saveDesc, 199);
+ in->readLine_OLD(saveDesc, 199);
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, *file));
delete in;
}
Modified: scummvm/trunk/engines/parallaction/saveload.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.cpp 2008-09-03 17:46:42 UTC (rev 34314)
+++ scummvm/trunk/engines/parallaction/saveload.cpp 2008-09-03 17:53:25 UTC (rev 34315)
@@ -114,25 +114,25 @@
char n[16];
char l[16];
- f->readLine(s, 199);
+ f->readLine_OLD(s, 199);
- f->readLine(n, 15);
+ f->readLine_OLD(n, 15);
- f->readLine(l, 15);
+ f->readLine_OLD(l, 15);
- f->readLine(s, 15);
+ f->readLine_OLD(s, 15);
_vm->_location._startPosition.x = atoi(s);
- f->readLine(s, 15);
+ f->readLine_OLD(s, 15);
_vm->_location._startPosition.y = atoi(s);
- f->readLine(s, 15);
+ f->readLine_OLD(s, 15);
_score = atoi(s);
- f->readLine(s, 15);
+ f->readLine_OLD(s, 15);
_globalFlags = atoi(s);
- f->readLine(s, 15);
+ f->readLine_OLD(s, 15);
// TODO (LIST): unify (and parametrize) calls to freeZones.
// We aren't calling freeAnimations because it is not needed, since
@@ -147,12 +147,12 @@
uint16 _si;
for (_si = 0; _si < _vm->_numLocations; _si++) {
- f->readLine(s, 20);
+ f->readLine_OLD(s, 20);
s[strlen(s)] = '\0';
strcpy(_vm->_locationNames[_si], s);
- f->readLine(s, 15);
+ f->readLine_OLD(s, 15);
_vm->_localFlags[_si] = atoi(s);
}
@@ -161,10 +161,10 @@
uint32 value;
for (_si = 0; _si < 30; _si++) {
- f->readLine(s, 15);
+ f->readLine_OLD(s, 15);
value = atoi(s);
- f->readLine(s, 15);
+ f->readLine_OLD(s, 15);
name = atoi(s);
_vm->addInventoryItem(name, value);
@@ -351,7 +351,7 @@
Common::InSaveFile *f = getInSaveFile(i);
if (f) {
- f->readLine(buf, 199);
+ f->readLine_OLD(buf, 199);
delete f;
count++;
@@ -431,7 +431,7 @@
Common::InSaveFile *inFile = getInSaveFile(SPECIAL_SAVESLOT);
if (inFile) {
- inFile->readLine(buf, 29);
+ inFile->readLine_OLD(buf, 29);
delete inFile;
if (strstr(buf, part)) {
@@ -455,7 +455,7 @@
char buf[30];
Common::InSaveFile *inFile = getInSaveFile(SPECIAL_SAVESLOT);
- inFile->readLine(buf, 29);
+ inFile->readLine_OLD(buf, 29);
delete inFile;
complete[0] = strstr(buf, "dino");
Modified: scummvm/trunk/engines/queen/resource.cpp
===================================================================
--- scummvm/trunk/engines/queen/resource.cpp 2008-09-03 17:46:42 UTC (rev 34314)
+++ scummvm/trunk/engines/queen/resource.cpp 2008-09-03 17:53:25 UTC (rev 34315)
@@ -132,7 +132,7 @@
seekResourceFile(re->bundle, re->offset);
char buf[512];
Common::SeekableSubReadStream stream(&_resourceFile, re->offset, re->offset + re->size);
- while (stream.readLine(buf, 512)) {
+ while (stream.readLine_OLD(buf, 512)) {
stringList.push_back(buf);
}
}
Modified: scummvm/trunk/engines/sword1/animation.cpp
===================================================================
--- scummvm/trunk/engines/sword1/animation.cpp 2008-09-03 17:46:42 UTC (rev 34314)
+++ scummvm/trunk/engines/sword1/animation.cpp 2008-09-03 17:53:25 UTC (rev 34315)
@@ -189,7 +189,7 @@
int lastEnd = -1;
_movieTexts.clear();
- while (f.readLine(line, sizeof(line))) {
+ while (f.readLine_OLD(line, sizeof(line))) {
lineNo++;
if (line[0] == '#' || line[0] == 0) {
continue;
Modified: scummvm/trunk/engines/sword2/resman.cpp
===================================================================
--- scummvm/trunk/engines/sword2/resman.cpp 2008-09-03 17:46:42 UTC (rev 34314)
+++ scummvm/trunk/engines/sword2/resman.cpp 2008-09-03 17:53:25 UTC (rev 34315)
@@ -113,7 +113,7 @@
// The resource.inf file is a simple text file containing the names of
// all the resource files.
- while (file.readLine(_resFiles[_totalClusters].fileName, sizeof(_resFiles[_totalClusters].fileName))) {
+ while (file.readLine_OLD(_resFiles[_totalClusters].fileName, sizeof(_resFiles[_totalClusters].fileName))) {
_resFiles[_totalClusters].numEntries = -1;
_resFiles[_totalClusters].entryTab = NULL;
if (++_totalClusters >= MAX_res_files) {
Modified: scummvm/trunk/engines/sword2/screen.cpp
===================================================================
--- scummvm/trunk/engines/sword2/screen.cpp 2008-09-03 17:46:42 UTC (rev 34314)
+++ scummvm/trunk/engines/sword2/screen.cpp 2008-09-03 17:53:25 UTC (rev 34315)
@@ -919,7 +919,7 @@
while (1) {
char buffer[80];
- char *line = f.readLine(buffer, sizeof(buffer));
+ char *line = f.readLine_OLD(buffer, sizeof(buffer));
if (!line || *line == 0) {
if (!hasCenterMark) {
Modified: scummvm/trunk/engines/sword2/startup.cpp
===================================================================
--- scummvm/trunk/engines/sword2/startup.cpp 2008-09-03 17:46:42 UTC (rev 34314)
+++ scummvm/trunk/engines/sword2/startup.cpp 2008-09-03 17:53:25 UTC (rev 34315)
@@ -68,7 +68,7 @@
int lineno = 0;
- while (fp.readLine(buf, sizeof(buf))) {
+ while (fp.readLine_OLD(buf, sizeof(buf))) {
char *errptr;
int id;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list