fix a bug when splitting author list

This commit is contained in:
Martin Monperrus
2018-09-03 20:32:10 +02:00
parent 5f9f16b222
commit 3175cd2c09
3 changed files with 25 additions and 2 deletions
+12
View File
@@ -229,3 +229,15 @@ MRREVIEWER = {Jean-Fran{\c{c}}ois Clouet},
author = "Foo Bar", author = "Foo Bar",
year = 2017 year = 2017
} }
@techreport{arXiv-1807.05030,
author = {Oscar Luis Vera{-}P{\'{e}}rez and
Benjamin Danglot and
Martin Monperrus and
Benoit Baudry},
title = {A Comprehensive Study of Pseudo-tested Methods},
year = {2018},
number = {1807.05030},
institution = {arXiv},
url = {http://arxiv.org/pdf/1807.05030},
}
+11
View File
@@ -653,6 +653,7 @@ class BTBTest extends PHPUnit_Framework_TestCase {
function test_identity() { function test_identity() {
$btb = new BibDataBase(); $btb = new BibDataBase();
$btb->load('bibacid-utf8.bib'); $btb->load('bibacid-utf8.bib');
bibtexbrowser_configure('BIBTEXBROWSER_BIBTEX_VIEW_FILTEREDOUT', '');
// computing the representation // computing the representation
$d = new SimpleDisplay(); $d = new SimpleDisplay();
@@ -663,6 +664,7 @@ class BTBTest extends PHPUnit_Framework_TestCase {
$nref = count($btb->bibdb); $nref = count($btb->bibdb);
$bibtex = $btb->toBibtex(); $bibtex = $btb->toBibtex();
// reparsing the new content // reparsing the new content
$btb2 = $this->_createDB($bibtex, 'bibacid-utf8.bib'); $btb2 = $this->_createDB($bibtex, 'bibacid-utf8.bib');
$d->setDB($btb2); $d->setDB($btb2);
@@ -750,6 +752,15 @@ class BTBTest extends PHPUnit_Framework_TestCase {
$this->assertEquals("[1]", $db->getEntryByKey('key2')->getAbbrv()); $this->assertEquals("[1]", $db->getEntryByKey('key2')->getAbbrv());
} }
function test_bug_201808() {
$btb = new BibDataBase();
$btb->load('bibacid-utf8.bib');
$this->assertEquals(4,count($btb->bibdb['arXiv-1807.05030']->getRawAuthors()));
$this->assertEquals(4,count($btb->bibdb['arXiv-1807.05030']->getFormattedAuthorsArray()));
$this->assertEquals("Oscar Luis Vera-Pérez, Benjamin Danglot, Martin Monperrus and Benoit Baudry",$btb->bibdb['arXiv-1807.05030']->getAuthor());
}
} // end class } // end class
@copy('bibtexbrowser.local.php.bak','bibtexbrowser.local.php'); @copy('bibtexbrowser.local.php.bak','bibtexbrowser.local.php');
+2 -2
View File
@@ -1394,7 +1394,7 @@ class BibEntry {
* return a string 'Unknown'. */ * return a string 'Unknown'. */
function getAuthor() { function getAuthor() {
if (array_key_exists(AUTHOR, $this->fields)) { if (array_key_exists(AUTHOR, $this->fields)) {
return getFormattedAuthorsString(); return $this->getFormattedAuthorsString();
} }
// 2010-03-02: commented the following, it results in misleading author lists // 2010-03-02: commented the following, it results in misleading author lists
// issue found by Alan P. Sexton // issue found by Alan P. Sexton
@@ -1444,7 +1444,7 @@ class BibEntry {
} }
function split_authors() { function split_authors() {
$array = preg_split('/ and /i', @$this->raw_fields[Q_AUTHOR]); $array = preg_split('/ and( |$)/ims', @$this->raw_fields[Q_AUTHOR]);
$res = array(); $res = array();
// we merge the remaining ones // we merge the remaining ones
for ($i=0; $i < count($array)-1; $i++) { for ($i=0; $i < count($array)-1; $i++) {