[LyX/master] Consider that "and" in BibTeX name lists is case-insensitive (#10465)

Juergen Spitzmueller spitz at lyx.org
Sat Feb 19 10:25:54 UTC 2022


commit fcc139b06e31c39baf51486f697c809bec5534a2
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sat Feb 19 11:55:29 2022 +0100

    Consider that "and" in BibTeX name lists is case-insensitive (#10465)
---
 src/BiblioInfo.cpp |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp
index 638579a..1464e70 100644
--- a/src/BiblioInfo.cpp
+++ b/src/BiblioInfo.cpp
@@ -277,8 +277,14 @@ vector<docstring> const getAuthors(docstring const & author)
 	// in author names, but can happen (consider cases such as "C \& A Corp.").
 	docstring iname = subst(author, from_ascii("&"), from_ascii("$$amp!"));
 	// Then, we temporarily make all " and " strings to ampersands in order
-	// to handle them later on a per-char level.
-	iname = subst(iname, from_ascii(" and "), from_ascii(" & "));
+	// to handle them later on a per-char level. Note that arbitrary casing
+	// ("And", "AND", "aNd", ...) is allowed in bibtex (#10465).
+	static regex const and_reg("(.* )([aA][nN][dD])( .*)");
+	smatch sub;
+	string res = to_utf8(iname);
+	while (regex_match(res, sub, and_reg))
+		res = sub.str(1) + "&" + sub.str(3);
+	iname = from_utf8(res);
 	// Now we traverse through the string and replace the "&" by the proper
 	// output in- and outside groups
 	docstring name;


More information about the lyx-cvs mailing list