[Scummvm-git-logs] scummvm master -> e207fda7f7c104c897c6ab5caf3dc24563971359

sev- sev at scummvm.org
Tue May 12 12:41:57 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e207fda7f7 COMMON: Allow ignoring CR line breaks in SeekableReadStream::readLine()


Commit: e207fda7f7c104c897c6ab5caf3dc24563971359
    https://github.com/scummvm/scummvm/commit/e207fda7f7c104c897c6ab5caf3dc24563971359
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-05-12T14:41:53+02:00

Commit Message:
COMMON: Allow ignoring CR line breaks in SeekableReadStream::readLine()

Changed paths:
    common/stream.cpp
    common/stream.h
    devtools/create_titanic/zlib.cpp


diff --git a/common/stream.cpp b/common/stream.cpp
index 988c1ab53e..8a7359865b 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -124,7 +124,7 @@ enum {
 	CR = 0x0D
 };
 
-char *SeekableReadStream::readLine(char *buf, size_t bufSize) {
+char *SeekableReadStream::readLine(char *buf, size_t bufSize, bool handleCR) {
 	assert(buf != nullptr && bufSize > 1);
 	char *p = buf;
 	size_t len = 0;
@@ -159,7 +159,7 @@ char *SeekableReadStream::readLine(char *buf, size_t bufSize) {
 		// * DOS and Windows use CRLF line breaks
 		// * Unix and OS X use LF line breaks
 		// * Macintosh before OS X used CR line breaks
-		if (c == CR) {
+		if (c == CR && handleCR) {
 			// Look at the next char -- is it LF? If not, seek back
 			c = readByte();
 
@@ -187,12 +187,12 @@ char *SeekableReadStream::readLine(char *buf, size_t bufSize) {
 	return buf;
 }
 
-String SeekableReadStream::readLine() {
+String SeekableReadStream::readLine(bool handleCR) {
 	// Read a line
 	String line;
 	while (line.lastChar() != '\n') {
 		char buf[256];
-		if (!readLine(buf, 256))
+		if (!readLine(buf, 256, handleCR))
 			break;
 		line += buf;
 	}
diff --git a/common/stream.h b/common/stream.h
index aa2f6e3a7f..a3843290e2 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -629,9 +629,10 @@ public:
 	 *
 	 * @param s	the buffer to store into
 	 * @param bufSize	the size of the buffer
+	 * @param handleCR	if set (default), then CR and CR/LF are handled as well as LF
 	 * @return a pointer to the read string, or NULL if an error occurred
 	 */
-	virtual char *readLine(char *s, size_t bufSize);
+	virtual char *readLine(char *s, size_t bufSize, bool handleCR = true);
 
 
 	/**
@@ -643,8 +644,10 @@ public:
 	 * of the line, *without* the end of a line marker. This method
 	 * does not indicate whether an error occurred. Callers must use
 	 * err() or eos() to determine whether an exception occurred.
+	 *
+	 * @param handleCR	if set (default), then CR and CR/LF are handled as well as LF
 	 */
-	virtual String readLine();
+	virtual String readLine(bool handleCR = true);
 
 	/**
 	 * Print a hexdump of the stream while maintaing position. The number
diff --git a/devtools/create_titanic/zlib.cpp b/devtools/create_titanic/zlib.cpp
index fe2a12b82d..8c0ffabfd4 100644
--- a/devtools/create_titanic/zlib.cpp
+++ b/devtools/create_titanic/zlib.cpp
@@ -49,11 +49,11 @@ namespace Common {
  */
 void debug(int level, const char *s, ...) {}
 
-char *SeekableReadStream::readLine(char *buf, size_t bufSize) {
+char *SeekableReadStream::readLine(char *buf, size_t bufSize, bool handleCR) {
 	return nullptr;
 }
 
-String SeekableReadStream::readLine() {
+String SeekableReadStream::readLine(bool handleCR) {
 	return String();
 }
 




More information about the Scummvm-git-logs mailing list