Jean-Marc Lasgouttes schrieb:

I think something is wrong here. Arguments in [] are optional. I doubt
that you code will handle \makebox(3,2){contents} gracefully.

You are right, I missed this case.

You should use getFullOpt to read such optional strings (also in the
> other kind of \makebox).

Thanks for the hint, this makes the code much smaller. Attached the corrected 
fix.
Here's a TeX-testfile with all possible cases to see that the patch works:
http://bugzilla.lyx.org/attachment.cgi?id=2469&action=view

thanks and regards
Uwe
Index: Parser.cpp
===================================================================
--- Parser.cpp	(revision 24239)
+++ Parser.cpp	(working copy)
@@ -317,6 +317,13 @@
 	return res.empty() ? string() : '[' + res + ']';
 }
 
+string Parser::getFullParentheseOpt()
+{
+	Arg arg = getFullArg('(', ')');
+	if (arg.first)
+		return '(' + arg.second + ')';
+	return arg.second;
+}
 
 string const Parser::verbatimEnvironment(string const & name)
 {
Index: Parser.h
===================================================================
--- Parser.h	(revision 24239)
+++ Parser.h	(working copy)
@@ -158,6 +158,8 @@
 	 * <tt>\begin{name}</tt> must be parsed already, <tt>\end{name}</tt>
 	 * is parsed but not returned.
 	 */
+	std::string getFullParentheseOpt();
+	/// \returns getArg('(', ')') including the parentheses
 	std::string const verbatimEnvironment(std::string const & name);
 	/// Returns the character of the current token and increments the token position.
 	char getChar();
Index: text.cpp
===================================================================
--- text.cpp	(revision 24239)
+++ text.cpp	(working copy)
@@ -2345,6 +2345,23 @@
 
 		else if (t.cs() == "parbox")
 			parse_box(p, os, FLAG_ITEM, outer, context, true);
+		
+		//\makebox() is part of the picture environment and different from \makebox{}
+		//\makebox{} will be parsed by parse_box when bug 2956 is fixed
+		else if (t.cs() == "makebox") {
+			if (p.next_token().character() == '(') {
+				//the syntax is: \makebox(x,y)[position]{content}
+				//the content can be left as is, the rest is put into an ERT
+				string xy = p.getFullParentheseOpt();
+				string pos = p.getFullOpt();
+				handle_ert(os, "\\makebox" + xy + pos, context);
+			} else {
+				//the syntax is: \makebox[width][position]{content}
+				string width = p.getFullOpt();
+				string position = p.getFullOpt();
+				handle_ert(os, "\\makebox" + width + position, context);
+			}
+		}
 
 		else if (t.cs() == "smallskip" ||
 			 t.cs() == "medskip" ||

Reply via email to