projects
/
supertux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
62ff7f7
)
don't use istream::readsome
author
Matthias Braun
<matze@braunis.de>
Wed, 1 Dec 2004 19:49:08 +0000
(19:49 +0000)
committer
Matthias Braun
<matze@braunis.de>
Wed, 1 Dec 2004 19:49:08 +0000
(19:49 +0000)
SVN-Revision: 2232
lib/lisp/lexer.cpp
patch
|
blob
|
history
diff --git
a/lib/lisp/lexer.cpp
b/lib/lisp/lexer.cpp
index
6b693f2
..
7d4fbec
100644
(file)
--- a/
lib/lisp/lexer.cpp
+++ b/
lib/lisp/lexer.cpp
@@
-20,6
+20,7
@@
#include <sstream>
#include <stdexcept>
#include <sstream>
#include <stdexcept>
+#include <iostream>
#include "lexer.h"
#include "lexer.h"
@@
-36,7
+37,7
@@
Lexer::Lexer(std::istream& newstream)
try {
// trigger a refill of the buffer
c = 0;
try {
// trigger a refill of the buffer
c = 0;
- bufend =
c + 1;
+ bufend =
0;
nextChar();
} catch(EOFException& e) {
}
nextChar();
} catch(EOFException& e) {
}
@@
-53,15
+54,16
@@
Lexer::nextChar()
if(c >= bufend) {
if(eof)
throw EOFException();
if(c >= bufend) {
if(eof)
throw EOFException();
- std::streamsize n = stream.readsome(buffer, BUFFER_SIZE);
-
+ stream.read(buffer, BUFFER_SIZE);
+ size_t bytes_read = stream.gcount();
+
c = buffer;
c = buffer;
- bufend = buffer +
n
;
+ bufend = buffer +
bytes_read
;
// the following is a hack that appends an additional ' ' at the end of
// the file to avoid problems when parsing symbols/elements and a sudden
// EOF. This is faster than relying on unget and IMO also nicer.
// the following is a hack that appends an additional ' ' at the end of
// the file to avoid problems when parsing symbols/elements and a sudden
// EOF. This is faster than relying on unget and IMO also nicer.
- if(
n
== 0 || stream.eof()) {
+ if(
bytes_read
== 0 || stream.eof()) {
eof = true;
*bufend = ' ';
++bufend;
eof = true;
*bufend = ' ';
++bufend;
@@
-85,7
+87,7
@@
Lexer::getNextToken()
switch(*c) {
case ';': // comment
switch(*c) {
case ';': // comment
- while(
!stream.eof()
) {
+ while(
true
) {
nextChar();
if(*c == '\n') {
++linenumber;
nextChar();
if(*c == '\n') {
++linenumber;
@@
-103,12
+105,6
@@
Lexer::getNextToken()
int startline = linenumber;
try {
while(1) {
int startline = linenumber;
try {
while(1) {
- if(stream.eof()) {
- std::stringstream msg;
- msg << "Parse Error in line " << startline << ": "
- << "Couldn't find end of string.";
- throw std::runtime_error(msg.str());
- }
nextChar();
if(*c == '"')
break;
nextChar();
if(*c == '"')
break;