Re: [patch] Re: Double hyphens/en dashes in LyX-Code

2016-04-24 Thread Georg Baum
Scott Kostyshak wrote:

> Please commit.

Done at dc38ae873a8b.


Georg



Re: [patch] Re: Double hyphens/en dashes in LyX-Code

2016-04-24 Thread Scott Kostyshak
On Sun, Apr 24, 2016 at 02:12:52PM +0200, Georg Baum wrote:
> Andrew Parsloe wrote:
> 
> > http://www.lyx.org/trac/ticket/10074. This is a regression since they
> > display correctly as two hyphens in 2.1.4 in all cases (default,
> > emphasis, bolding, colour).
> 
> Thank you very much for reporting this. I did indeed make a mistake when I 
> removed the special meaning of double hyphens in standard text.
> 
> The attached patch fixes that. I overlooked that end_pos could also be -1, 
> which means that text_ is to be considered until the end. With the fix, both 
> cases are considered: if end_pos is not -1, then it is taken into account 
> while checking for the next character, and if it is -1, then only 
> text_.size() is taken into account.
> 
> Scott, I would like to put this into 2.2.0. The code that is changed is 
> central, so I would appreciate any review I could get, but the regression is 
> important, and I am also 100% sure that the fix is correct and cannot 
> introduce another regression.

Please commit.

Scott

> 
> 
> Georg

> diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
> index 9fe4de8..a405b6a 100644
> --- a/src/Paragraph.cpp
> +++ b/src/Paragraph.cpp
> @@ -1192,7 +1192,9 @@ void Paragraph::Private::latexSpecialChar(otexstream & 
> os,
>   break;
>   case '-':
>   os << '-';
> - if (i + 1 < end_pos && text_[i+1] == '-') {
> + if (i + 1 < static_cast(text_.size()) &&
> + (end_pos == -1 || i + 1 < end_pos) &&
> + text_[i+1] == '-') {
>   // Prevent "--" becoming an endash and "---" becoming
>   // an emdash.
>   // Within \ttfamily, "--" is merged to "-" (no endash)
> 



signature.asc
Description: PGP signature


[patch] Re: Double hyphens/en dashes in LyX-Code

2016-04-24 Thread Georg Baum
Andrew Parsloe wrote:

> http://www.lyx.org/trac/ticket/10074. This is a regression since they
> display correctly as two hyphens in 2.1.4 in all cases (default,
> emphasis, bolding, colour).

Thank you very much for reporting this. I did indeed make a mistake when I 
removed the special meaning of double hyphens in standard text.

The attached patch fixes that. I overlooked that end_pos could also be -1, 
which means that text_ is to be considered until the end. With the fix, both 
cases are considered: if end_pos is not -1, then it is taken into account 
while checking for the next character, and if it is -1, then only 
text_.size() is taken into account.

Scott, I would like to put this into 2.2.0. The code that is changed is 
central, so I would appreciate any review I could get, but the regression is 
important, and I am also 100% sure that the fix is correct and cannot 
introduce another regression.


Georg
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 9fe4de8..a405b6a 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -1192,7 +1192,9 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
 		break;
 	case '-':
 		os << '-';
-		if (i + 1 < end_pos && text_[i+1] == '-') {
+		if (i + 1 < static_cast(text_.size()) &&
+		(end_pos == -1 || i + 1 < end_pos) &&
+		text_[i+1] == '-') {
 			// Prevent "--" becoming an endash and "---" becoming
 			// an emdash.
 			// Within \ttfamily, "--" is merged to "-" (no endash)