Ok? It works fine but I'm not sure whether I should revert the 
LyxLex::operator void const *()...

I've also made InsetVSpace::read use the new syntax.

-- 
Angus
Index: src/lyxlex.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxlex.C,v
retrieving revision 1.47
diff -u -p -r1.47 lyxlex.C
--- src/lyxlex.C	2 Dec 2003 10:19:51 -0000	1.47
+++ src/lyxlex.C	2 Dec 2003 12:09:09 -0000
@@ -256,15 +256,19 @@ int LyXLex::findToken(char const * str[]
 }
 
 
-LyXLex::operator void *() const
+LyXLex::operator void const *() const
 {
-	return isOK() ? const_cast<LyXLex *>(this) : 0;
+	// This behaviour is NOT the same as the std::streams which would
+	// use fail() here. However, our implementation of getString() et al.
+	// can cause the eof() and fail() bits to be set, even though we
+	// haven't tried to read 'em.
+	return pimpl_->is.bad() ? 0 : this;
 }
 
 
 bool LyXLex::operator!() const
 {
-	return !isOK();
+	return pimpl_->is.bad();
 }
 
 
@@ -316,5 +320,4 @@ LyXLex & LyXLex::operator>>(bool & s)
 	}
 	return *this;
 }
-
 
Index: src/lyxlex.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxlex.h,v
retrieving revision 1.37
diff -u -p -r1.37 lyxlex.h
--- src/lyxlex.h	2 Dec 2003 10:19:51 -0000	1.37
+++ src/lyxlex.h	2 Dec 2003 12:09:09 -0000
@@ -55,10 +55,10 @@ public:
 		LEX_TOKEN = -4
 	};
 
-	/// straem is open and end of straem is not reached
+	/// stream is open and end of stream is not reached
 	bool isOK() const;
 	/// stream is ok
-	operator void *() const;
+	operator void const *() const;
 	/// stream is not ok
 	bool operator!() const;
 	/// return true if able to open file, else false
Index: src/insets/insetvspace.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetvspace.C,v
retrieving revision 1.5
diff -u -p -r1.5 insetvspace.C
--- src/insets/insetvspace.C	2 Dec 2003 10:19:51 -0000	1.5
+++ src/insets/insetvspace.C	2 Dec 2003 12:09:10 -0000
@@ -15,6 +15,7 @@
 
 #include "buffer.h"
 #include "BufferView.h"
+#include "debug.h"
 #include "dispatchresult.h"
 #include "funcrequest.h"
 #include "gettext.h"
@@ -78,21 +79,21 @@ InsetVSpace::priv_dispatch(FuncRequest c
 		return InsetOld::priv_dispatch(cmd, idx, pos);
 	}
 }
-		
+
 
 void InsetVSpace::read(Buffer const &, LyXLex & lex)
 {
-	if (lex.isOK()) {
-		lex.next();
-		space_ = VSpace(lex.getString());
-	}
-
-	if (lex.isOK())
-		lex.next();
-	if (lex.getString() != "\\end_inset") {
+	BOOST_ASSERT(lex.isOK());
+	string vsp;
+	lex >> vsp;
+	if (lex)
+		space_ = VSpace(vsp);
+
+	string end_token;
+	lex >> end_token;
+	if (end_token != "\\end_inset")
 		lex.printError("Missing \\end_inset at this point. "
 			       "Read: `$$Token'");
-	}
 }
 
 
@@ -232,7 +233,7 @@ InsetVSpaceMailer::InsetVSpaceMailer(Ins
 
 string const InsetVSpaceMailer::inset2string(Buffer const &) const
 {
-	return params2string(inset_.space_);
+	return params2string(inset_.space());
 }
 
 
@@ -247,7 +248,7 @@ void InsetVSpaceMailer::string2params(st
 	LyXLex lex(0,0);
 	lex.setStream(data);
 	string name, vsp;
-	lex >> name >> vsp; 
+	lex >> name >> vsp;
 	if (lex)
 		vspace = VSpace(vsp);
 }
Index: src/insets/insetvspace.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetvspace.h,v
retrieving revision 1.2
diff -u -p -r1.2 insetvspace.h
--- src/insets/insetvspace.h	28 Nov 2003 17:38:39 -0000	1.2
+++ src/insets/insetvspace.h	2 Dec 2003 12:09:10 -0000
@@ -36,19 +36,21 @@ public:
 		  OutputParams const &) const;
 	///
 	int plaintext(Buffer const &, std::ostream &,
-	    OutputParams const &) const;
+		      OutputParams const &) const;
 	///
 	int linuxdoc(Buffer const &, std::ostream &,
-	    OutputParams const &) const;
+		     OutputParams const &) const;
 	///
 	int docbook(Buffer const &, std::ostream &,
-	    OutputParams const &) const;
+		    OutputParams const &) const;
 	///
 	void read(Buffer const &, LyXLex & lex);
 	///
 	void write(Buffer const & buf, std::ostream & os) const;
 	///
 	bool display() const { return true; }
+	/// How much?
+	VSpace const & space() const { return space_; }
 
 protected:
 	///
@@ -56,8 +58,8 @@ protected:
 	DispatchResult
 	priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
 
-public:
-	/// how much
+private:
+	///
 	VSpace space_;
 };
 

Reply via email to