...

Yuriy Skalko yuriy.skalko at gmail.com
Sun Nov 1 21:03:03 UTC 2020


> Apart from patches 5 & 10 these seem ok to me.
> I am not sure we want to ditch that bformat version, just because its not 
> currently used, someone might have opinion.
> I do not understand yet why the changes in AuthorList in 10.
> 
> Pavel

Pavel, thanks for reviewing patches!
I've committed that 8 patches.

We can leave that bformat version and to remove code duplication just 
delegate it to the version with docstring argument, as in attached patch.

I've started patch #10 after I saw `const` in this code:

     void setUsed(bool u) const { used_ = u; }

It works because used_ is declared as mutable. Is it really meant to 
work this way (with breaking constness)? The rest changes followed 
removing const here to allow compilation.

Maybe it is not worth to go this deep since const in C++ is not reliable 
and cannot guarantee constness of the object: in LyX there are many 
const methods that modify private implementation via d pointer (Buffer, 
Paragraph, etc).


Yuriy
-------------- next part --------------
From 0e0e40abb0bd1ee5e6a10ec1283380b821a4d387 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.skalko at gmail.com>
Date: Sun, 1 Nov 2020 22:39:21 +0200
Subject: [PATCH] Simplify bformat

---
 src/support/lstrings.cpp | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp
index ad19d7f35d..f0e79b88b3 100644
--- a/src/support/lstrings.cpp
+++ b/src/support/lstrings.cpp
@@ -1544,11 +1544,7 @@ docstring bformat(docstring const & fmt, docstring const & arg1, int arg2)
 
 docstring bformat(docstring const & fmt, char const * arg1, docstring const & arg2)
 {
-	LATTEST(contains(fmt, from_ascii("%1$s")));
-	LATTEST(contains(fmt, from_ascii("%2$s")));
-	docstring str = subst(fmt, from_ascii("%1$s"), from_ascii(arg1));
-	str = subst(str, from_ascii("%2$s"), arg2);
-	return subst(str, from_ascii("%%"), from_ascii("%"));
+	return bformat(fmt, from_ascii(arg1), arg2);
 }
 
 
-- 
2.28.0.windows.1



More information about the lyx-devel mailing list